gazebo_msgs/msg/model_state.hpp not found

asked 2019-12-10 04:19:39 -0500

LeoE gravatar image

I'm trying to set up a gazebo simulation with ROS2-eloquent and whysoever gazebo_msgs can not be found.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)
project(controller)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(communication REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)


include_directories(
  include
  include/controller
  include/controller/tasks
  ${YAML_CPP_INCLUDEDIR}
)

#################### LIBRARY FOR TASKS #############################################################
add_library(task_lib  SHARED
                      src/tasks/task_super_class.cpp
                      src/tasks/cart_pole_task.cpp
                      src/tasks/turtlebot_task.cpp)

ament_target_dependencies(task_lib
                          rclcpp
                          gazebo_msgs
                          geometry_msgs
                          nav_msgs
                          communication)

target_link_libraries(task_lib ${YAML_CPP_LIBRARIES})


#################### EXECUTABLE FOR NODE ############################################################
add_executable(controller_node  src/main.cpp
                                src/controller.cpp)

ament_target_dependencies(controller_node
                          rclcpp
                          gazebo_msgs
                          std_msgs
                          geometry_msgs
                          nav_msgs
                          tf2
                          tf2_ros
                          communication)

target_link_libraries(controller_node task_lib ${YAML_CPP_LIBRARIES})

install(TARGETS
  task_lib
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin)

install(TARGETS
    controller_node
    DESTINATION lib/${PROJECT_NAME}
)

gazebo_msgs is declared as a build and exec dependency in the package.xml.

And I get the following error:

fatal error: gazebo_msgs/msg/model_state.hpp: No such file or directory
 #include "gazebo_msgs/msg/model_state.hpp"
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I installed ros2 using sudo apt install ros-eloquent-desktop and installed gazebo with sudo apt install ros-eloquent-gazebo-ros-pkgs

I sourced source /opt/ros/eloquent/setup.bash and the environment variables seem to be set correctly, at least printenv | grep -i ROS shows the following (correct as far as I know) output:

LD_LIBRARY_PATH=/home/leonard/ai_evaluation/install/controller/lib:/home/leonard/ai_evaluation/install/gazebo_msgs/lib:/home/leonard/ai_evaluation/install/communication/lib:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:/opt/ros/eloquent/opt/yaml_cpp_vendor/lib:/opt/ros/eloquent/opt/rviz_ogre_vendor/lib:/opt/ros/eloquent/lib
AMENT_PREFIX_PATH=/home/leonard/ai_evaluation/install/model_node:/home/leonard/ai_evaluation/install/controller:/home/leonard/ai_evaluation/install/gazebo_msgs:/home/leonard/ai_evaluation/install/agent_py:/home/leonard/ai_evaluation/install/agent_model_interface:/home/leonard/ai_evaluation/install/communication:/opt/ros/eloquent
ROS_VERSION=2
ROS_LOCALHOST_ONLY=0
ROS_PYTHON_VERSION=3
PYTHONPATH=/home/leonard/ai_evaluation/install/gazebo_msgs/lib/python3.6/site-packages:/home/leonard/ai_evaluation/install/agent_py/lib/python3.6/site-packages:/home/leonard/ai_evaluation/install/agent_model_interface/lib/python3.6/site-packages:/home/leonard/ai_evaluation/install/communication/lib/python3.6/site-packages:/opt/ros/eloquent/lib/python3.6/site-packages
PATH=/opt/ros/eloquent/bin:/home/leonard/bin:/home/leonard/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ROS_DISTRO=eloquent

And if I look into the folders I can find gazebo_msgs under /opt/ros/eloquent/include/gazebo_msgs

Anybody knows where my mistake is?

edit retag flag offensive close merge delete

Comments

Can you provide the CMake output ?

From the paths listed here it looks like the gazebo_msgs used will be /home/leonard/ai_evaluation/install/gazebo_msgs and not the one from /opt/ros/eloquent

marguedas gravatar image marguedas  ( 2020-01-22 06:50:50 -0500 )edit