Skip to main content

AitStar

Struct AitStar 

Source
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| Batch

This 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) and c_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 from x to 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 whose h_con must not be recomputed are the reverse roots, so this checks “x ∉ X_goal”, as OMPL’s updateReverseSearchVertex does.
  • 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 because g_hat is 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 uses c_hat + h_con(x) as the second key. Keys follow h_con as 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, not h_con, which is not admissible beyond the current graph), samples through Sampler::sample_informed with a rejection fallback, and restarts the reverse search from the goals, as OMPL does. Batches can come out smaller than batch_size when INFORMED_ATTEMPTS draws per sample do not find a useful one.
  • An invalid edge triggers the paper’s LPA* repair (update_state of 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>
where Sp: StateSpace, Sa: Sampler<Sp::State>, C: ValidityChecker<Sp>,

Source

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,

Source

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
Source

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.

Source

pub fn run<R: Rng + ?Sized>(&mut self, iterations: usize, rng: &mut R)

Runs iterations iterations.

Source

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.

Source

pub fn vertex_count(&self) -> usize

The number of forward-tree vertices, including the start.

Source

pub fn sample_count(&self) -> usize

The number of samples not connected to the forward tree.

Source

pub const fn batch_count(&self) -> usize

The number of batches started so far.

Trait Implementations§

Source§

impl<Sp: Clone + StateSpace, Sa: Clone, C: Clone, N: Clone> Clone for AitStar<Sp, Sa, C, N>
where Sp::State: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Sp: Debug + StateSpace, Sa: Debug, C: Debug, N: Debug> Debug for AitStar<Sp, Sa, C, N>
where Sp::State: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Sp, Sa, C, N> Forget for AitStar<Sp, Sa, C, N>

§

impl<Sp, Sa, C, N> Freeze for AitStar<Sp, Sa, C, N>
where Sp: Freeze, Sa: Freeze, C: Freeze, <Sp as StateSpace>::State: Freeze, GoalRegion<<Sp as StateSpace>::State>: Freeze, Vec<Node<<Sp as StateSpace>::State>>: Freeze, N: Freeze,

§

impl<Sp, Sa, C, N> Move for AitStar<Sp, Sa, C, N>

§

impl<Sp, Sa, C, N> RefUnwindSafe for AitStar<Sp, Sa, C, N>

§

impl<Sp, Sa, C, N> Send for AitStar<Sp, Sa, C, N>
where Sp: Send, N: Send, C: Send, Sa: Send, <Sp as StateSpace>::State: Send, GoalRegion<<Sp as StateSpace>::State>: Send, Vec<Node<<Sp as StateSpace>::State>>: Send,

§

impl<Sp, Sa, C, N> Sync for AitStar<Sp, Sa, C, N>
where Sp: Sync, N: Sync, C: Sync, Sa: Sync, <Sp as StateSpace>::State: Sync, GoalRegion<<Sp as StateSpace>::State>: Sync, Vec<Node<<Sp as StateSpace>::State>>: Sync,

§

impl<Sp, Sa, C, N> Unpin for AitStar<Sp, Sa, C, N>
where Sp: Unpin, N: Unpin, C: Unpin, Sa: Unpin, <Sp as StateSpace>::State: Unpin, GoalRegion<<Sp as StateSpace>::State>: Unpin, Vec<Node<<Sp as StateSpace>::State>>: Unpin,

§

impl<Sp, Sa, C, N> UnsafeUnpin for AitStar<Sp, Sa, C, N>

§

impl<Sp, Sa, C, N> UnwindSafe for AitStar<Sp, Sa, C, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.