ROS2 安装与测试

文章目录

ROS2 安装与测试

ROS2 安装

基于 Ubuntu 22.04 LTS 操作系统。

1. 设置编码

shell 复制代码
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 
echo 'export LANG=en_US.UTF-8' >> ~/.bashrc
source ~/.bashrc

2. 添加源

shell 复制代码
sudo apt update && sudo apt install curl gnupg lsb-release 
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg 
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

如遇报错 "Failed to connect to raw.githubusercontent.com",可参考

https://www.guyuehome.com/37844

3. 安装 ROS2

shell 复制代码
sudo apt update
sudo apt upgrade
sudo apt install ros-humble-desktop

4. 设置环境变量

shell 复制代码
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc 
source ~/.bashrc

ROS2 示例测试

测试底层通信系统 DDS 是否正常。

实例一:命令行实例

启动第一个终端,执行以下命令:

shell 复制代码
ros2 run demo_nodes_cpp talker

启动第二个终端,执行以下命令:

shell 复制代码
ros2 run demo_nodes_py listener

若 "Hello World" 能够在两个终端中正常传输,则说明底层通信系统 DDS 正常。

实例二:小海龟仿真实例

启动第一个终端,执行以下命令:

shell 复制代码
ros2 run turtlesim turtlesim_node

启动第二个终端,执行以下命令:

shell 复制代码
ros2 run turtlesim turtle_teleop_key

第一个终端启动了一个小海龟仿真器,第二个终端可以输入指令(上下左右)来控制小海龟运动。

参考链接

https://book.guyuehome.com/ROS2/1.系统架构/1.3_ROS2安装方法/

相关推荐
winfreedoms6 天前
ROS2知识大白话
笔记·学习·ros2
何伯特7 天前
ROS与Conda的兼容性问题深度解析与解决方案
conda·ros
LS_learner8 天前
RViz(ROS Visualization)显示传感器数据、机器人状态、路径规划结果等各种信息的强大图形界面
ros2
LS_learner9 天前
ROS2的jazzy版本的机器人3D仿真软件gazebo的安装和使用
ros2
LS_learner9 天前
Xacro 和 SDF 是进行复杂机器人系统开发与高级仿真的关键技能
ros2
LS_learner9 天前
URDF(Unified Robot Description Format)机器人领域中用于描述机器人模型的标准 XML 格式
ros2
LS_learner9 天前
机器人描述中的Xacro、SDF与URDF在实际项目中的协作流程
ros2
LS_learner9 天前
Gazebo 机器人三维物理仿真平台
ros2
hhzz10 天前
利用Terraform格式模板文件创建和部署基本网络资源
阿里云·云原生·ros·terraform·资源编排
github5actions12 天前
ROS开发实战:如何用rviz文件保存和加载你的SLAM可视化配置(附避坑指南)
ros·slam·rviz·机器人开发