gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Document the various ways of controlling a joint

Open chapulina opened this issue 3 years ago • 10 comments

Ignition Gazebo offers many out-of-box controllers with different features and intended use cases, for example:

It can be difficult for users to choose what to use. So it would be nice to have a high-level joint control tutorial explaining the features and usage of each of them, and why a user would choose one over the other.

Desired behavior

We should have a new tutorial in https://ignitionrobotics.org/api/gazebo/5.1/tutorials.html which summarizes all ways of controlling a joint.

Alternatives considered

Instead of documenting just joint controllers, we could document all ways of moving things, including links, models, etc. This reminds me of this great Gazebo classic tutorial: Setting Velocity on Joints and Links

Implementation suggestion

Add a tutorial here: https://github.com/ignitionrobotics/ign-gazebo/tree/ign-gazebo5/tutorials

chapulina avatar Sep 09 '21 01:09 chapulina

Hey @chapulina Can I please work on this issue

ishaanmane avatar Sep 23 '21 07:09 ishaanmane

Hi @ishaanmane

Nobody pick this issue yet! it's all yours! Happy to review your PRs.

ahcorde avatar Sep 23 '21 07:09 ahcorde

Hi. Is there any progress on this? I’m a new user to Gazebo looking for a joint control tutorial. (I can’t get any of the related demo worlds in Garden to work.) Thanks

LeePerry avatar Sep 25 '23 05:09 LeePerry

Hi @ahcorde, I think I can document the various joint controllers and also for the movement of link and models. So, should I contribute to this issue ?

yaswanth1701 avatar Nov 19 '23 04:11 yaswanth1701

Hi @yaswanth1701,

Feel free to contribute, there are two places that you can contribute with tutorials:

  • https://github.com/gazebosim/gz-sim/tree/gz-sim7/tutorials ( the joint controller docs may live here)
  • https://github.com/gazebosim/docs/tree/master/harmonic ( if yo uare thinking about porting this http://gazebosim.org/tutorials?tut=set_velocity&cat= too, the best place probrably is here)

ahcorde avatar Nov 20 '23 09:11 ahcorde

Oh, thanks a lot. I will start working on this.

yaswanth1701 avatar Nov 20 '23 13:11 yaswanth1701

Hi @ahcorde and @azeey, I wrote a bit of a tutorial for the joint controllers and was thinking of asking for your suggestions on whether this is the right direction or if should I make some changes. If possible can you please give your input on this?


Tutorial for Joint controllers

1) joint_controller

  • Joint controller which can be attached to a model with a reference to a single joint.
  • Currently, only the first axis of a joint is actuated.

possible use of this controller type is where one wants only to actuate a single joint.

modes of joint_controller

  1. Velocity mode

  2. Force mode

Velocity mode:

This mode lets the user control the desired joint directly.

parameters:

<joint_name> (type: String):
specify the joint name (same as one in SDF)
<use_force_mode>(type: Bool): 
by default, this is set to False or one can explicitly specify it as False. 
<initial_velocity> (type: Double):
specify the initial command velocity(default is set to 0.0)

Force mode:

A user who wants to control joint velocity using a PID controller can use this mode.

parameters:

<joint_name> (Type: String):
specify the joint name (same as one in the SDF file)
<use_force_control> (Type: Bool):
set this to True
<p_gain> (Type: Double):
The proportional gain of the PID. The default value is 1.
<i_gain> (Type: Double):
The integral gain of the PID. The default value is 0
<d_gain> (Type: Double):
The derivative gain of the PID. The default value is 0.
<i_max> (Type: Double):
The integral upper limit of the PID. The default value is 1.
<i_min> (Type: Double):
The integral lower limit of the PID. The default value is -1.
<cmd_max> (Type: Double):
Output the max value of the PID. The default value is 1000.
<cmd_min> (Type: Double):
Output min value of the PID. The default value is -1000.
<cmd_offset> (Type: Double):
Command offset (feed-forward) of the PID. The default value is 0.

This mode lets the user explicitly set the values of PID gains and also bounds for velocity.

Note: This mode is for the user who looking to manually tune PID for velocity control according to a specific use case (e.g. Custom models). For general purposes, velocity mode will give the best results.

In both the modes commanded velocity(cmd_vel) can be published or subscribed at the topic: /model/<model_name>/joint/<joint_name>/cmd_vel.

Example usage:

At the end of the model’s SDF file append the following lines:

  • Velocity mode
<plugin filename="gz-sim-joint-controller-system"
name="gz::sim::systems::JointController">
<joint_name>joint_name</joint_name>
<initial_velocity>5.0</initial_velocity>
</plugin>
</model>
</world>
</sdf>
  • Force mode:
<plugin
 filename="gz-sim-joint-controller-system"
 name="gz::sim::systems::JointController">
 <joint_name>joint_name</joint_name>
 <use_force_commands>true</use_force_commands>
 <p_gain>0.2</p_gain>
 <i_gain>0.01</i_gain>
 </plugin>
 </model>
 </world>
 </sdf>

yaswanth1701 avatar Dec 02 '23 19:12 yaswanth1701

@yaswanth1701 thank you so much for taking this on!

What you have so far is definitely in the right direction. I would say it would be great to build a full example of a robot where the joint is controlled with these modes and to include example commands and expected results (eg. a gif showing the robot move in a certain direction or robot arm going to a certain configuration). We should assume the audience to be beginners learning Gazebo so including just the <plugin> snippets might not be sufficient to get them going.

Regarding the parameters, I think it would be better to link to https://gazebosim.org/api/sim/8/classgz_1_1sim_1_1systems_1_1JointPositionController.html than to list them in the tutorial.

azeey avatar Dec 05 '23 16:12 azeey

@azeey thanks for the review, Sure I will try make it more friendly towards beginners and will let you know on updates soon.

yaswanth1701 avatar Dec 05 '23 16:12 yaswanth1701