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>
impl<Sp, Sa, C> FmtStar<Sp, Sa, C>
Sourcepub fn new(
space: Sp,
sampler: Sa,
checker: C,
config: FmtStarConfig,
) -> Result<Self, Error>
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,
impl<Sp, Sa, C, N> FmtStar<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,
config: FmtStarConfig,
nn: N,
) -> Result<Self, Error>
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.
Sourcepub 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>
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.