Run motor while create is moving

5 replies [Last post]
firetiger5
firetiger5's picture
Title: NooBot
Joined: 05/03/2012
Posts:
BotPoints: 23
User offline. Last seen 10 years 18 weeks ago.

I am trying to program the motor to run while the create is driving to the certain destination so that it could be ready at the same time. Any ideas?

~ARIGATO
-From firetiger5

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

Try this:

  1. mrp(0, 500, 5000); // starts moving motor 0
  2. create_drive_straight(200); // starts moving the Create
  3. sleep(5); // wait for the Create to move; you could also use the Create's distance sensors if you want better accuracy
  4. create_stop(); // stop the Create
  5. bmd(0); // wait for the motor to move
  6.  
  7. // At this point the Create and motor have both moved and are stopped.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

firetiger5
firetiger5's picture
Title: NooBot
Joined: 05/03/2012
Posts:
BotPoints: 23
User offline. Last seen 10 years 18 weeks ago.

Thank you very much, the robot works great.
~ARIGATO
-From firetiger5

~ARIGATO
-From firetiger5

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

No problem. :-) By the way, welcome to the Botball Community!

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

firetiger5
firetiger5's picture
Title: NooBot
Joined: 05/03/2012
Posts:
BotPoints: 23
User offline. Last seen 10 years 18 weeks ago.

Thanks, and I have programmed the robot (CBC robot) to use its motors to move and then stop, then the servos move the claw to collect the Kelp then move the motors toward the next Kelp. But when the robot runs the servos close the claw and move toward the next set of kelp at the same time. How can I make it so that they go in order?

~ARIGATO
-From firetiger5

cannonh
Title: NooBot
Joined: 07/09/2012
Posts:
BotPoints: 19
User offline. Last seen 9 years 11 weeks ago.

I'm assuming you are just using a set_servo_position to move your servo and then following it up with your nav code. set_servo_position does not wait for the servo to slew/rotate to the desired position. I would place an msleep(500) or something like that after the set_servo_position so that way the servo will be in the desired position before moving.