%% 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 vehicleDimensions object.

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);

% Copyright 2018 The MathWorks, Inc.