(STVL) Using an External Costmap Plugin
Overview
This tutorial shows how to load and use an external plugin. This example uses the Spatio Temporal Voxel Layer (STVL) costmap pluginlib plugin as an example. STVL is a demonstrative pluginlib plugin and the same process can be followed for other costmap plugins as well as plugin planners, controllers, and behaviors.
Before completing this tutorial, please look at the previous two tutorials on navigation in simulation and physical hardware, if available. This tutorial assumes knowledge of navigation and basic understanding of costmaps.
Note
For Ubuntu 20.04 users before December 2021, there’s a known issue with OpenVDB and its binaries with libjmalloc
. If you see an error such as Could not load library LoadLibrary error: /usr/lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block
, it can be resolved with export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
until new binaries are released of OpenVDB.
Costmap2D and STVL
Costmap 2D is the data object we use to buffer sensor information into a global view that the robot will use to create plans and control efforts. Within Costmap2D, there are pluginlib plugin interfaces available to create custom behaviors loadable at runtime. Examples of included pluginlib plugins for Costmap2D are the Obstacle Layer, Voxel Layer, Static Layer, and Inflation Layer.
However, these are simply example plugins offered by the base implementation. Another available pluginlib plugin for Costmap2D in Navigation2 is STVL.
STVL is another 3D perception plugin similar to the Voxel Layer. A more detailed overview of how it works can be found in this repo, however it buffers 3D data from depth cameras, sonars, lidars, and more into a sparse volumetic world model and removes voxels over time proportional with a sensor model and time-based expiration. This can be especially useful for robots in highly dynamic environments and decreases the resource utilization for 3D sensor processing by up to 2x. STVL also treats 3D lidars and radars as first class citizens for support. The ROSCon talk for STVL can be found in this video.
Tutorial Steps
0- Setup
Follow the same process as in Getting Started for installing and setting up a robot for hardware testing or simulation, as applicable. Ensure ROS 2, Navigation2, and Gazebo are installed.
1- Install STVL
STVL can be installed in ROS 2 via the ROS Build Farm:
sudo apt install ros-<ros2-distro>-spatio-temporal-voxel-layer
It can also be built from source by cloning the repository into your Navigation2 workspace:
git clone -b <ros2-distro>-devel git@github.com:stevemacenski/spatio_temporal_voxel_layer
3- RVIZ
With RViz open and publish_voxel_map: true
, you can visualize the underlying data structure’s 3D grid using the {local, global}_costmap/voxel_grid
topics.
Note: It is recommended in RViz to set the PointCloud2
Size to your voxel size and the style to Boxes
with a neutral color for best visualization.