Skip to main content

RrtSharp

Struct RrtSharp 

Source
pub struct RrtSharp<Sp: StateSpace, Sa, C, St, N = LinearScan<<Sp as StateSpace>::State>> { /* private fields */ }
Expand description

RRT#: grows a graph like RRG and keeps the cost-to-come of every promising vertex optimal on that graph by replanning after each extension (Arslan and Tsiotras 2013).

Each iteration extends the nearest vertex toward a goal-biased sample, like RrtStar, and links the new vertex both ways to its neighbors (the same radius or k-nearest rule, from RrtStarConfig). Instead of RRT*’s one-step rewiring, a replanning step then runs an LPA*-like relaxation: vertices whose lookahead cost lmc improved are processed cheapest key (lmc + h) first, until no queued vertex can beat the best goal vertex. Vertices that cannot (lmc + h >= c_best) stay unprocessed. Because the graph only grows and edge costs are fixed, costs only decrease and the underconsistent case of LPA* never occurs.

After every step the cost of RrtSharp::best_path is the shortest-path cost to the goal region on the current graph, so it never increases and improves faster per sample than RRT*.

Edges are motion-checked lazily, in travel direction, and at most once: only when they would lower a vertex’s lmc. This is sound for directional checkers and costs fewer checks than checking every graph edge eagerly. Informed sampling works as in RRT*.

The secondary key of the paper, min(g, lmc), is replaced by the vertex id as the tie break, which keeps runs deterministic.

§Examples

use rand_core::SeedableRng;
use sampling_planning::{
    Euclidean, GoalRegion, Problem, StraightLine, UniformBox, Validity, ValidityChecker,
    trees::{RrtSharp, RrtStarConfig},
};

/// 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 problem = Problem {
    space: Euclidean::<2>,
    sampler: UniformBox::new([0.0, 0.0], [10.0, 10.0]),
    checker: Free,
    steering: StraightLine::new(1.0),
    start: [1.0, 1.0],
    goal: GoalRegion::new([9.0, 9.0], 0.5),
};

let gamma = 1.5 * RrtStarConfig::gamma_lower_bound(2, 100.0);
let mut planner = RrtSharp::new(problem, RrtStarConfig::new(gamma, 1.0)).expect("valid");
planner.run(1000, &mut rand_pcg::Pcg64Mcg::seed_from_u64(1));

assert!(planner.best_path().expect("free space").cost < 11.5);

Implementations§

Source§

impl<Sp, Sa, C, St> RrtSharp<Sp, Sa, C, St>
where Sp: StateSpace, Sa: Sampler<Sp::State>, C: ValidityChecker<Sp>, St: Steering<Sp>,

Source

pub fn new( problem: Problem<Sp, Sa, C, St>, config: RrtStarConfig, ) -> Result<Self, Error>

Creates a planner with a LinearScan nearest-neighbor index.

§Errors

The same as RrtSharp::with_nearest_neighbors.

Source§

impl<Sp, Sa, C, St, N> RrtSharp<Sp, Sa, C, St, N>
where Sp: StateSpace, Sa: Sampler<Sp::State>, C: ValidityChecker<Sp>, St: Steering<Sp>, N: NearestNeighbors<Sp>,

Source

pub fn with_nearest_neighbors( problem: Problem<Sp, Sa, C, St>, config: RrtStarConfig, nn: N, ) -> Result<Self, Error>

Creates a planner with the given empty nearest-neighbor index.

§Errors
Source

pub fn step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> bool

Runs one iteration: extend, then replan. Returns whether a vertex was added.

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 to the goal region on the current graph, or None if the goal was not reached yet. Its cost never increases as iterations run.

Source

pub fn node_count(&self) -> usize

The number of graph vertices, including the start.

Trait Implementations§

Source§

impl<Sp: Clone + StateSpace, Sa: Clone, C: Clone, St: Clone, N: Clone> Clone for RrtSharp<Sp, Sa, C, St, 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

Auto Trait Implementations§

§

impl<Sp, Sa, C, St, N> Forget for RrtSharp<Sp, Sa, C, St, N>

§

impl<Sp, Sa, C, St, N> Freeze for RrtSharp<Sp, Sa, C, St, N>
where Problem<Sp, Sa, C, St>: Freeze, Vec<Vertex<<Sp as StateSpace>::State>>: Freeze, N: Freeze,

§

impl<Sp, Sa, C, St, N> Move for RrtSharp<Sp, Sa, C, St, N>

§

impl<Sp, Sa, C, St, N> RefUnwindSafe for RrtSharp<Sp, Sa, C, St, N>
where Problem<Sp, Sa, C, St>: RefUnwindSafe, Vec<Vertex<<Sp as StateSpace>::State>>: RefUnwindSafe, N: RefUnwindSafe,

§

impl<Sp, Sa, C, St, N> Send for RrtSharp<Sp, Sa, C, St, N>
where N: Send, Problem<Sp, Sa, C, St>: Send, Vec<Vertex<<Sp as StateSpace>::State>>: Send,

§

impl<Sp, Sa, C, St, N> Sync for RrtSharp<Sp, Sa, C, St, N>
where N: Sync, Problem<Sp, Sa, C, St>: Sync, Vec<Vertex<<Sp as StateSpace>::State>>: Sync,

§

impl<Sp, Sa, C, St, N> Unpin for RrtSharp<Sp, Sa, C, St, N>
where N: Unpin, Problem<Sp, Sa, C, St>: Unpin, Vec<Vertex<<Sp as StateSpace>::State>>: Unpin,

§

impl<Sp, Sa, C, St, N> UnsafeUnpin for RrtSharp<Sp, Sa, C, St, N>
where Problem<Sp, Sa, C, St>: UnsafeUnpin, Vec<Vertex<<Sp as StateSpace>::State>>: UnsafeUnpin, N: UnsafeUnpin,

§

impl<Sp, Sa, C, St, N> UnwindSafe for RrtSharp<Sp, Sa, C, St, N>
where Problem<Sp, Sa, C, St>: UnwindSafe, Vec<Vertex<<Sp as StateSpace>::State>>: UnwindSafe, N: UnwindSafe,

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.