-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add PID controller to control joint using effort #294
Add PID controller to control joint using effort #294
Conversation
- add PID Implementation - add effort base Position Controller - add effort base Velocity Controller
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.
can you use the PID from https://github.com/ros-controls/control_toolbox ?
then I suggest you to add new control modes: POSITION_PID, VELOCITY_PID and EFFORT_PID, and keep the behaviour of the current controllers. This is important just in case we want to backport this feature to an older version
Sure, I can use the control_toolbox PID. I am not sure how you want me to add new control modes in terms of usage. Maybe something like that ? <!-- define control interface -->
<ros2_control name="my_GazeboSystem" type="system">
<hardware>
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
</hardware>
<joint name="my_joint">
<!-- define command interface -->
<command_interface name="velocity_PID">
<param name="kp">10</param>
<param name="ki">2</param>
<param name="kd">0.1</param>
<param name="max_integral_error">1000</param>
</command_interface>
<!-- define state interface -->
<state_interface name="position">
<param name="initial_value">0</param>
</state_interface>
<state_interface name="velocity"/>
<state_interface name="effort"/>
</joint>
</ros2_control> |
Yes I think this is what @ahcorde suggests. Don't forget to register the handles in Please also add a section to the documentation, and maybe also a demo to the demos package using this new feature. |
@ahcorde @christophfroehlich, I have updated the PID implementation and added the new control mode. Please let me know if you notice any issues with this implementation. I will also update the documentation and provide examples during this week. |
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.
Looks good so far. Waiting for examples and documentation.
with gz_ros2_control there is a position_proportional_gain_ factor for a position-controlled joint with velocity interface. This would be easy to include here, is there a use-case for this?
@christophfroehlich @ahcorde I added the doc and example and fix all your comment. I let you review everything. Let me know if you got and problem with the new feature. |
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.
Please run pre-commit locally and also colcon test (see flake8 errors).
Sorry I forgot to run colcon test before commit. The current version should pass all colcon test @christophfroehlich |
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.
format CI is also failing
gazebo_ros2_control_demos/launch/vertical_cart_example_position_pid.launch.py
Outdated
Show resolved
Hide resolved
gazebo_ros2_control_demos/launch/vertical_cart_example_velocity_pid.launch.py
Outdated
Show resolved
Hide resolved
Sorry for the confusion with the CI I was not running pre-commit with the arg --all-files so I was not seeing all error @ahcorde |
Fyi: If you use the github UI to apply the suggested changes, it would be clearer for reviewer to see if this was applied or not. |
Sorry for that, is there any other change needed in this PR ? @christophfroehlich @ahcorde |
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.
LGTM
gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system.hpp
Outdated
Show resolved
Hide resolved
- ``pos_max_integral_error``: Maximum summation of the error | ||
|
||
The same definitions apply to the ``vel_*`` parameters. | ||
|
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.
do you mind to add here the command to run the examples ? Then it's good to go
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.
@ahcorde done
…_controller' into add_effort_velocity_and_position_controller
…_and_position_controller
https://github.com/Mergifyio backport iron master |
✅ Backports have been created
|
@chameau5050 any plan to include these changes in |
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Christoph Fröhlich <[email protected]> (cherry picked from commit f769c6c)
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Christoph Fröhlich <[email protected]> (cherry picked from commit f769c6c) # Conflicts: # gazebo_ros2_control/src/gazebo_system.cpp
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Christoph Fröhlich <[email protected]> (cherry picked from commit f769c6c) Co-authored-by: chameau5050 <[email protected]>
@ahcorde maybe in a few months but not in the short term |
Change :
Motivation :
The primary goal behind these changes is to model the behavior of a low-level joint controller more accurately, rather than relying on workarounds within the physics engine. Additionally, addressing some limitations related to closed-loop kinematic chains using Position and Velocity control interfaces is another objective. The PR could maybe also solve this issue #240
Change in usage :
The usage remains largely the same as before, with one key difference. If you declare parameters kp, ki, or kd using the command_interface for Position or Velocity, the controller will apply effort to the joint based on the specified PID gains instead of directly setting the joint position or velocity.
Usage exemple :
Here’s an example of the new usage for controlling the velocity of a joint using an Effort PID:
The second example retains the original behavior, where a Velocity controller sets the velocity of the joint in the physics engine :