Robotics StackExchange | Archived questions

Setting Gui in System plugin and order of loading plugins

I want to try to set the Gui while running the simulator like this:

namespace gazebo { class SystemGUI : public SystemPlugin {

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

public: SystemGUI() : SystemPlugin() { }

public: virtual ~SystemGUI()
{
  this->connections.clear();
  this->userCam.reset();
}

public: void Load(int /*_argc*/, char ** /*_argv*/)
{
  this->connections.push_back(
      event::Events::ConnectPreRender(
        std::bind(&SystemGUI::Update, this)));
}

private: void Init()
{
}

private: void Update()
{

  if (!this->userCam)
  {
    this->userCam = gui::get_active_camera();

    if (this->userCam != NULL)
    {

      const ignition::math::Angle &yaw = 0;     
      this->userCam->Yaw(yaw);
    }
  }

  rendering::ScenePtr scene = rendering::get_scene();

  if (!scene || !scene->Initialized())
    return;

  if (scene->GetVisual("ground_plane"))
  {
    std::cout << "Has ground plane visual\n";
  }
}

};

GZREGISTERSYSTEM_PLUGIN(SystemGUI) }

but unfortunately the Yaw is not set to 0. Any idea how I can set the Gui while my simulation is running? I run Gazebo like this: gzclient -g libsimulator_system.so

The main goal is to run the whole simulator like: roslaunch simulator_world simulator.launch My world file ends with:

But this way the System plugin will exit prematurely [ INFO] [1568787274.691299252]: Finished loading Gazebo ROS API Plugin. [ INFO] [1568787274.692145228]: waitForService: Service [/gazebo/setphysicsproperties] has not been advertised, waiting... [ INFO] [1568787274.743609739]: waitForService: Service [/gazebogui/setphysicsproperties] has not been advertised, waiting... [ INFO] [1568787274.744664911]: Finished loading Gazebo ROS API Plugin. [ INFO] [1568787277.237475087]: SystemPlugin::SystemGUI [ INFO] [1568787277.237626131]: SystemPlugin::Exit SystemGUI [ INFO] [1568787277.248128220]: WorldPlugin::Enter plugin [ INFO] [1568787277.248723325]: WorldPlugin::Init -> IsLoaded: 1 [ INFO] [1568787277.252055953]: WorldPlugin::Init -> groundplane

Thanks in advance

Asked by PeterHer on 2019-09-18 07:31:06 UTC

Comments

Answers