JaciBrunning / Pathfinder

Cross-Platform, Multi-Use Motion Profiling and Trajectory Generation
MIT License
255 stars 78 forks source link

Tank drive wiki clarification #11

Closed newjanson closed 7 years ago

newjanson commented 7 years ago

I have been reading over the Tankdrive EncoderFollower documentation, and I'm not sure what this means:

double angleDifference = Pathfinder.boundHalfDegrees(desired_heading - gyro_heading);
double turn = 0.8 * (-1.0/80.0) * angleDifference;

The line that I'm unsure about is double turn = 0.8 * (-1.0/80.0) * angleDifference;. What does 0.8 * (-1.0/80.0) mean? Is this just a mystery P value of 0.01? Why is it negative?

I'm sorry if I'm missing something, but I don't get what significance 80 or 0.8 has in this equation.

JaciBrunning commented 7 years ago

You're correct in saying that it is a simple P gain on the angle difference. The calculation for this value comes from Team 254's Presentation on Motion Profiling. It seems to work well in most cases, but can be changed to your preference.

The negative part doesn't matter, it just means you'll have to switch the left and right motors

// Switch the +/- if you don't want turn's P gain to be negative
left.set(l+ turn);
right.set(r - turn);
newjanson commented 7 years ago

Thanks!