Society of Robots - Robot Forum

General Misc => Misc => Topic started by: ert481 on August 04, 2008, 04:55:38 PM

Title: $50 robot programing
Post 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
Title: Re: $50 robot programing
Post by: Kohanbash on August 05, 2008, 09:52:32 PM
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
Title: Re: $50 robot programing
Post by: ert481 on August 06, 2008, 10:53:36 AM
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 ?           
Title: Re: $50 robot programing
Post by: Kohanbash on August 06, 2008, 11:48:55 AM
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
Title: Re: $50 robot programing
Post by: ert481 on August 06, 2008, 11:57:27 AM
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?
Title: Re: $50 robot programing
Post by: pomprocker on August 06, 2008, 12:22:18 PM
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();
Title: Re: $50 robot programing
Post by: ert481 on August 06, 2008, 12:26:32 PM
thanks!!  (finally)
Title: Re: $50 robot programing
Post by: ert481 on August 06, 2008, 12:36:46 PM
do you need to type:

{
robot_go_straight(and what do I put in between these ? );
}

or just

robot_go_straight();
Title: Re: $50 robot programing
Post by: pomprocker on August 06, 2008, 12:45:28 PM
nothing, its a void function, just empty parenthesis
Title: Re: $50 robot programing
Post by: ert481 on August 06, 2008, 12:53:48 PM
i got the hole thing figured out. :P