ROS2小乌龟测试

ROS2小乌龟测试

下载turtlesim功能包

source /opt/ros/humble/setup.bash
git clone https://github.com/ros/ros_tutorials.git -b humble-devel

# 创建工作空间
mkdir -p turtle_dev/src && cd turtle_dev/src

解决依赖

rosdep install -i --from-path src --rosdistro eloquent -y

构建空间

colcon build
不能在python virtual environment下构建

设置环境变量

. install/setup.bash

运行节点

ros2 run turtlesim turtlesim_node

ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key

查看信息

查看节点信息

ros2 node list
ros2 node info /turtlesim

查看话题列表和话题内容

ros2 topic list # -t 参数显示话题传输的数据类型
ros2 topic echo /turtle1/pose

查看话题用的带宽

ros2 topic bw /turtle1/pose

使用命令行发布话题
ros2 topic pub -r 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}}"

使用service生成新的小乌龟

ros2 service
ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"

action机制给小乌龟发目标点

ros2 action
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "theta: 3"
posted @   sgqmax  阅读(74)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示