如果您有TurtleBot或任何其他机器人在/ cmd_vel话题上监听运动命令,则可以在现实世界中尝试一些Twist消息。 始终确保从较小的线速度和角速度开始。 首先尝试应进行单纯的旋转,以免机器人突然在房间内飞来飞去以致毁坏家具。
If you have a TurtleBot or any other robot that listens on the / cmd_vel topic for motion commands, you can try some Twist messages in the real world. Always be sure to start with small values for the linear and angular speeds. Try a pure rotation first so that your robot will not suddenly fly across the room and ruin the furniture.
首先打开机器人电源,然后启动恰当的启动文件。 如果您有原始的TurtleBot(iRobot创建基础),使用SSH连接机器人的笔记本电脑并运行:
First power on your robot and launch the appropriate startup files. If you have an original TurtleBot (iRobot Create base), ssh into the robot’s laptop and run:
roslaunch rbx1_bringup turtlebot_minimal_create.launch
如果您已经拥有包含校准参数的启动文件,请运行该文件。 上面使用的启动文件包含校准参数,这些参数在我自己的TurtleBot的低层地毯上效果很好。 您可能需要针对自己的机器人及其运行的地板类型进行调整。 使用前面介绍的校准过程来找到最适合您的参数。
If you already have your own launch file that includes your calibration parameters, run that file instead. The launch file used above includes calibration parameters that work well on a low ply carpet for my own TurtleBot. You will likely have to adjust them for your own robot and the type of floor surface it will run on. Use the calibration procedure described earlier to find the parameters that work best for you.
要以每秒1.0弧度(每转一圈约6秒)的速度逆时针旋转机器人,请运行以下命令:
To rotate the robot counterclockwise in place at 1.0 radians per second (about 6 seconds per revolution), run the command:
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0, y: 0, z: 0}, angular: {x: 0, y: 0, z: 1.0}}'
您可以在TurtleBot上运行此命令(在另一个终端中使用ssh之后),也可以在你的工作站上运行此命令,前提是您已经设置了ROS网络。
You can run this command either on the TurtleBot (after using ssh in another terminal) or you can run it on your workstation assuming you have already set up ROS networking.
要停止机器人,请键入Ctrl-C,并在必要时发布空的Twist消息:
To stop the robot, type Ctrl-C and, if necessary, publish the empty Twist message:
(TurtleBot在第一次键入Ctrl-C后应该自行停止。)
(A TurtleBot should stop on its own after typing Ctrl-C the first time.)
接下来,要以每秒0.1米(每秒约4英寸或每英尺3秒)的速度向前移动机器人,请确保在机器人前方有足够的空间,然后运行以下命令:
Next, to move the robot forward at a speed of 0.1 meters per second (about 4 inches per second or 3 seconds per foot), make sure you have lots of space in front of the robot, then run the command:
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0}}'
要停止移动,请键入Ctrl-C,并在必要时发布空的Twist消息:
To stop the movement, type Ctrl-C , and, if necessary, publish the empty Twist message:
rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'
如果您对结果感到满意,请尝试线性x和角度z值的其他组合。 例如,以下命令应使机器人沿顺时针方向旋转:
If you feel satisfied with the result, try other combinations of linear x and angular z values. For example, the following command should send the robot turning in a clockwise circle:
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.15, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.4}}'
要停止移动,请键入Ctrl-C,并在必要时发布空的Twist消息:
To stop the movement, type Ctrl-C , and, if necessary, publish the empty Twist message:
rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'
如前所述,尽管使用命令行发送Twist消息用于调试和测试非常有用,但我们通常不会直接从命令行将Twist消息发布到机器人。 通常,我们会从ROS节点以编程方式发送此类消息,该节点以某些有趣的方式控制机器人的行为。 接下来让我们看看。
As we mentioned earlier, we don’t often publish Twist messages to the robot directly from the command line although it can be useful for debugging and testing purposes. More often, we will send such messages programmatically from a ROS node that controls the robot’s behavior in some interesting way. Let’s look at that next.