Skip to content
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 an example with a passive joint #172

Merged
merged 18 commits into from
Apr 30, 2024

Conversation

christophfroehlich
Copy link
Contributor

Adds a demo example with a passive joint: A pendulum hinged on the existing cart example.

I also added a hint that the physics of the passive joint are not rendered correct if position or velocity interface is used.

README.md Outdated
Comment on lines 257 to 266
The following example shows a cart with a pendulum arm. This uses the effort command interface for the cart's degree of freedom on the rail, and the physics of the passive joint of the pendulum is solved correctly.
```bash
ros2 launch gazebo_ros2_control_demos pendulum_example_effort.launch.py
ros2 run gazebo_ros2_control_demos example_effort
```
*Attention*: If the position or velocity command interface is used instead, the motion of the pendulum is not calculated correctly and does not move at all, see the following example. This also holds true if a mimicked joint with position or velocity interface is used.
```bash
ros2 launch gazebo_ros2_control_demos pendulum_example_position.launch.py
ros2 run gazebo_ros2_control_demos example_position
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following example shows a cart with a pendulum arm. This uses the effort command interface for the cart's degree of freedom on the rail, and the physics of the passive joint of the pendulum is solved correctly.
```bash
ros2 launch gazebo_ros2_control_demos pendulum_example_effort.launch.py
ros2 run gazebo_ros2_control_demos example_effort
```
*Attention*: If the position or velocity command interface is used instead, the motion of the pendulum is not calculated correctly and does not move at all, see the following example. This also holds true if a mimicked joint with position or velocity interface is used.
```bash
ros2 launch gazebo_ros2_control_demos pendulum_example_position.launch.py
ros2 run gazebo_ros2_control_demos example_position
```
The following example shows a cart with a pendulum arm. This uses the effort command interface for the cart's
degree of freedom on the rail, and the physics of the passive joint of the pendulum is solved correctly.
```bash
ros2 launch gazebo_ros2_control_demos pendulum_example_effort.launch.py
ros2 run gazebo_ros2_control_demos example_effort

Attention: If the position or velocity command interface is used instead, the motion of the pendulum is not
calculated correctly and does not move at all, see the following example. This also holds true if a mimicked joint
with position or velocity interface is used.

ros2 launch gazebo_ros2_control_demos pendulum_example_position.launch.py
ros2 run gazebo_ros2_control_demos example_position

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that you want to delete the hint with the position interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde could you please give me an update about what you want me to change here? According to the reactions below, I'd suggest to add the hint with the position interface again.

christophfroehlich and others added 2 commits January 9, 2023 17:42
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
@Fixit-Davide
Copy link

Sorry, what is the technical reason for the " If the position or velocity command interface is used instead, the motion of the pendulum is not calculated correctly and does not move at all"?

@christophfroehlich
Copy link
Contributor Author

Sorry, what is the technical reason for the " If the position or velocity command interface is used instead, the motion of the pendulum is not calculated correctly and does not move at all"?

I never had a look into the gazebo code, but what I think from a mathematical/physical perspective what happens is:
If you use the effort interface, then the physics engine solves the whole rigid-body-dynamics, for example written in the standard matrix notation:
image
If we use a different interface (velocity, position) for a degree-of-freedom, then the states of the respective DOF are hardcoded and the coupling via M \DDot q is broken, because the acceleration of this DOF in \DDot q is not updated.

Maybe @ahcorde can verify my guess.

doc/index.rst Outdated

.. note::

If the position or velocity command interface is used instead, the motion of the pendulum is not calculated correctly and does not move at all, see the following example. This also holds true if a mimicked joint with position or velocity interface is used.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you open an issue about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a bug or a feature :D

doc/index.rst Outdated Show resolved Hide resolved
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Copy link
Collaborator

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the urdfs are different one is using a macro and the other doesn't.

I tested both examples, the effort one is working and I can see the passive joint moving, but the position one the passive joint is static.

Do you mind to take a look ? and reduce diff between the two new URDFs ?

@christophfroehlich
Copy link
Contributor Author

the urdfs are different one is using a macro and the other doesn't.

I tested both examples, the effort one is working and I can see the passive joint moving, but the position one the passive joint is static.

exactly, that is the point I wanted to highlight and have adressed in the docs and opened the issue: it would have saved me some days of debugging of my project ;)

Do you mind to take a look ? and reduce diff between the two new URDFs ?

yes I'll have a look why the URDFs are different

@christophfroehlich
Copy link
Contributor Author

@ahcorde I made both URFDs equal now (inertia was not important for the position case).

@ahcorde ahcorde merged commit 7d5ec5d into ros-controls:master Apr 30, 2024
3 of 5 checks passed
@ahcorde
Copy link
Collaborator

ahcorde commented Apr 30, 2024

@christophfroehlich

The position joints are working now, can we close this issue #240 ?

Do you want to backport this ?

@christophfroehlich christophfroehlich deleted the add_passive_joint_demo branch April 30, 2024 14:28
@christophfroehlich
Copy link
Contributor Author

The position joints are working now, can we close this issue #240 ?

What do you mean? I don't think that this behavior changed, at least not with this PR. The pendulum does not move if the cart is commanded with position interface?

Do you want to backport this ?

yes please. the rolling version will die when gazebo classic is not released to noble anymore.

@ahcorde
Copy link
Collaborator

ahcorde commented Apr 30, 2024

Now it's moving:

pendulum_position

@ahcorde
Copy link
Collaborator

ahcorde commented Apr 30, 2024

https://github.com/Mergifyio backport humble iron

Copy link
Contributor

mergify bot commented Apr 30, 2024

backport humble iron

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Apr 30, 2024
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 7d5ec5d)

# Conflicts:
#	doc/index.rst
mergify bot pushed a commit that referenced this pull request Apr 30, 2024
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 7d5ec5d)

# Conflicts:
#	doc/index.rst
ahcorde added a commit that referenced this pull request Apr 30, 2024
* Add an example with a passive joint (#172)

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 7d5ec5d)

# Conflicts:
#	doc/index.rst

* Fixed docs

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Christoph Fröhlich <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
ahcorde added a commit that referenced this pull request Apr 30, 2024
* Add an example with a passive joint (#172)

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 7d5ec5d)

# Conflicts:
#	doc/index.rst

* Fixed docs

Signed-off-by: Alejandro Hernández Cordero <[email protected]>

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Christoph Fröhlich <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
@christophfroehlich
Copy link
Contributor Author

Now it's moving:

Passive joints were always "moving", but as if they were fixed in inertial frame. A movement of the parent link did not effect the respective joint.

For demonstration purposes, I change the initial pose to be in the lower equilibrium to make this clearer:
https://github.com/ros-controls/gazebo_ros2_control/assets/3367244/630cc8b8-6cb4-4dbc-9caa-948c085052e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants