From: Paul O. <pj...@gm...> - 2010-01-26 16:52:13
|
The solution to my problem is simple: SetSpeed(0,0) appeared to do nothing because main() returned 0 before the player_position2d_cmd_vel_t is sent over serial. If I do: lookForTwoBlobs() SetSpeed(0,0) idle for a second exit program it works OK. On Sun, Jan 24, 2010 at 5:17 PM, Paul Ozog <pj...@gm...> wrote: > My Position2d device (provided by the "roomba" driver for a Roomba 500) is > not stopping when i tell it to. But in stage, the robots stop fine. > > I have something like so: > > int main () { > ... > p2d.SetMotorEnable(true); > lookForBlobs(2); // Function i wrote - turns clockwise until 2 blobs are > in sight. > > cout<<"Sending stop command..."<<endl; > p2d.SetSpeed(0,0); // Stop turning. > > return 0; > } > > lookForBlobs is a pretty simple routine that does the following (pseudo > code-ish): > > void lookForBlobs(unsigned int count) { > > p2d.SetSpeed(0, TURNSPEED); > > while (!hasFoundCountBlobs) { > PlayerClientProx.Read(); > if bfinder.GetCount() equals 2 > hasFoundCountBlobs = True; > } > > } > > The output when used on a roomba 500: > > $ ./a.out > ... > Sending stop command... > > $ > > So the bot sees two blobs, sends the stop command, exits the program, but > the roomba keeps on turning! The player sever must be Killed manually. Am > I doing something wrong? If i make the stop command in a while loop, ie: > > while (True) > p2d.SetSpeed(0,0); > > That stops the robot from turning... but this is not ideal... If anyone can > help i'd appreciate it. Thanks > > > Paul > > > > |