ROS2安装与配置

ROS1中由master和client组成,如果master挂掉,那么系统就会挂。而ROS2是真正的分布式,通过DDS通信。

设置源

推荐清华源

1
2
3
4
sudo apt update
sudo apt install curl gnupg2 lsb-release
curl https://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

安装

ROS2有多个不同的版本,按照字母顺序更新。比如说eloquent比dashing更新。

1
sudo apt install ros-eloquent-desktop

设置环境变量

1
2
echo "source /opt/ros/eloquent/setup.bash" >> ~/.bashrc
echo "source ~/namespace_name/install/setup.sh" >> ~/.bashrc

需要在~目录下建立一个文件夹用来存放ros2代码和编译结果文件。

RMW组件

RMW组件即DDS通信组件。获取本地相关动态库

1
2
3
4
5
6
7
8
9
10
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_c.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_connext_c.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_connext_cpp.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_Cpp.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_fastrtps_c.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_fastrtps_Cpp.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_introspection_c.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_introspection_Cpp.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_opensplice_c.so
/opt/ros/eloquent/lib/libvisualization_msgs__rosidl_typesupport_opensplice_cpp.so

ROS2支持connext/fastrtps/introspection/opensplice,同时提供C/C++两个版本。

dds切换:

1
2
3
sudo apt update
sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-opensplice-cpp # for OpenSplice
sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-connext-cpp # for RTI Connext (需要购买授权)

设置环境变量RMW_IMPLEMENTATION=rmw_opensplice_cpp切换使用OpenSplice。

ROS2-Bouncy或更新版本, 设置RMW_IMPLEMENTATION=rmw_connext_cpp使用RTI。


ROS2安装与配置
https://blog.jackeylea.com/ros2/installation-setup-of-ros2/
作者
JackeyLea
发布于
2020年11月2日
许可协议