ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

Choosing the right coefficients for Gazebo simulation

asked 2012-03-27 01:24:10 -0500

Rosia Nicolae gravatar image

updated 2012-03-30 06:30:24 -0500

Hello, I am trying to create an URDF and simulate it in Gazebo for a 4WD Skid steering robot. The chasis is actually a box with the following properties:

  • body_width (base_size_y) : 22 cm
  • body_length (base_size_x) : 27 cm
  • body_height (base_size_z) : 5 cm
  • body_mass : 5 kg

    and wheels:

  • wheel_diameter : 0.12065 m
  • wheel_width : 0.060325 m
  • wheel_mass 0.181436948 kg

    I have created the URDF and a differential drive plugin for gazebo to simulate the model but I have no idea how to choose appropriate values for torque, mu1, mu2, kp, kd and inertia matrix. The values that I am currently using are taken/combined from the erratic/guardian/turtlebot stacks.

    By publishing the odometry (calculated in the plugin) and comparing the robot's position in Gazebo and RViz I can see that the model slips a lot while performing turns.

    Relevant files: myrobot.urdf.xacro myrobot_constants.xacro myrobot_wheel.xacro myrobot_materials.xacro

    Any help is appreciated.

    Thanks in advance.


    Here is the output from Solidworks for the chassis:

    Output  coordinate System: -- default --
    Mass = 489.90 grams
    Volume = 181445.50 cubic millimeters
    Surface area = 189380.73 millimeters^2
    Center of mass: ( millimeters )
           X = 41.53
           Y = 93.76
           Z = 131.23
    Principal axes of inertia and principal moments of inertia: ( grams *
    square millimeters )
    Taken at the center of mass.
            Ix = (0.00, 0.01, 1.00)        Px = 4157521.05
            Iy = (1.00, 0.00, 0.00)        Py = 5704820.80
            Iz = (0.00, 1.00, -0.01)       Pz = 9356042.65
    Moments of inertia: ( grams * square millimeters )
    Taken at the center of mass and aligned with the output coordinate system.
           Lxx = 5704820.80        Lxy = 0.00      Lxz = -0.00
           Lyx = 0.00      Lyy = 9355391.53        Lyz = 58176.21
           Lzx = -0.00     Lzy = 58176.21  Lzz = 4158172.18
    Moments of inertia: ( grams * square millimeters )
    Taken at the output coordinate system.
           Ixx = 18448329.91       Ixy = 1907623.47        Ixz = 2669963.78
           Iyx = 1907623.47        Iyy = 18637105.26       Iyz = 6086030.51
           Izx = 2669963.78        Izy = 6086030.51        Izz = 9309884.18

    And here is how I've put it in URDF:

    <link name="base_link">
            <mass value="${chassis_mass}" />
            <origin xyz="0.04153 0.09376 0.13123" />
            <inertia ixx="0.00415752105" ixy="0.0" ixz="0.0"
                     iyy="0.0057048208" iyz="0.0"
                     izz="0.00935604265" />

    Is this correct? I guess this is only correct if my model has the coordinate system aligned with the representation from Gazebo, right?

  • edit retag flag offensive close merge delete



    the update URDF block for base_link ineria looks right. Yes, assuming the coordinate system from your SWX export aligns with the coordinate of the URDF Link. Can you update the inertia blocks of the attached xacro files? Can you also post an approximation of slippage in your simulation? Thanks.

    hsu gravatar imagehsu ( 2012-03-30 09:44:15 -0500 )edit

    4 Answers

    Sort by ยป oldest newest most voted

    answered 2012-03-27 04:02:22 -0500

    DimitriProsser gravatar image

    This may or may not help, but when I was building my robot's simulator, I used my real robot as the model. I calculated my real robot's speed and did my best to match it in Gazebo. I tuned the real robot such that a cmd_vel message of 1.2m/s ahead would result in exactly 1.2m/s. I then did the same in Gazebo. I set the cmd_vel to 1.2m/s and measured Gazebo's result. If the wheels were slipping too much, I would adjust the constants in the simulator.

    <kp> and <kd> are basically the "solidness" of your model. As such, you want <kp> to be very high and <kd> to be low (I use a value of 1). As for <mu1> and <mu2>, I determined those by using the method that I mentioned above. (Mine came out to be mu1 = 200 and mu2 = 100 for my large robot). I tuned torque in the same way.

    The only one that I can't help you with is the inertia of the wheels. I used my SolidWorks model of the robot to automatically calculate the mass-moments of inertia for each wheel. See this question for help.

    edit flag offensive delete link more

    answered 2012-11-18 17:16:01 -0500

    It seems that the units for Inertia in Gazebo are Kg (meters)^2. -- sorry for the poor layout.

    This is the standard SI units for Inertia. If solidworks is giving your units in g mm^2 then to convert to kg m^2 you would need to:

    divide by 1 000 000 to convert from mm^2 to m^2.

    divide by 1000 to convert from g to kg.

    therefore you Ixx value of yours should be correct notwithstanding any differences in axes as I notice that you have used Izz as your Ixx value. To get around this potentially confusing issue, I typically have drawn the object as per a "rest" orientation, and used this as the basis for all values inputed into the urdf file.

    You should only need to use the Inertia values about the centre of gravity, if your centre of gravity is not colocated with your origin then use the <origin> parameter for inertia for Gazebo to convert.

    Hope this helps

    Peter Milani

    edit flag offensive delete link more

    answered 2012-03-30 09:49:31 -0500

    hsu gravatar image

    Friction / slippage is sensitive to constraint satisfaction (LCP) convergence. You may try increasing the LCP inner iterations (<quickStepIters> in electric world file or <solver iters="10"/> in fuerte world file) from 10 to 200 and check how friction slippage is affected.

    edit flag offensive delete link more

    answered 2012-12-19 08:15:12 -0500

    brawner gravatar image

    These answers all provide good information. I just want to point out that you should be taking the values for the moment of inertia from the block that specifies the 'moment of inertia taken at the center of mass aligned with the output coordinate system'. And then make sure your output coordinate system matches the link origin. That is, you can insert a reference coordinate system in SolidWorks where the visual and collision origins are set. If this weren't the base_link, you would place the output coordinate system at the origin location of the joint connecting the link to its parent link.

    edit flag offensive delete link more

    Your Answer

    Please start posting anonymously - your entry will be published after you log in or create a new account.

    Add Answer

    The deadline to submit a proposal to present at ROSCon 2017 is June 25, 2017. Submit yours now!

    Question Tools



    Asked: 2012-03-27 01:24:10 -0500

    Seen: 4,332 times

    Last updated: Dec 19 '12