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

CMake error with custom messages

asked 2021-02-18 02:54:58 -0500

Spyros gravatar image

updated 2021-02-18 03:25:23 -0500

I created 2 custom messages in my package to publish data through one of my nodes. The .msg files are:

bearing_angles.msg

float left_edge
float right edge

bearArray.msg

bearArray[] bear_array

I changes my CMakeLists.txt of my package, so it looks like this:

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)

add_message_files(
  FILES
  Num.msg
  bearing_angles.msg
  bearArray.msg
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES door_detector_1
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
#  DEPENDS system_lib
)

But when I build my package from catkin_ws directory, with catkin_make, I get this error:

  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 326, in load_msg_depends
    load_msg_depends(msg_context, depspec, search_path)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 315, in load_msg_depends
    depspec = msg_context.get_registered(resolved_type)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 439, in get_registered
    if self.is_registered(full_msg_type):
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 428, in is_registered
    package, base_type = package_resource_name(full_msg_type)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/names.py", line 104, in package_resource_name
    val = tuple(name.split(PRN_SEPARATOR))
RuntimeError: maximum recursion depth exceeded while calling a Python object
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):

  execute_process(/home/spyros/catkin_ws/build/catkin_generated/env_cached.sh
  "/usr/bin/python2" "/usr/bin/empy" "--raw-errors" "-F"
  "/home/spyros/catkin_ws/build/door_detector_1/cmake/door_detector_1-genmsg-context.py"
  "-o"
  "/home/spyros/catkin_ws/build/door_detector_1/cmake/door_detector_1-genmsg.cmake"
  "/opt/ros/melodic/share/genmsg/cmake/pkg-genmsg.cmake.em") returned error
  code 1
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/em_expand.cmake:25 (safe_execute_process)
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:303 (em_expand)
  door_detector_1/CMakeLists.txt:74 (generate_messages)


-- Configuring incomplete, errors occurred!
See also "/home/spyros/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/spyros/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:768: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

I think I miss something in the CMakeLists.txt file, but I didn't find it so far. What am I missing here? Any feedback is appreciated.

I use Ubuntu 18, ROS melodic, and my node is written in python 2.7

UPDATE (CMake error): After @gvdhoorn answer

CMake Error at /home/spyros/catkin_ws/build/door_detector_1/cmake/door_detector_1-genmsg.cmake:3 (message):
  Could not find messages which
  '/home/spyros/catkin_ws/src/door_detector_1/msg/bearing_angles.msg' depends
  on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

  Cannot locate message [float] in package [door_detector_1] with paths
  [['/home/spyros/catkin_ws/src/door_detector_1/msg']]
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  door_detector_1/CMakeLists.txt:74 (generate_messages)


-- Configuring incomplete, errors occurred!
See also "/home/spyros/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/spyros/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:768: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-18 03:02:33 -0500

gvdhoorn gravatar image

I think I miss something in the CMakeLists.txt file, but I didn't find it so far.

No, there doesn't appear to be anything wrong with your CMakeLists.txt.

It's most likely this:

The .msg files are:

bearing_angles.msg

float left_edge
float right edge

bearArray.msg

bearArray[] bear_array

notice how you've given the bear_array field the type "unbounded array of bearArray".

In words: a bearArray message has a single field, which is an array of bearArray messages.

You've defined a bearArray messages in terms of itself, which we also call "recursion", which leads to:

RuntimeError: maximum recursion depth exceeded while calling a Python object

Did you actually mean to use bearing_angles[] bear_array?

edit flag offensive delete link more

Comments

yes, I want to use a bearArray message, which is an array of bearing_angles messages. Is this the right way? bearing_angles[] bear_array

Spyros gravatar image Spyros  ( 2021-02-18 03:08:55 -0500 )edit
1

yes.

As I suggested at the end of my answer.

note btw that bear_array to me sounds like an array of bears, which is probably not what this is going to be about.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-18 03:13:38 -0500 )edit

Not really handy name indeed. I changed my .msg file as you suggested, and I got a new cmake error after building (check updated post)

Spyros gravatar image Spyros  ( 2021-02-18 03:26:38 -0500 )edit
Cannot locate message [float] in package [door_detector_1] with paths

this is unrelated to your previous error.

float is not a valid field type. Only float32 or float64 are valid.

See wiki/msg.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-18 04:07:02 -0500 )edit

this solved and my last error. Now my package is built without problems. Thanks!

Spyros gravatar image Spyros  ( 2021-02-18 04:12:34 -0500 )edit

Question Tools

Stats

Asked: 2021-02-18 02:54:58 -0500

Seen: 1,069 times

Last updated: Feb 18 '21