Gazebo | Ignition | Community
Ask Your Question

shared pointer error when using world plugin

asked 2013-06-19 11:47:39 -0600

Zahra gravatar image


I get the following error :

gazebo: /usr/include/boost/smartptr/sharedptr.hpp:418: T* boost::shared_ptr<t>::operator->() const [with T = gazebo::physics::Entity]: Assertion `px != 0' failed.

when I am trying to use a world plugin in my world file . I have two models with different names that I want to control when using one world plugin, the models as following:

<include> <uri>model://moveable_door</uri> <name>doorentrance0</name> <pose>-3.097225 4.648542 0 0 0 0</pose> </include>

<include> <uri>model://moveable_door</uri> <name>doorentrance1</name> <pose>-3.097225 4.648542 3.6 0 0 0</pose> </include>

this error happens when I use both of those models, but when I use only one model in my world file, everything works fine. My purpose is to use this world plugin to manipulate this “moveable_door” model.sdf that I built in ./gazebo/models directory, and using this one model with different names, and controlling them with one world plugin.

Can anyone help me plz how to solve it, any ideas and suggestions are so much appreciated.

edit retag flag offensive close merge delete


For better response, please post more info, such as source code and methods of reproducing the error. Thanks!

hsu gravatar imagehsu ( 2013-06-20 10:36:57 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2013-06-20 16:00:45 -0600

Zahra gravatar image


the following is the source and the sdf model and the world file , the error I get gazebo: /usr/include/boost/smartptr/sharedptr.hpp:418: T* boost::shared_ptr<t>::operator->() const [with T = gazebo::physics::Entity]: Assertion `px != 0' failed.

So is there a way to use one model with multiple names and poses and controlling it with my world plugin without having to build multiple sdf models. Because as I mentioned earlier I dont get this error when I have multiple sdf. models with different names. Hope I could clarify the problem this time. Thanks in advance!

namespace gazebo

{ class AnimationTest : public WorldPlugin





  // Destructor
public: ~AnimationTest()

   // Disconnect the boost at the world update start signal. 


public: void Load(physics::WorldPtr _model, sdf::ElementPtr _sdf) {

// Store the pointer to the model this->model_ = model; this->model2 = _model;

// Listen to the update event. This event is broadcast every // simulation iteration.

this->updateConnection = event::Events::ConnectWorldUpdateBegin( boost::bind(&AnimationTest::OnUpdate, this,_1));


public: void close_door() { gazebo::common::PoseAnimationPtr anim( new gazebo::common::PoseAnimation("test", 1000.0, false));

  key = anim->CreateKeyFrame(0);
  key->SetTranslation( math::Vector3(-3.097225, 4.648542 ,0) );
  key->SetRotation( math::Quaternion(0,0,0.0) );

  key = anim->CreateKeyFrame(14.0);
  key->SetTranslation( math::Vector3(-3.097225, 4.648542 ,0) );
  key->SetRotation( math::Quaternion(0,0,1.5) );

 this->model_ ->GetEntity("doorentrance0")->SetAnimation(anim);

public: void close_doorentrance1() { gazebo::common::PoseAnimationPtr anim2( new gazebo::common::PoseAnimation("test", 1000.0, false));

  key2 = anim2->CreateKeyFrame(0);
  key2->SetTranslation( math::Vector3(-3.097225, 4.648542 ,3.6) );
  key2->SetRotation( math::Quaternion(0,0,0.0) );

  key2 = anim2->CreateKeyFrame(14.0);
  key2->SetTranslation( math::Vector3(-3.097225, 4.648542 ,3.6));
  key2->SetRotation( math::Quaternion(0,0,1.5) );

 this->model2_ ->GetEntity("doorentranc1")->SetAnimation(anim2);

model.sdf :

<sdf version="1.4"> <model name="doorentrance0"> <static>true</static> <pose>1 0 0.0 0 0 0</pose> <link name="body"> <pose>0 0 0.0 0 0 0</pose> <collision name="geom"> <geometry> <mesh> <uri>file://meshes/DoorAndFrame.dae</uri> <scale>0.35 0.2 0.33</scale> </mesh> </geometry> </collision> <visual name="visual1"> <geometry> <mesh> <uri>file://meshes/DoorAndFrame.dae</uri> <scale>0.35 0.2 0.33</scale> </mesh> </geometry>



<sdf version="1.4"> <world name="my_world">

<include> <uri>model://Light_bulbs</uri> <name>light11</name> <pose>-1 0 0 0 0 0</pose> </include>

<include> <uri>model://ground_plane</uri> </include>

<include> <uri>model://moveable_door</uri> <name>doorentrance0</name> <pose>-3.097225 4.648542 0 0 0 0</pose> </include>

<include> <uri>model://moveable_door</uri> <name>doorentrance1</name> <pose>-3.097225 4.648542 3.6 0 0 0</pose> </include> <plugin filename="" name="door_plugin"/> </world> </sdf>

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2013-06-19 11:47:39 -0600

Seen: 222 times

Last updated: Jun 20 '13