ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

catkin can't find geometry_msgs even though it's on CMAKE_PREFIX_PATH

asked 2022-10-25 11:56:58 -0500

TheAlmightySand gravatar image

updated 2022-10-25 13:27:50 -0500

gvdhoorn gravatar image

I have run sudo apt install -y ros-geometry-msgs, but when I try to build my project with it, I get this error:

CMake Error at /opt/ros/noetic/share/genmsg/cmake/genmsg-extras.cmake:271 (message):

Could not find 'share/geometry_msgs/cmake/geometry_msgs-msg-paths.cmake'
 (searched in '/home/tjpowell/Robot_files/RobotCodeRospy/test3/devel;
/home/tjpowell/Robot_files/RobotCodeRoscpp/test3/devel;/opt/ros/noetic').

echo $CMAKE_PREFIX_PATH:

/home/tjpowell/Robot_files/RobotCodeRospy/test3/devel:
/home/tjpowell/Robot_files/RobotCodeRoscpp/test3/devel:
/opt/ros/noetic:
/usr/share/geometry_msgs/cmake

When I print $CMAKE_PREFIX_PATH at the beginning of CMakeLists.txt using cmake_print_variables, it gives the above value as well, with /usr/share/geometry_msgs/cmake.

ls /usr/share/geometry_msgs/cmake:

geometry_msgs-msg-extras.cmake  geometry_msgs-msg-paths.cmake  geometry_msgsConfig-version.cmake  geometry_msgsConfig.cmake

package.xml:

<?xml version="1.0"?>                                                                                                                                                                                              
<package format="2">                                                                                                                                                                                                 
<name>test3_abhi</name>                                                                                                                                                                                            
<version>0.0.0</version>                                                                                                                                                                                           
<description>The test3_abhi package</description>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<buildtool_depend>catkin</buildtool_depend>                                                                                                                                                                        
<build_depend>roscpp</build_depend>                                                                                                                                                                                
<build_depend>rospy</build_depend>                                                                                                                                                                                 
<build_depend>std_msgs</build_depend>                                                                                                                                                                                 
<build_depend>message_generation</build_depend>                                                                                                                                                                   
<build_export_depend>message_runtime</build_export_depend>                                                                                                                                                       
<build_export_depend>roscpp</build_export_depend>                                                                                                                                                                  
<build_export_depend>rospy</build_export_depend>                                                                                                                                                                   
<build_export_depend>std_msgs</build_export_depend>                                                                                                                                                                
<exec_depend>roscpp</exec_depend>                                                                                                                                                                                  
<exec_depend>rospy</exec_depend>                                                                                                                                                                                   
<exec_depend>std_msgs</exec_depend>                                                                                                                                                                                   
<exec_depend>message_runtime</exec_depend>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
<export>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
</export>                                                                                                                                                                                                        
</package>

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)                                                                                                                                                                              
project(test3_abhi)                                                                                                                                                                                                                                                                                                                                                                                                                   
include(CMakePrintHelpers)                                                                                                                                                                                         
set (geometry_msgs_DIR "/usr/share/geometry_msgs/cmake")                                                                                                                                                           
cmake_print_variables(CMAKE_PREFIX_PATH)           

find_package(catkin REQUIRED COMPONENTS                                                                                                                                                                              roscpp                                                                                                                                                                                                             rospy                                                                                                                                                                                                              std_msgs                                                                                                                                                                                                           message_generation                                                                                                                                                                                                 geometry_msgs                                                                                                                                                                                                    )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                        ##   * add a build_depend                                                                                                                                                                                                                                                                                                                              
add_service_files(                                                                                                                                                                                                   FILES                                                                                                                                                                                                              TSP.srv                                                                                                                                                                                                                                                                                                                                                                                                             )              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ## Generate added messages and services with any dependencies listed here                                                                                                                                          
generate_messages(                                                                                                                                                                                                   DEPENDENCIES                                                                                                                                                                                                       std_msgs                                                                                                                                                                                                           geometry_msgs                                                                                                                                                                                                    )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

catkin_package(                                                                                                                                                                                                      INCLUDE_DIRS include                                                                                                                                                                                             #  LIBRARIES test3_abhi                                                                                                                                                                                              CATKIN_DEPENDS roscpp rospy std_msgs geometry_msgs message_runtime                                                                                                                                               #  DEPENDS system_lib                                                                                                                                                                                              )                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                 include_directories(                                                                                                                                                                                               # include                                                                                                                                                                                                            ${catkin_INCLUDE_DIRS}                                                                                                                                                                                           )                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                set(CMAKE_EXE_LINKER_FLAGS                                                                                                                                                                                             ${CMAKE_EXE_LINKER_FLAGS}                                                                                                                                                                                          "-fopenmp")                                                                                                                                                                                                    

add_compile_options(                                                                                                                                                                                                   -I/opt/ros/noetic/include -I/usr/local/include/dynamixel-sdk)                                                                                                                                                  

add_executable(test3_printemo src/test3_printemo.cpp include/abhi.cpp)                                                                                                                                             

target_link_libraries(test3_printemo ${catkin_LIBRARIES} #${OpenCV_LIBS}                                                                                                                                               Qt5Widgets Qt5Gui Qt5Test Qt5Concurrent Qt5Core                                                                                                                                                                    dxl_x64_cpp boost_system pcl_visualization                                                                                                                                                                         pcl_common pthread phidget21                                                                                                                                                                                       realsense2 hdf5_serial                                                                                                                                                                                             blas hdf5_serial_hl boost_filesystem                                                                                                                                                                               boost_thread opencv_highgui                                                                                                                                                                                        opencv_ximgproc opencv_photo                                                                                                                                                                                       opencv_calib3d opencv_imgcodecs                                                                                                                                                                                    opencv_imgproc opencv_core)      

add_executable(tsp src/TSPSrv.cpp include/abhi.cpp)                                                                                                                                                                

target_link_libraries(tsp ${catkin_LIBRARIES} #${OpenCV_LIBS}                                                                                                                                                          Qt5Widgets Qt5Gui Qt5Test Qt5Concurrent Qt5Core                                                                                                                                                                    dxl_x64_cpp boost_system pcl_visualization                                                                                                                                                                         pcl_common pthread phidget21                                                                                                                                                                                       realsense2 hdf5_serial                                                                                                                                                                                             blas hdf5_serial_hl boost_filesystem                                                                                                                                                                               boost_thread opencv_highgui                                                                                                                                                                                        opencv_ximgproc opencv_photo                                                                                                                                                                                       opencv_calib3d opencv_imgcodecs                                                                                                                                                                                    opencv_imgproc opencv_core)
edit retag flag offensive close merge delete

Comments

@TheAlmightySand: Welcome to ROS Answers. You do not need to close your question upon receiving the answer. Instead, you upvote and click on the checkmark ✓ to accept the correct answer. You have already accepted the correct answer below. Therefore, please ignore my message. Just remember not to close your questions in the future.

ravijoshi gravatar image ravijoshi  ( 2022-10-26 04:02:10 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2022-10-25 13:34:11 -0500

gvdhoorn gravatar image

updated 2022-10-25 13:44:36 -0500

There are a couple things which confuse me about your post:

  1. you don't say anything about the OS you're using (although it's likely a Debian/Ubuntu (derivative), because of the use of apt)
  2. you tagged this noetic, but then install ros-geometry-msgs, which is not a package in ROS Noetic (as that would be called ros-noetic-geometry-msgs)
  3. you show paths to /usr, which are not normally paths used by / present in ROS distribution packages
  4. you also show paths to /opt/ros/noetic, which is indeed where normal ROS Noetic package would end up
  5. you appear to be manually specifying absolute include paths using add_compile_options(..). That's never really a good idea, but probably an attempt to get things working?

All-in-all, it's a bit messy.

Could it be you've (inadvertently) installed some UpstreamPackages?

If so, and you did not intent to: I'd suggest removing them and installing their Noetic counterparts.

If this is an OS that doesn't have binary packages of ROS Noetic and you used the upstream packages on purposes: don't mix-and-match. It doesn't work (reliably) as you've found out.

Also: don't manually manipulate your CMAKE_PREFIX_PATH. If you find you have to do that, something else is not configured correctly. Manually changing it is not the solution.

PS: and pedantic, but: "CMake can't find geometry_msgs [..]", not "Catkin can't find [..]". It's all CMake. This has nothing to do with Catkin.

edit flag offensive delete link more

Comments

The issue was the ros-geometry-msgs package. Uninstalling that and installing ros-noetic-geometry-msgs, like you said (and then adding it as a dependency in my package.xml) fixed the issue. Thank you!

TheAlmightySand gravatar image TheAlmightySand  ( 2022-10-25 15:49:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-10-25 11:56:58 -0500

Seen: 499 times

Last updated: Oct 25 '22