ROS2与turtlebot4仿真入门教程-turtlebot4遥控
原创
©著作权归作者所有:来自51CTO博客作者创客智造ROS的原创作品,请联系作者获取转载授权,否则将追究法律责任
说明:
步骤:
ros2 launch turtlebot4_ignition_bringup ignition.launch.py
- 效果图:
HMI界面控制
- 通过HMI界面的数字键1234控制
- 1为确认,2为dock,34为上下选择
- 如图:
- 通过HMI界面的方向键盘控制
- 要先设置Linear和angular的值才能控制,每按动一次发送一次速度命令
- 如图:
- 通过键盘wasd键控制
- 要先设置Linear和angular的值才能控制
- 勾选后,控制w前进,a左转,s后退,d右转
- 如图:
- 通过滑条控制
- 勾选后,拖动滑条设置速度,反复拖动才能一直前进或转向,每次拖动一次发送一次速度命令
- 如图
键盘控制
ros2 run teleop_twist_keyboard teleop_twist_keyboard
- 根据提示的按键操作,按住键持续发送速度命令,i前进,j左转,k停止,l右转,,后退
- 启动效果如下:
$ ros2 run teleop_twist_keyboard teleop_twist_keyboard
This node takes keypresses from the keyboard and publishes them
as Twist messages. It works best with a US keyboard layout.
---------------------------
Moving around:
u i o
j k l
m , .
For Holonomic mode (strafing), hold down the shift key:
---------------------------
U I O
J K L
M < >
t : up (+z)
b : down (-z)
anything else : stop
q/z : increase/decrease max speeds by 10%
w/x : increase/decrease only linear speed by 10%
e/c : increase/decrease only angular speed by 10%
CTRL-C to quit
currently: speed 0.5turn 1.0
命令控制
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.0}}"
ros2 action send_goal /drive_distance irobot_create_msgs/action/DriveDistance "{distance: 0.5, max_translation_speed: 0.3}"
- 驱动弧线,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}"
ros2 action send_goal /rotate_angle irobot_create_msgs/action/RotateAngle "{angle: 1.0, max_rotation_speed: 0.3}"