Gazebo | Ignition | Community
Ask Your Question

Spawn object attached to a frame in simulation

asked 2022-09-06 21:24:22 -0600

MarqRazz gravatar image

updated 2022-09-07 07:52:32 -0600

ROS Version: Humble

Gazebo Version: Fortress

I'm looking for suggested ways of spawning an object that is attached to a robot arm at run time. That is I'm spawning a URDF model of the arm at startup and then I want to spawn and attach an object to an arm link while running the simulation.

If I use the service interface with the following command: ign service -s /world/depot/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/root/calibration_ws/cal_grid/model.sdf", name: "sdf_model"'

And here is my sdf defined model and joint to attach it to the robot:

<model name="charuco_default">
    <link name="charuco_link">      
      <visual name="visual">
      <collision name="collision">
  <joint name="cal_joint" type="fixed">
    <pose>0 0 2 0 0 0</pose>

But when I spawn the object it is not attached to my robots link and appears at world 0,0,0

When I look in the UI I can see that the model sdf_model (which is the name I spawned with) lists the Parent Entry as 1 which is the same for my robot which I assume means world is the parent. image description

If I run: ign model -m sdf_model I get.

    Model: [66]
  - Name: sdf_model
  - Pose [ XYZ (m) ] [ RPY (rad) ]:
    [-0.000000 0.000000 -0.004950]
    [0.000001 0.000001 0.000065]
  - Link [67]
    - Name: charuco_link
    - Parent: sdf_model [66]
    - Mass (kg): 1.000000
    - Inertial Pose [ XYZ (m) ] [ RPY (rad) ]:
      [0.000000 0.000000 0.000000]
      [0.000000 -0.000000 0.000000]
    - Inertial Matrix (kg.m^2):
      [1.000000 0.000000 0.000000]
      [0.000000 1.000000 0.000000]
      [0.000000 0.000000 1.000000]
    - Pose [ XYZ (m) ] [ RPY (rad) ]:
      [0.000000 0.000000 0.000000]
      [0.000000 -0.000000 0.000000]

Any ideas to make it work as desired?

More testing...

So I tried to set my model name of my sdf to the robot's name but get a bunch of errors looking it up.

 [ign gazebo-4] [Err] [] Error Code 19: Msg: Child frame with name[charuco_default] specified by joint with name[cal_joint] not found in model with name[kinova].
[ign gazebo-4] [Err] [] Error Code 24: Msg: FrameAttachedToGraph error, Non-LINK vertex with name [kinova::cal_joint] is disconnected; it should have 1 outgoing edge in MODEL attached_to graph.
[ign gazebo-4] [Err] [] Error Code 24: Msg: Graph has __model__ scope but sink vertex named [kinova::cal_joint] does not have FrameType LINK or STATIC_MODEL when starting from vertex with name [kinova::cal_joint].
[ign gazebo-4] [Err] [] Error Code 25: Msg: relative_to name[charuco_default] specified by joint with name[cal_joint] does not match a nested model, link, joint, or frame name in model with name[kinova].
[ign gazebo-4] [Err] [] Error Code 27: Msg: PoseRelativeToGraph error, Vertex with name [kinova::cal_joint] is disconnected; it should have 1 incoming edge ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-09-28 13:40:53 -0600

azeey gravatar image

SDFormat models have to be self contained, i.e, a joint cannot reference a link/frame outside of the model (except world). So when you tried to spawn your model, it's failing at the SDFormat parsing stage.

This kind of thing is best accomplished using a plugin. My suggestion is to try using the DetachableJoint plugin. You can put the plugin in the object you're spawning at runtime. By default, the DetachableJoint plugin creates a fixed joint between two links when it gets loaded.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-09-06 21:24:22 -0600

Seen: 344 times

Last updated: Sep 28 '22