ROS2 Dashing安装教程

尽管ROS-1让我们可以轻松地与复杂的硬件和软件组件进行通信,但使用ROS-1开发实际可用产品的过程涉及一些复杂的问题。例如,假设在制造业中需要一大群异构机器人(例如,移动机器人、机械臂等)协同工作,由于ROS-1的体系结构不支持多master的概念,因此很难在多异构机器人之间建立通信。

ROS,更具体地说,ROS-1,目前推动机器人技术在开源社区发展到了一个里程碑式的水平。尽管在软硬件连接同步方面存在缺陷与不足,但是ROS-1提供了一种简单的通信策略,该策略使得用户能够轻松地将任何复杂的传感器连接到微型计算机或微控制器中。在过去的十年里,ROS-1已经发展壮大,拥有一个庞大的功能包列表,每个功能包都能解决一个或一些问题,并一定程度上消除了重新发明轮子的问题。这些功能包带来了一种看待机器人技术的全新方式,并使得当前可用的机器人系统具备了一定的智能。通过连接几个小规模的功能包,用户就可以创建一个全新的复杂自治系统。

尽管有其他方法用于网络中节点之间的通信(我们将在第6章探讨),但它们之间没有安全的通信方式。任何连接到master的用户都可以很容易地访问可用话题的列表,还可以使用或修改它们。鉴于此,人们通常使用ROS-1来验证概念,或者构建科学研究的快速解决方案。
在使用ROS-1进行原型设计验证和创建最终产品之间出现了一条难以逾越的鸿沟,这主要是因为ROS-1不是实时的。通过无线连接(Wi-Fi)使用有线连接(以太网)时,系统组件之间的网络连接有所不同,这可能导致数据接收延迟,甚至丢失数据,从而导致系统不稳定。
考虑到这一点,OSRF开始了改进和建设下一代ROS——ROS-2的旅程。目前ROS-2正处于开发之中,主要目的是修复ROS-1在通信中存在的风险和不足。在本章中,读者将了解ROS-2的概念及其与ROS-1的区别以及特点。为了读者能够更好地理解和比较,本章的组织方式与前一章相似:

安装ROS 2 Dashing
参考官网地址:https://index.ros.org/doc/ros2/Installation/Crystal/Linux-Install-Binary/

  1. 设置UTF-8编码
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
  1. 更新软件源
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'
  1. 安装ros2
    桌面版 : 包含ROS, RViz, demos, tutorials [推荐]
sudo apt install ros-dashing-desktop

基础版:(包含通讯库、消息包、命令行工具,没有GUI工具)

sudo apt install ros-dashing-ros-base

这是一个很漫长的过程,需要耐心的等待…

  1. 安装自动补全工具
    ros2的命令行使用argcomplete工具进行补全:
 sudo apt install python3-argcomplete

导入配置脚本

source /opt/ros/dashing/setup.bash

通过如下命令添加到.bashrc

echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc

5.安装附加RMW实现

sudo apt update
sudo apt install ros-dashing-rmw-opensplice-cpp # for OpenSplice
sudo apt install ros-dashing-rmw-connext-cpp # for RTI Connext (requires license agreement)

6.ROS 2和ROS 1之间通过ros-bridge通信

sudo apt update
sudo apt install ros-dashing-ros1-bridge

测试
创建工作空间,Clone并编译

mkdir  ~/ros2_ws
cd /ros2_ws
git clone https://github.com/zhangrelay/ros2_tutorials
cd ros2_tutorials
colcon build

可能会遇见的问题colcon:command not found
ROSwiki官网推荐了新的软件包编译工具colcon。ROS编译工具主要经历了三个阶段:

  1. catkin 2. ament 3. colcon。

什么是colcon?

colcon is a command line tool to improve the workflow of building, testing and using multiple software packages.It automates the process, handles the ordering and sets up the environment to use the packages.

colcon是一个命令行工具,用于改进编译,测试和使用多个软件包的工作流程。它实现过程自动化,处理需求并设置环境以便于使用软件包。


安装和使用,请参考:http://colcon.readthedocs.io/en/latest/index.html

下面简述流程:

一共两步:

1. sudo apt install python3-colcon-common-extensions

2. colcon build (source install/setup.bash )

具体使用教程参考官网链接进行。

编译过程如下:

Starting >>> roscpp_tutorials
Starting >>> rospy_tutorials
Starting >>> turtlesim
--- stderr: rospy_tutorials                                                
CMake Warning:
  Manually-specified variables were not used by the project:

    CATKIN_INSTALL_INTO_PREFIX_ROOT


---
Finished <<< rospy_tutorials [16.41s]
--- stderr: turtlesim                                                      
CMake Warning:
  Manually-specified variables were not used by the project:

    CATKIN_INSTALL_INTO_PREFIX_ROOT


---
Finished <<< turtlesim [29.56s]
--- stderr: roscpp_tutorials                                  
CMake Warning:
  Manually-specified variables were not used by the project:

    CATKIN_INSTALL_INTO_PREFIX_ROOT


---
Finished <<< roscpp_tutorials [39.06s]
Starting >>> ros_tutorials
--- stderr: ros_tutorials                            
CMake Warning:
  Manually-specified variables were not used by the project:

    CATKIN_INSTALL_INTO_PREFIX_ROOT


---
Finished <<< ros_tutorials [2.63s]

Summary: 4 packages finished [42.15s]
  4 packages had stderr output: ros_tutorials roscpp_tutorials rospy_tutorials turtlesim

设置环境变量
source /install/setup.sh

运行第一个终端

cd /ros_ws/ros2_tutorials/install
ros2 run demo_nodes_cpp listener

第二个终端

ros2 run demo_nodes_cpp talker

仿真(运行小海龟画矩形)
第一个终端

ros2 run turtlesim turtlesim_node 

第二个终端

ros2 run turtlesim draw_square 

在这里插入图片描述

五、ROS1和ROS2环境变量设置
为了避免每次使用ROS都执行一次source命令,这里我们介绍一种设置方法。可以通过以下步骤,使用alias命令将两个环境都设置到bash脚本,来进行两个环境的共存设置:
使用以下命令调出bash脚本并进行编辑:
在这里插入图片描述
注释掉以下两行,

#source /opt/ros/melodic/setup.bash
#source /opt/ros/dashing/setup.bash

在末尾添加:


#ROS 1.0 melodic or ROS 2.0 Dashing
echo Hello alvin! ROS 1.0 or ROS 2.0? 1=Melodic 2=Dashing 
read ROS
if (($ROS==1));then
source /opt/ros/melodic/setup.bash
echo "Melodic"
elif (($ROS==2));then
source /opt/ros/dashing/setup.bash
echo "Dashing"
else
echo "Non-ROS"

每次打开终端

使用Dashing
在这里插入图片描述

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr Robot

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值