Dead Reckonin

Hey, I was wondering can anyone give me some pointers or even tell me where I should start when it comes to dead reck’. I dont even know where to begin I have the concept down. I just need someone to point me in the right direction. Thanx

First of all you need a counter. The 26.2 ms area of the autonomous loop ( between Getdata() and Putdata()) should work nicely. You can just increment an int every time the new data if statement is true with no need to mess with interrupt driven timers. Next you can use the “rom” prefix to store large arrays of constants in program space instead of ram (ex: rom const unsigned char left_motor_values] = {254, 195, 127, 42}). Create these arrays for left motor, right motor, and any other functions (10pt ball remover?) with one value for each segment or time period of the autonomous period (a segment could be to drive forward, or to turn, or to hit the ball). Also make a time length array that contains the number of cycles each segment should last. Then create a variable be the segment index for the arrays. Whenever the counter reaches value in the time length array, increment the index and reset the counter to zero to move on to the next segment. The last segment probably should do nothing, because if you just keep driving, you are bound to find a wall to slam into and the refs hate to see a robot spinning wheels and burning a hole in the carpet :ahh:

To store more than one routine (left and right starting positions for example) on the robot, simply make more arrays with slightly different names (left_motor_values01, left_motor_values02, etc…) and use switches on the robot or OI to select which set of values to use. If you wanted something more advanced then you could make 2by2 matrices instead of arrays and use switches to select the row to use. Well that’s about all I can think of right now. Good Luck!

Creative! I would have hard-coded it!

Keep in mind that dead reckoning is only as good as the hardware platform its on. In software everything should always be constant - the real world never works that way. Motors behave differently in different environments for example. You can calibrate your software fairly precisely, but it will probably degrade over time. If you’re going to use dead reckoning you need something that will make sure it stays accurate. You can use rotation counters on your wheels for example but those have their own problems.