Skip to main content

FmtStar

Struct FmtStar 

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

FMT*: draws a batch of samples, then marches a tree outward from the start in order of cost-to-come, connecting each unvisited neighbor of the cheapest open node to its locally cheapest open neighbor.

Single-query and asymptotically optimal, like RrtStar, but it checks each motion at most once and only for the locally best parent, so it typically needs far fewer collision checks. Each FmtStar::plan call draws a fresh batch.

Edges are direct motions checked in travel direction, parent to child. The goal center is added as a sample when it is valid.

§Examples

use rand_core::SeedableRng;
use sampling_planning::{
    Euclidean, GoalRegion, UniformBox, Validity, ValidityChecker,
    roadmaps::{FmtStar, FmtStarConfig},
};

/// 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 = FmtStarConfig { gamma: 1.5 * FmtStarConfig::gamma_lower_bound(2, 100.0) };
let mut fmt = FmtStar::new(Euclidean::<2>, sampler, Free, config).expect("valid");

let goal = GoalRegion::new([9.0, 9.0], 0.5);
let mut rng = rand_pcg::Pcg64Mcg::seed_from_u64(1);
let path = fmt.plan(&[1.0, 1.0], &goal, 1000, &mut rng).expect("valid start");

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

Implementations§

Source§

impl<Sp, Sa, C> FmtStar<Sp, Sa, C>
where Sp: StateSpace, Sa: Sampler<Sp::State>, C: ValidityChecker<Sp>,

Source

pub fn new( space: Sp, sampler: Sa, checker: C, config: FmtStarConfig, ) -> Result<Self, Error>

Creates a planner with a LinearScan nearest-neighbor index.

§Errors

Error::InvalidRadius if gamma is not positive and finite.

Source§

impl<Sp, Sa, C, N> FmtStar<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, config: FmtStarConfig, nn: N, ) -> Result<Self, Error>

Creates a planner; every batch gets a clone of the given empty nearest-neighbor index.

§Errors

Error::InvalidRadius if gamma is not positive and finite.

Source

pub fn plan<R: Rng + ?Sized>( &mut self, start: &Sp::State, goal: &GoalRegion<Sp::State>, samples: usize, rng: &mut R, ) -> Result<Option<Path<Sp::State>>, Error>

Draws samples states, keeps the valid ones, and marches from start until a node in goal is the cheapest open node.

Returns None if the wavefront dies out first: the batch does not connect start and goal under the current radius.

§Errors

Error::InvalidStart if start does not check as valid.

Trait Implementations§

Source§

impl<Sp: Clone + StateSpace, Sa: Clone, C: Clone, N: Clone> Clone for FmtStar<Sp, Sa, C, N>

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 FmtStar<Sp, Sa, C, N>

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 FmtStar<Sp, Sa, C, N>

§

impl<Sp, Sa, C, N> Freeze for FmtStar<Sp, Sa, C, N>
where Sp: Freeze, Sa: Freeze, C: Freeze, N: Freeze,

§

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

§

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

§

impl<Sp, Sa, C, N> Send for FmtStar<Sp, Sa, C, N>
where Sp: Send, N: Send, C: Send, Sa: Send,

§

impl<Sp, Sa, C, N> Sync for FmtStar<Sp, Sa, C, N>
where Sp: Sync, N: Sync, C: Sync, Sa: Sync,

§

impl<Sp, Sa, C, N> Unpin for FmtStar<Sp, Sa, C, N>
where Sp: Unpin, N: Unpin, C: Unpin, Sa: Unpin,

§

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

§

impl<Sp, Sa, C, N> UnwindSafe for FmtStar<Sp, Sa, C, N>
where Sp: UnwindSafe, Sa: UnwindSafe, C: 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.