Gazebo | Ignition | Community
Ask Your Question
0

fatal error: gazebo/gazebo.hh: No such file or directory

asked 2020-01-31 11:07:38 -0500

Kyriakos gravatar image

updated 2020-02-04 09:52:36 -0500

Jose Luis Rivero gravatar image

Hey, I want to add a gps sensor on my robot. Initially i tried adding the gps sensor in the urdf.xacro file, but no much luck there. So I thought to create a .cpp file as i found by hector_plugins. But when im trying to compile the c++ file i get the following error

fatal error: gazebo/gazebo.hh: No such file or directory
 #include <gazebo/gazebo.hh>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

When I'm doing the plugin_tutorials everything works perfectly, but when I try to compile it with my files i get the above error. My aim is to extract data about the x,y,z position of my rover.

My cpp code:

#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <ignition/math/Vector3.hh>

namespace gazebo
{
    class ModelPush : public ModelPlugin
        {
            public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
            //Store pointer to model
            this->model = _parent;

            //Listen to update event. This event is broadcast every simulation iteration
            this->updateConnection = event::Events::ConnectWorldUpdateBegin(
                    std::bind(&ModelPush::OnUpdate, this));

        }

        //Called by the world update start event
        public: void OnUpdate()
        {
            //Get x,y,z position
            this->model->GetWorldPose();
        }

        //Pointer to the model
        private: physics::ModelPtr model;

        //Pointer to the update event connection
        private: event::ConnectionPtr updateConnection;
        };

        //Register plugin with simulation
        GZ_REGISTER_MODEL_PLUGIN(ModelPush)
}

And to compile it i added these two lines in the CMakeLists.txt

add_executable(xyz_push src/xyz_push.cpp)
target_link_libraries(xyz_push ${catkin_LIBRARIES})

Any help will be appreciated. Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-04 09:55:31 -0500

Jose Luis Rivero gravatar image

First, be sure that you have install the libgazeboX-dev (where X is the version of gazebo being used) package if your are using Debian/Ubuntu system.

Second, give a look again into the tutorial and remember to include the include_directories(${GAZEBO_INCLUDE_DIRS}) in our CMakeLists.txt file.

edit flag offensive delete link more

Comments

Thanks for your answer but this is not the problem, i have everything installed and when i insert the include_directories(${GAZEBO_INCLUDE_DIRS}) the code still doesn't compile When i do the tutorial it works perfectly without any errors regarding #include gazebo/gazebo.hh but when i try to compile the code above i get that error.

Kyriakos gravatar imageKyriakos ( 2020-02-04 13:05:47 -0500 )edit

cmake cache could be tricking you, remove the CMakeCache.txt file from the build directory and try again. If that does not fix the situation I would recommended to start using the tutorial example and change the tutorial files by yours progressively. Good luck.

Jose Luis Rivero gravatar imageJose Luis Rivero ( 2020-02-04 13:11:35 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-01-31 11:07:38 -0500

Seen: 1,165 times

Last updated: Feb 04