Society of Robots - Robot Forum
Software => Software => Topic started 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!
-
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.
-
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!
-
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.
-
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.
-
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