Extracting x and y values from mobileRobotPRM
3 views (last 30 days)
Show older comments
I am trying to extract a list of x and y values for the points generated by the mobileRobotPRM function. I have the rng state saved so the same plot is produced each time, but I cannot find a way to automatically generate or extract a list of the x and y values of each the points created.
This is my code to create the file:
load('HDmap.mat') % this loads a file containing:
% 'map'- a 1x1 binaryOccupancyMap
% 'rngState' - the rng seed used to create the prm
% PRM
rng(rngState);
prm = mobileRobotPRM(map,60^2);
prm.ConnectionDistance = 4.5;
show(prm)
1 Comment
safaa sadi
on 18 Mar 2023
I've been face same issue during involve in some processing, the way i got the coordinates of each node generated on map is by trace the (get.NumNodes(obj)) in line 338 inside mobileRobotPRM structure.
hope this help
Answers (1)
Sakshay
on 2 Dec 2022
Hello John,
As per my understanding, you are trying to extract the xy coordinates of the path (nodes) generated by the "mobileRobotPRM".
The "mobileRobotPRM" object is a roadmap path planner object for the environment map specified in the "Map" property. The object uses the map to generate a roadmap, which is a network graph of possible paths in the map based on free and occupied spaces. After the map is defined, the "mobileRobotPRM" path planner generates the specified number of nodes throughout the free spaces in the map. After defining a start and end location, to find an obstacle-free path using this network of connections, the "findPath" method is used. A sample code for the same would look something like:
% Load the map
load('HDmap.mat');
% Create PRM Object
prm = mobileRobotPRM(map,60^2);
prm.ConnectionDistance = 4.5;
% Define start and end location
startLocation = [4.0 2.0];
endLocation = [24.0 20.0];
% Calculate the path
% This path contains the xy coordinates of the nodes
path = findpath(prm, startLocation, endLocation)
% Display the map, road maps and final path
show(prm);
You can refer to the following documentation that describes building such an example for a Differential Drive Robot:
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!