loading
 
interfacing an Arduino with robo realm?
Rustlabs from Australia  [1 posts]
16 year
is it possible to interface an Arduino Diecimila with the robo realm software?

P.S. I'm kind of a newb
Anonymous 16 year
I've got the same question...
Anonymous 16 year
Hi,

We've yet to get an Arduino but know that since it does accept a serial connection it is possible to use the Serial module to communicate with the device. We initially did this with the Parallax Boe-Bot before the BoeBot module was created (if you have a GUI that is built for a device that is always easier to use but not required). Have a look at the serial module and some of the other posts in the forum as to how people have used the serial module to control all sorts of devices.

Hopefully we will have a specialized Arduino module at some point ...

STeven.
Arduino
Anonymous from United Kingdom  [99 posts]
16 year
I have controlled Arduino based devices from RoboRealm.  Basically just setup the code on your Arduino to continually read the serial port(using the serial.read command)  The Arduino will need to execute the desired code based on the incoming serial stream.  For instance if you want to control a servo, have the Arduino take the serial input and pass it to the servo. Have roborealm output an appropriate serial character that gives the desired servo position based on the camera output.  

good luck!
Anonymous 16 year
profmason,

Any chance you could post a quick snippet of Arduino code that could serve as an example? Or perhaps a link to such an example?

Thanks,
STeven.
Shane from United States  [6 posts] 15 year
Yes please?

Anonymous 15 year
Hi Shane,

      Proff Mason has posted some code and a .robo on his website

      http://profmason.com/?p=543

      Good luck and let us know what you manage to do with the two.

jeff from United States  [3 posts] 15 year
Hey Guys,
I am SOO close to getting this working.. i'm just getting hung up on the arduino code. It's giving me a couple errors. (copy/paste quotes are not real ASCII characters etc.) PROFMASON - Thanks a ton for your posts on how to do this! Can you direct me on why i'm getting the errors in the arduino sketch? - its appreciated!

I had to modify the .robo file ProfMason posted because it kept crashing the robo program.  but i got that working and it looks like this:
-------------------------------------------------------

-------------------------------------------------------

and my arduino sketch error...
-------------------------------------------------------

-------------------------------------------------------

Anonymous from United Kingdom  [99 posts] 15 year
Just a shot in the dark, but did you include the header file:

#include <Servo.h>

This is required at the top of your code to make the servo calls work.  I also note that your Servo is highlighted, which probably means it is a reserved word.  On my code, it is in the same script as the rest of the code (IE not color coded as per reserved words)

Are you importing any other headers besides the Servo.h?  One of these might use 'Servo' as a reserved word.

I suspect  you might be using the wiring servo library instead of the library that I used which is linked here:
http://www.arduino.cc/playground/uploads/ComponentLib/servo.zip

hope this helps!
profmason

jeff from United States  [3 posts] 15 year
Hey Prof,
I just swapped out the standard 'Servo' library for the one you linked to above and i'm still getting "Servo" in a different color (as a reserved word)

here is the exact code im using, and the errors below it..
Thanks for the above suggestions tho!

------------------------------------------------
//This is the library of servo commands
#include <Servo.h>
Servo servo1;
int state = HIGH;
int NumIn[] = {0,0,0};
int v = 0;
int d = 0;
int LED = 7;
void setup() {
pinMode(LED, OUTPUT); // sets pin7 as a digital output for the LED
pinMode(1,OUTPUT);
digitalWrite(LED, state); // toggle LED
servo1.attach(14); //analog pin 0
// Set Serial mode to 2400 8N1 and send out Ready on the serial line.
Serial.begin(2400);
Serial.println("Ready");
}
void loop() {
// Wait for input from the serial port
byte i = 0;
while (d != 78) { // wait for header again
d = nextByte();
NumIn[i] = d;
i += 1;
}
// Since the input is in the form of an array three values this has to be
// processed to return a 3 digit number IE 1,2,3 becomes 123
if (NumIn[1] == 78) {NumIn [2] = NumIn[0]; NumIn[1]=0;NumIn[0]=0;}
else if (NumIn[2] == 78) {NumIn[2]=NumIn[1];NumIn[1]=NumIn[0];NumIn[0]=0;}
v = 100 * NumIn[0] + 10 * NumIn[1] + NumIn[2];
//The input should be an angle between 0 and 180 degrees, rotate the servo
//to that angle
servo1.write(v);
//This servo refresh command actually makes the servo move.
Servo::refresh();
delay (10);
// Toggle the State of the LED
if (state == HIGH)
state = LOW;
else
state = HIGH;
digitalWrite(LED, state); // toggle LED
for (int j=i-1; j<4; j++) {
NumIn[j] = 0; // null out NumIn
}
Servo::refresh();
}
// This function waits for data, if there is no data, then it refreshes the servo.
// If the servo isn’t refreshed every 50ms, it doesn’t track
int nextByte() {
while(1) {Servo::refresh();
if(Serial.available() > 0) {
int b = Serial.read();
b = b - 48; //Convert ASCII # to DEC #
return b;
}
}
}
-------------------------------
-------------------------------
and the errors:

In file included from C:\Documents and Settings\trash\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:4,


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token


c:/documents and settings/trash/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared


In file included from C:\Documents and Settings\trash\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:6,

------------------------------------
jeff from United States  [3 posts] 15 year
Hey guys,
I eventually got this working using a different arduino sketch, and a little vbscript. - thanks for your suggestions!
Sam from United States  [4 posts] 15 year
Jeff, I have the same issue how did you fix it?
Anonymous from United Kingdom  [99 posts] 15 year
Be more specific Sam....

One thing you should be sure not to do is to name your file servo.  Python will then think your file is the servo library and give you errors!  DONE THAT!

I am working on an arduino based PID controller (well at least the PD part) which is talking roborealm through a serial protocol.  It is controlling this cutie:
http://profmason.com/?p=783
If you look closely, you can see roborealm running on the screen.

I have a winter student working on an autonomous blimp.  We just got the camera going on Friday.   The blimp is also arduino based:
http://mtsacflight.blogger.com
Sam from United States  [4 posts] 15 year
Thanks for the reply,
I'm trying to compile the arduino code you have on your website, but it gives me this error:
19: error: servo.h: No such file or directory In function 'void setup()':
In function 'void loop()':
In function 'int nextByte':

I used the servo library you mentioned by putting it into the hardware/libraries/ folder and still get the same error.

Also the arduinoserver.robo file causes my robo realm to crash upon opening it.  I'm assuming that has something to do with the com port I'm using.
Anonymous from United Kingdom  [99 posts] 15 year
OK, I think I know the problem.

Arduino changed the servo library between version 11 and 12.  I wrote everything for version 11.  Version 12 has a built in hardware servo library that uses one of the timers and only works on ports 9 and 10.  The calls are conflicting between the two libraries.  Last night I rewrote the software servo library and renamed it SoftwareServo on my system.  Someone else did this in a nice package and fixed a small timing issue.   To fix these issues download the updated library from here.  
http://www.avride.com/pop/store/SoftwareServo_millisSet_addon.zip
Just copy the files into your hardware/libraries and hardware/cores directories.

I had to change all my references to servo in the code to SofwareServo and it worked again.

Take a look at the code in yellow at the bottom of this page which shows how to talk to the updated library.
http://www.arduino.cc/playground/ComponentLib/Servo
Anonymous 15 year
Sam,

If that robofile continues to crash RR please post it here so we can take a look at it.

STeven.
Baghdad_boy from New Zealand  [11 posts] 14 year
Hello ProfMason, I am having a bit of trouble getting the Arduino to listen to the COM port.

I am using COM1 in roborealm and I have changed to the same port on the Arduino. When I open the serial monitor in the Arduino IDE (i think thats what the technical term for the program is) it has a message at the bottom saying "COM1 is already in use. Try quitting any program that may be using it".

I have both set to a baud rate of 9600. Any idea how I can get around this. I thought that it would be a good thing that another program is using the same COM port, that way it can receive data through it haha.
Paul from Netherlands  [2 posts] 14 year

Im wondering, do I need a actual physical serial connection with the arduino? Or does the USB connection somehow emulate the serial connection?

In other words, will this work over USB?
Baghdad_boy from New Zealand  [11 posts] 14 year
Ahh, Its good to be back on this forum. I haven't had time to do any Roborealm for months but exams are gonna start and end soon and I'll have 3 weeks to dedicate to Roborealm YAY!

Anyway, to answer your question, the Arduino communicates through serial. The USB is just an interface for the serial. This will work just fine with a USB version of the Arduino, the computer will detect it as a serial device and you can communicate over a COM port.

I don't know the terminology or technicalities behind it though, so someone might like to explain it better.

Hope that answers your question :)
Paul from Netherlands  [2 posts] 14 year

Thanks, that answers my question 100% (I suspected as much, but didnt know for sure.)

(ahhh. my arduino was supposed to arrive today... now I will have to wait until monday :-(...)

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index