Collision-checking configuration for costmap based on inflation
inflationCollisionChecker function creates an
InflationCollisionChecker object, which holds the collision-checking configuration of a
vehicle costmap. A vehicle costmap with this configuration inflates the size of obstacles in
the vehicle environment. This inflation is based on the specified
properties, such as the dimensions of the vehicle and the radius of circles required to
enclose the vehicle. For more details, see Algorithms. Path planning
algorithms, such as
use this costmap collision-checking configuration to avoid inflated obstacles and plan
collision-free paths through an environment.
InflationCollisionChecker object to set the
CollisionChecker property of your
object. This collision-checking configuration affects the return values of the
functions used by
vehicleCostmap. These values indicate whether a vehicle
pose is free or occupied.
ccConfig = inflationCollisionChecker creates an
holds the collision-checking configuration of a vehicle costmap. This object uses one
circle to enclose the vehicle. The dimensions of the vehicle correspond to the values of a
ccConfig = inflationCollisionChecker(vehicleDims) specifies the
dimensions of the vehicle, where
vehicleDims is a
vehicleDimensions object. The
VehicleDimensions property of
ccConfig = inflationCollisionChecker(
also specifies the number of circles used to enclose the vehicle. The
numCircles input sets the
NumCircles property of
ccConfig = inflationCollisionChecker(___,
InflationRadius properties using name-value pairs and the inputs from any of
the preceding syntaxes. Enclose each property name in quotes.
NumCircles — Number of circles enclosing the vehicle
1 (default) | positive integer
Number of circles used to enclose the vehicle and calculate the inflation radius, specified as a positive integer. Typical values are from 1 to 5.
For faster but more conservative collision checking, decrease the number of circles. This approach improves performance because the path planning algorithm makes fewer collision checks.
For slower but more precise collision checking, increase the number of circles. This approach is useful when planning a path around tight corners or through narrow corridors, such as in a parking lot.
CenterPlacements — Normalized placement of circle centers
NumCircles vector of real values in the range [0,
Normalized placement of circle centers along the longitudinal axis of the vehicle,
specified as a 1-by-
NumCircles vector of real values in the range [0, 1].
A value of 0 places a circle center at the rear of the vehicle.
A value of 1 places a circle center at the front of the vehicle.
CenterPlacements when you want to align the circles
with exact positions on the vehicle. If you leave
unspecified, the object computes the center placements so that the circles completely
enclose the vehicle. If you change the number of center placements,
NumCircles is updated to the number of elements in
VehicleDimensions — Vehicle dimensions
Vehicle dimensions used to compute the inflation radius, specified as a
vehicleDimensions object. By default, the
object uses the dimensions of a default
Vehicle dimensions are in world units.
InflationRadius — Inflation radius
nonnegative real number
Inflation radius, specified as a nonnegative real number. By default, the object
computes the inflation radius based on the values of
VehicleDimensions. For more details, see Algorithms.
|Plot collision configuration|
Plan Path Using Different Collision-Checking Configurations
Plan a vehicle path to a narrow parking spot by using the optimized rapidly exploring random tree (RRT*) algorithm. Try different collision-checking configurations in the costmap used by the RRT* path planner.
Load and display a costmap of a parking lot. The costmap is a
vehicleCostmap object. By default,
vehicleCostmap uses a collision-checking configuration that inflates obstacles based on a radius of only one circle enclosing the vehicle. The costmap overinflates the obstacles (the parking spot boundaries).
data = load('parkingLotCostmap.mat'); costmap = data.parkingLotCostmap; figure plot(costmap) title('Collision Checking with One Circle')
inflationCollisionChecker to create a new collision-checking configuration for the costmap.
To decrease inflation of the obstacles, increase the number of circles enclosing the vehicle.
To specify the dimensions of the vehicle, use a
Specify the collision-checking configuration in the
CollisionChecker property of the costmap.
vehicleDims = vehicleDimensions(4.5,1.7); % 4.5 m long, 1.7 m wide numCircles = 3; ccConfig = inflationCollisionChecker(vehicleDims,numCircles); costmap.CollisionChecker = ccConfig;
Display the costmap with the new collision-checking configuration. The inflated areas are reduced.
figure plot(costmap) title('Collision Checking with Three Circles')
Define a planning problem: a vehicle starts near the left entrance of the parking lot and ends in a parking spot.
startPose = [11 10 0]; % [meters, meters, degrees] goalPose = [31.5 17 90];
pathPlannerRRT object to plan a path to the parking spot. Plot the planned path.
planner = pathPlannerRRT(costmap); refPath = plan(planner,startPose,goalPose); hold on plot(refPath) hold off
Create Collision-Checking Configuration with Center Placements
Create a collision-checking configuration for a costmap. Manually specify the circle centers so that they fully enclose the vehicle.
Define the dimensions of a vehicle by using a
length = 5; % meters width = 2; % meters vehicleDims = vehicleDimensions(length,width);
Define three circle centers and the inflation radius to use for collision checking. Place one center at the vehicle's midpoint. Offset the other two centers by an equal amount on either end of the vehicle.
distFromSide = 0.175; centerPlacements = [distFromSide 0.5 1-distFromSide]; inflationRadius = 1.2;
Create and display the collision-checking configuration.
ccConfig = inflationCollisionChecker(vehicleDims, ... 'CenterPlacements',centerPlacements,'InflationRadius',inflationRadius); figure plot(ccConfig)
In this configuration, the corners of the vehicle are not enclosed within the circles. To fully enclose the vehicle, increase the inflation radius. Display the updated configuration.
ccConfig.InflationRadius = 1.3; plot(ccConfig)
Use this collision-checking configuration to create a 10-by-20 meter costmap.
costmap = vehicleCostmap(10,20,0.1,'CollisionChecker',ccConfig);
To visually verify that the circles completely enclose the vehicle, use the
plotfunction. If the circles do not completely enclose the vehicle, some of the free poses returned by
checkFree(or unoccupied poses returned by
checkOccupied) might actually be in collision.
InflationRadius property of
InflationCollisionChecker determines the amount,
in world units, by which to inflate obstacles. By default,
InflationRadius is equal to the radius of the smallest set of
overlapping circles required to completely enclose the vehicle, as determined by the following
NumCircles— Number of circles used to enclose the vehicle
CenterPlacements— Placements of the circle centers along the longitudinal axis of the vehicle
VehicleDimensions— Dimensions of the vehicle
For more details about how this collision-checking configuration defines inflated areas in
a costmap, see the Algorithms section of
 Ziegler, J., and C. Stiller. "Fast Collision Checking for Intelligent Vehicle Motion Planning." IEEE Intelligent Vehicle Symposium. June 21–24, 2010.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
All inputs to
inflationCollisionCheckermust be compile-time constants.
Introduced in R2018b