Quote:
Originally Posted by SamcFuchs
Ok, I can see how that would be effective...how does it compare to using encoders for correction?
|
Jared probably has a slightly different way of looking at this, but I think there's a more fundamental change needed first to make sure you go straight. The encoder vs gyro problem becomes much easier to try. Instead of left, right profiles, I rewrite it as a distance, angle profile, and then use a distance PID loop and an angle PID loop.
angle = (right_distance - left_distance) / width
distance = (left_distance + right_distance) / 2
You can do a similar transform for your powers (pardon any sign errors) to get back to actual outputs you physically have.
left_voltage = distance_voltage - turn_voltage
right_voltage = distance_voltage + turn_voltage
This then lets you control what you care about.
In the presence of tire slip and tire wear, you won't always go straight with just encoders. A gyro has a different set of issues (noise), but isn't affected by those problems. So, we use the gyro for the angle of the robot instead of computing the angle as above.
Just re-phrasing your loops to be an angle, distance pair of loops has huge benefit. Unless your robot has all it's mass perfectly centered over the two drive wheels, your left, right PID loop won't be able to do good distance control and turn control without compromises. I tend to find that good distance control results in a small amount of turn chatter and oscillation. (You can work out the physics to show that the two sides are coupled in left, right, but not in angle, distance) A angle, distance loop doesn't make that assumption.
If you really want to do left, right with a gyro, you can reverse the equations above.