Society of Robots - Robot Forum
General Misc => Misc => Topic started by: ert481 on August 04, 2008, 04:55:38 PM
-
I want to find out if you can program the $50 robot to like go forward for so long, stop, turn, go forward, stop.
this is my first robot that I built and I don't know any codes for programing. please give me the code (if the robot can do this) so I can look at it. thanks
-
Hi
Yes the $50 robot can do that.
In psuedocode you would tell the robot to:
driveLeftWheelForward
driveRightWheelForward
sleep(whateverTimeYouWant)
stopLeftWheel
stopRightWheel
sleep(whateverTimeYouWant)
driveLeftWheelForward
driveRightWheelReverse
sleep(whateverTimeYouWant)
etc...
See http://www.societyofrobots.com/programming_differentialdrive.shtml for driving information
-
i'm not sure if its psuedocode. i do know that i'm just changing the code that admin (or whoever wrote that tutorial) told me to download and compile.
when i compiled it this is the type of code that it had on it:
{
servo_left(25)
servo_right(44) this is straight. this is one of the things he had on the code.
}
is it psuedocode? ???
and if its not can you give me what i told you in this type of code ?
-
hi
psuedocode is part me being lazy and part making it general.
so the admin gave C code which is what you need to program the robot with, the psuedocode is just an english version of what needs to be coded.
so anytime I wrote
driveLeftWheelForward you would replace it with servo_left(25)
etc...
You may need to experiment to change the values in the parentheses to some other value
-
what about sleep( ) ?
i put it in between the servo code and clicked build and it had an error. this is what i typed:
{
servo_left(25);
servo_right(44);
}
sleep(500)
{
servo_left(44);
servo_right(44);
}
}
}
anything wrong with it?
and how do I stop the robot?
-
theres no function called sleep...thats pseudocode also.
look in the SoR_Utils.h file for the delay function.
There are already simplified functions in there also.
robot_go_straight();
robot_turn_left();
etc.
to make it stop just call the function
robot_hold_position();
-
thanks!! (finally)
-
do you need to type:
{
robot_go_straight(and what do I put in between these ? );
}
or just
robot_go_straight();
-
nothing, its a void function, just empty parenthesis
-
i got the hole thing figured out. :P