使用ROS的demo
启动前检查Pre-launch Check
提示Tip请先掌握Please first acquire basic knowledge ofROS
. You can refer to the ROS1 Tutorial and ROS2 Tutorial to understand the common conventions of theROS
的基本知识。可以参考ROS1教程以及ROS2教程,了解对
ROS系统的常见约定。system.
请检查确保完成以下事项:Please ensure the following are completed:
-
已经安装完成ROS-SDK,如果是第一次安装SDK,建议在SDK installation is complete; if it is your first time installing the SDK, it is recommended to首次安装后重启restart一次after the first installation. -
已经通过了编译并没有报错Compilation has been completed without errors. -
已经完成工作空间的sourceThe workspace has been sourced. -
如果使用If using the CAN-COMHUB,请确定正确连接CAN总线,确定已经能够搜索到设备HUB, ensure the CAN bus is correctly connected and devices can be detected.在终端使用lsusb查询可看到以下设备Use lsusb in the terminal to see the following devices.
-
确保遥控器已经关闭;或者打开时,拨到的是Ensure the remote control is turned off; or if it is on, ensure it is set to CAN模式mode.关于遥控器与模式,请参阅产品用户手册中关于遥控器的部。For information about the remote control and modes, please refer to the remote control section in the product user manual.
底盘类设备Chassis Devices
警告Warning注意,Be首次尝试使用软件控制机器人时,请确保机器人活动范围内没有其他障碍,或将机器人架起。cautious, when attempting to control the robot with software for the first time, ensure there are no obstacles within the robot's range of motion, or elevate the robot.
底盘的测试demo有以下两个:There are two test demos for the chassis:
* demo_basic_ctrl.launch
* demo_key_ctrl.launch
demo_basic_ctrl.launch
是标准的启动文件,可以配套自动驾驶直接使用,通过使用 is a standard launch file that can be used directly with autonomous driving, controlling the robot's movement via the /cmd_vel
话题来控制机器人的移动。topic.
demo_key_ctrl.launch
是支持键盘控制的启动文件,使用 supports keyboard control, using turtle_teleop_key
来利用键盘控制机器人。如果你还没有看过to control the robot with the keyboard. If you have not yet seen the ROS 的 turtlesim
教程,请先查看tutorial,
please turtlesim教程。check it out first.
提示Tip注意并不是使用方向键控制移动,请查看终端打印的使用方式提示,按下提示中的前进按钮。Note that the movement is not controlled with the arrow keys, please check the usage tips printed in the terminal and press the forward button indicated.
成功启动launch后会得到以下终端消息Successful launch will display the following terminal message
launch文件中参数设置和通讯For parameter settings and communication msg
请查阅 in the launch file, please refer to the src/drivers/xpkg_vehicle/README.md
文件,以下解释几个关键参数: file, below are explanations of a few key parameters:
-
calc_speed
是设置里程计计算方式,sets the odometer calculation method,true
为用速度计算,for using speed,false
为用电机码盘值计算,建议采用默认false设置for using motor encoder values, with the default setting recommended as false. -
mode_can_lock
是CAN模式锁定设置,is the CAN mode lock setting,true
为强制CAN模式,如果用遥控器切换到其他模式会警告并等待恢复,设置forces CAN mode, switching to other modes with the remote control will trigger a warning and wait for recovery, settingfalse
则由用户选择控制模式allows the user to choose the control mode.
!!!note
如果出现底盘无法控制,可能是If the chassis cannot be controlled, it may be because mode_can_lock
设置 is set to false
,并且切换到了其他模式, and it has been switched to another mode.
-
rate_x
是输入速度的倍率控制,1为全速,在测试时建议先设置为controls the rate multiplier for input speed, 1 is full speed, it is recommended to set it below 0.2以下2 during testing.
成功启动launch包后可以通过After successfully launching the package, you can view ROS topics through rostopic list
查看ROS话题,以下为几个关键话题:, below are a few key topics:
底盘节点向话题The chassis node sends messages of typenav_msgs/Odometry
to the topic/odom
发送消息类型为nav_msgs/Odometry。此消息表示底盘里程计信息,包含底盘当前位姿信息以及线速度角速度信息。. This message represents the chassis odometer information, including the current pose of the chassis as well as linear and angular velocity information.底盘节点向话题The chassis node sends messages of typetf2_msgs/TFMessage
to the topic/tf
发送消息类型为tf2_msgs/TFMessage,包含底盘tf变换信息,需要在launch参数中启动。, which include chassis tf transformation information, to be enabled in launch parameters.底盘节点从话题The chassis node subscribes to messages of typegeometry_msgs/Twist
from the topic/cmd_vel
订阅消息类型为geometry_msgs/Twist。底盘接收到该消息后进行移动,其中. Upon receiving this message, the chassis moves, wherelinear.x
/linear.y
为线速度,represent linear velocity, andangular.z
为旋转角速度。represents rotational speed.