sampling_planning/problem.rs
1//! Planning problems and their solutions.
2
3use alloc::vec::Vec;
4
5use crate::{GoalRegion, StateSpace};
6
7/// Everything a planner needs to know about the world.
8///
9/// `Sa` is a [`Sampler`](crate::Sampler), `C` a [`ValidityChecker`](crate::ValidityChecker) and
10/// `St` a [`Steering`](crate::Steering) function, all over the space `Sp`. Planners take the
11/// problem by value and check the start state when they are created.
12#[derive(Debug, Clone)]
13pub struct Problem<Sp: StateSpace, Sa, C, St> {
14 /// The configuration space.
15 pub space: Sp,
16 /// Draws the states the planner grows toward.
17 pub sampler: Sa,
18 /// Decides which states and motions are allowed.
19 pub checker: C,
20 /// Extends nodes toward samples.
21 pub steering: St,
22 /// The initial state. Must be [`Validity::Valid`](crate::Validity::Valid).
23 pub start: Sp::State,
24 /// Where the path has to end.
25 pub goal: GoalRegion<Sp::State>,
26}
27
28/// A solution path.
29#[derive(Debug, Clone, PartialEq)]
30pub struct Path<S> {
31 /// The states from the start to a state in the goal region. Never empty.
32 pub states: Vec<S>,
33 /// The path length under [`StateSpace::distance`].
34 pub cost: f64,
35}