0
$\begingroup$

Rosanswers logo

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


Originally posted by phil123456 on ROS Answers with karma: 51 on 2020-03-10

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2020-03-11

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by phil123456 on 2020-03-11:\

  • 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 ?

Comment by gvdhoorn on 2020-03-11:
There are two targets in the CMakeLists.txt: rplidarNode and rplidarNodeClient.

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

Comment by phil123456 on 2020-03-11:
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

Comment by gvdhoorn on 2020-03-12:
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.

Comment by phil123456 on 2020-03-12:
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://[email protected]':
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...

Comment by gvdhoorn on 2020-03-12:
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.

Comment by phil123456 on 2020-03-12:
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

Comment by phil123456 on 2020-03-12:
wow this is so cool https://github.com/Slamtec/rplidar_ros/pull/27

thanks mate

(I meant 'find' in the previous comment)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.