Home | Tutorials | Wiki | Issues
Ask Your Question
0

Attaching plugin to a model programmatically

asked 2017-05-28 11:25:13 -0500

jelavice gravatar image

Is it possible to attach plugin to a model directly from the code (not in the sdf files or xml files). So I want to add the model programmatically inside the simulation and then attach a model plugin to that model by specifying the path to the plugin library.

Something like:

//load model

worldPtr_->InsertModelFile(modelName);

//get model pointer

modelPtr = getModelPtr();

//attach a plugin to that model

attachPlugin(modelPtr, pluginName)

The code above should be executed inside the world plugin. Is something like that even possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-05-29 02:19:02 -0500

jelavice gravatar image

This can be done by manually calling the function "Create" with prototype static TPtr Create( const std::string & _filename, const std::string & _name). This function is defined in the ModelPlugin.hh header. After that, the "Load" function with prototype void Load(physics::ModelPtr _parent, sdf::ElementPtr /_sdf/) should be called.

This will load the plugin dynamically and register it to the gazebo server.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-28 11:25:13 -0500

Seen: 86 times

Last updated: May 29 '17