Error while compiling gazebo plugin

~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/user/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10")
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 3 packages in topological order:
-- ~~  - studying_gazebo
-- ~~  - writing_plugins
-- ~~  - robot_description
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'studying_gazebo'
-- ==> add_subdirectory(studying_gazebo)
-- +++ processing catkin package: 'writing_plugins'
-- ==> add_subdirectory(writing_plugins)
-- Could NOT find gazebo (missing: gazebo_DIR)
-- Could not find the required component 'gazebo'. The following CMake error indicates that you either need to install the package withthe same name or change your environment so that it can be found.
CMake Error at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "gazebo" with any
  of the following names:

    gazeboConfig.cmake
    gazebo-config.cmake

  Add the installation prefix of "gazebo" to CMAKE_PREFIX_PATH or set
  "gazebo_DIR" to a directory containing one of the above files.  If "gazebo"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  writing_plugins/CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeError.log".
make: *** [Makefile:1594: cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

What I can understand from this error is that it not able to find gazebo but gazebo is already added as a dependency. I have check the entire internet and tried all out but this error still exist.

Definitely there is an error in the course. Your code is correct and you have done the proper steps.
We are looking into why this error is happening and finding a solution.

We will come back to you later today with the solution.

I apologize for the inconvenience

1 Like

Hello @HrithikVerma ,

We’ve finally spotted the error. It is in the CMakeLists.txt file, in the way the packages are searched on the system. The correct code is like this:

...

find_package(gazebo REQUIRED)

find_package(catkin REQUIRED COMPONENTS
  gazebo_plugins
  gazebo_ros
  roscpp
)

...

I’ve already updated the notebook instructions so you should check them as well. If you follow the indicated steps it should now compile properly.

1 Like

@albertoezquerro Now with this changes it compiling perfect.Just one question.

while creating catkin_pakage package we added gazebo as a dependency so that why it added both in cmake as well in pakage.xml. Now as you suggested we remove it from cmake but gazebo is still present in pakage.xml as build dependency. Can you please explain why we do so.

Thanks in advance.

In line 9 of my_gazebo_plugin.cc a “;” is missing.
plus: #include <gazebo/physics/physics.hh>

You can remove gazebo from the package.xml as build dependency. It is a mistake, it is not required.

1 Like

@ferdinand97 You are correct #include <gazebo/physics/physics.hh> need to be added for executing 5.1 world plugin.
Please correct this @rtellez @albertoezquerro this unit has few mistakes which would very difficult for beginners to solve.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.