-
Notifications
You must be signed in to change notification settings - Fork 392
Reset JTC PID's to zero on_activate() #1840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch, thank you! I would normally ask for a test but this is not only pretty hard to capture in a unit test but also clearly required when going through a deactivate/activate cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense.
Thanks for fixing it @MarqRazz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your case this makes totally sense. But should we make this optional? See the save_i_term parameter of the PidROS class. I could think of an application, where the current behavior could be the desired one.
I don't think the old behavior would ever be correct. It's applying control between steps with an unknown and large amount of time. I can see use cases where you want to calculate control values before you forward them to hardware (i.e. a chained controller g-comp situation) but that should not require the JTC keep the old memory values for the PID that was running last and shutdown in an unknown way. |
Then I haven't understood the issue. Is the PID called with the passed time since deactivation? What I had in mind is something like a model-free gravity compensation in effort control mode, or leaking hydraulic valves in velocity control mode, where the integral term should be retained after re-activation. I don't have a usecase for that, I was just thinking if there might be one. |
The PID is called with duration, but the value can be seconds to minuets old and the internal derivative and integral terms terms it keeps can be from a motion that failed because of over torque or speed or all kinds of situations that you don't want propagated to reactivate. This is the line of code that is causing the impulse with the old values. When it re-activates |
There is no "old term for derivative", the velocity error is directly multiplied by the D-gain However, I totally understand your point with the integral action, I just think we could add a parameter save_i_term and use this overload ros2_controllers/pid_controller/src/pid_controller.yaml Lines 128 to 132 in b21a7e1
|
@christophfroehlich , I think we should discuss that new |
(cherry picked from commit 18c9f1f)
(cherry picked from commit 18c9f1f) # Conflicts: # joint_trajectory_controller/src/joint_trajectory_controller.cpp
Co-authored-by: Marq Rasmussen <[email protected]>
When running the JTC in velocity control mode I noticed that the joints receive an impulse on reactivation after is has thrown a previous fault in motion. In the below example you can see this joint gets an impulse of -4 rad/sec down to zero as I reactivate the JTC. The impulse causes my hardware to throw another fault.

This change adds a

reset()
call to each joints PID controller so that the old command values are zero'd out when (re)activating.