I use gazebo to simulate a robot arm. To control its joints, I use PID controllers. As you might know, PID are sometimes pretty hard to tune and this is the case for a robotic arm. To avoid any tuning, and because I don't need the PID values to be realistic, I set to zero the derivative and integral parameters, increase a lot the proportional gain and add a lot of damping in my joints. By doing this, I can get a well working arm but only if I disable the gravity.

My question is the following. Do you have an idea how I could simulate a very strong actuator with not necessarily realistic parameters?

EDIT 1: Setting the integral and derivative gain is stupid. The integral gain helps in correcting the effect of the gravity. The derivative gain counters the loss of stability and speed due to the integral gain.

This question somehow leads to another. Do you know what tuning do the robotic arm manufacturer (big arms for car industry for example). I guess that this arm use actuators with a very strong torque and a low maximum speed which reduces the need of tuning.

EDIT 2: More info on my setup. I use gazebo 6, with ODE. The robot description is in SDF. I control the robot with a model plugin. As a PID controler I use the PID class from the common library of gazebo and get directly the JointControler associated to the model.

Let say that I would like actuators very robust without any tuning needed. This way I could have a simulation WITH dynamics (by opposition to the SetPosition method). Do you think it is possible ?

  • $\begingroup$ Would the offline programming techniques suit what you're after? For example: easy-rob.com/uploads/media/rds.pdf $\endgroup$
    – SteveO
    Commented Mar 19, 2016 at 0:17
  • $\begingroup$ Your question does not make much sense. The gazebo motor simulation is likely a simulation of an ideal motor (a torque source only) unless you have intentionally added a more complex one in. Perhaps some more information on what you are trying to accomplish would help. $\endgroup$
    – hauptmech
    Commented Mar 19, 2016 at 6:53
  • $\begingroup$ @hauptmech: What gazebo motor simulation are you talking about. The only way to actuate a joint is to use PID Controller. And if you want it to work, you need to tune it. $\endgroup$
    – Robin
    Commented Mar 19, 2016 at 18:10
  • $\begingroup$ @SteveO: interesting paper, I'll check a deeper sight on it. The implementation of the realistic dynamic simulation looks however pretty hard. $\endgroup$
    – Robin
    Commented Mar 19, 2016 at 18:44
  • $\begingroup$ @debzsud There's a lot of ways to use gazebo. More info on what API's you are using or anything like that will get you a better answer. $\endgroup$
    – hauptmech
    Commented Mar 20, 2016 at 8:59

3 Answers 3


What you're asking for cannot be accomplished with a PID controller. As I understand your question, you want to be able to choose PID gains that would always produce a "good" trajectory, without tuning. You said it's alright if the motor output is unrealistic, i.e. the motors are "very strong" therefore can produce unlimited torque. However, you cannot escape the fact the your system has inherent dynamics. The response of the joint will always be affected by its inertia and damping, so unless you set those values to zero your response will change as they change. Since a robotic arm with more than 1 joint is nonlinear, inertia and apparent damping due to centrifugal and Coriolis effects will be changing constantly.

More Explanation

First, you seem to have some misunderstanding of how a PID controller works. A really simplistic description would be, given you want to get to some position $x_d$ and speed $v_d$:

  • the proportional term: the farther I am from $x_d$, the harder I push toward $x_d$
  • the derivative term: the slower/faster I am than $v_d$, the harder I push to speed up/slow down
  • the integral term: gee, all this pushing I've been doing hasn't gotten me much closer to $x_d$, I should push harder in that direction

Yes, the derivative term can help to reduce the oscillations introduced by the integral term, but that is not its purpose.

PID controllers are a great example of classical control, and are very useful because they can be tuned experimentally without knowing the exact mathematical model of the system you want to control. With some clever tuning you can make it so that the PID controller gives you a reasonable response for a small range of parameters, allowing them to work with nonlinear systems or linear time-variant systems, but there are two qualifying statements there: the parameter range has to be small and the controller has to be tuned. The parameter variation for multi degree of freedom robotic arms can be quite large (e.g. your inertia could double or halve in value) so achieving what you want without tuning at all is very difficult.

Possible Solutions

  1. Turn off gravity and move your arm really slowly (i.e. large derivative gain relative to your proportional gain). The nonlinearities of robotic arms mostly come from dynamic coupling between joints, moving slowly should keep them really small.

  2. Manually program the trajectories of each joint in the sim (fudging the dynamics). Let's say you're starting from angular position $\theta_0$ and you want to get to $\theta_d$. You could program the joints so that when they get a command to move to $\theta_d$ they follow a specific trajectory, for example $\theta(t) = \theta_0 + (\theta_d - \theta_0)(1 - e^{-t/\tau})(1 + t/\tau))$ will give you a smooth trajectory with no overshoot from the initial to the final position. Just adjust $\tau$ until it's as fast or slow as you like. The only problem with this method is that if you interrupt it during its motion it will look weird due to discontinuity.


Industrial robot controllers (and most "real" robot arm controllers) will have a feedforward term to remove the effect of gravity. Often called gravity compensation. You noticed how necessary this is when you disabled gravity...

Check your chain of libraries for an artificial limit being set on the joint effort (torque).

You might take a look at moveit! to see if it helps you. Otherwise you are going to have to take the time to learn a bit of robotics (and controls) math.

  • $\begingroup$ Sometimes there's no shorter paths to the goal: you ought to read a book, debzsud ;) $\endgroup$ Commented Jul 20, 2016 at 18:57

I can get a well working arm but only if I disable the gravity.

It seems to me you are not using feedback linearizing approach with your PID controller. Remember PD and PID work only with linear models. If you have no uncertainties in your model which is what you are looking for by saying "an ideal motor", then PD works very well. Once you add uncertainties in your model then you need to utilize PID to overcome the steady state error.

  • $\begingroup$ Well, good point. The integral gain actually prevents the arm to fall down. I still have problems to tune it, or the joints converge much to slow to their targets, or the arm stops before reaching the targets. My question is more: is there a way to mathematically/programmatically cheat (using unrealistic values or chunck of code) and be sure to get actuators that converge fast enough and precisely to their targets? $\endgroup$
    – Robin
    Commented Mar 19, 2016 at 18:13
  • $\begingroup$ I got your point CroCo, but I'd rather tone down your sentence "Remember PD and PID work only with linear models". That's not true: PID work great with nonlinear plants too. That has been their fortune in many applications. This happens because the high open-loop gain helps reduce the effects of nonlinearities and uncertainties in the closed-loop system, allowing even a linear compensator to deliver acceptable performance when applied to nonlinear plants. Just say that feedback linearization and/or I term will help PID work better. $\endgroup$ Commented Jul 20, 2016 at 18:51
  • $\begingroup$ @Ugo, thanks for the info. I will double check it but it seems to me even though increasing gains will reduce errors, it is impractical due to saturation phenomenon. $\endgroup$
    – CroCo
    Commented Jul 20, 2016 at 22:51
  • $\begingroup$ @CroCo you're definitely right about saturation, something that is always there 'cause purely linear plants do not exist in nature, actually. Further, high gains will drive the system more toward instability, of course. My argument was thus only very general to highlight that even though nature is nonlinear, a linear controller does its job pretty well - in the operative conditions we can profitably determine. $\endgroup$ Commented Jul 21, 2016 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.