CMake cannot find gazebo_ros while building Gazebo package (Unit 4.30)

Hi,
I am facing the following error while trying to build the gazebo package.

Following is my CMake file:

cmake_minimum_required(VERSION 3.8)
project(my_box_bot_gazebo)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclpy REQUIRED)
find_package(gazebo_ros REQUIRED)
find_package(my_box_bot_description REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

install(
  DIRECTORY
    launch
    worlds
    models
  DESTINATION
    share/${PROJECT_NAME}/
)

ament_package()

Could someone please clarify if there is any additional setup needed or do I need to install anything for it to work?

Best,
Ninad Mehta

Did you add it in the package.xml?

Hi, @duckfrost2
Following is my package.xml:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>my_box_bot_gazebo</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="user@todo.todo">user</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclpy</depend>
  <depend>my_box_bot_description</depend>
  <depend>gazebo_ros</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

I have added the following dependency in package.xml:

<depend>gazebo_ros</depend>

Are we to add any other lines? Could this possibly be an installation issue?
since I am running this course on the platform, I am unsure whether I should install additional packages using sudo apt install , or if this dependency should already be available in the environment.
Kindly guide whenever possible.

Best,
Ninad Mehta

You dont need to install anyhing extra.
Let me have a look in depth.
In the mean time try sourcing the /opt/ros/ distribution , removing the buld folders and retry again. I will see if I can reproduce your issue

I think I fixed it for you , It seems the documentation wasn’t updated for the new Gazebo . I had to install: sudo apt install ros-jazzy-ros-gz, and update the CMakelists.txt and package.xml.

Sorry about the inconvenience, I will see into this issue and resolve it as soon as possible.

1 Like

It is working as expected now. Thank you. I checked my CMake.Lists and Package.xml and it appears we don’t have to include ‘gazebo_ros’ related lines now.
Please do let me know what changed and why we don’t have to include it in CMake.Lists anymore (so that I can understand it better for future units).
Thank you for looking into this!

Best,
Ninad Mehta

Hi, yeah, its because in the new version of Gazebo, gazebo_ros is not used anymore. We probably missed that update in the notebook. If you find more issues please let us know ok? We will try to solve it asap
Again sorry for the confusion

1 Like

No worries at all. I will post as always if I face any issues.
Thank you for the explanation!

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