Replay motions -- how do you really want this to work?

In 2014, I was working with Steve on a “re-run” for 2915a’s toss up robot. He used this program at the world championships, where it worked surprisingly well until he changed his drive motors (without recording his autonomous programs again) and everything turned to a disaster.

The first iteration of the program was based off of time and joystick values like some of you have mentioned. This proved to be inaccurate because of inconsistencies with battery voltages and motors wearing out/getting weaker as they are worn in.

The second iteration was based off of a PID controller which took snapshots of the position of the wheels in encoder ticks every x ms. This again proved to be below average because of accumulative error, and there were problems getting control loop to work to a standard we were happy with because of the ever changing target.

What we had work the best was a hybrid of the two with velocity targets instead of positional targets, and essentially stripping the PID down to just the proportional component. This mean’t that we could essentially run the robot off the joystick values to try and hit a target RPM, and then offset the values with the error. In regards to the rate of sampling, we found that there was a sweet spot of around 50ms. I’m not sure why, probably a mixture between what you guys have discussed and the reactivity of the control loop we used.

Here are a couple of auton programs using it:

If you look up the games from 2014 worlds you will probably see some others if you are interested.

I don’t think there will be an out of the box solution that will work for every robot. Every robot is different.

I have in the past held back in posting the code for this specific rerun because of a number of reasons (both competitive advantage and not wanting to give people the answers), but at this point if you want to get a similar algorithm to run on your robot you will have to understand it pretty well anyway so I don’t think there is much harm in making it public. You can find the 2014 code here: GitHub - Jackbk/VEX

It certainly won’t work out of the box, but I hope some people will be able to take inspiration from it and improve on the theory behind it. If I were to continue with it I would probably start by improving how the data is stored, as well as having some sort of memory of how accurate the last autonomous run was, and to try to correct for the error it recorded the previous time.

I should probably mention that it wasn’t as accurate as conventional programming, but it was much faster and we could achieve a lot more in the autonomous period. Lining up on walls/bump/goals helped a lot with accuracy during the run.

EDIT: fixed description of iteration 3 because I had it confused with something else I wrote and it was wrong