Society of Robots - Robot Forum

Software => Software => Topic started by: benjammin105 on February 09, 2010, 11:40:04 PM

Title: Motor Commands??
Post by: benjammin105 on February 09, 2010, 11:40:04 PM
I just got my new axon in and my first robot is coming together and nicely so far. I just ordered the sabertooth 2X5 motor controller and it should be in next week. I'm still a rookie at all of this and was wondering how I would go about giving this motor driver commands in the C language. I mean I wanna make it drive for certain distances and turn and that kind of stuff. I'm reading thru the tutorial information and didn't see anything explaining this kind of thing. Thanks!
Title: Re: Motor Commands??
Post by: Admin on February 10, 2010, 12:12:37 AM
If you are using WebbotLib, just look up the sabertooth commands in the manual.

For the older Axon code, do this:
http://www.societyofrobots.com/axon/axon_function_list.shtml#misc (http://www.societyofrobots.com/axon/axon_function_list.shtml#misc)

then delay for a bit:
http://www.societyofrobots.com/axon/axon_function_list.shtml#timers (http://www.societyofrobots.com/axon/axon_function_list.shtml#timers)

then do a different motor command.
Title: Re: Motor Commands??
Post by: benjammin105 on February 11, 2010, 06:17:13 PM
I wasn't using that library but I am now! I downloaded the manual and printed it and put it in a binder. This will get me thru most of my questions.Thanks!
Title: Re: Motor Commands??
Post by: benjammin105 on February 11, 2010, 08:29:02 PM
Another quick question...I'm looking for a way to make my robot drive for a specific amount of time before stopping and doing other actions. Would I be able to do this by using the act_setspeed command and then using delays until it has traveled the distance I need? I'm also wondering if the delays would make it stop as opposed to driving for the selected time.
Title: Re: Motor Commands??
Post by: Webbot on February 11, 2010, 08:56:33 PM
The motors continue to work in the background. So 'yes' you could use a delay and make WebbotLib work.

However: for program design this isn't good design.

For example: what would happen if the robot hit something during that time. Perhaps it would reverse for a few seconds. Ok - but what if it hit something whilst reversing?

You really need to think about a state machine. Sounds complex - but need not be.

Title: Re: Motor Commands??
Post by: Admin on February 11, 2010, 10:20:13 PM
If you consider yourself a beginner, just work with a delay for now until you get the hang of things and the basics working.

A more fancy way to do it would be:

while(nothing_in_the_way)
   {drive_forward()}
rotate_90_degrees();//if something in the way, it turns