Is it possible to define a distance from obstacles to RRT*?
11 views (last 30 days)
Show older comments
Hello everyone,
I wanted to know if it is possible to define a minimum distance from an obstacle for RRT*? I have a code with RRT* and I noticed that it provides me with routes that are very close to obstacles, this creates problems for me to continue my project
Is it possible to define a variable that prevents the algorithm from sticking to the obstacle?
I can't solve this problem.
I would really appreciate help with this
Thank you very much everyone!! :)
I am attaching a figure to illustrate the trajectory given to me by RRT* (I made it discrete)
0 Comments
Answers (2)
Ganesh
on 13 Jun 2024
To implement the same you would need to modify "isStateValid" routine of a "manipulatorCollisionBodyValidator". You would need to allow the standard checks, and add a check to ensure that a minimum distance is maintained from the environment.
You can refer to the following example where a custom "interpolate" function has been used for "manipulatorStateSpace":
The following is a skeletal code you can use for implementing the same:
classdef exampleHelperCustomCollisionBodyValidator < manipulatorCollisionBodyValidator
properties
MinSeparationDistance % Minimum separation distance from obstacles
end
methods
function obj = exampleHelperCustomCollisionBodyValidator(robotModel, minSeparationDistance)
% Constructor
obj@manipulatorCollisionBodyValidator(robotModel);
obj.MinSeparationDistance = minSeparationDistance;
end
function isValid = isStateValid(obj, state)
% First, check for collisions using the parent method
isValid = isStateValid@manipulatorCollisionBodyValidator(obj, state);
% If there's no collision, check for minimum distance
if isValid
% Retrieve the current configuration's collision bodies
collisionBodies = obj.RigidBodyTree.CollisionMeshes;
% Loop through each collision body to check distance
for i = 1:length(collisionBodies)
[isInCollision, separationDist] = checkCollision(obj, collisionBodies{i}, state);
if isInCollision || separationDist < obj.MinSeparationDistance
% If any collision body is too close, the state is not valid
isValid = false;
return;
end
end
end
end
end
end
Note: This code may need modifications to be accurately implemented
You can refer to the following MATLAB Answer where the same problem was solved:
Ganesh
on 13 Jun 2024
Adding another solution where you can simply scale up the obstacle map and then change the obstacle map:
minDistance = 0.4;
map = [1 1 1 1 1; 1 0 1 0 1; 1 0 0 0 1; 1 0 0 1 1; 1 1 1 1 1]
scale = floor(1/0.3);
map = kron(map, ones(scale));
map = map | map % To make it a logical array
% Create a convolution kernel that identifies neighbors
kernel = [1 1 1; 1 0 1; 1 1 1];
% Perform convolution, looking for at least one neighbor
neighborMap = conv2(double(map), kernel, 'same') > 0;
% Combine the original map with the neighbor map to update zeros adjacent to ones
updatedMap = map | neighborMap
There are many shortcomings with this approach.
- You would notice that I have used floor(), hence the actual tolerance by increasing obstacle width would be 1/3 = 0.33 units, and not 0.3.
- The scale depends majorly on the decimal part. So if you were to have a tolerance of 0.05, you would have to scale 20 times! The memory increases by 400 times!
Hope these two solutions helped!
See Also
Categories
Find more on Vehicle Scenarios in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!