gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.17k stars 477 forks source link

Attach a joint between models in world plugin #2617

Open osrf-migration opened 5 years ago

osrf-migration commented 5 years ago

Original report (archived issue) by Anonymous.


Hi, I would like to attach a joint between models in world plugin I follow the tutorial in World plugins. I can add the model to the world, however, I want to attach a joint between models like this

    sphereSDF.SetFromString(
       "<sdf version ='1.4'>\
          <model name ='sphere'>\
        <include>\
            <uri>model://payload</uri>\
            <pose>0.0 0.0 0.35 0 -1.57 0</pose>\
           </include>\
        <joint name='payload_link_drone_joint' type='fixed'>\
          <parent>iris::base_link</parent>\
          <child>unique_sphere::payload::payload_link</child>\
          <pose>-0.00 0.0 -0.25 0 0.0 0.0</pose>\
        </joint>\
          </model>\
        </sdf>");
        sdf::ElementPtr model = sphereSDF.Root()->GetElement("model");
         model->GetAttribute("name")->SetFromString("unique_sphere");
         this->world->InsertModelSDF(sphereSDF);

But the joint doesn't appear, is there any problem with my code?

osrf-migration commented 5 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


If you run with --verbose, is there any console output? There is some quite complicated code for identifying the parent and child links of a joint:

osrf-migration commented 5 years ago

Original comment by q199493422 (Bitbucket: q199493422).


When I run with --verbose, it shows some errors

[Err] [InsertModelWidget.cc:302] Missing model.config for model "/home/ncrl/src/Firmware/Tools/sitl_gazebo/models/.git"
[Err] [Joint.cc:262] EXCEPTION: Couldn't Find Parent Link[iris::base_link]
[Err] [Model.cc:209] LoadJoint Failed

I'm sure that the parent link name is correct. I don't know why it shows that it couldn't find Parent Link. The model's configuration is as following Screenshot from 2019-04-19 11-09-58.png