Gazebo | Ignition | Community
Ask Your Question

How to edit grid size using system plugin

asked 2017-04-18 11:42:53 -0500

l4ncelot gravatar image


I would like to edit grid size. I've written simple system plugin to do this, but it's not working for some reason.

When I print out the cell count from grid 0 I get 2000 as expected. But in Gazebo there's no change to default grid size. It's still grid consisting of 20x20 cells.

Here's the code:

#include <gazebo/rendering/rendering.hh>
#include <gazebo/gazebo.hh>
#include <ros/ros.h>

namespace gazebo{
    class GridPlugin : public SystemPlugin {
        void Load(int /*_argc*/, char ** /*_argv*/){
            this->connections_.push_back(event::Events::ConnectRender(boost::bind(&GridPlugin::Update, this)));
        void Update(){
            rendering::ScenePtr scene = rendering::get_scene();

            if(!scene || !scene->Initialized()){

            auto grid = scene->GetGrid(0);
            if(!grid) return;

            ROS_INFO("cell count: %d", scene->GetGrid(0)->GetCellCount());

        std::vector<event::ConnectionPtr> connections_;

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-18 13:22:26 -0500

chapulina gravatar image

There are usually two scenes in Gazebo, one for gzserver and another for gzclient. It is possible that the scene you're changing is in the server. You could try using a GUI plugin to be sure you're on the client process.

edit flag offensive delete link more


Is there a way to check whether I'm in server or client scene through system plugin? What's GUI plugin, I've never heard about it and I cannot find example of it on gazebo site.

l4ncelot gravatar imagel4ncelot ( 2017-04-18 13:51:37 -0500 )edit

Here's a tutorial: I'm not sure about verifying whether the scene is on client or server

chapulina gravatar imagechapulina ( 2017-04-18 14:22:53 -0500 )edit

Thank you. I've encountered one problem while writing the GUIplugin. How do I compile the plugin in ROS package? When I try to create SHARED library I get this error: /usr/include/gazebo-7/gazebo/gui/qt.h:23:17: fatal error: QtGui: No such file or directory I think I need to link qt libraries there, but I'm not quite sure.

l4ncelot gravatar imagel4ncelot ( 2017-04-19 05:13:59 -0500 )edit

Oh sorry, there's already CMakeLists file in your example. I didn't see that :).

l4ncelot gravatar imagel4ncelot ( 2017-04-19 05:19:11 -0500 )edit

Question Tools

1 follower


Asked: 2017-04-18 11:42:53 -0500

Seen: 2,300 times

Last updated: Apr 18 '17