【 rbx1翻译 第七章、控制移动基座】第九节、使用里程计走正方形

7.9 Navigating a Square using Odometry (使用里程计走正方形)

就像我们使用基于里程表的往返脚本一样,我们将使用 /odom和 /base_link(或 /base_footprint)坐标系之间的tf转换来监视机器人的位置和方向。 但是,这次我们将尝试通过设置四个路径点(每个角点一个)来将机器人移动到一个正方形。 在运行结束时,我们可以看到机器人与起始位置和方向的接近程度。 让我们从模拟开始,然后在真实的机器人上进行尝试。
As we did with the odometry-based out-and-back script, we will monitor the position and orientation of the robot using the tf transform between the /odom and /base_link (or /base_footprint ) frames. However, this time we will attempt to move the robot in a square by setting four waypoints, one at each corner. At the end of the run, we can see how close the robot gets back to the starting location and orientation. Let’s start with a simulation and then try it on a real robot.

7.9.1 Navigating a Square in the ArbotiX Simulator (在ArbotiX Simulator中走正方形)

如果您已经运行了模拟的TurtleBot或Pi机器人,请先使用Ctrl-C结束模拟,以便我们从头开始测量里程。 然后再次启动模拟的机器人,运行RViz,然后运行nav_square.py脚本,如下所示:
If you already have a simulated TurtleBot or Pi Robot running, first Ctrl-C out of the simulation so we can start the odometry readings from scratch. Then bring up the simulated robot again, run RViz , then run the nav_square.py script as follows:

roslaunch rbx1_bringup fake_turtlebot.launch
rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz
rosrun rbx1_nav nav_square.py

一个经典的结果如下所示:
A typical result is shown below:
【 rbx1翻译 第七章、控制移动基座】第九节、使用里程计走正方形_第1张图片
和以前一样,里程计箭头说明了机器人沿其路线的各个点的前进方向。 如您所见,正方形并非与网格线完全对齐,但这还不错。
As before, the odometry arrows illustrate the heading of the robot at various points along its route. As you can see, the square is not perfectly aligned with the grid lines, but it’s not bad.

7.9.2 Navigating a Square using a Real Robot (使用Real Robot走正方形)

如果您有机器人,请立即尝试使用nav_square脚本,以了解其在现实世界中的里程表中表现如何。 首先终止所有正在运行的模拟机器人,然后启动您的机器人的启动文件。 对于TurtleBot,您可以运行:
If you have a robot, try out the nav_square script now to see how well it does with real-world odometry. First terminate any running simulated robots, then launch the startup file(s) for your robot. For a TurtleBot you would run:

roslaunch rbx1_bringup turtlebot_minimal_create.launch

(或者,如果您已经创建了一个启动文件来存储校准参数,则可以使用自己的启动文件。)
(Or use your own launch file if you have created one to store your calibration parameters.)

确保您的机器人有足够的工作空间-至少在机器人前方1.5米处且两侧至少有1米距离。
Make sure your robot has plenty of room to work in—at least 1.5 meters ahead of it and on either side.

如果您使用的是TurtleBot,我们还需要运行odom_ekf.py脚本,以便能够在RViz中查看TurtleBot的组合里程计坐标系。 如果您不使用TurtleBot,则可以跳过此步骤。 启动文件应在TurtleBot的笔记本电脑上运行:
If you are using a TurtleBot, we also need to run the odom_ekf.py script to be able to see the TurtleBot’s combined odometry frame in RViz . You can skip this if you are not using a TurtleBot. The launch file should be run on the TurtleBot’s laptop:

roslaunch rbx1_bringup odom_ekf.launch

如果RViz仍在您的工作站上运行,请关闭它,并使用ekf配置文件将其恢复。 或者,只需取消选中Odometry显示并选中Odometry EKF显示。
If RViz is still running on your workstation, shut it down and bring it back up with the ekf configuration file. Alternatively, simply un-check the Odometry display and check the Odometry EKF display.

rosrun rviz rviz -d `rospack find rbx1_nav`/nav_ekf.rviz

最后,再次运行nav_square.py脚本:
Finally, run the nav_square.py script again:

rosrun rbx1_nav nav_square.py

下图显示了在地毯上使用我自己的TurtleBot时的结果:
The following image shows the results when using my own TurtleBot on a low-ply carpet:
【 rbx1翻译 第七章、控制移动基座】第九节、使用里程计走正方形_第2张图片
如您所见,结果还不错。 在现实世界中,机器人最终离开了起点11厘米,并且偏离了原始方向约15度。 但是,当然,如果我们第二次运行脚本而没有重新定位机器人,则整个轨迹过程中起始方向错误将一直抛出。
As you can see, the result is not too bad. In the real world, the robot ended up 11 cm away from the starting point and about 15 degrees off the original orientation. But of course, if we were to run the script a second time without repositioning the robot, the error in the starting orientation would throw off the entire trajectory.

7.9.3 The nav_square.py Script (nav_square.py脚本)

nav_square.py脚本与我们刚刚看过的基于里程表的往返脚本几乎相同,因此我们将不在此处显示。 唯一的区别是,我们现在将机器人的运动分为4次,每次都走1米长的路程并旋转90度,来代替原来的分为两次,每次1米长的路径旋转180度。 您可以在下面的链接中查看代码,也可以在rbx1_nav / nodes目录中查看自己的副本。
The nav_square.py script is nearly identical to the odometry-based out-and-back script that we just looked at so we won’t display it here. The only difference is that we now send the robot along four 1 meter legs using 90 degree rotations instead of two 1 meter legs using 180 rotations. You can look at the code at the link below or by viewing your own copy in the rbx1_nav/nodes directory.

源链接:nav_square.py
Link to source: nav_square.py

7.9.4 The Trouble with Dead Reckoning (路径推算的麻烦)

仅依靠内部运动数据而不参考外部地标导航路线的过程称为路径推算。 任何在任何时间段内完全依赖路径推算的机器人最终都将完全迷失。 问题的根源在于,里程表中即使很小的误差也会随着时间而累积。 想象一下,例如,在机器人直线移动3米之前,即使他的估计值仅仅只有1度的误差。 在运行结束时,机器人的位置将累积超过5厘米的误差。 由于机器人不知道它与预期的目标相距5厘米,因此下一次运动的计算在开始之前就会被减去此数量。
The processing of navigating a course while relying only on internal motion data and without reference to external landmarks is referred to as dead reckoning. Any robot that relies entirely on dead reckoning for any length of time will eventually become completely lost. The root of the problem is that even small errors in odometry accumulate over time. Imagine for example an error of even 1 degree in the robot’s estimated heading just before it moves straight for 3 meters. At the end of the run, the robot will be have accumulated an error of over 5 cm in its position. Since the robot does not know that it is 5 cm away from its intended destination, the calculation of the next movement will be off by this amount before it even gets started.

幸运的是,很早以前,机器人专家就开始尝试各种方法,将地标或其他外部参考合并到机器人导航中,我们将在SLAM一章中使用ROS进行相同的操作。
Fortunately, roboticists long ago started working on various ways to incorporate landmarks or other external references into robot navigation and we will do the same with ROS in the chapter on SLAM.

你可能感兴趣的:(ROS机器人学习,rbx1书籍)