Sample a state space for motion planning by using uniform distribution, and then use the sampled states to find an optimal path between two points in the input state space. Use an RRT path planner to compute an optimal path between the two points.
Create Uniform State Sampler
Load a probability occupancy grid into the MATLAB® workspace.
Create an occupancy map from the input occupancy grid.
Define the lower and upper limits of the state space variables x
, y
, and theta
from the occupancy map.
Create a state space SE(2) object using the specified state variables.
Create a uniform state sampler to uniformly sample the specified state space.
Configure RRT Path Planner
Check the validity of the states in the input state space by using a state validator.
Configure the RRT path planner. Use the uniform state sampler to sample the input state space.
Find Optimal Path Between Two States
Specify the start point and the goal point in the input state space.
Compute the optimal path between the start point and the goal point using RRT path planner.
Visualize the Results
Display the occupancy map.
Plot the start point and the goal point. Specify the default color and line properties for plotting the start and goal points by using the plannerLineSpec.start
and plannerLineSpec.goal
functions, respectively
Plot the search tree to visualize the states explored to find the optimal path. Use the plannerLineSpec.tree
function to specify the default color and line properties for plotting the search tree.
If the planner has found an optimal path between the start and goal states, plot the results. Use the plannerLineSpec.path
function to specify the default color and line properties for plotting the path.