|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Simple Autonomous Code
Im having trouble doing autonomous mode. My team and I have agreed to go with dead reckoning. I was wondering if anyone can help me with a simple code to make the motors drive for 1 second and stop i just need help getting started.
After I see a sample code for the motors then I can figure it out this would be appreciated thanks. -Ryan |
|
#2
|
||||
|
||||
|
Re: Simple Autonomous Code
Set a simple counter that is incremented every time. Then use conditional statements (like an if statement) to do certain things within a set time. As for actually running the motors, you have to find out which PWM you are using. Then, do something like this:
pwm01=235; assuming pwm01 is the PWM you are using on your robot. |
|
#3
|
|||
|
|||
|
Re: Simple Autonomous Code
I don't have any example code, but you could use the fact that the code is executed once every 26.2 milliseconds and use some decrementing (or incrementing) counters and some if statements...
well, sort of an example, but definitely needs refinement Code:
count = count + 1;
if (count = 15)
{
pwm01 = 180;
pwm02 = 180;
}
if (count = 45)
{
pwm01 = 255;
pwm02 = 0;
}
EDIT: got beaten to it... oh well I'll leave it there for the code |
|
#4
|
|||
|
|||
|
Re: Simple Autonomous Code
You can find a very good, yet simple autonomous code on this innovation first link. It not only allows you to go forward, but you can turn in any direction. It is based on time as well so I think it would be perfect for what your looking for. You just have to change the timing, speed, and pwm settings. Its really very simple and useful. You can modify it anyway you like by simply inserting or deleting times, speeds, and directions. You can also use if statements to create switches on the robot wired to the digital inputs that will allow you to write several different autonomous modes. Consider it an improved version of dead reckoning. (dead reckoning++)?
http://www.ifirobotics.com/forum/viewtopic.php?t=75 |
|
#5
|
|||
|
|||
|
Re: Simple Autonomous Code
thank you i think i can program autonomous now
-Ryan |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Out of the Box Camera Code | russell | Programming | 9 | 21-10-2009 05:28 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| Simple Autonomous Mode Example | deltacoder1020 | Programming | 5 | 08-03-2004 20:22 |