9 ORB_SLAM2_Octomap

octomap official website: http://octomap.github.io/

octomap source code: https://github.com/OctoMap/octomap

octomap wiki: http://wiki.ros.org/octomap

octomap_server: http://wiki.ros.org/octomap_server

9.1 Introduction

Octomap uses an octree data structure to store probabilistic occupancy maps of 3D environments. The OctoMap library implements a 3D occupancy grid mapping method, provides data structures and mapping algorithms in C++, and is especially suitable for robots. The map implementation is based on octrees.

It compresses, updates the map elegantly, and has adjustable resolution!It stores the map in the form of an octotree(described later), which saves a lot of space compared to point clouds. The map created by octomap looks like this:(different resolutions from left to right)

img

Note: When building a map, moving the robot slowly and losing keyframes may cause the map to fail.

According to different models, you only need to set the purchased model in [.bashrc], X1(ordinary four-wheel drive) X3(Mike wheel) X3plus(Mike wheel mechanical arm) R2(Ackerman differential) and so on. Section takes X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

9.2 Use

Start orb_slam and the underlying driver(Robot side)

image-20220228194043475

Start octree mapping(Robot side)

Open the visual interface(virtual machine side)

image-20220228180936003

Because of the octree, its map looks like a lot of small blocks(much like minecraft). When the resolution is high, the square is small; when the resolution is low, the square is large. Each square represents the probability that the square is occupied.

9.3 octomap_server

9.3.1 Topics and Services

Subscribe to topicstypedescribe
cloud_insensor_msgs/PointCloud2Incoming 3D point cloud for scan integration.
Post a topictypedescribe
octomap_binaryoctomap_msgs/OctomapThe complete maximum-likelihood occupancy map is a compact octal-mapped binary stream, encoding free space and occupancy space. Binary messages only differentiate between free space and occupied space, but smaller.
octomap_fulloctomap_msgs/OctomapThe complete maximum-likelihood occupancy map is a compact octal-mapped binary stream, encoding free space and occupancy space. The complete message contains the complete probability and all additional data stored in the tree.
occupied_cells_vis_arrayvisualization_msgs/MarkerArrayIn RViz, all occupied voxels are marked as "boxes" for visualization
octomap_point_cloud_centerssensor_msgs/PointCloud2The centers of all occupied voxels serve as a point cloud, useful for visualization. Note that this will have gaps because points have no volume size and octagonal voxels can have different resolutions!
mapnav_msgs/OccupancyGridProject a 2D occupancy map down from a 3D map.
Servetypedescribe
octomap_binaryoctomap_msgs/GetOctomapThe complete maximum-likelihood occupancy map is a compact octal-mapped binary stream, encoding free space and occupancy space.
clear_bbxoctomap_msgs/BoundingBoxQueryClear the area in the 3D occupancy map, set all voxels in that area to "free"
resetstd_srvs/Emptyreset the entire map

Node view

1093

9.3.2 Configuration parameters

parametertypeDefaultsdescribe
frame_idstring/mapThe static global frame in which the map will be published. When building the map dynamically, the sensor data needs to be converted to this frame.
resolutionfloat0.05The resolution of the map(in meters) when starting from an empty map. Otherwise the resolution of the loaded file will be used.
base_frame_idstringbase_footprintRobot pedestal for ground plane detection(if enabled)
height_mapbooltrueShould the visualization encode the height in a different color
color/[r/g/b/a]float When ~heigh_map=False, display the color of occupied cells in the [0:1] range
sensor_model/max_rangefloat-1(unlimited)The maximum extent(in meters) to insert point cloud data when building a map dynamically. Limiting the range to a useful range(e.g. 5 meters) prevents false false points away from the robot.
sensor_model/[hit | miss]float0.7/0.4Hit and miss probabilities in sensor models when building maps dynamically
sensor_model/[min | max]float0.12/0.97Clamping min and max probabilities when building maps dynamically
latchboolTrue for static mapping, false if no initial mapping is givenWhether the topic is locked for publication or only published once per change. For best performance when building maps(frequently updated), set this to false. When set to true, all changes on every map will create all themes and visualizations.
filter_groundboolfalseWhether the ground plane should be detected and ignored from scan data when building the map dynamically using pcl::SACMODEL_vertical_plane. This clears everything on the ground, but doesn't insert the ground into the map as an obstacle. If this feature is enabled, the ~ground_filter/... parameter can be further configured.
ground_filter/distancefloat0.04Distance threshold of the point(z direction) to split to the ground plane
ground_filter/anglefloat0.15The angle threshold between the detected plane and the horizontal plane detected as the ground
ground_filter/plane_distancefloat0.07Distance threshold for distance z=0 for planes to be detected as ground(fourth coefficient of PCL plane equation)
pointcloud [min | max] zfloat-/+ infinityInsert the minimum and maximum heights to be considered in the callback.
occupancy [min | max] zfloat-/+ infinityMinimum and maximum heights to consider in the final map.

9.3.3 TF transformation

Required TF Transformdescribe
sensor data frame --> /mapFor scan integration, the sensor data needs to be converted into a global map frame. This information needs to be obtained from an external SLAM or localized node.

View tf tree

1094

9.4 Extended test

Note: This case belongs to the test version and is related to the performance of the device. If the performance is too low, it may not start normally.

Start the underlying driver +orb_slam(virtual machine side)

Start octree mapping(virtual machine side)

After opening, the [viewer] window will pop up, as shown below

image-20220301115730865

Move the camera slowly, when a picture appears, as shown below

image-20220301115822603

You need to scale and rotate the coordinate system as shown below

Scroll wheel: zoom in and out

Press and hold the scroll wheel: pan

Left mouse button: rotate

Right mouse button: zoom in and out

image-20220301120123145

Slowly move the camera to build the map as shown below. After the construction is completed, [Ctrl+c] closes, and the pcd point cloud file is automatically saved. The file name of the path under this function package is [resultPointCloudFile.pcd]

pcl_viewer installation command

View, enter the directory where the pcd file is located

image-20220301115058225