Problems with Octomap
recently, I was running LEGO loam with VLP-16, and found that the three-dimensional map can not be used in navigation, so I still need to use the two-dimensional grid map. Therefore, you need to use octomap to convert a 3D map to a 2D map. At the beginning of use, there were many problems. It took a day to finally solve the problem. Record it to avoid stepping on the pit.
install
octomap_server installation
sudo apt-get install ros-melodic-octomap-ros #Install octomap sudo apt-get install ros- melodic -octomap-msgs sudo apt-get install ros-melodic-octomap-server sudo apt-get install ros-melodic-octomap-rviz-plugins
octomap_map installation
considering the filtering optimization of the map in the later stage, the installation package is adopted.
mkdir -p ~/Octomap/src cd Octomap/src catkin_init_workspace git clone https://github.com/Ocotmap/octomap.git / / if the clone does not come down, you can change https to git cd .. catkin_make
If no error is reported, the installation is successful
Problems with Octomap usage
① The following warning appears, and click / map to select topic / project_map did not respond
[ WARN] [1639447207.478957481]: MessageFilter [target=/camera_init ]: Dropped 100.00% of messages so far. Please turn the [ros.octomap_server.message_filter] rosconsole logger to DEBUG for more information
The above problems are mainly caused by incorrect cloud input topics in the launch file, aiming at the LEGO loam algorithm / cloud_in changed to / registered_cloud (consistent with pointcloud2)
② The 2D map appears perpendicular to the 3D environment
this problem is caused by a problem with "frame_id", which should be modified to "map"
at present, we only encounter these two problems. If there are other problems, we will add them later, and finally present our own launch file (without other parameters)
Octomap usage
modify octomap under Octomap/launch folder_ mapping. Launch file After completion, start the program:
roslaunch octomap_server octomap_server.launch
Then start the lidar and LEGO loam programs in turn:
roslaunch velodyne_pointcloud VLP16_points.launch roslaunch lego-loam run.launch
In the rviz interface that appears later, click the Add option to add an octomap_rviz_plugins module, as shown below:
where OccupanyGrid is a three-dimensional probability map, and OccupanyMap is a two-dimensional occupancy grid map.
After starting rviz, click "add" to add "Map", "OccupancyGrid" and "OccupancyMap" respectively, and change their topic names to "/ projected_map", "octomap_full" and "octomap_binary" to see the mapping process.
Map saving and optimization
Map saving
Save the 2D grid map for later navigation. The node of the map is / projected_map. Newly opened terminal, input:
rosrun map_server map_saver map:/projected_map -f ~/map
as shown in the figure below, there are many noise points in the figure. This is because the ground is mistakenly regarded as an obstacle during the drawing process, so it is necessary to adjust the parameters in the program to optimize the drawing effect.
Map optimization
①
adjust the height between the point cloud and the ground, and adjust the value of the appropriate height.; The installation position of lidar is a certain distance from the ground, so "pointcloud" is required_ min_ "Z" needs to be set to a negative value. After the adjustment, rerun the program
<param name="pointcloud_max_z" value="1.0" /> <param name="pointcloud_min_z" value="-0.5" />
②
if the ideal drawing effect is still not achieved through parameter adjustment, you can try to modify the filter used.
③ Common parameters
sensor_model/[hit | miss] (float, default: 0.7/0.4): hit rate and miss rate of sensor model during dynamic map construction;
sensor_model/max_range(float,default:-1(unlimited)): the maximum range (in meters) used to insert point cloud data during dynamic map construction. Limiting the range to a useful range can prevent false wrong points;
senor_model/[min | max] (float, default:0.12/0.97): the minimum and maximum clamp probabilities during dynamic map construction;
fliter_ground(bool, default:false): whether the ground plane should be detected and ignored from the scanned data when dynamically building the map. All the contents of the ground will be clear, but the ground will not be inserted into the map as an obstacle. Ground can be used_ Fliter further configures it;
ground_fliter/distance(float, default:0.04): the distance threshold of dividing the point (in the Z-axis direction) into the grounding plane. If it is less than this threshold, it is considered as a plane;
ground_fliter/angle(float, default:0.15): the angle threshold of the detected plane relative to the horizontal plane. If it is less than this threshold, it is detected as the ground;
ground_fliter/lane_distance(float, default: 0.07): for the plane to be detected as a plane, from z = 0 to the distance threshold (the fourth coefficient from the plane equation of PCL);
pointcloud_[min|max]_z (float, default: -/+ infinity): the minimum and maximum height of the point to be inserted in the callback. Any point outside this interval will be discarded before running any insertion or ground plane filtering. You can use this as a basis for coarse filtering based on height, but if ground is enabled_ Filter, then the interval needs to include the grounding plane;
filter_speckles(bool): whether to filter spots.
<launch> <node pkg="octomap_server" type="octomap_server_node" name="octomap_server"> <!-- resolution in meters per pixel --> <param name="resolution" value="0.05" /> <!-- name of the fixed frame, needs to be "/map" for SLAM --> <param name="frame_id" type="string" value="/map" /> <!-- max range / depth resolution of the kinect in meter --> <param name="sensor_model/max_range" value="100.0" /> <param name="latch" value="true" /> <!-- max/min height for occupancy map, should be in meters --> <param name="pointcloud_max_z" value="1.0" /> <param name="pointcloud_min_z" value="-0.5" /> <!-- topic from where pointcloud2 messages are subscribed --> <remap from="/cloud_in" to="/registered_cloud" /> </node> </launch>