Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to spawn multiple clone of model using msg::Factory?

asked 2018-11-13 07:12:13 -0500

AchmadFathoni gravatar image

updated 2018-11-13 10:33:07 -0500

I am using model spawner according this world plugin tutorial with option number three using msg::factory

  transport::NodePtr node(new transport::Node());
  node->Init(_parent->Name());
  transport::PublisherPtr factoryPub =
  node->Advertise<msgs::Factory>("~/factory");
  msgs::Factory msg;

  msg.set_sdf_filename("model://cylinder");

  msgs::Set(msg.mutable_pose(),
      ignition::math::Pose3d(
        ignition::math::Vector3d(1, -2, 0),
        ignition::math::Quaterniond(0, 0, 0)));

  factoryPub->Publish(msg)

I use this option because it let me set the spawn position. My problem is I do not know how to spawn another clone with same SDF model file using this method, I tried call factoryPub->Publish(msg) again but it seem gazebo only spawn a model per SDF model file.

edit retag flag offensive close merge delete

Comments

Can you include the version of Gazebo you are using?

nkoenig gravatar imagenkoenig ( 2018-11-13 09:32:21 -0500 )edit

@nkoenig, already in the tag

AchmadFathoni gravatar imageAchmadFathoni ( 2018-11-13 10:33:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-14 09:18:55 -0500

nkoenig gravatar image

I think you'll need to change the name of the model. Or, you can upgrade to gazebo8 or gazebo9. Since gazebo8 the factory.proto has been modified to automatically rename models. Since you are on gazebo7, you'll have to modify the model name before sending the message.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-13 07:12:13 -0500

Seen: 148 times

Last updated: Nov 14 '18