sampling_planning/informed.rs
1//! Batch-informed planners: BIT* and AIT*.
2//!
3//! These planners process samples in batches and search the implicit random geometric graph
4//! over them in order of a heuristic estimate of the solution cost through each edge, like A*.
5//! After the first solution they only sample and keep states that can still improve it.
6//!
7//! [`BitStar`] orders its search by the geometric cost-to-go. [`AitStar`] computes the
8//! cost-to-go over the graph itself with a lazy reverse search (LPA*, no collision checks) and
9//! repairs it whenever the forward search finds an edge invalid; see its docs for the loop.
10//!
11//! ```mermaid
12//! graph LR
13//! Batch["new batch: prune, sample informed set"] --> Expand["expand vertices into edge queue"]
14//! Expand --> Edge["pop best edge"]
15//! Edge -->|can improve| Check["check motion, add or rewire"]
16//! Check --> Expand
17//! Edge -->|cannot improve| Batch
18//! ```
19
20mod ait_star;
21mod batch;
22mod bit_star;
23mod queues;
24
25use core::fmt;
26
27pub use ait_star::{AitStar, AitStarConfig};
28pub use bit_star::{BitStar, BitStarConfig};
29
30use crate::Validity;
31
32/// Why a batch-informed planner could not be created.
33#[derive(Debug, Clone, Copy, PartialEq, Eq)]
34pub enum Error {
35 /// The start state did not check as [`Validity::Valid`]; carries the actual result.
36 InvalidStart(Validity),
37 /// The radius constant, k-nearest constant or radius cap is not positive (the constants
38 /// must also be finite).
39 InvalidRadius,
40 /// The batch size is zero.
41 EmptyBatch,
42}
43
44impl fmt::Display for Error {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 match self {
47 Self::InvalidStart(validity) => write!(f, "start state is not valid ({validity:?})"),
48 Self::InvalidRadius => f.write_str("radius constants and the cap must be positive"),
49 Self::EmptyBatch => f.write_str("batch size must be at least one"),
50 }
51 }
52}
53
54impl core::error::Error for Error {}