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

[SOLVED] package compiles with catkin_make but fails with catkin_make_isolated

asked 2020-03-10 17:08:54 -0500

phil123456 gravatar image

updated 2020-03-11 11:41:58 -0500

Hello

rplidar_ros that compiles fine with catkin_make does not compile anymore with catkin_make_isolated

-- Build files have been written to: /home/pi/ros_catkin_ws/build_isolated/rplidar_ros
==> make -j4 -l4 in '/home/pi/ros_catkin_ws/build_isolated/rplidar_ros'
[ 11%] Building CXX object CMakeFiles/rplidarNode.dir/src/node.cpp.o
[ 22%] Building CXX object CMakeFiles/rplidarNode.dir/sdk/src/rplidar_driver.cpp.o
[ 44%] Built target rplidarNodeClient
/home/pi/ros_catkin_ws/src/rplidar_ros/src/node.cpp:37:10: fatal error: std_srvs/Empty.h: No such file or directory
 #include "std_srvs/Empty.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/rplidarNode.dir/build.make:63: CMakeFiles/rplidarNode.dir/src/node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1001: CMakeFiles/rplidarNode.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
<== Failed to process package 'rplidar_ros':
  Command '['/home/pi/ros_catkin_ws/devel_isolated/image_transport/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2

Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/rplidar_ros && /home/pi/ros_catkin_ws/devel_isolated/image_transport/env.sh make -j4 -l4

what am I missing there ?

  • catkin_make refuses to build non homogenous packages
  • catkin_make_isolated ignore other packages

how do contour this ?

thanks

[ edit : giving a try with catkin tools...and I get the same issue :-( ]

[ edit : it finaly slam's !!! yes !! thanks gvdhoorn !!!]

image description

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-03-11 03:33:45 -0500

gvdhoorn gravatar image

updated 2020-03-11 04:04:38 -0500

This is not really a problem with CMI, but with rpilidar_ros.

There are a few things not entirely correct with that package's build script:

  1. the build script does not make the dependency on std_srvs of its targets explicit
  2. the build script does not resolve the dependency on std_srvs

re: target dependencies: as you can see in catkin documentation/.../C++ message or service dependencies, all CMake targets which depend on messages must add appropriate add_dependencies(<target> ..) lines to their build scripts. The CMakeLists.txt (this one) of rplidar_ros doesn't do this -- not for rplidarNode nor for rplidarNodeClient.

The result could be that Catkin/CMake may decide to start building targets before their dependencies have been built. This obviously leads to problems, such as headers which cannot be found.

re: missing dependency: while the package manifest does state the dependency on std_srvs (here), the build script does not. Notice here how it find_package(..)s roscpp, rosconsole and sensor_msgs, but it doesn't mention std_srvs at all.

This causes the catkin_INCLUDE_DIRS to not contain the include path for std_srvs, potentially causing header lookup problems during compilation.

re: CMI vs catkin_make: the big difference between CMI and catkin_make is that the former builds all packages in isolation, while the latter essentially merges all CMakeLists.txt into a single context. The consequence is that build scripts which work with catkin_make may break with CMI, as dependencies between build targets exist in the single context of catkin_make, but no longer exist when building with CMI.

This is not a problem of CMI, but is caused by the build scripts of those packages being broken.

In the case of rpilidar_ros, you should:

  1. add std_srvs to the find_package(catkin ..) call
  2. add add_dependencies(<target> ${catkin_EXPORTED_TARGETS}) for all targets

And finally: if you want to be nice, and this fixes your issue, you may want to consider submitting a PR to Slamtec/rplidar_ros which fixes these two issues (but seeing as there are 127 forks, I'm pretty sure someone has already fixed this, but they haven't bothered to submit a PR).


Edit:

edit : giving a try with catkin tools...and I get the same issue :-(

which makes sense, as the package is broken. CMI and catkin_tools both build packages in complete isolation, which causes them to expose the same problems with build scripts.

edit flag offensive delete link more

Comments

  • I added the std_srvs line and it compiles fine

  • I am not sure about the second part, what do you mean for "all targets" ? how do I figure the dependencies ?

phil123456 gravatar image phil123456  ( 2020-03-11 10:27:17 -0500 )edit

There are two targets in the CMakeLists.txt: rplidarNode and rplidarNodeClient.

Technically, you should add add_dependencies(..) lines for both of those.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-11 11:27:34 -0500 )edit

I'll have a look, I updated my question in the mean time, thanks for helping me dude, I was so desperate to make this work

phil123456 gravatar image phil123456  ( 2020-03-11 11:41:08 -0500 )edit

So now that you have things working, will you update Slamtec/rplidar_ros#26 and submit a PR to contribute your fixes? That would save future users a lot of time, trying to diagnose what you had to do.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-12 03:03:53 -0500 )edit

I tried but I have a permission denied...it's the first time I push my own bug fix, I feel like a young virgin lol

(note that I am pushing on the slamtec repo, not the robopeak one)

git branch fix_missing_std_srvs_include
git commit -m "fix missing include when compiling in isolation"
Username for 'https://github.com': phil123456
Password for 'https://phil123456@github.com':
remote: Permission to Slamtec/rplidar_ros.git denied to phil123456.
fatal: unable to access 'https://github.com/Slamtec/rplidar_ros.git/': The requested URL returned error: 403

I get the feeling I miss a step...

phil123456 gravatar image phil123456  ( 2020-03-12 09:49:12 -0500 )edit

This might help: opensource.com/How to create a pull request in GitHub.

You cannot just push to someone else's Github repository. That's not allowed.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-12 09:53:18 -0500 )edit

ah yes someone told me about pull requests, I'll have a look, thanks

btw how did you fire the 2 targets ? rplidarNode and rplidarNodeClient

phil123456 gravatar image phil123456  ( 2020-03-12 10:07:59 -0500 )edit

wow this is so cool https://github.com/Slamtec/rplidar_ro...

thanks mate

(I meant 'find' in the previous comment)

phil123456 gravatar image phil123456  ( 2020-03-12 10:23:14 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-10 17:08:54 -0500

Seen: 1,788 times

Last updated: Mar 11 '20