Porting Vacuum Gripper to Gazebo Garden

I am working on creating a vacuum gripper plugin for Gazebo Garden. I want to create something simple that dynamically creates a fixed joint during runtime between two links.

Currently I have a plugin loading and it’s creating a joint. But I have hit a problem with the Physics system not receiving updates.

From the code here you can see the physics system only creates “New” entities: gz-sim/Physics.cc at bb85d05a373eb8cb21d0c8881918374234b2227f · gazebosim/gz-sim · GitHub

The issue I am facing is that when I add a joint, I believe my plugin (using the ISystemUpdate interface) is running after the physics system. Which means my entity is no longer “new” when the physics system reruns on the next timestep.

I have tried moving to a plugin which implements ISystemPreUpdate, but the issue is that the model map is not populated at that time (or so I believe) as I get the following error when referencing any entity as the parent of the joint.

[Err] [Physics.cc:1657] Joint's parent model entity [40] not found on model map.

I think this is because the model map is built during the Update step of the physics system, not sure why it would be empty in the PreUpdate function of my plugin though… (I don’t see where it is cleared).

Any pointers on how to dynamically add joints in Gazebo would be appreciated. It seems possible from the code but I can’t get the system execution ordering right to get it to work.

Do you have a minimal code example of the plugin? If so, I am very willing to have a look at it.
No guarantees though, as given the lack of documentation about the core Gazebo concepts, there’s a low probability that I will understand it better than you… Yet two minds see more than one…

Re,
Johan

I was able to get a bit further. I have some code that creates two entities, one a model with a name pose and parent entity set to world. The other is a joint with all the pre-requisite components for that. I can see that it runs through the Physics engine and is properly added but I get this:

[Err] [SDFFeatures.cc:774] The link of the parent frame [tool_link] with resolved link name [tool_link] of joint [fixed_joint] could not be resolved. The joint will not be constructed

I can’t provide you with the code but it basically looks like:

parent = new Entity()
ecm.setComponent(parent, Pose(Blah))
ecm.setComponent(parent, Model())
ecm.setComponent(parent, Name("parent"))
ecm.setComponent(parent, parentEntitiy(World))

joint = new Entitiy()
joint.setComponent(... Joint, Name, JointType, Pose, ThreadPitch)... // Not important
joint.setComponent(joint, ParentEntitiy(parent))
joint.setComponent(joint, ParentName("tool_link"))
joint.setComponent(joint, ChildName("object"))

This is erroring because the joint is trying to attach a model outside the joints parent.

Basically I am trying to weld together two SDF models using a fixed joint in a third model.
It seems this is illegal, but I don’t know if there is a way to otherwise weld two separate models together. I wonder if I could parent them all to the same entity and if that would work? Or maybe put all objects in the world into one “model”. Don’t know if there is performance penalties associated with that.

I didn’t check it in detail, but I think this might be what you are looking for: AttachableJoint (or at least a good pointer?).

I found above reference in this issue: Dynamically create/remove joint #126

This is another vacuum gripper plugin but unfortunately for Gazebo Classic.

Ah yes, that solved the issue!

I was thinking that I needed to use DetachableJoint in my SDF such as its intended. But, after rereading that issue I realized the point was that DetachableJoints can be dynamically added and removed unlike normal joints.

After changing my above code to just be a joint that has the “DetachableJoint” component, it worked as intended. Thank you for all the help!