Unable to get any msgs/srvs to work in CMakeLists [closed]
I am trying to build a controller node for a robot in ROS2 foxy and CMake is kicking my ass. When I try to add a library none of the msgs/srvs work either my custom one or a built in such as std_msgs
Here is the type of error I get from the console, it's pretty much the same for all the msgs/srvs:
colcon build --packages-select legged_robot_controller
Starting >>> legged_robot_controller
--- stderr: legged_robot_controller
In file included from /home/robdome/ros2_ws/src/legged_robot_controller/src/control.cpp:31:
/home/robdome/ros2_ws/src/legged_robot_controller/include/legged_robot_controller/control.hpp:38:10: fatal error: std_srvs/srv/Empty.hpp: No such file or directory
38 | #include <std_srvs/srv/Empty.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/control.dir/build.make:63: CMakeFiles/control.dir/src/control.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:107: CMakeFiles/control.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed <<< legged_robot_controller [5.58s, exited with code 2]
Summary: 0 packages finished [6.01s]
1 package failed: legged_robot_controller
1 package had stderr output: legged_robot_controller
Here is my CMakeLists:
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(legged_robot_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(dynamixel_sdk REQUIRED)
add_library( control src/control.cpp )
ament_target_dependencies( control
rclcpp
tf2_ros
std_srvs
std_msgs
geometry_msgs
nav_msgs
sensor_msgs
legged_robot_msgs_generate_messages_cpp
)
include_directories(
include/${PROJECT_NAME}
)
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include/${PROJECT_NAME}
)
ament_export_include_directories(include)
ament_export_dependencies(rclcpp geometry_msgs sensor_msgs std_srvs std_msgs legged_robot_msgs
tf2_ros)
ament_package()
I've spent that last day or so trying to figure it out on my own to no avail, I apologize if I'm doing something stupid I'm new to ROS and don't have a whole lot of C++ experience.