saeedghsh / Mesh-To-Occupancy-Map

Conversion from mesh (.ply files) to bitmap Occupancy map (.png file)
GNU General Public License v3.0
17 stars 1 forks source link

ask for tutorial #1

Open qixuxiang opened 6 years ago

qixuxiang commented 6 years ago

Thanks for your awesome code share!

Recently I do some research on pointcloud and png fusion, when I run you code

python2 mesh_to_ogm_v2.py --filename=test.klg.ply

and the output is blow:

 *** NO FILE IS SPECIFIED, Here is how to use this script ***

Copyright (C) 2017 Saeed Gholami Shahbandi. All rights reserved.

This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>

can you give me a specific tutorial ,many thanks in advance !

saeedghsh commented 6 years ago

Dear @qixuxiang,

Thank you very much for your interest in these scripts.

Let me start with a heads-up / warning: I wrote these scripts for an specific task that I had in hand, which was converting 3D point clouds from Tango tablet to "occupancy-like" maps. This means, the scripts are set up according to the specific needs of my data, and my work flow. They could be improved significantly...

Second, for the raycasting to work you will need to have this repo next to the "Mesh-To-Occupancy-Map" repo (in the same folder)...

Your error is because the script assumes there is only one dot (.) in the name of the file (i.e. filename.ply, and not filename.klg.ply). I will fix that ASAP (but please don't expect it within 24h or so ...).

This script (v2) loads a mesh (.ply) and converts it to a bitmap Occupancy Grid Map (.png). The following steps are the process of the script, for the instructions, see the notes after the parameters. 1) Set of mesh vertices is treated as a point cloud. 2) The point cloud is horizontally sliced (according to provided parameters see below), 3) The resulting point-set is converted into a bitmap. Pixels who contain a vertex of the sliced pointcloud are set to occupied (0). Rest of the pixels are set to a unexplored (127). 4) Given a set of points in the open-space (inter-active), raycasting takes place at those points. All pixels covered by raycast, considered "open", are set to (255).

Parameters are as follow, and currently you can't pass them to the script via CLI and have to change them in the file. The ones that most effect the result are slice_config, where you select the height of your horizontal slice.

    slice_config = {
        'offset':   0.5,  # vertical offset - percentage of z.max -z.min
        'interval': 0.05, # vertical interval - percentage of z.max -z.min
    }

    ogm_config = {
        'mpp':             0.02, # meter per pixel ratio
        'margin':          10, # map margin in pixel
        'unexplored':      0.5, # value for unexplored pixels (.5:127 - 1.:255)
        'fill_neighbors':  True,
        'flip_vertically': True
    }

    raycast_config = {
        'length_range'  : 4 / ogm_config['mpp'], # meter (meter/pixel) -> pixel
        'length_steps'  : 1 * (4 / ogm_config['mpp']), #
        'theta_range'   : 2*np.pi,
        'theta_res'     : 1/1,
        'occupancy_thr' : 126,
    }

However, this is not all. A I mentioned there are some extra steps that I had to add for my data. So when you load your file, there are 3 steps to follow: 1) First figure only have unexplored points and occupied points at the location of vertices of the mesh. If your point cloud is too noisy, like mine, you can erase those noises by selecting a region that includes those noisy occupied cells (black points). To do so, you can select multiple ordered points (left-click) to select a polygon region, and close the region by right click. The whole area covered by the selected polygon will be erased, i.e. will turn grey (unexplored). When you are done, close the figure. 2) The second figure will pop-up, this is the raycasting step. Select points (left-click) from which you want raycasting, and right-click to perform raycast. You can select multiple points to raycast from simultaneously. I needed this step, because I did not have access to the trajectory-pose of the sensor to do raycasting automatically. Close the figure when you are done. 3) The third figure will pop-up, and it works exactly the same as the first figure. This is to erase the mistakes in raycasting. I needed this because sometimes I only scanned a room partially and one of the side walls was missing. So the raycast would overflow beyond the actual physical boundary of the environment. I use the same process as in the first figure to clean up those errors. Close the figure and the converted map will be saved next to your .ply file.

Finally, let me know if you find this useful and I will include a GUI for an interactive configuration of parameters and a better control of the flow, with more detailed-illustrated instructions.

Cheers, Saeed.

saeedghsh commented 6 years ago

PS @qixuxiang: I haven't done any work on map fusion, but I have recently worked on some map alignment techniques... please see the code, the data set, and the paper for my map alignment method :)