ros1_bridge: ros1_bridge fails to build from source

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • ros1_bridge from source. ROS Melodic and ROS2 Crystal by deb
  • Version or commit hash:
    • 961ddee6b76bcb670ce3cb939d125044de820102
  • DDS implementation:
    • Fast-RTPS

Steps to reproduce issue

  1. Clone https://github.com/PX4/px4_ros_com master branch to a ROS2 workspace;
  2. Clone https://github.com/PX4/px4_msgs master branch to the same ROS2 workspace;
  3. Clone https://github.com/PX4/px4_ros_com ros1 to a ROS1 workspace;
  4. Clone https://github.com/PX4/px4_msgs ros1 branch to the same ROS1 workspace;
  5. Build both workspaces using colcon;
  6. Clone the ros1_bridge to the ROS2 workspace;
  7. Issue the following commands before building the ros1_bridge, by the same order:
unset ROS_DISTRO
source /opt/ros/melodic/setup.bash
source /opt/ros/crystal/setup.bash # or local_setup.bash

# source the ROS workspaces
source <ros1_ws_dir>/install/setup.bash
source <ros2_ws_dir>/install/local_setup.bash
  1. Build the ros1_bridge using colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure.

Expected behavior

It’s expected that the ros1_bridge builds successfully. A notice that the above works when using the ROS2 Bouncy release.

Actual behavior

Output from the console:

ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.
Starting >>> ros1_bridge
-- Found rmw: 0.6.1 (/opt/ros/crystal/share/rmw/cmake)
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Override CMake install command with custom implementation using symlinks instead of copying resources
-- Found rosidl_adapter: 0.6.2 (/opt/ros/crystal/share/rosidl_adapter/cmake)
-- Found rclcpp: 0.6.2 (/opt/ros/crystal/share/rclcpp/cmake)
-- Found rmw_implementation_cmake: 0.6.1 (/opt/ros/crystal/share/rmw_implementation_cmake/cmake)
-- Found ament_lint_auto: 0.6.3 (/opt/ros/crystal/share/ament_lint_auto/cmake)
-- Added test 'copyright' to check for copyright in CMake / C / C++ / Python code
-- Added test 'cppcheck' to perform static code analysis on C / C++ code
-- Added test 'cpplint' to check C / C++ code against the Google style
-- Added test 'flake8' to check Python code syntax and style conventions
-- Added test 'lint_cmake' to check CMake code style
-- Added test 'pep257' to check Python code against some of the style conventions in PEP 257
-- Added test 'uncrustify' to check C / C++ code style
-- Added test 'xmllint' to check XML markup files
-- Found px4_msgs: 0.1.0 (/home/nuno/PX4/px4_ros_com_ros2/install/px4_msgs/share/px4_msgs/cmake)
-- Found action_msgs: 0.6.2 (/opt/ros/crystal/share/action_msgs/cmake)
-- Using CATKIN_DEVEL_PREFIX: /home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/devel
-- Using CMAKE_PREFIX_PATH: /home/nuno/PX4/px4_ros_com_ros2/install/px4_msgs;/home/nuno/PX4/px4_ros_com_ros2/install/px4_ros_com;/home/nuno/PX4/px4_ros_com_ros1/install/px4_ros_com;/home/nuno/PX4/px4_ros_com_ros1/install/px4_msgs;/opt/ros/melodic;/opt/ros/crystal
-- This workspace overlays: /home/nuno/PX4/px4_ros_com_ros1/install/px4_ros_com;/home/nuno/PX4/px4_ros_com_ros1/install/px4_msgs;/opt/ros/melodic
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON              
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/test_results
-- Found gtest: gtests will be built
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.7.14                                
Traceback (most recent call last):              
  File "/home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/nuno/PX4/px4_ros_com_ros2/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 'crystal' 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/nuno/PX4/px4_ros_com_ros2/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:81 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/CMakeFiles/CMakeOutput.log".
See also "/home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/CMakeFiles/CMakeError.log".
--- stderr: ros1_bridge
Traceback (most recent call last):
  File "/home/nuno/PX4/px4_ros_com_ros2/build/ros1_bridge/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/nuno/PX4/px4_ros_com_ros2/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 'crystal' 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/nuno/PX4/px4_ros_com_ros2/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:81 (find_package)


---
Failed   <<< ros1_bridge	[ Exited with code 1 ]
                                
Summary: 0 packages finished [1.09s]
  1 package failed: ros1_bridge
  1 package had stderr output: ros1_bridge

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 49 (18 by maintainers)

Most upvoted comments

The error message sounds like your environment is setup incorrectly. Please follow the standard steps to build the ros1_bridge and avoid reusing terminal between the builds / workspaces. Also avoid sourcing multiple setup files as described above.

Out of my head I would suggest:

  • Terminal A:
    • source /opt/ros/melodic/setup.bash
    • build <ros1_ws_dir>
  • Terminal B:
    • source /opt/ros/crystal/setup.bash # or local_setup.bash
    • build <ros2_ws_dir>
  • Terminal C:
    • source <ros1_ws_dir>/install/setup.bash
    • source <ros2_ws_dir>/install/setup.bash
      • make sure to use the latest Debian packages of Crystal to ensure this recursively sources /opt/ros/crystal
    • build <ros1_bridge>