hbrobotics/ros_arduino_bridge — pull request #6 by KristofRobot (2013-08-16 09:15:04+00:00)
Title: Enhanced PID algorithm

Hello,

I enhanced the PID algorithm based on the series of blog posts at http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
Specifically:
1. Avoid derivative kickback - http://brettbeauregard.com/blog/2011/04/improving-the-beginner%E2%80%99s-pid-derivative-kick/
2. Allow smooth on-the-fly tuning changes - http://brettbeauregard.com/blog/2011/04/improving-the-beginner%E2%80%99s-pid-tuning-changes/
3. Reset windup mitigation - http://brettbeauregard.com/blog/2011/04/improving-the-beginner%E2%80%99s-pid-reset-windup/
4. Bumpless initialization - http://brettbeauregard.com/blog/2011/04/improving-the-beginner%E2%80%99s-pid-initialization/

The most useful/important change is 4) - it allows "bumpless" initialization, and it also resets the PID when stopping the robot, allowing the PID to start cleanly for the next move. This is really necessary, as otherwise, during the first seconds, the PID will rely on the values before stopping, and momentarily output false information.

The main trigger for updating the code was my playing with "rosrun rbx1_nav nav_square.py" (http://code.google.com/p/ros-by-example/source/checkout).
With the old code, after a turn, and when starting the next straight leg, the PID code would still remember the values from the previous turn, and for a few moments the robot would be veering in the direction it previously turned to. This code fully solves that.

I also took the opportunity to make fixes 1-3, which should make the PID code more robust.

Let me know if you would rather have me submit the changes 1-4 as separate patches.

Cheers,

Kristof