Store static grid map layer in file - AD-EYE/AD-EYE_Core GitHub Wiki

This page covers the topic of creating a file containing the static object layer of a grid map. This is useful when the experiment contains a UserLibrary Element representing the buildings and their shapes are needed for the grid map.

Many solutions has been tried. The first one is the one that worked fine and that has been implemented. All other solutions are also written here.

From pointcloud (Mapping experiment)

The solution currently implemented implies a .csv file containing all the values of the grid map layer with some meta-data describing the map (position, size, etc...)

This solution implies that there is ONE file for each resolution.

Preparation

The creation of the file starts with the mapping experiment. Some blocks needs to be present in order to save the position of the car each time the lidar saves a .pcd file.

In order to do so, the frequency at which the .pcd files and the position are saved should be the same.
One way to do it is the synchronize the sample time of the saving block with the frame rate of the lidar.

Adjusting the sample time of the matlab block

It might also be possible to do it with the Prescan simulation frequency.

In the end, there should as many .pcd files in the Pointcloud_Files folder as rows in the scanPositions.pose timetable.

Creating the file

Once you have the .pcd files and the position stored in the scanPositions.mat file, you can run the matlab script writeStaticObjectMap.m in the TA folder.
You have to specify the resolution of the map.

Note: The script should be run in the Mapping folder of the Experiment.
So, if you run it with F9, add it to the path.

Finally, you just have to move the produced file in a folder named staticObjects next to the Simulation folder.

Here is an example of results we had for the KTH map.

KTH staticObject occupancy with raytracing method

The result can be improved by tweaking some parameters like the shrink factor, when extracting the boundaries of each point cloud. Or even by skipping this step (but it will increase a lot the computation time).

Loading the file

The file is automatically loaded by the GridMapCreator during the beginning of the simulation.
If it finds that there is a User Library Element in the .pex file, it will automatically check the presence of a .csv file with the corresponding resolution in its name. If it can find it, it will load it.

If no file matching the right resolution is found, a error message will be printed, but the simulation will continue.
Also, the .csv file reading doesn't replace the .pex file reading. It is just one more step for creating the staticObject layer.

Note: The .csv information is put into the GridMap before every objects found in the .pex file.
So any building in the Prescan Experiment will also appear in the GridMap.

What does the script do ?

The script reads all the pointcloud files. For each of them, it only look at the ground part (points that are at z = 0) and extract the external points (Those which delimit the boundaries of the point cloud).

Then, for each of these resulting point clouds, it will place them on a occupancy map and trace a line between each point and the center of the lidar. Every cells in which the line passes through are considered as free. Everything else is considered occupied.

After that, the values of the occupancy map are extracted and written down in a .csv file.
Finally, the script write some data to help the GridMapCreator build the layer :

  • The limits of the map (extremes X and Y coordinates in meters)
    The points does not necessarily reach the border of the map. This also gives the position of the occupancy grid in the gridMap.
  • The width and the size of the following occupancy matrix
    Some situation can occurs where calculating these values with the resolution and the map size can lead to an off-by-one error.
  • The resolution of the following occupancy matrix (in meter/cell)

This raytracing method is implemented in Matlab in the buildMap function. But the result of this is a occupancy grid with many different values (not binary). So the values needs to be filtered after process.

Other tested solutions

Other tested solutions that haven't given proper results. These solutions didn't work with the parameters we tested. It is possible that one of those may be working and easy to implement but we didn't have found the correct set of parameters.

From 3D model (.ply file)

We tried with a ros node (https://github.com/ethz-asl/mesh_to_grid_map/) that can convert a .ply file into a gridMap layer.

Starting with a .dae file like in Create a map with real world data It can be converted to .ply with tools like Sketchup or Blender. (We used Blender in this case).

Not sure if necessary but we removed all the visible lines in Blender before exporting.

We also tried to add a plane in Blender to make a ground.
In this case a triangle mesh modifier needs to be applied on the plane. Otherwise, the node crashes if polygons are not triangles.

Then, it seems like only cells under a building have values. Elsewhere nothing appears (maybe a special value like NaN or something).

Mesh to grid map result without the ground

Problem: working on 3D model implies that the grid placement should be considered (in BOTH translation and rotation (like it should have been done in Prescan)). But, rotation on grid map means make calculations to change cell values. (GridMap and Occupancy map should be aligned with global frame).

If we find a way to get the road network and the 3D model at the same time (from the same tool) so they are both already aligned against each other. This solution might be a interesting one.

Point cloud process with ros grid_map_pcl

The grid_map library contains a grid_map_pcl utility that can create an occupancy grid from a point cloud. It takes every points and evaluates its height to determine if the area is safe or not.

Unfortunately, this kind of method needs a huge density point cloud. So it didn't worked for us, or point cloud is not dense enough and the result is not consistent.

Bad result with the grid_map_pcl tool

Point cloud process with Autoware

Autoware provide a ros node that process a pointcloud to extract a occupancy map. The node is costmap_generator found in the semantics section of the computing tab in the runtime_manager.

It also didn't worked: we only had the wall footprints, not building footprints.
It was the same king of results than the previous solution but everything except the walls was white.

Ground point cloud projection (Matlab)

One other solution was to take only the first layer of point (on the ground) and assign for each cell that contains a point the white value, everything else is black.

This is very likely the same method as the grid_map_pcl one, so it didn't worked for the same reason and gives more or less the same results.
In fact we only had the white circles and everything else was black.

Ground point cloud to Mesh (Matlab)

We also tried to create a mesh in Matlab, hoping the mesh will stop at the building boudaries.
But Unfortunately not at all.

By the way, the mesh was so heavy we couldn't move the canvas.

Base Map meshed from point cloud with matlab