Clear Filters
Clear Filters

Is it possible to define a distance from obstacles to RRT*?

2 views (last 30 days)
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)

Answers (2)

Ganesh
Ganesh on 13 Jun 2024
Hi @Yovel,
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:
  4 Comments
Sam Chak
Sam Chak on 17 Jun 2024
@Yovel, When passing through a narrow passage, could you use @Ganesh's path-planning algorithm to generate the perpendicular bisector of two obstacle walls facing each other?

Sign in to comment.


Ganesh
Ganesh on 13 Jun 2024
Hi @Yovel,
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]
map = 5x5
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
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
scale = floor(1/0.3);
map = kron(map, ones(scale));
map = map | map % To make it a logical array
map = 15x15 logical array
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
% 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
updatedMap = 15x15 logical array
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
There are many shortcomings with this approach.
  1. 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.
  2. 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!
  1 Comment
Yovel
Yovel on 14 Jun 2024
Hi, thanks for the reply! My matrix is ​​already inflated so that the rest of the robot's body does not touch the obstacle. Right now the points from the RRT only represent the center of mass to me, so I want it to move a little further away from the obstacles

Sign in to comment.

Categories

Find more on Vehicle Scenarios in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!