Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to edit grid size using system plugin

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

l4ncelot gravatar image

Hi,

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 {
    public:
        void Load(int /*_argc*/, char ** /*_argv*/){
            this->connections_.push_back(event::Events::ConnectRender(boost::bind(&GridPlugin::Update, this)));
        }
    private:
        void Update(){
            rendering::ScenePtr scene = rendering::get_scene();

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

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

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

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

    GZ_REGISTER_SYSTEM_PLUGIN(GridPlugin)
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Comments

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: http://gazebosim.org/tutorials?tut=gui_overlay 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
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 148 times

Last updated: Apr 18