0
$\begingroup$

Gazebo Answers logo

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?


Originally posted by jelavice on Gazebo Answers with karma: 5 on 2017-05-28

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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.


Originally posted by jelavice with karma: 5 on 2017-05-29

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.