pub struct PRM<S: State, SP: StateSpace<StateType = S>, G: Goal<S>> {
pub timeout: f64,
pub connection_radius: f64,
/* private fields */
}Expand description
An implementation of the Probabilistic Roadmap (PRM) algorithm.
PRM is a multi-query, sampling-based algorithm that is particularly effective in static environments. It works by first constructing a “roadmap” graph of valid states and then querying this graph to find paths.
§Algorithm Overview
- Construction Phase: a. Sample a number of states randomly from the state space. b. For each valid sample, find all nearby nodes already in the roadmap. c. If a valid, collision-free motion exists between the new sample and a neighbor, add an edge connecting them in the roadmap.
- Query Phase: a. Connect the start and goal states to the roadmap. b. Use a graph search algorithm (in this case, Breadth-First Search) to find a path on the roadmap from the start to the goal.
Fields§
§timeout: f64The time allocated for roadmap construction, in seconds.
connection_radius: f64The radius within which to search for neighbors to connect to a new sample.
Implementations§
Source§impl<S, SP, G> PRM<S, SP, G>
impl<S, SP, G> PRM<S, SP, G>
Sourcepub fn new(timeout: f64, connection_radius: f64, config: &PlannerConfig) -> Self
pub fn new(timeout: f64, connection_radius: f64, config: &PlannerConfig) -> Self
Creates a new PRM planner with the specified parameters.
§Parameters
timeout- The time in seconds to spend building the roadmap.connection_radius- The radius for connecting new nodes to the roadmap.config- The planner configuration, for planner-specific parameters.
Sourcepub fn get_roadmap(&self) -> Vec<Node<S>>
pub fn get_roadmap(&self) -> Vec<Node<S>>
Get private variable roadmap as a clone.
TODO: Determine if this needs to be obtainable.
Sourcepub fn set_problem_definition(&mut self, pd: Arc<ProblemDefinition<S, SP, G>>)
pub fn set_problem_definition(&mut self, pd: Arc<ProblemDefinition<S, SP, G>>)
Update ProblemDefinition. This is so that you can use an already sampled roadmap but just change the start and goal states.
Sourcepub fn construct_roadmap(&mut self) -> Result<(), PlanningError>
pub fn construct_roadmap(&mut self) -> Result<(), PlanningError>
Constructs the probabilistic roadmap.
This method populates the roadmap by sampling states and connecting them until the specified timeout is reached.