源码安装ros2步骤,参考官方教程(英文):官网教程
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt update && sudo apt install -y \
build-essential \
cmake \
git \
python3-colcon-common-extensions \
python3-lark-parser \
python3-pip \
python-rosdep \
python3-vcstool \
wget
python3 -m pip install -U \
argcomplete \
flake8 \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest \
pytest-cov \
pytest-runner \
setuptools
sudo apt install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev
# For Crystal Clemmys
sudo apt install libopensplice69 # from packages.ros.org/ros2/ubuntu
# For Bouncy Bolson
sudo apt install libopensplice67 # from packages.ros.org/ros2/ubuntu
sudo apt install -q -y \
rti-connext-dds-5.3.1 # from packages.ros.org/ros2/ubuntu
cd /opt/rti.com/rti_connext_dds-5.3.1/resource/scripts && source ./rtisetenv_x64Linux3gcc5.4.0.bash; cd -
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs import src < ros2.repos
最后一步耗时不确定,看网速,成功的画面和结果参考:vcs import src ros2.repos
cd ~/ros2_ws/
# On Ubuntu Linux Bionic Beaver 18.04 用下面这个指令
colcon build --symlink-install
# On Ubuntu Linux Xenial Xerus 16.04 用下面这个指令
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp
make[2]: *** [assimp-4.1.0-prefix/src/assimp-4.1.0-stamp/assimp-4.1.0-download] Error 1
make[1]: *** [CMakeFiles/assimp-4.1.0.dir/all] Error 2
make: *** [all] Error 2
---
Failed <<< rviz_assimp_vendor [ Exited with code 2 ]
Aborted <<< rcl_interfaces
Aborted <<< lifecycle_msgs
Aborted <<< rviz_ogre_vendor
解决办法是重新编译一次就不会了:
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp
--- stderr: rviz_ogre_vendor
CMake Error at CMake/Utils/MacroLogFeature.cmake:100 (MESSAGE):
-----------------------------------------------------------------------------
-- The following REQUIRED packages could NOT be located on your system.
-- Please install them before continuing this software installation.
-- If you are in Windows, try passing -DOGRE_DEPENDENCIES_DIR=
-----------------------------------------------------------------------------
+ Xaw: X11 Athena widget set
-----------------------------------------------------------------------------
Call Stack (most recent call first):
CMake/Dependencies.cmake:399 (MACRO_DISPLAY_FEATURE_LOG)
CMakeLists.txt:352 (include)
make[2]: *** [ogre-master-ca665a6-prefix/src/ogre-master-ca665a6-stamp/ogre-master-ca665a6-configure] Error 1
make[1]: *** [CMakeFiles/ogre-master-ca665a6.dir/all] Error 2
make: *** [all] Error 2
---
Failed <<< rviz_ogre_vendor [ Exited with code 2 ]
Aborted <<< geometry_msgs
Aborted <<< test_msgs
Aborted <<< std_srvs
解决办法,我尝试了补充下面的库:
/*
The following NEW packages will be installed:
cppcheck libpocofoundation9v5-dbg python3-nose
The following NEW packages will be installed:
clang-format pydocstyle pyflakes pyflakes3 python-pyflakes python3-funcsigs python3-mock python3-pbr python3-pep8 python3-pyflakes uncrustify
*/
sudo apt install cppcheck libpocofoundation9v5-dbg python3-nose clang-format pydocstyle pyflakes pyflakes3 python-pyflakes python3-funcsigs python3-mock python3-pbr python3-pep8 python3-pyflakes uncrustify
最后起作用的是这句话:
sudo apt install libxaw7-dev
我的理解是编译的时候是找dev版本里面的,而不是正式版本里面的,所以就算我之前安装了libxaw7也不行。成功如下:
--- stderr: ros1_bridge
Failed to load Python extension for LZ4 support. LZ4 compression will not be available.
---
原因是对应的库没有安装好,解决办法:
查找lz4相关的安装包
apt-cache search lz4
根据提示可以知道是python相关的包不对,那么我们就重新安装对应的包
sudo apt install python-roslz4
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp
[1.919s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/sph/catkin_ws/devel' in the environment variable CMAKE_PREFIX_PATH seems to be a catkin workspace but it doesn't contain any 'local_setup.*' files. Maybe the catkin version is not up-to-date?
[1.919s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/opt/ros/kinetic' in the environment variable CMAKE_PREFIX_PATH seems to be a catkin workspace but it doesn't contain any 'local_setup.*' files. Maybe the catkin version is not up-to-date?
Starting >>> ament_package
Starting >>> ament_flake8
Starting >>> fastcdr
Starting >>> poco_vendor
Finished <<< poco_vendor [0.76s]
Starting >>> ament_cppcheck
Finished <<< fastcdr [0.76s]
Starting >>> fastrtps
Finished <<< ament_package [1.02s]
Finished <<< ament_flake8 [1.03s]
Starting >>> ament_cmake_core
Starting >>> ament_pep257
Finished <<< ament_cmake_core [0.46s]
Starting >>> ament_cmake_test
Finished <<< ament_cppcheck [0.76s]
Starting >>> ament_cmake_libraries
Finished <<< fastrtps [0.90s]
Starting >>> ament_cmake_export_libraries
Finished <<< ament_cmake_test [0.22s]
Starting >>> ament_cmake_include_directories
Finished <<< ament_cmake_libraries [0.23s]
Starting >>> ament_cmake_export_dependencies
Finished <<< ament_cmake_export_libraries [0.18s]
Starting >>> ament_cmake_export_definitions
Finished <<< ament_pep257 [0.84s]
Starting >>> ament_cmake_export_include_directories
Finished <<< ament_cmake_include_directories [0.21s]
Starting >>> ament_cmake_export_link_flags
Finished <<< ament_cmake_export_dependencies [0.21s]
Starting >>> ament_cmake_python
Finished <<< ament_cmake_export_definitions [0.21s]
Starting >>> ament_cmake_export_interfaces
Finished <<< ament_cmake_export_include_directories [0.21s]
Starting >>> ament_cmake_target_dependencies
Finished <<< ament_cmake_export_link_flags [0.22s]
Starting >>> ament_copyright
Finished <<< ament_cmake_python [0.51s]
Finished <<< ament_cmake_export_interfaces [0.43s]
Starting >>> ament_index_python
Starting >>> ament_lint_auto
Finished <<< ament_cmake_target_dependencies [0.72s]
Starting >>> ament_cmake
Finished <<< ament_lint_auto [0.45s]
Starting >>> gtest_vendor
Finished <<< ament_copyright [0.82s]
Starting >>> ament_lint_cmake
Finished <<< ament_cmake [0.19s]
Starting >>> uncrustify_vendor
Finished <<< ament_index_python [0.84s]
Starting >>> ament_cpplint
Finished <<< gtest_vendor [0.72s]
Starting >>> ament_xmllint
Finished <<< ament_lint_cmake [1.02s]
Starting >>> ament_cmake_lint_cmake
Finished <<< uncrustify_vendor [1.09s]
Starting >>> ament_uncrustify
Finished <<< ament_cpplint [1.08s]
Starting >>> libyaml_vendor
Finished <<< ament_cmake_lint_cmake [0.49s]
Starting >>> ament_cmake_copyright
Finished <<< ament_xmllint [0.85s]
Starting >>> ament_cmake_gtest
Finished <<< ament_cmake_gtest [0.15s]
Starting >>> ament_cmake_pytest
Finished <<< libyaml_vendor [0.29s]
Starting >>> osrf_pycommon
Finished <<< ament_cmake_copyright [0.25s]
Starting >>> ament_cmake_cppcheck
Finished <<< ament_uncrustify [0.95s]
Starting >>> ament_cmake_cpplint
Finished <<< ament_cmake_pytest [0.46s]
Starting >>> ament_cmake_uncrustify
Finished <<< ament_cmake_cpplint [0.20s]
Starting >>> ament_cmake_flake8
Finished <<< ament_cmake_cppcheck [0.27s]
Starting >>> ament_cmake_pep257
Finished <<< ament_cmake_uncrustify [0.20s]
Starting >>> ament_cmake_xmllint
Finished <<< ament_cmake_pep257 [0.22s]
Starting >>> console_bridge_vendor
Finished <<< ament_cmake_flake8 [0.28s]
Starting >>> gmock_vendor
Finished <<< osrf_pycommon [0.85s]
Finished <<< ament_cmake_xmllint [0.23s]
Starting >>> launch
Starting >>> ament_lint_common
Finished <<< gmock_vendor [0.48s]
Starting >>> ament_cmake_gmock
Finished <<< ament_lint_common [0.46s]
Starting >>> rosidl_adapter
Finished <<< console_bridge_vendor [0.56s]
Starting >>> rosidl_typesupport_interface
Finished <<< ament_cmake_gmock [0.17s]
Starting >>> fastrtps_cmake_module
Finished <<< rosidl_typesupport_interface [0.27s]
Starting >>> connext_cmake_module
Finished <<< rosidl_adapter [0.34s]
Starting >>> rosidl_parser
Finished <<< fastrtps_cmake_module [0.23s]
Starting >>> opensplice_cmake_module
Finished <<< launch [0.88s]
Starting >>> rmw_implementation_cmake
Finished <<< connext_cmake_module [0.27s]
Starting >>> python_cmake_module
Finished <<< opensplice_cmake_module [0.23s]
Starting >>> ament_cmake_ros
Finished <<< rosidl_parser [0.33s]
Starting >>> rosidl_actions
Finished <<< rmw_implementation_cmake [0.27s]
Starting >>> python_qt_binding
Finished <<< python_cmake_module [0.28s]
Starting >>> launch_testing
Finished <<< ament_cmake_ros [0.28s]
Starting >>> ament_index_cpp
Finished <<< rosidl_actions [0.55s]
Finished <<< python_qt_binding [0.54s]
Starting >>> rosidl_cmake
Starting >>> qt_gui
Finished <<< rosidl_cmake [0.33s]
Starting >>> rosidl_generator_c
Finished <<< ament_index_cpp [0.69s]
Starting >>> rosidl_generator_dds_idl
Finished <<< qt_gui [0.36s]
Starting >>> tinyxml_vendor
Finished <<< launch_testing [0.89s]
Starting >>> rcl_logging_log4cxx
Finished <<< tinyxml_vendor [0.16s]
Starting >>> rcl_logging_noop
Finished <<< rosidl_generator_dds_idl [0.38s]
Starting >>> urdfdom_headers
Finished <<< rcl_logging_log4cxx [0.27s]
Starting >>> class_loader
Finished <<< rcl_logging_noop [0.31s]
Starting >>> orocos_kdl
Finished <<< urdfdom_headers [0.20s]
Starting >>> urdfdom
Finished <<< rosidl_generator_c [0.75s]
Starting >>> rosidl_generator_cpp
Finished <<< orocos_kdl [0.47s]
Starting >>> rosidl_typesupport_introspection_c
Finished <<< urdfdom [0.60s]
Starting >>> libcurl_vendor
Finished <<< class_loader [0.78s]
Starting >>> urdf
Finished <<< rosidl_typesupport_introspection_c [0.36s]
Starting >>> osrf_testing_tools_cpp
Finished <<< libcurl_vendor [0.21s]
Starting >>> ament_cmake_auto
Finished <<< rosidl_generator_cpp [0.80s]
Starting >>> rosidl_typesupport_introspection_cpp
Finished <<< urdf [0.37s]
Starting >>> rviz_assimp_vendor
Finished <<< ament_cmake_auto [0.25s]
Starting >>> rviz_ogre_vendor
Finished <<< osrf_testing_tools_cpp [0.47s]
Starting >>> rcutils
Finished <<< rviz_assimp_vendor [0.30s]
Starting >>> resource_retriever
Finished <<< rosidl_typesupport_introspection_cpp [0.54s]
Starting >>> tinyxml2_vendor
Finished <<< rviz_ogre_vendor [0.49s]
Starting >>> qt_gui_py_common
Finished <<< tinyxml2_vendor [0.23s]
Starting >>> yaml_cpp_vendor
Finished <<< resource_retriever [0.50s]
Starting >>> rviz_rendering
Finished <<< qt_gui_py_common [0.42s]
Starting >>> ament_pep8
Finished <<< yaml_cpp_vendor [0.62s]
Starting >>> tlsf
Finished <<< rcutils [1.59s]
Finished <<< tlsf [0.47s]
Starting >>> rmw
Starting >>> pluginlib
Finished <<< ament_pep8 [0.87s]
Starting >>> kdl_parser
Finished <<< kdl_parser [0.36s]
Starting >>> ament_pyflakes
Finished <<< pluginlib [0.43s]
Starting >>> ament_clang_format
Finished <<< rviz_rendering [1.77s]
Finished <<< rmw [1.06s]
Starting >>> rmw_fastrtps_shared_cpp
Starting >>> rosidl_typesupport_connext_cpp
Finished <<< ament_pyflakes [0.83s]
Starting >>> rosidl_typesupport_fastrtps_cpp
Finished <<< rosidl_typesupport_connext_cpp [0.27s]
Starting >>> rosidl_typesupport_opensplice_cpp
Finished <<< rmw_fastrtps_shared_cpp [0.41s]
Starting >>> rmw_connext_shared_cpp
Finished <<< ament_clang_format [1.16s]
Starting >>> rosidl_typesupport_connext_c
Finished <<< rosidl_typesupport_opensplice_cpp [0.27s]
Starting >>> rosidl_typesupport_opensplice_c
Finished <<< rosidl_typesupport_fastrtps_cpp [0.45s]
Starting >>> rosidl_typesupport_fastrtps_c
Finished <<< rmw_connext_shared_cpp [0.26s]
Starting >>> rmw_fastrtps_dynamic_cpp
Finished <<< rosidl_typesupport_connext_c [0.28s]
Starting >>> rmw_connext_cpp
Finished <<< rosidl_typesupport_opensplice_c [0.29s]
Starting >>> rmw_opensplice_cpp
Finished <<< rosidl_typesupport_fastrtps_c [0.45s]
Starting >>> rmw_fastrtps_cpp
Finished <<< rmw_connext_cpp [0.30s]
Finished <<< rmw_opensplice_cpp [0.27s]
Starting >>> ament_pclint
Starting >>> rttest
Finished <<< rmw_fastrtps_dynamic_cpp [0.78s]
Starting >>> qt_dotgraph
Finished <<< qt_dotgraph [0.31s]
Starting >>> qt_gui_app
Finished <<< rttest [0.66s]
Starting >>> rviz_rendering_tests
Finished <<< rmw_fastrtps_cpp [0.75s]
Starting >>> rmw_implementation
Finished <<< ament_pclint [0.86s]
Starting >>> test_osrf_testing_tools_cpp
Finished <<< qt_gui_app [0.34s]
Starting >>> ros_environment
Finished <<< rmw_implementation [0.43s]
Starting >>> rosidl_typesupport_c
Finished <<< ros_environment [0.19s]
Starting >>> ament_cmake_nose
Finished <<< test_osrf_testing_tools_cpp [0.39s]
Starting >>> ament_cmake_clang_format
Finished <<< ament_cmake_nose [0.17s]
Starting >>> ament_cmake_pclint
Finished <<< ament_cmake_clang_format [0.21s]
Starting >>> ament_cmake_pep8
Finished <<< rviz_rendering_tests [0.88s]
Starting >>> ament_cmake_pyflakes
Finished <<< ament_cmake_pclint [0.23s]
Starting >>> qt_gui_core
Finished <<< rosidl_typesupport_c [0.51s]
Starting >>> rosidl_generator_py
Finished <<< ament_cmake_pyflakes [0.20s]
Starting >>> rosidl_typesupport_cpp
Finished <<< ament_cmake_pep8 [0.31s]
Finished <<< qt_gui_core [0.22s]
Finished <<< rosidl_typesupport_cpp [0.40s]
Finished <<< rosidl_generator_py [0.95s]
Starting >>> rosidl_default_runtime
Starting >>> rosidl_default_generators
Finished <<< rosidl_default_runtime [0.24s]
Finished <<< rosidl_default_generators [0.23s]
Starting >>> builtin_interfaces
Starting >>> unique_identifier_msgs
Starting >>> lifecycle_msgs
Starting >>> std_srvs
Finished <<< unique_identifier_msgs [1.14s]
Finished <<< builtin_interfaces [1.26s]
Starting >>> rcl_interfaces
Starting >>> action_msgs
Finished <<< std_srvs [1.43s]
Starting >>> std_msgs
Finished <<< lifecycle_msgs [1.70s]
Starting >>> rosgraph_msgs
Finished <<< action_msgs [1.51s]
Starting >>> example_interfaces
Finished <<< rosgraph_msgs [1.26s]
Starting >>> test_msgs
Finished <<< rcl_interfaces [2.15s]
Starting >>> pendulum_msgs
Finished <<< std_msgs [2.38s]
Starting >>> geometry_msgs
Finished <<< pendulum_msgs [1.25s]
Starting >>> actionlib_msgs
Finished <<< example_interfaces [2.06s]
Finished <<< test_msgs [2.87s]
Starting >>> rcl
Finished <<< actionlib_msgs [1.21s]
Finished <<< geometry_msgs [2.06s]
Starting >>> sensor_msgs
Starting >>> tf2
Starting >>> tf2_msgs
Finished <<< tf2 [0.89s]
Starting >>> nav_msgs
Finished <<< tf2_msgs [1.58s]
Starting >>> visualization_msgs
Finished <<< sensor_msgs [2.53s]
Starting >>> diagnostic_msgs
Finished <<< rcl [2.63s]
Starting >>> rcl_yaml_param_parser
Finished <<< nav_msgs [1.83s]
Starting >>> rcl_action
Finished <<< rcl_yaml_param_parser [0.61s]
Starting >>> rclcpp
Finished <<< visualization_msgs [2.09s]
Starting >>> map_msgs
Finished <<< rcl_action [1.27s]
Starting >>> rclpy
Finished <<< diagnostic_msgs [1.73s]
Starting >>> shape_msgs
Finished <<< rclpy [0.83s]
Starting >>> ros2cli
Finished <<< shape_msgs [1.35s]
Starting >>> rqt_gui
Finished <<< rclcpp [2.58s]
Starting >>> message_filters
Finished <<< map_msgs [2.43s]
Finished <<< ros2cli [1.31s]
Starting >>> rqt_py_common
Starting >>> launch_ros
Finished <<< rqt_gui [1.15s]
Starting >>> rqt_gui_py
Finished <<< launch_ros [1.20s]
Finished <<< message_filters [1.63s]
Starting >>> tf2_ros
Starting >>> ros2pkg
Finished <<< rqt_py_common [1.74s]
Starting >>> rclcpp_action
Finished <<< rqt_gui_py [1.21s]
Starting >>> ros2msg
Finished <<< ros2pkg [1.10s]
Finished <<< tf2_ros [1.13s]
Starting >>> ros2run
Starting >>> tf2_geometry_msgs
Finished <<< rclcpp_action [1.11s]
Starting >>> trajectory_msgs
Finished <<< ros2msg [1.08s]
Starting >>> rcl_lifecycle
Finished <<< tf2_geometry_msgs [0.88s]
Starting >>> rviz_common
Finished <<< ros2run [1.07s]
Starting >>> stereo_msgs
Finished <<< rcl_lifecycle [0.75s]
Starting >>> laser_geometry
Finished <<< trajectory_msgs [1.52s]
Starting >>> ros2node
Finished <<< laser_geometry [0.88s]
Starting >>> ros2srv
Finished <<< stereo_msgs [1.85s]
Starting >>> ros2topic
Finished <<< ros2node [1.39s]
Starting >>> rqt_console
Finished <<< ros2srv [1.31s]
Starting >>> composition
Finished <<< rqt_console [0.46s]
Starting >>> demo_nodes_py
Finished <<< ros2topic [1.07s]
Starting >>> dummy_map_server
Finished <<< rviz_common [3.57s]
Starting >>> dummy_sensors
Finished <<< dummy_map_server [0.73s]
Starting >>> logging_demo
Finished <<< dummy_sensors [0.50s]
Starting >>> rclcpp_lifecycle
Finished <<< demo_nodes_py [1.16s]
Starting >>> tlsf_cpp
Finished <<< composition [2.10s]
Starting >>> demo_nodes_cpp
Finished <<< tlsf_cpp [0.65s]
Starting >>> sros2
Finished <<< rclcpp_lifecycle [1.20s]
Starting >>> robot_state_publisher
Finished <<< logging_demo [1.62s]
Starting >>> ros2service
Finished <<< sros2 [1.15s]
Starting >>> rqt_msg
Finished <<< demo_nodes_cpp [1.29s]
Starting >>> rviz_visual_testing_framework
Finished <<< robot_state_publisher [0.89s]
Starting >>> common_interfaces
Finished <<< rqt_msg [0.41s]
Starting >>> demo_nodes_cpp_native
Finished <<< common_interfaces [0.29s]
Starting >>> examples_rclcpp_minimal_client
Finished <<< ros2service [1.11s]
Starting >>> examples_rclcpp_minimal_composition
Finished <<< rviz_visual_testing_framework [0.85s]
Starting >>> rviz_default_plugins
Finished <<< demo_nodes_cpp_native [0.49s]
Starting >>> examples_rclcpp_minimal_publisher
Finished <<< examples_rclcpp_minimal_client [0.42s]
Starting >>> examples_rclcpp_minimal_service
Finished <<< examples_rclcpp_minimal_composition [0.56s]
Starting >>> examples_rclcpp_minimal_subscriber
Finished <<< examples_rclcpp_minimal_service [0.40s]
Starting >>> examples_rclcpp_minimal_timer
Finished <<< examples_rclcpp_minimal_publisher [0.57s]
Starting >>> examples_rclpy_executors
Finished <<< examples_rclcpp_minimal_subscriber [1.31s]
Starting >>> examples_rclpy_minimal_action_client
Finished <<< examples_rclcpp_minimal_timer [1.36s]
Starting >>> examples_rclpy_minimal_action_server
Finished <<< examples_rclpy_executors [2.14s]
Starting >>> examples_rclpy_minimal_client
Finished <<< examples_rclpy_minimal_action_client [1.60s]
Starting >>> examples_rclpy_minimal_publisher
Finished <<< examples_rclpy_minimal_action_server [1.50s]
Starting >>> examples_rclpy_minimal_service
Finished <<< examples_rclpy_minimal_client [1.67s]
Starting >>> examples_rclpy_minimal_subscriber
Finished <<< examples_rclpy_minimal_service [1.58s]
Starting >>> image_tools
Finished <<< examples_rclpy_minimal_publisher [1.70s]
Starting >>> intra_process_demo
Finished <<< examples_rclpy_minimal_subscriber [1.05s]
Starting >>> test_cli
Finished <<< image_tools [0.57s]
Starting >>> test_cli_remapping
Finished <<< intra_process_demo [0.75s]
Starting >>> test_rclcpp
Finished <<< test_cli [0.41s]
Starting >>> test_security
Finished <<< test_cli_remapping [0.43s]
Starting >>> examples_rclcpp_minimal_action_client
Finished <<< examples_rclcpp_minimal_action_client [0.67s]
Finished <<< test_security [0.72s]
Starting >>> examples_rclcpp_minimal_action_server
Starting >>> ros2multicast
Finished <<< examples_rclcpp_minimal_action_server [0.44s]
Starting >>> test_communication
Finished <<< ros2multicast [0.73s]
Starting >>> test_launch_ros
Finished <<< test_launch_ros [1.27s]
Starting >>> topic_monitor
Finished <<< test_rclcpp [3.03s]
Starting >>> ros2launch
Finished <<< test_communication [2.45s]
Starting >>> ros2param
Finished <<< topic_monitor [1.33s]
Starting >>> rqt
Finished <<< ros2launch [1.65s]
Starting >>> rqt_plot
Finished <<< ros2param [1.02s]
Starting >>> rqt_publisher
Finished <<< rqt_plot [0.38s]
Starting >>> rqt_py_console
Finished <<< rqt [1.01s]
Starting >>> rqt_service_caller
Finished <<< rqt_publisher [0.52s]
Starting >>> rqt_shell
Finished <<< rqt_py_console [0.39s]
Starting >>> rqt_top
Finished <<< rqt_service_caller [0.42s]
Starting >>> sros2_cmake
Finished <<< rqt_shell [0.41s]
Starting >>> tf2_eigen
Finished <<< rqt_top [0.46s]
Starting >>> tf2_sensor_msgs
Finished <<< sros2_cmake [0.31s]
Starting >>> dummy_robot_bringup
Finished <<< tf2_eigen [0.49s]
Starting >>> lifecycle
Finished <<< tf2_sensor_msgs [0.33s]
Starting >>> pendulum_control
Finished <<< dummy_robot_bringup [0.43s]
Starting >>> ros1_bridge
Finished <<< lifecycle [0.57s]
Finished <<< pendulum_control [0.54s]
Starting >>> ros2lifecycle
Starting >>> rqt_srv
Finished <<< rqt_srv [0.82s]
Finished <<< ros2lifecycle [1.20s]
Finished <<< rviz_default_plugins [13.9s]
Starting >>> rviz2
Finished <<< ros1_bridge [1.90s]
Finished <<< rviz2 [0.55s]
Summary: 230 packages finished [54.5s]
. ~/ros2_ws/install/local_setup.bash
ros2 run demo_nodes_cpp talker
. ~/ros2_ws/install/local_setup.bash
ros2 run demo_nodes_py listener
. install/setup.bash
成功的情况下不会有任何输出。
. ~/ros2_ws/install/local_setup.bash
ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
. ~/ros2_ws/install/local_setup.bash
ros2 run examples_rclcpp_minimal_publisher publisher_member_function
ros2: command not found
解决办法是:
. ~/ros2_ws/install/local_setup.bash
愉快地使用ros2吧!
如果想用回ros1,需要对~/.bashrc进行设置,不然你输入roscore的时候会提示:
Traceback (most recent call last):
File "/opt/ros/kinetic/bin/roscore", line 69, in
import roslaunch
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/__init__.py", line 61, in
from .scriptapi import ROSLaunch
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/scriptapi.py", line 42, in
import roslaunch.parent
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/parent.py", line 54, in
import roslaunch.server
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/server.py", line 78, in
from rosgraph_msgs.msg import Log
File "/home/sph/ros2_ws/install/rosgraph_msgs/lib/python3.5/site-packages/rosgraph_msgs/msg/__init__.py", line 2, in
from rosgraph_msgs.msg._clock import Clock # noqa: I100
File "/home/sph/ros2_ws/install/rosgraph_msgs/lib/python3.5/site-packages/rosgraph_msgs/msg/_clock.py", line 49
class Clock(metaclass=Metaclass):
^
SyntaxError: invalid syntax
解决办法:
查看系统变量
printenv | grep ROS
修改bashrc文件
gedit ~/.bashrc
添加内容(以主机是本机为例):
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/peng/catkin_ws/src:/opt/ros/kinetic/share:/opt/ros/kinetic/stacks
ROS_MASTER_URI=http://localhost:11311
ROSLISP_PACKAGE_DIRECTORIES=/home/peng/catkin_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
如果遇到问题
ERROR:colcon:colcon build: Duplicate package names not supported:
因为你在没有删除vcstool import的情况下重复import了一次
解决方法:
把src文件夹里面你从ros2的github下载的东西都删除,再做一次就可以了:
vcs import src < ros2.repos
--- stderr: rosidl_typesupport_opensplice_cpp
CMake Warning at /home/sph/ros2_ws/install/opensplice_cmake_module/share/opensplice_cmake_module/cmake/Modules/FindOpenSplice.cmake:100 (find_package):
Could not find a package configuration file provided by "opensplice" with
any of the following names:
openspliceConfig.cmake
opensplice-config.cmake
Add the installation prefix of "opensplice" to CMAKE_PREFIX_PATH or set
"opensplice_DIR" to a directory containing one of the above files. If
"opensplice" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:16 (find_package)
原因是没安装好opensplice库
解决办法,注意自己安装的ros2版本:
# For Crystal Clemmys
sudo apt install libopensplice69 # from packages.ros.org/ros2/ubuntu
# For Bouncy Bolson
sudo apt install libopensplice67 # from packages.ros.org/ros2/ubuntu