Gazebo | Ignition | Community
Ask Your Question

Effect of Stiffness and Mass on Gazebo Simulation stability

asked 2012-12-20 22:01:48 -0600

PMilani gravatar image

Hi All,

I've been developing a model that has hydraulic actuators that are as a result very stiff in that a small change to either the load on the actuator or on the valve spool will result in a relatively instant and relatively large change in the states of the actuator. These motors are represented by a class hydmotor;

//Hydraulic motor models
        hydmotor motor_joint1, motor_joint2, motor_joint3, motor_joint4, motor_joint5, motor_joint6, motor_joint7, motor_gripper;

during the update of the plugin the motors are run through a simulation step of their own based on their own states for pressureload using Gazebo provided dt (from get sim time) and GetVelocity(), returning the result (the force on the joint) via SetForce(axis, value):

    //motor_joint1.u = 0.5;
    motor_joint1.thetaspeed =joint1->GetVelocity(0)*motor_joint1.gearratio;
    //Calculate the Motor Dynamics

    joint1->SetForce(0, (motor_joint1.getTorque()*motor_joint1.gearratio));

dt is calculated from sim_Time. the method:


Is basically where the next state iteration is calculated for the motor (where the states are pressureload, and rotationalspeed and the input is the valve position.

These have been incorporated into a Gazebo model via a plugin so that it can talk to ROS. To get it to work required a dt value of around 0.1 ms in the solver. Anything larger and the model ( a serial robot made of a number of links) would end up as a jumbled heap. I tried increasing the iter value about 100 times and can see that the model works for a short time before becomming unstable and flying apart.

My question is why would stability be affected if I only add an additional variable of type hydmotor?

I would expect it to run slower sure, but not to affect the overall stability.

The stability issue can be corrected by making the solver timestep even slower. at the moment it sits at about dt = 0.000044 with iters = 95.


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-12-26 22:11:11 -0600

PMilani gravatar image

Okay, the reason why the model was failing was due to hydmotor::updateinput returning NaN. This was due to part of the modelling algorithm where the change in Pressureload would mean that the next iteration in the pressure would be greater than the supply pressure and result in a sqrt(-x) in the algorithm.This was due to the stiffness of the algorithm where the change in pressureload could push the pressure beyond the supply pressure. This would routinely happen and could only be overcome by making dt small.

However another solution could also be used where if Pressureload were greater than supply pressure, then we could accept that was a anomaly of the simulation (quite small dt showed that the Pressureload actually assymptotes to supply pressure). So to make the calculation more efficient when Pressureload was beyond supply pressure we would simply make it slightly less.

Problem was I wasn't picking up all cases of this in my updateInput, and once I modified it to pick up all cases I could easily increase dt a 100-fold with no ill effect. The simulation now runs at least in real time.



edit flag offensive delete link more

answered 2012-12-21 10:56:49 -0600

RoboUser gravatar image

You said:

My question is why would stability be affected if I only add an additional variable of type hydmotor?

I believe you answered your own question in your first sentence. You added a new model of your hydraulics which was very stiff and consequently you needed to drop your integration plant dt. This sort of problem is endemic to all numerical simulations really. If running your simulation slower isn't an option, I'd investigate if there's any way you can change your hydraulic model to make it less stiff.

edit flag offensive delete link more


Okay, but if it requires a small dt for one variable of type hydmotor, why would it require an even smaller dt as you add hydmotors. There is no great increase in complexity ie the number of floating point operations wouldn't be above say 40.

PMilani gravatar imagePMilani ( 2012-12-23 17:23:21 -0600 )edit

Question Tools


Asked: 2012-12-20 22:01:48 -0600

Seen: 1,943 times

Last updated: Dec 26 '12