create® 3入门教程-通过ROS2命令执行
说明:
- 介绍如何使用 ROS 2 命令行工具来使用 Create® 3 机器人的执行器
相关设备
- Turtlebot4机器人套件:采购地址
声音
- 弹奏一系列音符,播放一次快乐的序列:
ros2 topic pub /cmd_audio irobot_create_msgs/msg/AudioNoteVector "{append: false, notes: [{frequency: 392, max_runtime: {sec: 0,nanosec: 177500000}}, {frequency: 523, max_runtime: {sec: 0,nanosec: 355000000}}, {frequency: 587, max_runtime: {sec: 0,nanosec: 177500000}}, {frequency: 784, max_runtime: {sec: 0,nanosec: 533000000}}]}" -1
- 播放一次悲伤的序列:
ros2 topic pub /cmd_audio irobot_create_msgs/msg/AudioNoteVector "{append: false, notes: [{frequency: 369, max_runtime: {sec: 0,nanosec: 355000000}}, {frequency: 300, max_runtime: {sec: 0,nanosec: 533000000}}]}" -1
- 永远播放一个可怕的序列:
ros2 action send_goal /audio_note_sequence irobot_create_msgs/action/AudioNoteSequence "{iterations: -1, note_sequence: {append: false, notes: [{frequency: 82, max_runtime: {sec: 1,nanosec: 0}}, {frequency: 87, max_runtime: {sec: 1,nanosec: 0}}]}}"
驾驶
- 命令速度,您可以通过发布有关该主题的标准Twist消息来绕过 Create® 3 机器人。/cmd_vel
ros2 topic pub -r 20 /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.2, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"
- 开车一段距离,Drive Distance 动作以米为单位,最大速度以米/秒为单位。
ros2 action send_goal /drive_distance irobot_create_msgs/action/DriveDistance "{distance: 0.5,max_translation_speed: 0.15}"
- 旋转一个角度,旋转角度动作以弧度为单位的转角和以弧度每秒为单位的最大角速度。
ros2 action send_goal /rotate_angle irobot_create_msgs/action/RotateAngle "{angle: 1.57,max_rotation_speed: 0.5}"
- 驱动弧线,Drive Arc 动作以弧度为单位的弧角、以米为单位的弧半径、平移方向(1 表示向前,-1 表示向后)和最大平移速度(以米/秒为单位)。
$ ros2 action send_goal /drive_arc irobot_create_msgs/action/DriveArc "{angle: 1.57,radius: 0.3,translate_direction: 1,max_translation_speed: 0.3}"
- 墙跟随,Wall Follow 动作采用一侧(1=左,-1=右)和最长持续时间。
ros2 action send_goal /wall_follow irobot_create_msgs/action/WallFollow "{follow_side: 1, max_runtime: {sec: 1, nanosec: 0}}"
- 导航到位置,Navigate to Position 操作采用目标位置(以米为单位)和方向(以弧度为单位)。方向必须指定为消息的一部分,但可以通过设置achieve_goal_heading为忽略它false。
$ ros2 action send_goal /navigate_to_position irobot_create_msgs/action/NavigateToPosition "{achieve_goal_heading: true,goal_pose:{pose:{position:{x: 1,y: 0.2,z: 0.0}, orientation:{x: 0.0,y: 0.0, z: 0.0, w: 1.0}}}}"
对接
- 解除对接机器人,如果 Create® 3 机器人在其坞站上,您可以使用Undock 操作将其取消停靠:
ros2 action send_goal /undock irobot_create_msgs/action/Undock "{}"
- 对接机器人,如果 Create® 3 机器人看到它的停靠点(请查看停靠文档了解详细信息),您可以将其停靠在:
ros2 action send_goal /dock irobot_create_msgs/action/DockServo "{}"
急停
- 启用急停,如果在机器人的控制下,当电机被禁用时,它的灯环会变成黄色。
ros2 service call /e_stop irobot_create_msgs/srv/EStop "{e_stop_on: true}"
- 禁用急停
ros2 service call /e_stop irobot_create_msgs/srv/EStop "{e_stop_on: false}"
光环
- 多色的
ros2 topic pub /cmd_lightring irobot_create_msgs/msg/LightringLeds "{override_system: true, leds: [{red: 255, green: 0, blue: 0}, {red: 0, green: 255, blue: 0}, {red: 0, green: 0, blue: 255}, {red: 255, green: 255, blue: 0}, {red: 255, green: 0, blue: 255}, {red: 0, green: 255, blue: 255}]}" -1
- 将静态控制返回到 Create 3 Robot
ros2 topic pub /cmd_lightring irobot_create_msgs/msg/LightringLeds "{override_system: false, leds: [{red: 255, green: 0, blue: 0}, {red: 0, green: 255, blue: 0}, {red: 0, green: 0, blue: 255}, {red: 255, green: 255, blue: 0}, {red: 255, green: 0, blue: 255}, {red: 0, green: 255, blue: 255}]}" -1
- 动画
# Note: type 1 is blink and type 2 is spin
ros2 action send_goal /led_animation irobot_create_msgs/action/LedAnimation "{animation_type: 2,max_runtime:{sec: 10,nanosec: 0},lightring:{override_system: true, leds: [{red: 255, green: 0, blue: 0}, {red: 0, green: 255, blue: 0}, {red: 0, green: 0, blue: 255}, {red: 255, green: 255, blue: 0}, {red: 255, green: 0, blue: 255}, {red: 0, green: 255, blue: 255}]}}"
机器人电源
- 警告:这会立即关闭机器人和有效载荷
ros2 service call /robot_power irobot_create_msgs/srv/RobotPower "{}"
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号