0
$\begingroup$

Gazebo Answers logo

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)
} 

Originally posted by l4ncelot on Gazebo Answers with karma: 13 on 2017-04-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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.


Originally posted by chapulina with karma: 7504 on 2017-04-18

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by l4ncelot on 2017-04-18:
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.

Comment by chapulina on 2017-04-18:
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

Comment by l4ncelot on 2017-04-19:
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.

Comment by l4ncelot on 2017-04-19:
Oh sorry, there's already CMakeLists file in your example. I didn't see that :).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.