Gazebo | Ignition | Community
Ask Your Question

Gazebo 3.0 System Plugin Tutorial Crashing

asked 2014-05-20 04:35:37 -0600

Vineet gravatar image

Hi, I just installed Gazebo 3.0 from source and was doing all the tutorials in series. However I am stuck at the System Plugin tutorial.

After building the plugin here are the steps, 1) Launch gzserver in background using "gzserver & " 2) Launch gzclient using "gzclient -g", when I do this I get the following error -

gzclient: /usr/include/boost/smartptr/sharedptr.hpp:653: typename boost::detail::spmemberaccess<t>::type boost::sharedptr<t>::operator->() const [with T = gazebo::rendering::UserCamera; typename boost::detail::spmember_access<t>::type = gazebo::rendering::UserCamera*]: Assertion `px != 0' failed. Aborted (core dumped)

I searched but the only relevant discussion I could find is here. I am a beginner and too immature to understand that. Is there any way to solve this problem?

System Details: Gazebo 3.0 on Ubuntu 13.10, Latest ATI Catalyst Drivers

Code --

#include "gazebo/gui/GuiIface.hh" #include "gazebo/rendering/rendering.hh" #include "gazebo/gazebo.hh"

namespace gazebo { class SystemGUI : public SystemPlugin { public: virtual ~SystemGUI() { if (this->userCam) this->userCam->EnableSaveFrame(false); }

public: virtual void Load(int /*_argc*/, char ** /*_argv*/)

    private: virtual void Init()
    //this->updateConnection = event::Events::ConnectWorldUpdateBegin(boost::bind(&SystemGUI::OnUpdate, this, _1));
  // Get a pointer to the active user camera
  this->userCam = gui::get_active_camera();

  // Enable saving frames

  // Specify the path to save frames into

private: virtual void OnUpdate(const common::UpdateInfo & /*_info*/)

private: rendering::UserCameraPtr userCam;    
private: std::vector<event::ConnectionPtr> connections;
    private: event::ConnectionPtr updateConnection;



edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-20 06:41:39 -0600

AndreiHaidu gravatar image

Hi there,

The tutorial is kind of outdated. It crashes because the following code is ran before the rendering engine is initialized

 this->userCam = gui::get_active_camera();

To make sure you initialize the user camera after the engine has been initialized you should listen to the rendering events, and bind a callback function to it, for example:

void  MyPlugin::Init()
    // Initialize rendering related variables only when the rendering started
    this->updateConnection = event::Events::ConnectPreRender(
            boost::bind(&MyPlugin::InitAtRenderEvent, this));


this calls the following method, which initializes the user camera, at the first rendering event:

void MyPlugin::InitAtRenderEvent()

    // Set camera, can be set only after the rendering started
     this->userCam = gui::get_active_camera();

    // Listen to the update event.
    // This event is broadcast every simulation iteration.
    this->updateConnection = event::Events::ConnectRender(
            boost::bind(&MyPlugin::OnUpdate, this));

then the updateConnection is switched to call the OnUpdate method for every rendering event:

void MyPlugin::OnUpdate()
      //your code here
      std::cout << "Update" << std::endl;

Cheers, Andrei

edit flag offensive delete link more


Thanks, It worked.

Vineet gravatar imageVineet ( 2014-05-20 17:42:48 -0600 )edit

We should make an issue or pull request to fix the tutorial:

scpeters gravatar imagescpeters ( 2014-05-20 19:43:23 -0600 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-05-20 04:35:37 -0600

Seen: 712 times

Last updated: May 20 '14