How to spawn multiple clone of model using msg::Factory?
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.
Asked by AchmadFathoni on 2018-11-13 08:12:13 UTC
Answers
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.
Asked by nkoenig on 2018-11-14 10:18:55 UTC
Comments
Can you include the version of Gazebo you are using?
Asked by nkoenig on 2018-11-13 10:32:21 UTC
@nkoenig, already in the tag
Asked by AchmadFathoni on 2018-11-13 11:33:09 UTC