Society of Robots - Robot Forum

Software => Software => Topic started by: yankeefan238 on January 23, 2009, 08:42:39 PM

Title: 50$ Robot Code Question
Post by: yankeefan238 on January 23, 2009, 08:42:39 PM
I don't understand this code about the servos :

void robot_turn_left(void)
   {
   servo_left(25);
   servo_right(25);
   }
void robot_turn_right(void)
   {
   servo_left(44);
   servo_right(44);
   }
void robot_go_straight(void)
   {
   servo_left(25);
   servo_right(44);
   }
void hold_position(void)//37
   {
   servo_left(39);//39
   servo_right(35);//35
   }

The code is from the robot_source_50_sharpIR_v1 folder. In the folder there is the file SoR_Utils.h and it has the above code in it. I don't get the part where it says:

void robot_turn_left(void)
   {
   servo_left(25);
   servo_right(25);
   }

This function is supposed to make the robot turn left and the values in the parenthesis are the speed of each servo, right? But I thought when you want the robot to turn left you would make servo_left lower than servo_right so that the left servo turns slower than the right. This would cause the robot to turn left. I'm wondering why the values in parenthesis are both at 25?!?!

I could be thinking about this all wrong...
Title: Re: 50$ Robot Code Question
Post by: HDL_CinC_Dragon on January 23, 2009, 11:40:40 PM
The servos when mounted are in opposite directions thus when told to move in the same direction they actually move in a different direction. Directionally directional to the direction of the directed movement.
The parenthesis are not speeds, they are angles basically telling the servos to go to a certain angle but since they are modified for continuous rotation the pot that tells the circuit where the servo is never reaches that angle and thus keeps going.
Title: Re: 50$ Robot Code Question
Post by: yankeefan238 on January 24, 2009, 10:18:24 AM
Thanks a lot! That was driving me crazy.