# Properly making soft joints to world in Gazebo 9 + ROS Melodic

I'm trying to interact a position-controlled robot with "fixed" obstacles in its environment. In this case, they're a couple of floating spheres, "magically" fixed in space. I'm using default ros-melodic-desktop-full installations to do this, in this case Gazebo 9.13.1 on Windows.

With <static> obstacles and default constraint parameters, the robot "explodes" if it touches obstacles. This is reasonable behavior given the incompatible constraints of infinitely rigid object meets immovable object.

If I add some global constraint force mixing with <cfm> tags at world->physics scope, it stabilizes the simulation and makes the robot's contacts with the world understandable, but it also allows the joints to slide apart. This is also correct behavior from the standpoint of what CFM does, but it's not the desired behavior.

What I'd like to do is attach the floating spheres to the world frame using spring-dampers that are much softer than the robot joints, so that they easily slide out of the way if the robot collides without pulling the robot joints apart visibly.

I'm having a very hard time finding a correct and complete description on how to do this, partially because any suggestions are scattered across many years of SDF file format changes, unanswered ROS Answers and Gazebo Answers questions, and so on.

I have successfully held the spheres in place with fixed joints so they move a little with relaxed constraints. After a long time experimenting (because of lack of a complete example) I figured out I could put those joints in a nested <model> so I could write this "boundary condition" in my world file instead of the complex model file that defines the visual/inertial/collision geometry.

Now I'd like to soften the joints that hold the spheres in place. So I'm trying to set different <cfm> and <erp> values for the spheres' fixed joints, or maybe <implicit_spring_damper> or ... what? Everything I've tried has resulted in the spheres' displacements being the same order of magnitude as the robot's displacement.

I still can't find a documentation source that's any more useful than http://sdformat.org/spec?elem=joint&v..., but that just kind of tells me which tags I might try, not how they fit together.

The image was captured using these settings for the red sphere:

<model name="soft_fixed_big_red">
<include>
<uri>model://big_red</uri>
<name>red_sphere</name>
</include>
<joint name="bc" type="fixed">
<parent>world</parent>
<physics>
<ode>
<implicit_spring_damper>1</implicit_spring_damper>
<cfm>0.9</cfm>
<erp>0.2</erp>
</ode>
<provide_feedback>true</provide_feedback>
</physics>
</joint>
<pose>0.15 0.50 0.45 0 0 0</pose>
</model>


The spheres had mass properties like solid plastic when I started. I tried making them thin, extremely light spherical shells, which made it shakier but roughly similar in relative sphere and robot displacements.

At the world level (which contains the red and blue sphere models, ground plane, and sun), I have this:

<physics name ...
edit retag close merge delete

<dynamics> tagged joints may be a partial solution, but very verbose to go to 6DOF springiness

  <joint name="bcz" type="prismatic">
<parent>world</parent>
<axis>
<xyz>0 0 1</xyz>
<dynamics>
<damping>100</damping>
<spring_reference>0</spring_reference>
<spring_stiffness>1000</spring_stiffness>
</dynamics>
</axis>
</joint>

( 2021-02-05 16:20:43 -0500 )edit

I'm chasing the wrong modeling paradigm here and I think I'm probably going to go with virtual cardboard boxes for anything that can sit on the floor until I can get around to building some effort-controlled URx robots that more gracefully handle accidental contact with a rigid world.

However, the original question about using CFM and ERP to do 6DOF soft constraints comes up from time to time, hopefully someone can help there?

( 2021-02-05 16:50:14 -0500 )edit

I tried to add two prismatic joints in series with a light link in between and now the red sphere behaves correctly for a little while when in contact with the robot but then implodes to the origin.

( 2021-02-09 13:39:39 -0500 )edit

Serial joints now working correctly. Had the damping set too low on the second joint of the red sphere.

Working okay now with x, y, z, slides with critically-damped spring dampers using <implicit_spring_damper> set to 1 as well. Dummy link between joints is just 10 grams with kg-scale spheres, works okay.

( 2021-02-09 15:25:12 -0500 )edit

Sort by » oldest newest most voted

I solved this for 3DOF compliance on the red sphere with a chain of prismatic joints and links with <implicit_spring_damper> behavior and <dynamics> elements defining <damping>, <spring_stiffness> and <spring_reference> elements.

I used 10 gram links with reasonable symmetric inertia matrix elements and made the spring-dampers critically damped for the moving mass, and it seems pretty okay.

I had some trouble with the sphere snapping to the global origin, but only when I had the damping set way too low by mistake. Not 100% sure whether or not <implicit_spring_damper> was also helpful, but seems like there's a lot of discussion about having this turned on by default, which makes sense to me to avoid instabilities.

It's a pretty verbose way to define a 3DOF spring-damper but it works okay.

I found this discussion:

This suggests

A floating joint in Gazebo (SDF) is just no joint 😉

But I think the ability to define dynamics on various axes means that "no joint" and "a 6DOF joint" are not identically equal. It'd be cool to have some 2DOF and 3DOF translational joints that do this job more tersely.

We've already got revolute2 and ball joints for the rotational equivalent I guess.

A 6DOF bushing type joint on which one can define dynamics would be nice, but I think I know how to do the job I wanted to do now with the tools we have.

more

It looks like <implicit_spring_damper> is not actually supported yet at least in the way I'm using it. When I start Gazebo I get warnings that it's not supported. Need to check my SDF versions and support in Gazebo.

( 2021-02-10 20:35:18 -0500 )edit

Forgot the <physics><ode> tags around it.

( 2021-02-11 08:42:18 -0500 )edit