Quantcast
Channel: Gazebo: Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 7017

Access rendering::Scene through world plugin

$
0
0
Hi Guys, i want to access the scene data structure within my world plugin. I found the [Issue #1076](https://bitbucket.org/osrf/gazebo/issues/1076/system-plugin-loading-issue-since-gazebo) where someone tried something similar. Due to the comments i do not try to access the structure in the plugin initialization phase, but everytime the plugin is updated. Therefore in the Load function, a callback is registered by: void MyPlugin::Load(physics::WorldPtr _parent, sdf::ElementPtr _sdf) { // [...] // register UpdateBegin Callback this->updateConnection = event::Events::ConnectWorldUpdateBegin(boost::bind(&MyPlugin::OnUpdate, this,_1)); // [...] } The Callback function is defined as followed: void MyPlugin::OnUpdate(const common::UpdateInfo &_info) { rendering::ScenePtr scene = rendering::RenderEngine::Instance()->GetScene(); if(!scene) { gzerr << "(MyPlugin) rendering::RenderEngine::Instance()->GetScene() returned NULL.\n"; } else { gzmsg << "(MyPlugin) Scene loaded.... \n"; } // try alternative access scene = rendering::get_scene(this->world->GetName()); if(!scene) { gzerr << "(MyPlugin) rendering::get_scene() returned NULL.\n"; return; } else { gzmsg << "(MyPlugin) Scene loaded.... \n"; } } I tried this approach with **Gazebo 2.2.3 as well as with Gazeb 6.5.1** and obtain both times the following output, indicating that always a nullptr is returned: Error [MyPlugin.cc:221] (MyPlugin) rendering::RenderEngine::Instance()->GetScene() returned NULL. Error [MyPlugin.cc:231] (MyPlugin) rendering::get_scene() returned NULL. I assume that it is caused by the fact, that MyPlugin is of type WorldPlugin. I use the same approach in another SensorPlugin, where it works without any problems. Is there any alternative in order to access it within a WorldPlugin? With best regards!

Viewing all articles
Browse latest Browse all 7017

Trending Articles