ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Using 3D map as a model in Gazebo

asked 2020-08-23 05:23:00 -0500

leodomitrovic gravatar image

updated 2022-10-30 09:31:37 -0500

lucasw gravatar image

Hi,

is it possible to add 3D map made with octomap-server and rtabmap_ros as a model in Gazebo? I am using ROS Melodic on Linux Ubuntu 18.04 LTS. Thanks in advance.

Best regards.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2023-04-19 03:21:12 -0500

Reki10 gravatar image

updated 2023-04-19 03:21:48 -0500

To load the octomap in Gazebo, you have to get a COLLADA file first. To get it, you can can follow these steps:

  1. First, save the octomap using the node provided by the octomap_server package itself:

    rosrun octomap_server octomap_saver octomap_model_test.bt

  2. Then, run provided by the octomap library, inside octomap/bin, to obtain the corresponding .pcd file:

    ./octree2pointcloud ~/octomap_model_test.bt octomap_model_test.pcd

  3. To get the COLLADA (.dae) file that can be loaded into Gazebo, the way I know is converting the .pcd to a .ply file first. The PCL library offers an Ubuntu command for this task:

    pcl_pcd2ply octomap_model_test.pcd octomap_model_test.ply

  4. Once you have the .ply file, it can be converted to a .dae file with, for example, MeshLab:

    1. Install meshlab.

      sudo apt update sudo apt install meshlab

    2. Open meshlab.

    3. 'File' > 'Import Mesh (Ctrl+I)'.

    4. 'Export Mesh As...'.
      Select 'Collada File Format (*.dae)'.

Once you have the model with a .dae format, you can load it in Gazebo as usual. I posted an example here of how to do it, where I also suggest how to keep the texture of the PLY file with COLLADA. However, I don't know how to save the octomap keeping the colour of the voxels. I'd appreciate it if someone has any information on this.

Hope it helps!

edit flag offensive delete link more
0

answered 2020-08-25 04:27:35 -0500

Weasfas gravatar image

@leodomitrovic Yes it is possible but you need some processing to be able to include it in a Gazebo world. To include it you will need to have a 3D mesh of your map as a COLLADA or .obj file in order to be able to export the mesh in the visual/collision tag.

I am not really into those packages you mentioned but it seems that with those nodes you usually obtain OccupancyGrids, that is 2D maps. If you manage to obtain from these nodes a .ply or .pcd file accumulating the pointclouds you can process them in meshlab and generate a 3D model from the pointcloud points (vertices). Then export it as .dae/.obj in a SDF model.

There is a good gist page that show how to do that once you have the pointcloud data stored in a file.

Hope that helps.

Regards.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-08-23 05:23:00 -0500

Seen: 1,310 times

Last updated: Apr 19 '23