当前位置: 首页 > news >正文

ROS2指令总结(跟随古月居教程学习)


博主跟随古月居博客进行ROS2学习,对ROS2相关指令进行了总结,方便学习和回顾。
古月居ROS2博文链接:https://book.guyuehome.com/
本文会持续进行更新,觉得有帮助的朋友可以点赞收藏。

1. ROS2安装命令

$ sudo apt update && sudo apt install locales    # 软件源更新和安装
$ sudo locale-gen en_US en_US.UTF-8            # 将ubuntu系统语言环境改为英文的UTF-8,防止出现中文乱码
$ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8  # 更新Linux系统的本地化设置,特别是语言环境(locale)设置
$ export LANG=en_US.UTF-8       # 使当前所使用的编码格式生效
$ sudo apt update && sudo apt install curl gnupg lsb-release  # 添加ROS2软件源
$ 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         # 将软件源添加到系统对应的列表中
$ sudo apt update            # 扫描ROS2对应的软件源位置
$ sudo apt upgrade			 # ubuntu软件更新
$ sudo apt install ros-humble-desktop   # 安装ROS-humble桌面版
$ source /opt/ros/humble/setup.bash     # ROS2安装位置在终端中生效
$ echo " source /opt/ros/humble/setup.bash" >> ~/.bashrc    # ROS2在所有终端中生效,到此步ROS2就安装完成了
$ ros2 run demo_nodes_cpp talker       # 开启一个终端,打开talker节点
$ ros2 run demo_nodes_py listener      # 开启另一个终端,打开listener节点,测试通信系统是否有问题

2. ROS2基本命令

$ ros2:弹出ROS2的相关指令
$ ros2 run turtlesim turtlesim_node:海龟仿真节点
$ ros2 run turtlesim turtle_teleop_key:海龟控制节点
$ ros2 node:弹出node相关指令
$ ros2 node list:查看当前ROS2系统下的节点
$ ros2 node info /turtlesim :查看某个节点的具体信息
$ ros2 topic:弹出话题相关指令
$ ros2 topic list:查看当前系统下的话题
$ ros2 topic echo /turtle1/pose :echo查看某个话题下的消息数据
$ ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}":发布话题指令
$ ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}":发布服务请求,产生一只新海龟
$ ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "theta: 3":发布具体的动作目标
$ ros2 bag record /turtle1/cmd_vel:录制动作指令
$ ros2 bag play :复现动作指令
$ ros2 run usb_cam usb_cam_node_exe     # 相机驱动节点
$ export ROS_DOMAIN_ID=<your_domain_id>   # ROS2网络分组指令

3. ROS2开发环境配置指令

$ sudo apt install git:Git下载
$ git clone https://gitee.com/guyuehome/ros2_21_tutorials.git:cloneROS2源码
$ sudo dpkg -i code_1.95.1-1730355339_amd64.deb :vscode安装(dpkg安装.deb文件)

4. ROS2工作空间命令

$ mkdir -p ~/dev_ws/src           # 新建文件夹
$ cd ~/dev_ws/src                 # 进入src文件夹
$ git clone https://gitee.com/guyuehome/ros2_21_tutorials.git # 获取ros2代码包
$ sudo apt install -y python3-pip              # 下载pip
$ sudo pip3 install rosdepc                    # 下载rosdepc工具
$ sudo rosdepc init                            # rosdepc初始化
$ rosdepc update                               # rosdepc更新
$ cd ..                                        # 返回dev_ws目录 
$ rosdepc install -i --from-path src --rosdistro humble -y  # 安装代码包依赖
$ sudo apt install python3-colcon-ros          # 下载colcon编译工具
$ cd ~/dev_ws/                                 # 进入dev_ws目录
$ colcon build                                 # 编译工作空间
$ source install/local_setup.sh                # 仅在当前终端生效
$ echo " source ~/dev_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效

5. ROS2功能包命令

$ ros2 pkg create --build-type <build-type> <package_name> # 创建一个功能包
$ ros2 pkg create --build-type ament_cmake learning_pkg_c  # 创建C++版本的功能包
ros2 pkg create --build-type ament_python learning_pkg_python # 创建python版本功能包
$ colcon build   # 编译工作空间所有功能包
$ source install/local_setup.bash  # 仅在当前终端生效
$ echo " source ~/dev_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效注:install中的文件才是实际运行的文件,所以在src中修改代码后,必须通过编译和配置环境变量,才能正常运行修改后的代码。

6. ROS2节点命令

$ ros2 node                        # 查看节点相关指令
$ ros2 node list                   # 查看节点列表
$ ros2 node info <node_name>       # 查看节点信息
$ ros2 run learning_node node_helloworld     # 运行hello world节点

在这里插入图片描述

7. ROS2话题命令

$ ros2 ropic                                # 查看话题相关指令
$ ros2 topic list                           # 查看话题列表
$ ros2 topic info <topic_name>              # 查看话题信息
$ ros2 topic hz <topic_name>                # 查看话题发布频率
$ ros2 topic bw <topic_name>                # 查看话题传输带宽
$ ros2 topic echo <topic_name>              # 查看话题数据
$ ros2 topic pub <topic_name> <msg_type> <msg_data>   # 发布话题消息
$ ros2 service find <type_name>        # 查看某一个特殊类型的所有话题

在这里插入图片描述

8. ROS2服务命令

$ ros2 service                       # 查看服务相关指令
$ ros2 service list                  # 查看服务列表
$ ros2 service type <service_name>   # 查看服务数据类型
$ ros2 service call <service_name> <service_type> <service_data>   # 发送服务请求
$ ros2 service find <type_name>        # 查看某一个特殊类型的所有服务

在这里插入图片描述

9. ROS2动作命令

$ ros2 action                       # 查看话题相关指令
$ ros2 action list                  # 查看服务列表
$ ros2 action info <action_name>    # 查看服务数据类型
$ ros2 action send_goal <action_name> <action_type> <action_data>   # 发送服务请求

在这里插入图片描述

10. ROS2参数命令

$ ros2 param                           # 查看参数相关指令
$ ros2 param list                      # 查看参数列表
$ ros2 param get <node_name> <parameter_name>     # 查看某个参数的数据类型和值
$ ros2 param set <node_name> <parameter_name> <value>    # 设置对应参数的值
$ ros2 param dump <node_name>          # 查看节点中的所有参数的值
$ ros2 param load <node_name> <parameter_file>           # 加载参数文件
$ ros2 param delete <node_name> <parameter_name>         # 删除节点的某个参数
$ ros2 param describe <node_name> <parameter_name>       # 查看某个参数的描述性(具体)信息

在这里插入图片描述

http://www.lryc.cn/news/488640.html

相关文章:

  • IPTV智慧云桌面,后台服务器搭建笔记
  • 徒手从零搭建一套ELK日志平台
  • udp_socket
  • 肝了半年,我整理出了这篇云计算学习路线(新手必备,从入门到精通)
  • 【Golang】手搓DES加密
  • YouQu使用手册【元素定位】
  • Spark RDD sortBy算子什么情况会触发shuffle
  • 机器视觉相机重要名词
  • Django:从入门到精通
  • android viewpager2 嵌套 recyclerview 手势冲突
  • 依赖管理(go mod)
  • Apple Vision Pro开发001-开发配置
  • android 动画原理分析
  • Elasticsearch 6.8 分析器
  • 实验室资源调度系统:基于Spring Boot的创新
  • 实验三:构建园区网(静态路由)
  • 3. SQL优化
  • web——upload-labs——第十一关——黑名单验证,双写绕过
  • AWS CLI
  • springboot:责任链模式实现多级校验
  • CentO7安装单节点Redis服务
  • FreeRTOS学习14——时间管理
  • 统⼀数据返回格式快速⼊⻔
  • Python学习------第十天
  • Win11 24H2新BUG或影响30%CPU性能,修复方法在这里
  • element ui 走马灯一页展示多个数据实现
  • 40分钟学 Go 语言高并发:Goroutine基础与原理
  • Figma插件指南:12款提升设计生产力的插件
  • 【K8S系列】Kubernetes集群资源管理与调度 深度分析
  • delphi fmx android 离线人脸识别