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

Joint Tutorial needs topic_name in SDF examples. #2629

Open
wants to merge 1 commit into
base: gz-sim9
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 45 additions & 44 deletions tutorials/joint_controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ This is how the model will look:

```xml
<plugin
filename="gz-sim-joint-controller-system"
name="gz::sim::systems::JointController">
<joint_name>j1</joint_name>
<initial_velocity>1.0</initial_velocity>
filename="gz-sim-joint-controller-system"
name="gz::sim::systems::JointController">
<joint_name>j1</joint_name>
<initial_velocity>1.0</initial_velocity>
</plugin>
```

Expand Down Expand Up @@ -203,12 +203,13 @@ Replace the velocity mode plugin mentioned above with the following lines in the

```xml
<plugin
filename="gz-sim-joint-controller-system"
name="gz::sim::systems::JointController">
<joint_name>j1</joint_name>
<use_force_commands>true</use_force_commands>
<p_gain>0.2</p_gain>
<i_gain>0.01</i_gain>
filename="gz-sim-joint-controller-system"
name="gz::sim::systems::JointController">
<joint_name>j1</joint_name>
<use_force_commands>true</use_force_commands>
<p_gain>0.2</p_gain>
<i_gain>0.01</i_gain>
<topic>topic_name</topic>
</plugin>
```

Expand Down Expand Up @@ -309,17 +310,17 @@ For this let's use the previously discussed SDF file.

```xml
<plugin
filename="gz-sim-joint-position-controller-system"
name="gz::sim::systems::JointPositionController">
<joint_name>j1</joint_name>
<topic>topic_name</topic>
<p_gain>1</p_gain>
<i_gain>0.1</i_gain>
<d_gain>0.01</d_gain>
<i_max>1</i_max>
<i_min>-1</i_min>
<cmd_max>1000</cmd_max>
<cmd_min>-1000</cmd_min>
filename="gz-sim-joint-position-controller-system"
name="gz::sim::systems::JointPositionController">
<joint_name>j1</joint_name>
<topic>topic_name</topic>
<p_gain>1</p_gain>
<i_gain>0.1</i_gain>
<d_gain>0.01</d_gain>
<i_max>1</i_max>
<i_min>-1</i_min>
<cmd_max>1000</cmd_max>
<cmd_min>-1000</cmd_min>
</plugin>
```

Expand Down Expand Up @@ -591,28 +592,28 @@ This is how the model will look:
Append the following lines before `</model>` tag in the SDF file.

```xml
<plugin
filename="gz-sim-joint-trajectory-controller-system"
name="gz::sim::systems::JointTrajectoryController">
<joint_name>RR_position_control_joint1</joint_name>
<initial_position>0.7854</initial_position>
<position_p_gain>20</position_p_gain>
<position_i_gain>0.4</position_i_gain>
<position_d_gain>1.0</position_d_gain>
<position_i_min>-1</position_i_min>
<position_i_max>1</position_i_max>
<position_cmd_min>-20</position_cmd_min>
<position_cmd_max>20</position_cmd_max>

<joint_name>RR_position_control_joint2</joint_name>
<initial_position>-1.5708</initial_position>
<position_p_gain>10</position_p_gain>
<position_i_gain>0.2</position_i_gain>
<position_d_gain>0.5</position_d_gain>
<position_i_min>-1</position_i_min>
<position_i_max>1</position_i_max>
<position_cmd_min>-10</position_cmd_min>
<position_cmd_max>10</position_cmd_max>
<plugin
filename="gz-sim-joint-trajectory-controller-system"
name="gz::sim::systems::JointTrajectoryController">
<joint_name>RR_position_control_joint1</joint_name>
<initial_position>0.7854</initial_position>
<position_p_gain>20</position_p_gain>
<position_i_gain>0.4</position_i_gain>
<position_d_gain>1.0</position_d_gain>
<position_i_min>-1</position_i_min>
<position_i_max>1</position_i_max>
<position_cmd_min>-20</position_cmd_min>
<position_cmd_max>20</position_cmd_max>
<topic>topic_name</topic>
Copy link
Contributor

Choose a reason for hiding this comment

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

So what's the behavior without <topic> specified? Can we make sure that scenario works as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure you would need to pass it to the default topic instead. Is that preferred? Or just want it duplicated in that portion?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess my question is, has the default topic changed? I ask because #2546 changed some default topics for some systems and those systems had to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the default topic I don't believe has changed, the tutorial shows to publish this to control it:

gz topic -t "topic_name" -m gz.msgs.JointTrajectory -p '

Note that you need to have the topic name match that topic or it won't work.

And then it says to echo:

gz topic -e -t "/model/RR_position_control/joint_trajectory_progress"

Which once again if you change it to listen to published topic won't work. So one or the other needs to be changed/fixed to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

So @azeey do you want an example with only the default topic, only the "assigned topic" or one with both?

Copy link
Contributor

@caguero caguero Nov 18, 2024

Choose a reason for hiding this comment

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

@azeey , any final decision/comments here?

<joint_name>RR_position_control_joint2</joint_name>
<initial_position>-1.5708</initial_position>
<position_p_gain>10</position_p_gain>
<position_i_gain>0.2</position_i_gain>
<position_d_gain>0.5</position_d_gain>
<position_i_min>-1</position_i_min>
<position_i_max>1</position_i_max>
<position_cmd_min>-10</position_cmd_min>
<position_cmd_max>10</position_cmd_max>
</plugin>
```

Expand Down Expand Up @@ -667,7 +668,7 @@ In case, PID gains are not specified then by default force mode will work.
4) Checking the progress of the commanded trajectory.

```bash
gz topic -e -t "/model/RR_position_control/joint_trajectory_progress"
gz topic -e -t "/topic_name_progress"
```

This returns the progress of the commanded trajectory which is a value between (0,1].
Expand Down
Loading