Robotics StackExchange | Archived questions

shared pointer error when using world plugin

Hello,

I get the following error :

gazebo: /usr/include/boost/smartptr/sharedptr.hpp:418: T* boost::shared_ptr::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:

model://moveable_door doorentrance0 -3.097225 4.648542 0 0 0 0

model://moveable_door doorentrance1 -3.097225 4.648542 3.6 0 0 0

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.

Asked by Zahra on 2013-06-19 11:47:39 UTC

Comments

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

Asked by hsu on 2013-06-20 10:36:57 UTC

Answers

Hello,

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::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

{

 public:AnimationTest()

   {

}

  // Destructor
public: ~AnimationTest()

{
   // Disconnect the boost at the world update start signal. 
  event::Events::DisconnectWorldUpdateBegin(this->updateConnection);


}

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 :

true 1 0 0.0 0 0 0 0 0 0.0 0 0 0 file://meshes/DoorAndFrame.dae 0.35 0.2 0.33 file://meshes/DoorAndFrame.dae 0.35 0.2 0.33

            </visual>
        </link>

    </model>
   </sdf>

model.world:

<?xml version="1.0"?>

model://Light_bulbs light11 -1 0 0 0 0 0

model://ground_plane

model://moveable_door doorentrance0 -3.097225 4.648542 0 0 0 0

model://moveable_door doorentrance1 -3.097225 4.648542 3.6 0 0 0

Asked by Zahra on 2013-06-20 16:00:45 UTC

Comments