sampling-planning: motion planning for Rust
Sampling-based motion planners for continuous configuration spaces: RRT, RRT*, RRT#, RRT-Connect, PRM, PRM*, SPARS, SPARS2, FMT*, BFMT*, BIT*, AIT*, SST, SST* and KPIECE, together with the state spaces, samplers, nearest-neighbor structures and path shortcutting they build on.
This is a motion planning crate. It is named sampling-planning because the crate name motion-planning was already taken on crates.io.
The planners share one small set of traits (a state space, a sampler and a validity checker, plus a
steering function for the tree planners and a Propagator for the kinodynamic ones), so the
collision checker and the space are written once and work with every planner. The crate is #![no_std] with alloc, forbids unsafe, takes its
randomness from a caller-provided rand_core RNG and does its float math through libm: a seeded
run gives the same path on every platform.
Part of the planning and search crates; see also this crate's overview page.
Who this is for
- Robotics engineers who need a path for an arm, a mobile base or a car-like vehicle through a continuous space with obstacles, and who bring their own collision checker.
- Vehicles with a turning radius: the Dubins and Reeds-Shepp spaces plan along the actual shortest car paths, not along straight lines that are fixed up afterwards.
- Systems that can only be forward-simulated (no steering function, just "apply this control for
that long"): SST, SST* and KPIECE work over a
Propagatorinstead. - Anyone comparing planners on the same problem; the bundled example runs eleven of them on one world and draws the results.
- Embedded and other
no_stdtargets with an allocator, and test setups that need reproducible runs. - For discrete graphs and grids, heuristic-search is the better fit; for many robots sharing one map, mapf-search; for dynamics with bounded disturbances where the plan has to hold for every reachable state, robust-planning.
Installation
[]
= "0.1"
Features
- Tree planners: RRT, RRT* (radius or k-nearest) with optional informed sampling (Informed RRT*, with direct prolate-hyperspheroid sampling in Euclidean spaces), RRT-Connect (bidirectional), RRT# (RRG with LPA*-style replanning).
- Roadmaps: PRM (fixed radius or fixed k), PRM* (shrinking radius or
k ln nnearest), lazy PRM, SPARS (sparse roadmap spanner over a dense PRM* graph), SPARS2 (without one); multi-query, with Dijkstra queries on a reusable roadmap. - Batch-informed planners: BIT* (radius or k-nearest, informed batches, pruning) and AIT* (BIT*-style forward search guided by a lazy LPA* reverse search that is repaired on every invalid edge).
- Batch planners: FMT* (fast marching tree) and BFMT* (bidirectional, optimal or first-meeting termination).
- Kinodynamic planners: SST and SST* over a
Propagator(forward simulation) trait, with inactive leaves freed; single-level KPIECE over a user projection. - Path post-processing: greedy and randomized shortcutting (
shortcut,shortcut_random). - Nearest neighbors:
LinearScan(any metric),KdTree(Euclidean spaces, with removal and balanced rebuilds); nearest, radius and k-nearest queries. - State spaces:
Euclidean<N>, SO(2) (So2), SE(2) (Se2), Dubins and Reeds-Shepp cars (Dubins,ReedsShepp, with their shortest paths exposed), with samplersUniformBox,UniformAngleandUniformSe2. - Building blocks: straight-line steering (along the curve in the car spaces), ball-shaped goal regions.
Validity checks are three-valued (valid, invalid, unknown); planners treat unknown as invalid.
Not yet implemented: the batch-informed ABIT* and EIT*, multi-level KPIECE, and the SE(3) and compound state spaces.
Usage
See the crate documentation for a complete RRT* example and docs/design.md for the design. The example compares RRT, RRT-Connect, RRT*, Informed RRT*, RRT#, PRM*, SPARS, SPARS2, FMT*, BFMT* and BIT* on one world and draws their paths:
Minimum supported Rust version
Rust 1.85 (edition 2024). The MSRV applies to the library; tests and benchmarks may need a newer toolchain. It may be raised in a minor release when a dependency or a language feature calls for it.
Contributing
See CONTRIBUTING.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
The example in examples/ is public domain
(CC0-1.0), so you can copy it into anything.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.