pub struct AitStar<Sp: StateSpace, Sa, C, N = LinearScan<<Sp as StateSpace>::State>> { /* private fields */ }Expand description
AIT*: adaptively informed trees (Strub and Gammell 2020).
AIT* is BIT* with a problem-specific heuristic. Each batch of samples is
an implicit random geometric graph (RGG). An asymmetric bidirectional search runs on it: a
lazy reverse search from the goal states, Lifelong Planning A* (LPA*) without collision
checks, computes the cost-to-go h_con of every state over the RGG; the forward search
grows a tree from the start like BIT*, ordered by g_F(v) + c_hat(v, x) + h_con(x), and
checks the edges that come out on top. Every edge it finds invalid is removed from the
reverse search’s graph, and LPA* repairs the heuristic incrementally, so that the forward
search stops being drawn into obstacles.
graph LR
Batch["new batch: prune, sample, restart reverse search"] --> Reverse
Reverse["reverse search (LPA*) until the best edge is settled"] --> Edge["pop best edge"]
Edge -->|invalid| Repair["remove edge, update_state of its source"]
Repair --> Reverse
Edge -->|improves| Connect["add or rewire, expand"]
Connect --> Reverse
Edge -->|cannot improve| BatchThis follows Algorithms 2 to 6 of the ICRA 2020 paper (arXiv 2002.06599), with these choices:
- The heuristics are
g_hat(x) = d(start, x)andc_hat = d. The goal center is the first sample when it is valid; every state in the goal region is a goal of the reverse search, and any forward-tree vertex in it is a solution. - The reverse search runs on a fixed graph per batch: the RGG neighbors of every state
(radius, or k-nearest made symmetric) plus the forward-tree edges kept from earlier
batches, minus the invalid edges.
h_con[x]uses the motion fromxto its neighbor (travel direction), and invalid edges are stored directed, so directional checkers stay sound; the paper and OMPL blacklist both directions. - Algorithm 6, line 1 reads “
x ≠ x_init” in the paper; the states whoseh_conmust not be recomputed are the reverse roots, so this checks “x ∉ X_goal”, as OMPL’supdateReverseSearchVertexdoes. - Algorithm 5’s stopping rule (lines 10 to 12, including the printed “<” on line 11) is
replaced by OMPL’s edge-based rule: the reverse search pauses when the child of the best
forward edge is consistent (
h_con == h_exp) and that edge’s first key is below the reverse queue’s first key. This is sound becauseg_hatis consistent: by the triangle inequality an edge’s first key is at least its child’s first LPA* key, so the child is settled and every edge with an unsettled child has a larger true key. - The forward queue keys are
(g_F(v) + c_hat + h_con(x), g_F(v) + c_hat, g_F(v))as in the paper; OMPL usesc_hat + h_con(x)as the second key. Keys followh_conas the reverse search changes it, and are re-sorted after a rewiring lowered tree costs. - A new batch prunes like BIT* (with the geometric
h_hat, noth_con, which is not admissible beyond the current graph), samples throughSampler::sample_informedwith a rejection fallback, and restarts the reverse search from the goals, as OMPL does. Batches can come out smaller thanbatch_sizewhenINFORMED_ATTEMPTSdraws per sample do not find a useful one. - An invalid edge triggers the paper’s LPA* repair (
update_stateof its source); OMPL instead resets the whole reverse branch below it. - Edges are checked in travel direction, from tree parent to child.
The cost of AitStar::best_path never increases. Pruned states stay in memory until the
planner is dropped.
§Examples
use rand_core::SeedableRng;
use sampling_planning::{
Euclidean, GoalRegion, UniformBox, Validity, ValidityChecker,
informed::{AitStar, AitStarConfig},
};
/// Free space everywhere.
struct Free;
impl ValidityChecker<Euclidean<2>> for Free {
fn check_state(&self, _: &[f64; 2]) -> Validity {
Validity::Valid
}
fn check_motion(&self, _: &Euclidean<2>, _: &[f64; 2], _: &[f64; 2]) -> Validity {
Validity::Valid
}
}
let sampler = UniformBox::new([0.0, 0.0], [10.0, 10.0]);
let config = AitStarConfig::new(1.5 * AitStarConfig::gamma_lower_bound(2, 100.0));
let goal = GoalRegion::new([9.0, 9.0], 0.5);
let mut ait = AitStar::new(Euclidean::<2>, sampler, Free, [1.0, 1.0], goal, config)
.expect("valid");
ait.run(50, &mut rand_pcg::Pcg64Mcg::seed_from_u64(1));
assert!(ait.best_path().expect("free space").cost < 11.0);Implementations§
Source§impl<Sp, Sa, C> AitStar<Sp, Sa, C>
impl<Sp, Sa, C> AitStar<Sp, Sa, C>
Sourcepub fn new(
space: Sp,
sampler: Sa,
checker: C,
start: Sp::State,
goal: GoalRegion<Sp::State>,
config: AitStarConfig,
) -> Result<Self, Error>
pub fn new( space: Sp, sampler: Sa, checker: C, start: Sp::State, goal: GoalRegion<Sp::State>, config: AitStarConfig, ) -> Result<Self, Error>
Creates a planner with a LinearScan nearest-neighbor index.
§Errors
The same as AitStar::with_nearest_neighbors.
Source§impl<Sp, Sa, C, N> AitStar<Sp, Sa, C, N>where
Sp: StateSpace,
Sa: Sampler<Sp::State>,
C: ValidityChecker<Sp>,
N: NearestNeighbors<Sp> + Clone,
impl<Sp, Sa, C, N> AitStar<Sp, Sa, C, N>where
Sp: StateSpace,
Sa: Sampler<Sp::State>,
C: ValidityChecker<Sp>,
N: NearestNeighbors<Sp> + Clone,
Sourcepub fn with_nearest_neighbors(
space: Sp,
sampler: Sa,
checker: C,
start: Sp::State,
goal: GoalRegion<Sp::State>,
config: AitStarConfig,
nn: N,
) -> Result<Self, Error>
pub fn with_nearest_neighbors( space: Sp, sampler: Sa, checker: C, start: Sp::State, goal: GoalRegion<Sp::State>, config: AitStarConfig, nn: N, ) -> Result<Self, Error>
Creates a planner; every batch indexes its states in a clone of the given empty index.
§Errors
Error::InvalidStartifstartis not valid.Error::EmptyBatchif the batch size is zero.Error::InvalidRadiusifgamma, the k-nearest constant ormax_radiusis out of range.
Sourcepub fn step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> bool
pub fn step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> bool
Runs one iteration of Algorithm 2: starts a new batch if the forward queue is empty, advances the reverse search as far as the best edge needs, then processes that edge. Returns whether the forward tree changed.
A batch ends at the first popped edge whose estimate cannot beat the current solution.
When the batch’s graph holds no better path than the incumbent (or none at all), that
is the first edge, so every step starts a new batch: it adds up to batch_size states
and runs one neighbor query per stored state, which is quadratic with the
LinearScan default of AitStar::new. Use a KdTree and budget
by AitStar::batch_count as well. In free space a near-optimal run can reach 100
batches in a few hundred steps.
Sourcepub fn run<R: Rng + ?Sized>(&mut self, iterations: usize, rng: &mut R)
pub fn run<R: Rng + ?Sized>(&mut self, iterations: usize, rng: &mut R)
Runs iterations iterations.
Sourcepub fn best_path(&self) -> Option<Path<Sp::State>>
pub fn best_path(&self) -> Option<Path<Sp::State>>
The cheapest path found so far, or None if no vertex reached the goal yet. Its cost
never increases as iterations run.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
The number of forward-tree vertices, including the start.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
The number of samples not connected to the forward tree.
Sourcepub const fn batch_count(&self) -> usize
pub const fn batch_count(&self) -> usize
The number of batches started so far.