ros-controls / gazebo_ros2_control

Wrappers, tools and additional API's for using ros2_control with Gazebo Classic
Apache License 2.0
188 stars 120 forks source link

Fix sagging robots in position control #213

Closed gwalck closed 1 year ago

gwalck commented 1 year ago

Following up with my remarks on https://github.com/ros-controls/gazebo_ros2_control/pull/177#issuecomment-1584743086 and a request for a PR.

summary: in the discussion of the reset pos/vel commands it is said that setting position/velocity for joints is overriding physics, and should generally not be used,

I know from past experience with enforcing pose of an object at each time step was not sufficient to hold it in place (drift), velocity had to be set to zero as well. I immediately related the joint sagging issue to that pose drift.

Solution is to set zero velocity as well for that time step. Setting velocity to zero after fixing position is another override that stabilizes the physics and is unrelated to any robot physics.

here is a before and after on 2 robots

https://github.com/ros-controls/gazebo_ros2_control/assets/132376938/779a6c28-7479-471b-b1ef-ea1d9ea85150

https://github.com/ros-controls/gazebo_ros2_control/assets/132376938/97b2fc07-10a4-4985-9829-8ff768ec410e

https://github.com/ros-controls/gazebo_ros2_control/assets/132376938/14e6e9ea-f0f9-491e-88ca-f2530c94ab39

https://github.com/ros-controls/gazebo_ros2_control/assets/132376938/b0389edc-a6ba-43f9-b2d5-8aeeaf428567

Other solutions have used max efforts or adding high damping (which probably essentially set velocity to zero)

I believe this PR should therefore fix the following issues without requiring dynamics parameters.

https://github.com/ros-controls/gazebo_ros2_control/issues/90 https://github.com/ros-controls/gazebo_ros2_control/issues/73 https://github.com/UniversalRobots/Universal_Robots_ROS2_Gazebo_Simulation/issues/19

ahcorde commented 1 year ago

https://github.com/Mergifyio backport humble

mergify[bot] commented 1 year ago

backport humble

✅ Backports have been created

* [#214 Fix sagging robots in position control (backport #213)](https://github.com/ros-controls/gazebo_ros2_control/pull/214) has been created for branch `humble`