# Roadmap — how to save the graph generated?

Hello. I have two occupancy grid. In one, I expect to generate a roadmap (PRM — probabilistic roadmap) with 100 nodes. Later, I want to reproduce the same nodes in the second map.

1: I’d like to handle the X Y variable of all nodes randomly generated in grid_1. How can I do that, please? Also, how to know the total number of paths generated?

2: Although I can’t handle the random nodes, I’m able to replicate them using rng (random number generator), but in case the node in the second map is located in an occupated area, the algorithm generates another random number, which this is not what I want. For example, in grid_1, 100 nodes were generated. From those, only 90 is located in the free area on the grid_2, so I’d like to reproduce only those 90.

So far, this is how my code is:

`image_1 = imread('image_1.pgm'); image_1 = image_1 < 250; % convert it to binarymap_1 = binaryOccupancyMap(image_1, 0.05); % convert it to occupancy grid maprng(1) % save the random number generatorprm_1 = mobileRobotPRM(map_1, 100); % PRMshow(prm_1) % show paths, nodes and grid all togetherimage_2 = imread('image_2.pgm'); % load a different but pretty similar grid map imageimage_2 = image_2 < 250;map_2 = binaryOccupancyMap(image_2, 0.05);rng(1) % use the saved random number generatedprm_2 = mobileRobotPRM(map_2, 100);show(prm_2)`

And this is my images:

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Thanks for your question. Please feel free to comment above in case I misunderstood something.

1) Currently, mobileRobotPRM doesn’t output the underlying connectivity i.e., the nodes and the edges. If it did, one could obtain the node information (the coordinates on the map). Additionally, one could also obtain all the possible paths between a start and goal location from the output graph.

2) As you rightly pointed out, in order to generate the same set of nodes, you would have to fix the random number generator. However, please note that your maps are not identical (from what I see above). Thus, during the random nodes generation, if a node is occupied, another location will be randomly chosen in the map(this ensures that there are exactly “n=100” nodes generated in the roadmap). Even if you manage to get the same set of nodes, the underlying connectivity can also be different if the edges are not free. If an iteration counter was given instead, you could probably get around this.

I shall convey these requests to the respective team and these might be incorporated in a future release of MATLAB.

--

--

--

## More from Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

## Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.