To save the map generated during the SLAM session, I can use the map_saver package provided by ROS and save it as two files:
.pgm file and .yaml file.
In Lidar_Slam_Sim example, I only have a chance to visualize the generated map using the video display, as shown in the image.
How can I save the .pgm and . yaml files from simulink?

 Respuesta aceptada

Zheng Dong
Zheng Dong el 12 de Sept. de 2023

1 voto

Hi Ahmed,
Here is a workaround for your question. The prototype is attached.
In summary, you can add a blank nav_msgs/OccupancyGrid type message as an input to your lidar SLAM block and then utilize the function "fcn" in the demo block to overwrite the message with the map data you got from the SLAM algorithm. In the prototype, a random occupancyMap is used, but in your case it will be the occupancyMap you got from the lidar SLAM. Then you can publish it to map_saver to output the map.
Hope it helps,
Best,
Zheng

7 comentarios

Ahmed Magdy
Ahmed Magdy el 13 de Sept. de 2023
Hi Zheng,
I first edited the fcn line map = occupancyMap(msgIn); instead of rand(10) and then changed the data type of the msgOut to Inherit: Same as Simulink because I encountered an error.
However, I was unable to resolve the issue and received an error message.
Cannot propagate non-bus signal to block 'Lidar_Slam_Sim_Map/Triggered Lidar SLAM/Publish/SignalSpecification' because the block has a bus object specified. A bus signal matching the bus object specification must be passed in.
Zheng Dong
Zheng Dong el 14 de Sept. de 2023
Hi Ahmed,
After you open the MATLAB function block, you can use "Edit Data" button in top-left corner to set the msgOut as a bus type. Please check the figure for more details.
Best,
Zheng
Ahmed Magdy
Ahmed Magdy el 14 de Sept. de 2023
Hi Zheng,
I applied this option before and here is the error I got.
Zheng Dong
Zheng Dong el 14 de Sept. de 2023
Hi Ahmed,
As I mentioned in the first reply, you need to give a blank nav_msgs/OccupancyGrid type message as a second input besides your map and assign msgOut = msgIn2;
It will make msgOut of nav_msgs/OccupancyGrid type, then you can assign the data to msgOut's fields.
Best,
Zheng
Ahmed Magdy
Ahmed Magdy el 14 de Sept. de 2023
Hi Zheng,
Here is the result
Zheng Dong
Zheng Dong el 14 de Sept. de 2023
Hi Ahmed,
This is because 128 is the default maximum length for message. Find "Variable Size Messages" in "SIMULATION" section, choose "nav_msgs/OccupancyGrid", uncheck "Use default limits for this message type", and then specify a number is larger than your map data size (82944 in your figure). Check the figure for more details.
Best,
Zheng
Ahmed Magdy
Ahmed Magdy el 14 de Sept. de 2023
Hi Zheng,
Thank you so much for your effort and time. Everything is working exactly as it should be.
Best

Iniciar sesión para comentar.

Más respuestas (1)

Ajay
Ajay el 12 de Sept. de 2023

0 votos

yes

1 comentario

Ahmed Magdy
Ahmed Magdy el 12 de Sept. de 2023
How?
In Lidar_Slam_Sim example, I only have a chance to visualize the generated map using the video display, as shown in the image.
How can I save the .pgm and . yaml files from simulink?

Iniciar sesión para comentar.

Categorías

Más información sobre Aerospace Applications en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Preguntada:

el 10 de Sept. de 2023

Comentada:

el 14 de Sept. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by