ros2 / ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
Apache License 2.0
462 stars 297 forks source link

Failed to build bridge using melodic and bouncy #127

Closed sloretz closed 6 years ago

sloretz commented 6 years ago

Bug report

Required Info:

Steps to reproduce issue

. /opt/ros/melodic/setup.bash
. /opt/ros/bouncy/local_setup.bash
colcon build --packages-select ros1_bridge --cmake-force-configure

Expected behavior

The ROS 1 bridge should succeed.

Actual behavior

developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/melodic/setup.bash
developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/bouncy/local_setup.bash
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.
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 [4.98s]
  1 package failed: ros1_bridge
  1 package had stderr output: ros1_bridge

Additional information

Warning about ROS_DISTRO changing

The build fails because the output of this command can't be eval()'d to python.

/home/developer/workspaces/bridge_ws/build/ros1_bridge/devel/env.sh python -c "import os; print(dict(os.environ))"

The ROS_DISTRO warning appears to be the problem.

developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/melodic/setup.bash 
developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/bouncy/local_setup.bash 
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.

# Note, must have tried to build once for `env.sh` to exist.
developer@74e0cb101752:~/workspaces/bridge_ws$ /home/developer/workspaces/bridge_ws/build/ros1_bridge/devel/env.sh python -c "import os; print(dict(os.environ))"
ROS_DISTRO was set to 'bouncy' before. Please make sure that the environment does not mix paths from different distributions.
{'USERNAME': 'developer', 'ROS_DISTRO': 'melodic', 'LINES': '49', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'ROSLISP_PACKAGE_DIRECTORIES': '/home/developer/workspaces/bridge_ws/build/ros1_bridge/devel/share/common-lisp', 'HOME': '/home/developer', 'PATH': '/opt/ros/melodic/bin:/opt/ros/bouncy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/developer/.local/bin:/home/developer/.local/bin', 'CMAKE_PREFIX_PATH': '/home/developer/workspaces/bridge_ws/build/ros1_bridge/devel:/opt/ros/melodic', 'DISPLAY': ':0', 'AMENT_PREFIX_PATH': '/opt/ros/bouncy', 'TERM': 'xterm', 'XAUTHORITY': '/tmp/.docker.xauth', 'SHLVL': '2', 'LD_LIBRARY_PATH': '/opt/ros/melodic/lib:/opt/ros/bouncy/opt/rviz_yaml_cpp_vendor/lib:/opt/ros/bouncy/opt/rviz_ogre_vendor/lib:/opt/ros/bouncy/lib/x86_64-linux-gnu:/opt/ros/bouncy/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins', 'NVIDIA_VISIBLE_DEVICES': 'all', '_': '/home/developer/workspaces/bridge_ws/build/ros1_bridge/devel/env.sh', 'ROS_ETC_DIR': '/opt/ros/melodic/etc/ros', 'ROS_PYTHON_VERSION': '2', 'OGRE_RESOURCE_PATH': '/usr/lib/x86_64-linux-gnu/OGRE-1.9.0', 'GAZEBO_MASTER_URI': 'http://localhost:11345', 'PYTHONPATH': '/opt/ros/bouncy/lib/python3.6/site-packages:/opt/ros/melodic/lib/python2.7/dist-packages', 'QT_X11_NO_MITSHM': '1', 'ROS_ROOT': '/opt/ros/melodic/share/ros', 'PKG_CONFIG_PATH': '/opt/ros/melodic/lib/pkgconfig', 'ROS_PACKAGE_PATH': '/home/developer/workspaces/bridge_ws/src/ros1_bridge:/opt/ros/melodic/share', 'GAZEBO_MODEL_PATH': '/usr/share/gazebo-9/models:/usr/share/gazebo-9/models:', 'NVIDIA_DRIVER_CAPABILITIES': 'graphics,compat32,utility', 'COLUMNS': '123', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'OLDPWD': '/home/developer', 'HOSTNAME': '74e0cb101752', 'GAZEBO_MODEL_DATABASE_URI': 'http://models.gazebosim.org', 'GAZEBO_PLUGIN_PATH': '/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:', 'PWD': '/home/developer/workspaces/bridge_ws', 'ROS_MASTER_URI': 'http://localhost:11311', 'ROS_VERSION': '1', 'GAZEBO_RESOURCE_PATH': '/usr/share/gazebo-9:/usr/share/gazebo-9:', 'LD_LIBRARYPATH': '/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:/home/developer/.local/lib'}
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.

The bridge uses pkg-config to find ROS 1 packages. ROS 2 packages are found through CMake using find_package(). Therefore the CMAKE_PREFIX_PATH must not contain paths from ROS 1 which would overlay ROS 2 packages.

Yet later the instructions to build say the ROS 1 workspace must be sourced before the ROS 2 workspace

Next you need to source the ROS 1 environment, for Linux and ROS Melodic that would be:
source /opt/ros/melodic/setup.bash

and

# You have already sourced your ROS installation.
# Source your ROS 2 installation:
. <install-space-with-ros2>/local_setup.bash

If I don't source the ROS1 workspace then the error is a failure to find catkin

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 12, in <module>
    from catkin.environment_cache import generate_environment_script
ModuleNotFoundError: No module named 'catkin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/developer/workspaces/bridge_ws/build/ros1_bridge/catkin_generated/generate_cached_setup.py", line 20, in <module>
    from catkin.environment_cache import generate_environment_script
ModuleNotFoundError: No module named 'catkin'
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 [1.05s]
  1 package failed: ros1_bridge
  1 package had stderr output: ros1_bridge

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

developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/melodic/setup.bash 
developer@74e0cb101752:~/workspaces/bridge_ws$ . /opt/ros/bouncy/local_setup.bash 
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.
developer@74e0cb101752:~/workspaces/bridge_ws$ echo $CMAKE_PREFIX_PATH
/opt/ros/melodic
developer@74e0cb101752:~/workspaces/bridge_ws$ unset CMAKE_PREFIX_PATH
developer@74e0cb101752:~/workspaces/bridge_ws$ 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 [2.57s]
  1 package failed: ros1_bridge
  1 package had stderr output: ros1_bridge
dirk-thomas commented 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.

sloretz commented 6 years ago

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?

mikaelarguedas commented 6 years ago

Does it work with ament_tools ?

dirk-thomas commented 6 years ago

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/

mikaelarguedas commented 6 years ago

... 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:

``` docker run -it --rm osrf/ros2:bouncy-basic apt update && apt upgrade -y && apt install -y git ros-bouncy-ament-tools python3-colcon-common-extensions python3-rosdep apt install -y ros-melodic-actionlib-msgs ros-melodic-catkin ros-melodic-class-loader ros-melodic-cpp-common ros-melodic-diagnostic-msgs ros-melodic-gencpp ros-melodic-geneus ros-melodic-genlisp ros-melodic-genmsg ros-melodic-gennodejs ros-melodic-genpy ros-melodic-geometry-msgs ros-melodic-message-generation ros-melodic-message-runtime ros-melodic-nav-msgs ros-melodic-pluginlib ros-melodic-ros-environment ros-melodic-rosbag ros-melodic-rosbag-migration-rule ros-melodic-rosbag-storage ros-melodic-rosbuild ros-melodic-rosclean ros-melodic-rosconsole ros-melodic-roscpp-serialization ros-melodic-roscpp-traits ros-melodic-rosgraph ros-melodic-rosgraph-msgs ros-melodic-roslib ros-melodic-roslz4 ros-melodic-rosmaster ros-melodic-rosmsg ros-melodic-rosout ros-melodic-rospack ros-melodic-rosparam ros-melodic-rospy ros-melodic-rostime ros-melodic-rosunit ros-melodic-sensor-msgs ros-melodic-shape-msgs ros-melodic-std-msgs ros-melodic-std-srvs ros-melodic-stereo-msgs ros-melodic-topic-tools ros-melodic-trajectory-msgs ros-melodic-visualization-msgs ros-melodic-xmlrpcpp source /opt/ros/bouncy/setup.bash source /opt/ros/melodic/setup.bash mkdir -p ~/ros2_ws/src && cd ~/ros2_ws/src git clone https://github.com/ros2/ros1_bridge.git && cd ~/ros2_ws export ROSDISTRO_INDEX_URL='https://raw.githubusercontent.com/ros2/rosdistro/ros2/index.yaml' rosdep init rosdep update rosdep install --from-paths src --ignore-src --rosdistro bouncy -y ``` Build with ament_tools: ``` rm -rf build install ament build --symlink-install --only ros1_bridge ``` Build with colcon: ``` rm -rf build install colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure --event-handlers console_direct+ ``` Colcon console output ``` Starting >>> ros1_bridge -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found rmw: 0.5.0 (/opt/ros/bouncy/share/rmw/cmake) -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.5", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Override CMake install command with custom implementation using symlinks instead of copying resources -- Found rclcpp: 0.5.1 (/opt/ros/bouncy/share/rclcpp/cmake) -- Found rmw_implementation_cmake: 0.5.0 (/opt/ros/bouncy/share/rmw_implementation_cmake/cmake) -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'roscpp' -- Found roscpp, version 1.14.2 -- Checking for module 'std_msgs' -- Found std_msgs, version 0.5.11 -- Checking for module 'actionlib_msgs' -- Found actionlib_msgs, version 1.12.6 -- Checking for module 'diagnostic_msgs' -- Found diagnostic_msgs, version 1.12.6 -- Checking for module 'geometry_msgs' -- Found geometry_msgs, version 1.12.6 -- Checking for module 'nav_msgs' -- Found nav_msgs, version 1.12.6 -- Checking for module 'rosgraph_msgs' -- Found rosgraph_msgs, version 1.11.2 -- Checking for module 'sensor_msgs' -- Found sensor_msgs, version 1.12.6 -- Checking for module 'shape_msgs' -- Found shape_msgs, version 1.12.6 -- Checking for module 'stereo_msgs' -- Found stereo_msgs, version 1.12.6 -- Checking for module 'trajectory_msgs' -- Found trajectory_msgs, version 1.12.6 -- Checking for module 'visualization_msgs' -- Found visualization_msgs, version 1.12.6 -- Checking for module 'std_srvs' -- Found std_srvs, version 1.11.2 -- Checking for module 'topic_tools' -- Found topic_tools, version 1.14.2 -- Found ament_lint_auto: 0.5.2 (/opt/ros/bouncy/share/ament_lint_auto/cmake) -- Checking for module 'roslaunch' -- No package 'roslaunch' found -- 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 -- Using CATKIN_DEVEL_PREFIX: /root/ros2_ws/build/ros1_bridge/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/bouncy:/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: /root/ros2_ws/build/ros1_bridge/test_results -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.6.5") -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Using Python nosetests: /usr/bin/nosetests -- catkin 0.7.14 Failed <<< ros1_bridge [ Exited with code -11 ] ```

Looking into the colcon failure now.

sloretz commented 6 years ago

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.

Here's a Dockerfile that produces an environment where this error happens. ```Dockerfile FROM ubuntu:18.04 RUN apt-get update \ && apt-get install -y \ wget \ lsb-release \ sudo \ mercurial \ git \ vim \ cmake \ gdb \ software-properties-common \ python3-dbg \ python3-pip \ python3-venv \ build-essential \ && apt-get clean ENV USERNAME developer RUN useradd -U -ms /bin/bash $USERNAME \ && echo "$USERNAME:$USERNAME" | chpasswd \ && adduser $USERNAME sudo \ && echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/$USERNAME # Commands below run as the developer user USER $USERNAME # Install colcon RUN pip3 install -U --user setuptools \ && pip3 install --user colcon-common-extensions \ && /bin/sh -c 'echo "export PATH=\$PATH:/home/developer/.local/bin" >> ~/.bashrc' \ && /bin/sh -c 'echo "export LD_LIBRARYPATH=\$LD_LIBRARY_PATH:/home/developer/.local/lib" >> ~/.bashrc' # Install tzdata RUN export DEBIAN_FRONTEND=noninteractive \ && sudo apt-get update \ && sudo -E apt-get install -y \ tzdata \ && sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime \ && sudo dpkg-reconfigure --frontend noninteractive tzdata \ && sudo apt-get clean # Download bouncy RUN sudo /bin/sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' \ && ( wget -O - http://repo.ros2.org/repos.key | sudo apt-key add - ) \ && sudo apt-get update \ && sudo apt-get install -y \ `apt list "ros-bouncy-*" 2> /dev/null | \ grep '/' | awk -F/ '{print $1}' | \ grep -v -e ros-bouncy-ros1-bridge \ -e ros-bouncy-turtlebot2- \ -e "ros-bouncy.*-dbgsym" \ -e "ros-bouncy-.*opensplice" \ -e "ros-bouncy-.*connext" | tr '\n' ' '` \ && sudo apt-get clean # Download melodic RUN sudo /bin/sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' \ && sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 \ && sudo apt-get update \ && sudo apt-get install -y \ ros-melodic-desktop-full \ && sudo rosdep init \ && sudo apt-get clean RUN mkdir -p ~/bridge_ws/src \ && cd ~/bridge_ws/src \ && git clone https://github.com/ros2/ros1_bridge.git WORKDIR /home/developer/bridge_ws ```


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.

Linker errors ``` developer@a22db00080e9:~/bridge_ws$ unset CMAKE_PREFIX_PATH developer@a22db00080e9:~/bridge_ws$ colcon build Starting >>> ros1_bridge [Processing: ros1_bridge] [Processing: ros1_bridge] [Processing: ros1_bridge] --- stderr: ros1_bridge CMakeFiles/test_ros2_server_cpp.dir/test/test_ros2_server.cpp.o: In function `rclcpp::Service::Service(std::shared_ptr, std::__cxx11::basic_string, std::allocator > co nst&, rclcpp::AnyServiceCallback, rcl_service_options_t&)': test_ros2_server.cpp:(.text._ZN6rclcpp7ServiceIN15diagnostic_msgs3srv8SelfTestEEC2ESt10shared_ptrI10rcl_node_tERKNSt7__cxx1 112basic_stringIcSt11char_traitsIcESaIcEEENS_18AnyServiceCallbackIS3_EER21rcl_service_options_t[_ZN6rclcpp7ServiceIN15diagn ostic_msgs3srv8SelfTestEEC5ESt10shared_ptrI10rcl_node_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_18AnyServi ceCallbackIS3_EER21rcl_service_options_t]+0xb0): undefined reference to `rosidl_service_type_support_t const* rosidl_typesu pport_cpp::get_service_type_support_handle()' collect2: error: ld returned 1 exit status make[2]: *** [test_ros2_server_cpp] Error 1 make[1]: *** [CMakeFiles/test_ros2_server_cpp.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... CMakeFiles/test_ros2_client_cpp.dir/test/test_ros2_client.cpp.o: In function `rclcpp::Client::Client(rclcpp::node_interfaces::NodeBaseInterface*, std::shared_ptr, std::_ _cxx11::basic_string, std::allocator > const&, rcl_client_options_t&)': test_ros2_client.cpp:(.text._ZN6rclcpp6ClientIN15diagnostic_msgs3srv8SelfTestEEC2EPNS_15node_interfaces17NodeBaseInterfaceE St10shared_ptrINS5_18NodeGraphInterfaceEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER20rcl_client_options_t[_ZN6 rclcpp6ClientIN15diagnostic_msgs3srv8SelfTestEEC5EPNS_15node_interfaces17NodeBaseInterfaceESt10shared_ptrINS5_18NodeGraphIn terfaceEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER20rcl_client_options_t]+0xc0): undefined reference to `rosi dl_service_type_support_t const* rosidl_typesupport_cpp::get_service_type_support_handle()' collect2: error: ld returned 1 exit status make[2]: *** [test_ros2_client_cpp] Error 1 make[1]: *** [CMakeFiles/test_ros2_client_cpp.dir/all] Error 2 CMakeFiles/simple_bridge_1_to_2.dir/src/simple_bridge_1_to_2.cpp.o: In function `rclcpp::Publisher >, std::allocator >::Publisher(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_s tring, std::allocator > const&, rcl_publisher_options_t const&, std::shared_ptr > > > const&)': simple_bridge_1_to_2.cpp:(.text._ZN6rclcpp9PublisherIN8std_msgs3msg7String_ISaIvEEES4_EC2EPNS_15node_interfaces17NodeBaseIn terfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK23rcl_publisher_options_tRKSt10shared_ptrISaIS5_EE[_ZN6rclc pp9PublisherIN8std_msgs3msg7String_ISaIvEEES4_EC5EPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt1 1char_traitsIcESaIcEEERK23rcl_publisher_options_tRKSt10shared_ptrISaIS5_EE]+0x22): undefined reference to `rosidl_message_t ype_support_t const* rosidl_typesupport_cpp::get_message_type_support_handle > >()' collect2: error: ld returned 1 exit status make[2]: *** [simple_bridge_1_to_2] Error 1 make[1]: *** [CMakeFiles/simple_bridge_1_to_2.dir/all] Error 2 CMakeFiles/simple_bridge_2_to_1.dir/src/simple_bridge_2_to_1.cpp.o: In function `rclcpp::create_subscription_factory >, void (&)(std::shared_ptr > >), std::al locator, std_msgs::msg::String_ >, rclcpp::Subscription >, std::allocator > >(void (&)(std::shared_ptr > >), rclcpp::message_ memory_strategy::MessageMemoryStrategy >, std::allocator >::SharedPtr, st d::shared_ptr >)::{lambda(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string, std::allocator > const&, rcl_subscription_options_t&)#1}::operator()(rclcpp::node_interface s::NodeBaseInterface*, std::__cxx11::basic_string, std::allocator > const&, rcl_subscrip tion_options_t&) const': simple_bridge_2_to_1.cpp:(.text._ZZN6rclcpp27create_subscription_factoryIN8std_msgs3msg7String_ISaIvEEERFvSt10shared_ptrIS5 _EES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStrategyIT2_T1 _E9SharedPtrES6_ISI_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER2 6rcl_subscription_options_tE_clESO_SW_SY_[_ZZN6rclcpp27create_subscription_factoryIN8std_msgs3msg7String_ISaIvEEERFvSt10sha red_ptrIS5_EES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStra tegyIT2_T1_E9SharedPtrES6_ISI_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIc ESaIcEEER26rcl_subscription_options_tE_clESO_SW_SY_]+0xa6): undefined reference to `rosidl_message_type_support_t const* ro sidl_typesupport_cpp::get_message_type_support_handle > >()' collect2: error: ld returned 1 exit status make[2]: *** [simple_bridge_2_to_1] Error 1 make[1]: *** [CMakeFiles/simple_bridge_2_to_1.dir/all] Error 2 CMakeFiles/simple_bridge.dir/src/simple_bridge.cpp.o: In function `rclcpp::create_subscription_factory >, void (&)(std::shared_ptr > >), std::allocator, std_msgs::msg::String_ >, rclcpp::Subscription >, std::al locator > >(void (&)(std::shared_ptr > >), rclcpp::message_memory_strateg y::MessageMemoryStrategy >, std::allocator >::SharedPtr, std::shared_ptr< std::allocator >)::{lambda(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string, std::allocator > const&, rcl_subscription_options_t&)#1}::operator()(rclcpp::node_interfaces::NodeBaseInt erface*, std::__cxx11::basic_string, std::allocator > const&, rcl_subscription_options_t &) const': simple_bridge.cpp:(.text._ZZN6rclcpp27create_subscription_factoryIN8std_msgs3msg7String_ISaIvEEERFvSt10shared_ptrIS5_EES4_S 5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStrategyIT2_T1_E9Shar edPtrES6_ISI_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER26rcl_su bscription_options_tE_clESO_SW_SY_[_ZZN6rclcpp27create_subscription_factoryIN8std_msgs3msg7String_ISaIvEEERFvSt10shared_ptr IS5_EES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_NS_23message_memory_strategy21MessageMemoryStrategyIT2 _T1_E9SharedPtrES6_ISI_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE ER26rcl_subscription_options_tE_clESO_SW_SY_]+0xa6): undefined reference to `rosidl_message_type_support_t const* rosidl_ty pesupport_cpp::get_message_type_support_handle > >()' CMakeFiles/simple_bridge.dir/src/simple_bridge.cpp.o: In function `rclcpp::Publisher >, std::allocator >::Publisher(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string, std::allocator > const&, rcl_publisher_options_t const&, std::shared_ptr > > > const&)': simple_bridge.cpp:(.text._ZN6rclcpp9PublisherIN8std_msgs3msg7String_ISaIvEEES4_EC2EPNS_15node_interfaces17NodeBaseInterface ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK23rcl_publisher_options_tRKSt10shared_ptrISaIS5_EE[_ZN6rclcpp9Publ isherIN8std_msgs3msg7String_ISaIvEEES4_EC5EPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_t raitsIcESaIcEEERK23rcl_publisher_options_tRKSt10shared_ptrISaIS5_EE]+0x22): undefined reference to `rosidl_message_type_sup port_t const* rosidl_typesupport_cpp::get_message_type_support_handle > >()' collect2: error: ld returned 1 exit status make[2]: *** [simple_bridge] Error 1 make[1]: *** [CMakeFiles/simple_bridge.dir/all] Error 2 make: *** [all] Error 2 --- Failed <<< ros1_bridge [ Exited with code 2 ] Summary: 0 packages finished [94.79s] 1 package failed: ros1_bridge 1 package had stderr output: ros1_bridge ```
sloretz commented 6 years ago

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
dirk-thomas commented 6 years ago

After sourcing ROS 1 and ROS 2 the prefix path variables are set to:

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...

dirk-thomas commented 6 years ago

colcon/colcon-ros#23 should address the problem with the CMAKE_PREFIX_PATH.

dirk-thomas commented 6 years ago

This should be fixed with the latest release of colcon-ros 0.2.9.

sloretz commented 6 years ago

Thanks @dirk-thomas and @mikaelarguedas ! Closing.