Closed sloretz closed 6 years ago
The ROS_DISTRO warning appears to be the problem.
Please try to unset ROS_DISTRO
between sourcing ROS 1 and ROS 2.
Therefore the CMAKE_PREFIX_PATH must not contain paths from ROS 1 which would overlay ROS 2 packages.
This should better be phrased as: The CMAKE_PREFIX_PATH must not have the ROS 1 paths prepended as they would overlay ROS 2 packages.
The workspaces need to be sourced in the described order: first ROS 1, second ROS 2 (so that CMake finds ROS 2 packages in case of naming collisions). The CMAKE_PREFIX_PATH
could be reset after sourcing ROS 1 since neither other ROS 1 CMake config files is needed - but keeping them (at the end of the environment variable) doesn't harm either.
Same error during build when unsetting ROS_DISTRO
between sourcing ROS 1 and ROS 2
developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/melodic/setup.bash
developer@74e0cb101752:~/workspaces/bridge_ws$ unset ROS_DISTRO
developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/bouncy/local_setup.bash
developer@74e0cb101752:~/workspaces/bridge_ws$ colcon build --packages-select ros1_bridge --cmake-force-configure
Starting >>> ros1_bridge
--- stderr: ros1_bridge
Traceback (most recent call last):
File "/home/developer/workspaces/bridge_ws/build/ros1_bridge/catkin_generated/generate_cached_setup.py", line 22, in <module>
code = generate_environment_script('/home/developer/workspaces/bridge_ws/build/ros1_bridge/devel/env.sh')
File "/opt/ros/melodic/lib/python2.7/dist-packages/catkin/environment_cache.py", line 62, in generate_environment_script
env_after = ast.literal_eval(output.decode('utf8'))
File "/usr/lib/python3.6/ast.py", line 48, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
ROS_DISTRO was set to 'bouncy' before. Please make sure that the environment does not mix paths from different distributions.
^
SyntaxError: invalid syntax
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/usr/bin/python3
"/home/developer/workspaces/bridge_ws/build/ros1_bridge/catkin_generated/generate_cached_setup.py")
returned error code 1
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/all.cmake:198 (safe_execute_process)
/opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:20 (include)
/opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:12 (find_package)
/opt/ros/melodic/share/genmsg/cmake/genmsgConfig.cmake:197 (include)
/opt/ros/melodic/share/actionlib_msgs/cmake/actionlib_msgs-extras.cmake:2 (find_package)
/opt/ros/melodic/share/actionlib_msgs/cmake/actionlib_msgsConfig.cmake:197 (include)
CMakeLists.txt:77 (find_package)
---
Failed <<< ros1_bridge [ Exited with code 1 ]
Summary: 0 packages finished [5.05s]
1 package failed: ros1_bridge
1 package had stderr output: ros1_bridge
If I also edit /opt/ros/melodic/share/catkin/cmake/templates/env.sh.in
to contain unset ROS_DISTRO
below the check for CLI arguments then I get a failure to find FastRTPS
, just like I did when I cleared CMAKE_PREFIX_PATH
. I'm starting to think the failure to find FastRTPS
is a separate issue.
$ colcon build --packages-select ros1_bridge --cmake-force-configure
Starting >>> ros1_bridge
--- stderr: ros1_bridge
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find FastRTPS (missing: FastRTPS_INCLUDE_DIR FastRTPS_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/opt/ros/bouncy/share/fastrtps_cmake_module/cmake/Modules/FindFastRTPS.cmake:95 (find_package_handle_standard_args)
/opt/ros/bouncy/share/rmw_fastrtps_cpp/cmake/rmw_fastrtps_cpp-extras.cmake:20 (find_package)
/opt/ros/bouncy/share/rmw_fastrtps_cpp/cmake/rmw_fastrtps_cppConfig.cmake:30 (include)
/opt/ros/bouncy/share/rmw_implementation_cmake/cmake/call_for_each_rmw_implementation.cmake:61 (find_package)
CMakeLists.txt:208 (call_for_each_rmw_implementation)
---
Failed <<< ros1_bridge [ Exited with code 1 ]
Summary: 0 packages finished [1.94s]
1 package failed: ros1_bridge
1 package had stderr output: ros1_bridge
The CMAKE_PREFIX_PATH could be reset after sourcing ROS 1 since neither other ROS 1 CMake config files is needed - but keeping them (at the end of the environment variable) doesn't harm either.
I'm not sure what's happening yet. If the ROS 1 path in CMAKE_PREFIX_PATH
is harmless, why do both clearing CMAKE_PREFIX_PATH
and alternatively unsetting ROS_DISTRO
in env.sh.in
allow the the build to reach the point where FastRTPS
cannot be found?
Does it work with ament_tools ?
The warning message is there to warn "humans" - in this case this is what we want - mixing distributions. Maybe the warning message should be printed to stderr
and when being invoked only stdout
should be considered. That should fix the syntax error.
... the point where FastRTPS cannot be found
Maybe related to this question: https://answers.ros.org/question/296462/compilation-error-building-against-binary-bouncy-could-not-find-fastrtps/
... the point where FastRTPS cannot be found
Maybe related to this question: https://answers.ros.org/question/296462/compilation-error-building-against-binary-bouncy-could-not-find-fastrtps/
Could be related to this as well https://github.com/colcon/colcon-ros/pull/21
I tried based on one of our docker images and I can successfully build the bridge with ament_tools but not with colcon. I don;t get the same error though but figured I would post it here anyway.
List of commands I ran:
Looking into the colcon failure now.
Getting farther. The fastrtps issue could have been an old colcon version. I built a new container from the Dockerfile below, and I've managed to get past the cmake configure
stage. To do so I had to unset CMAKE_PREFIX_PATH
.
Running the commands in the README I get the same error caused by the ROS_DISTRO
warning. If I unset CMAKE_PREFIX_PATH
and re-run the build then the configure step succeeds, but the build fails with linker errors. I'll move onto debugging that.
Does it work with ament_tools ?
Yes, a build with ament build
succeeds in the above Dockerfile. No need to unset CMAKE_PREFIX_PATH
, and no linker errors.
developer@b766ee2aeb4d:~/bridge_ws$ . /opt/ros/melodic/setup.bash
developer@b766ee2aeb4d:~/bridge_ws$ . /opt/ros/bouncy/setup.bash
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributio
ns.
developer@b766ee2aeb4d:~/bridge_ws$ ament build
# Topological order
- ros1_bridge
# .... a lot of output, the build succeeds
After sourcing ROS 1 and ROS 2 the prefix path variables are set to:
AMENT_PREFIX_PATH=/opt/ros/bouncy
CMAKE_PREFIX_PATH=/opt/ros/melodic
You certainly need colcon-ros
0.2.7 or newer to extend the CMAKE_PREFIX_PATH
during the build step to CMAKE_PREFIX_PATH=$AMENT_PREFIX_PATH:$CMAKE_PREFIX_PATH
which can be checked in the file build/ros1_bridge/cmake_args.last
. Also log/latest_build/ros1_bridge/command.log
will confirm that the right CMake prefix path is passed.
A manual invocation of CMake with the same command fails for me to find FastRTPS. Interestingly if I replace the -DCMAKE_PREFIX_PATH=...
argument with setting the environment variable before invoking cmake
it does work. It looks like colcon-ros
needs to be patched to not pass the prefix path as a -D
but through the environment instead...
colcon/colcon-ros#23 should address the problem with the CMAKE_PREFIX_PATH
.
This should be fixed with the latest release of colcon-ros
0.2.9.
Thanks @dirk-thomas and @mikaelarguedas ! Closing.
Bug report
Required Info:
Steps to reproduce issue
Expected behavior
The ROS 1 bridge should succeed.
Actual behavior
Additional information
Warning about ROS_DISTRO changing
The build fails because the output of this command can't be
eval()
'd to python.The
ROS_DISTRO
warning appears to be the problem.README conflicting information
There seems to be conflicting information in the README. A warning in one paragraph says
CMAKE_PREFIX_PATH
must not contain ROS 1 paths which would suggest that/opt/ros/<ros1 distro>
should not be sourced.Yet later the instructions to build say the ROS 1 workspace must be sourced before the ROS 2 workspace
and
If I don't source the ROS1 workspace then the error is a failure to find catkin
If I instead interpret the warning about CMAKE_PREFIX_PATH as meaning that variable should be wiped of any ROS 1 paths, I get a failure to find FastRTPS instead