![Rosanswers logo](https://i.sstatic.net/yuGTR.png)
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:
- the build script does not make the dependency on
std_srvs
of its targets explicit
- 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:
- add
std_srvs
to the find_package(catkin ..)
call
- 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)