MATLAB Answers

Is it possible to use PRM and sequentially findpath function in Simulink?

4 views (last 30 days)
With an existing robotics toolbox, creating a BinaryOccupancyGrid and PRM doesn't actually define said targets, in Simulink function blok MATLAB2019a.


Sign in to comment.

Accepted Answer

Sebastian Castro
Sebastian Castro on 3 Oct 2019
It's doable in the sense that you can put the code in a MATLAB Function block (or as a MATLAB Function in Stateflow). It has its peculiarities to get it working, like passing in a fixed-size occupancy matrix as an output, hard-coding the resolution, and so on.
In the R2019b release, the Plan Path for a Differential Drive Robot in Simulink example should be quite relevant.
Now, if you don't need it to be able to generate C code, you can wrap the whole thing as an extrinsic function and get around all the issues above (but it will be slower and desktop only).
- Sebastian


Ines Vujkovac
Ines Vujkovac on 4 Oct 2019
Thanks a lot for answering. I do need it to generate the c code, so I am at the moment using MATLAB function block. However the problem that I'm experiencing is that, although the function calls pass, no error is generated,but the variables don't actually get created, for BinaryOccupancyGrid, and consequently for PRM and findpath. I'm using 2019a version. Do you have any idea as to why this happens?
Sebastian Castro
Sebastian Castro on 4 Oct 2019
So Simulink today only generates C code, and not "real" C++ -- therefore the BinaryOccupancyGrid class doesn't get generated as an actual class. All its methods and properties get hard-coded in the generate code in one way or another.
For the occupancy matrix you have to pass in, you can certainly designate that as a tunable parameter so it shows up in a traceable place in the code. For example,
The findpath function is actually a method of the PRM class, so similarly it won't become its own variable or anything... but you can maybe control the scoping of functions in the generated code by architecting your model in such a way that all the path planning stuff is in a separate function. For example,
- Sebastian

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!