Repository navigation
Rename RTB plot style arguments to <thing>_style in figure scripts #55
Description
RTB is moving to one naming convention for the dict-valued Matplotlib style arguments of its mobile-robot plotting methods: <thing>_style, where the thing is what is drawn. The old names will keep working with a DeprecationWarning, so nothing breaks, but the book's figure scripts should move to the new names. This Issue lists what has to change here.
RTB side: not merged yet. RTB PR petercorke/robotics-toolbox-python#772 does this for the drivers (goal_style, path_style); the same change for the planners, PRM and EKF follows as a separate RTB PR. Update the scripts below once that has been released.
Published code (notebooks): no change needed
notebooks/chap4.ipynb, chap5.ipynb and chap6.ipynb use none of the renamed arguments. They call bug.plot(), dx.plot(path), dx.plot(labelvalues=True), robot.plot_xy(color=...), ekf.plot_xy(color=...) and ekf.plot_ellipse(...), which are unaffected. Chapters 4-6 only were searched; this needs a quick check of any other chapter that plots a planner, EKF or vehicle.
So no errata is needed on the code. Still to check, since the book source is not in this repo: whether any prose, caption or margin box names path_marker, goal_marker, edge or vertex.
Correction: path_marker= has no effect, and the book shows the default look
PlannerBase.plot accepts path_marker and path_marker_reverse but never reads them. The path is drawn from line and line_r (each a tuple of dicts, one per layer), whose defaults are black with dashed yellow for forward motion and black with dashed red for reverse. So in fig5_16.py and fig5_20.py the path_marker= argument was always silently ignored.
The published book shows the default yellow/black (and red/black) look, which is what those two scripts have always produced. Figures 5.21 and 5.22 pass no style at all and rely on the same defaults plus direction=; they are unaffected.
RTB is making path_marker and path_marker_reverse deprecated aliases of path_style and path_reverse_style that now take effect (petercorke/robotics-toolbox-python#778). That would change figures 5.16 and 5.20 away from the published look when regenerated, so the argument should be deleted from both scripts, not renamed:
fig5_16.pyline 17:dx.plot(p, inflated=True, path_marker=pmarker)becomesdx.plot(p, inflated=True), and the unusedpmarker = dict(...)goes.fig5_20.pyline 30: droppath_marker=striped_line, and the unusedstriped_line = (...)goes.
Figure scripts (unpublished): rename arguments
| Script | Current | New |
|---|---|---|
figures/code/chapter5/fig5_12.py (lines 25, 42) |
goal_marker=, colorbar=dict(...) |
goal_style=, colorbar_style= |
figures/code/chapter5/fig5_16.py (line 17) |
path_marker= (ignored today) |
delete the argument |
figures/code/chapter5/fig5_19.py (lines 16, 26) |
edge=, vertex= |
edge_style=, vertex_style= |
figures/code/chapter5/fig5_20.py (line 30) |
edge=, vertex=, path_marker= (ignored today) |
edge_style=, vertex_style=; delete path_marker= |
figures/code/chapter6/fig6_11.py (line 29) |
ellipse=dict(...) in ekf.plot_map |
ellipse_style= |
figures/code/chapter6/fig6_13.py (line 99) |
ellipse=dict(...) in ekf.plot_map |
ellipse_style= |
figures/code/chapter4/fig4_26.py has local variables called start_marker and goal_marker passed to plt.plot; these are not RTB arguments and need no change.
Checklist
- RTB release containing the new argument names
- Update the six figure scripts above
- Re-run them and check the figures are unchanged (5.16 and 5.20 only after deleting
path_marker=) - Search the book source for the old argument names
- Check the other chapters for planner, EKF and vehicle plotting calls
Also: fig5_5.py passes label='path' to Bug2.run
Bug2.run used to swallow unknown keyword arguments, so label='path' was ignored and the legend entry for the robot's path read "robot path". RTB PR petercorke/robotics-toolbox-python#780 makes label a real argument (default "robot path"), so regenerating Fig 5.5 gives the legend text "path". Remove label='path' from the call if the published legend text should be kept.
Erratum: the Bug2 path length in Fig 5.5 is 1306, not 1307
RTB PR petercorke/robotics-toolbox-python#780 (open, not yet merged) corrects the tolerance of the m-line crossing test in Bug2 from half a cell to sqrt(2)/2 of a cell. A line at 45 degrees to the grid passes between two diagonal neighbours at that distance from each, so with the old tolerance the robot could step over it and was then reported as "trapped" (that case does not occur in the book).
The only book case whose result changes is the house floorplan, bedroom to kitchen (Fig 5.5, bug.run(places.br3, places.kitchen)): the robot is now recognised as back on the m-line one step earlier at one place, so the path has 1306 points rather than 1307. The first 867 points are identical, and the rest is the old path with one point removed. The kitchen to bedroom path (3985) and map1 (334) are unchanged. In RTB the change is documented as versionchanged:: 1.4.5, the version of the release that is planned.
Erratum: the PRM roadmap edge counts in chapter 5 are twice the number of connections
PRMPlanner added every roadmap connection from both of its ends, and pgraph's UGraph counts what it is given, so the roadmap summary printed UGraph: 50 vertices, 222 edges, 12 components and UGraph: 300 vertices, 10,000 edges, 13 components. These are twice the number of connections. RTB PR petercorke/robotics-toolbox-python#781 adds each connection once, giving:
| points | printed before | printed now |
|---|---|---|
| 50 | 222 edges |
111 edges |
| 300 | 10,000 edges |
5,000 edges |
The number of components (12 and 13), the vertices, and the paths found (br3 to kitchen, br2 to kitchen) are unchanged. The roadmap figures (Figs 5.19, 5.20) look as they did in the book: older pgraph overlaid the parallel edges, newer pgraph draws them as arcs, and with each connection added once the roadmap is straight lines again. No change is needed to the scripts. Errata to be added for the two printed counts.
Activity