Motion Planning, step 4
Shorter, smoother paths
RRT paths wander. Cut out the detours with random shortcuts, then drive the result.
RRT paths wander
Every RRT edge points at a random sample, and the search stops at the first path it finds. So the path zig-zags: the arm swings back and forth on its way, and the motion takes far longer than it needs to. Run the starter and watch the purple route.
Measure a path by its length in joint space, summed over its segments:
Random shortcutting
The cheapest fix is also the most common. MoveIt runs a version of it on almost every plan:
- Pick two different segments of the path, and a random point on each: and , with uniform in .
- If the straight edge is free, splice it in: keep the path up to , then , , and the rest from .
- Repeat, say, 200 times.
A straight line is the shortest way between two points, so every accepted shortcut makes the path shorter. Picking points part-way along segments matters: it lets the path cut corners, not just skip whole waypoints.
| Waypoints | Joint-space length | |
|---|---|---|
| RRT path | ~25 | ~7.5 rad |
| after shortcutting | ~12 | ~2 rad |
Your task
The starter comes with a working rrt. Implement shortcut(path, iters=200), then set path = shortcut(rrt(START, GOAL)) and drive it inside phase("execute").
The arm's actual motion must be at most 3.0 rad long in joint space. A good shortcut lands near 2 rad, so that leaves room for an unlucky run.