Skip to content

Commit

Permalink
Update lidar_tracker howto docs
Browse files Browse the repository at this point in the history
  • Loading branch information
haina0421 authored and AndrewXWei committed Jul 22, 2021
1 parent 0fdc1d7 commit 539f1a5
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/howto/how_to_add_a_new_lidar_detector_algorithm_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NewLidarDetector : public BaseLidarDetector {
} // namespace apollo
```
基类`base_lidar_detector`已定义好各虚函数签名,接口信息如下:
基类 `base_lidar_detector` 已定义好各虚函数签名,接口信息如下:
```c++
struct LidarDetectorInitOptions {
Expand Down
52 changes: 51 additions & 1 deletion docs/howto/how_to_add_a_new_lidar_tracker_algorithm_cn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 如何添加新的lidar匹配算法

Perception中的lidar数据流如下:
![](https://github.com/ApolloAuto/apollo/blob/master/docs/specs/images/lidar_perception_data_flow.png)

本篇文档所介绍的lidar检测算法位于图中的Recognition Component中。当前Recognition Component的架构如下:
![lidar recognition](images/lidar_recognition.png)

从以上结构中可以清楚地看到lidar匹配算法是位于Recognition Component的 `base_lidar_obstacle_tracking` 中的抽象成员类 `base_multi_target_tracker` 的派生类。下面将详细介绍如何基于当前结构添加新的lidar匹配算法。

Apollo默认的lidar匹配算法为MlfEngine,它可以轻松更改或替换为不同的算法。本篇文档将介绍如何引入新的lidar匹配算法,添加新算法的步骤如下:

1. 定义一个继承基类 `base_multi_target_tracker` 的类
Expand All @@ -11,7 +19,7 @@ Apollo默认的lidar匹配算法为MlfEngine,它可以轻松更改或替换为

## 定义一个继承基类 `base_multi_target_tracker` 的类

所有的lidar匹配算法都必须继承基类`base_multi_target_tracker`,它定义了一组接口。 以下是匹配算法继承基类的示例:
所有的lidar匹配算法都必须继承基类 `base_multi_target_tracker`,它定义了一组接口。 以下是匹配算法继承基类的示例:

```c++
namespace apollo {
Expand All @@ -37,6 +45,48 @@ class NewLidarTracker : public BaseMultiTargetTracker {
} // namespace apollo
```
基类 `base_multi_target_tracker` 已定义好各虚函数签名,接口信息如下:
```c++
struct MultiTargetTrackerInitOptions {};
struct MultiTargetTrackerOptions {};
struct LidarFrame {
// point cloud
std::shared_ptr<base::AttributePointCloud<base::PointF>> cloud;
// world point cloud
std::shared_ptr<base::AttributePointCloud<base::PointD>> world_cloud;
// timestamp
double timestamp = 0.0;
// lidar to world pose
Eigen::Affine3d lidar2world_pose = Eigen::Affine3d::Identity();
// lidar to world pose
Eigen::Affine3d novatel2world_pose = Eigen::Affine3d::Identity();
// hdmap struct
std::shared_ptr<base::HdmapStruct> hdmap_struct = nullptr;
// segmented objects
std::vector<std::shared_ptr<base::Object>> segmented_objects;
// tracked objects
std::vector<std::shared_ptr<base::Object>> tracked_objects;
// point cloud roi indices
base::PointIndices roi_indices;
// point cloud non ground indices
base::PointIndices non_ground_indices;
// secondary segmentor indices
base::PointIndices secondary_indices;
// sensor info
base::SensorInfo sensor_info;
// reserve string
std::string reserve;
void Reset();
void FilterPointCloud(base::PointCloud<base::PointF> *filtered_cloud,
const std::vector<uint32_t> &indices);
};
```

## 实现新类 `NewLidarTracker`

为了确保新的匹配算法能顺利工作,`NewLidarTracker`至少需要重写`base_multi_target_tracker`中定义的接口Init(),Track()和Name()。其中Init()函数负责完成加载配置文件,初始化类成员等工作;而Track()则负责实现算法的主体流程。一个具体的`NewLidarTracker.cc`实现示例如下:
Expand Down
50 changes: 50 additions & 0 deletions docs/howto/how_to_add_a_new_lidar_tracker_algorithm_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# How to add a new lidar tracker algorithm

The processing flow of lidar perception module is shown below: :
![](https://github.com/ApolloAuto/apollo/blob/master/docs/specs/images/lidar_perception_data_flow.png)

The tracker algorithm introduced by this document is located at Recognition Component listed below. Current architecture of Recognition Component is shown:
![lidar recognition](images/lidar_recognition.png)

As we can see from above structure, lidar tracker algorithm, such as MlfEngine, is the derived class of `base_multi_target_tracker` which acts as a abstract class member of `base_lidar_obstacle_tracking` located in Recognition Component. Next, We will introduce how to add a new lidar tracker algorithm.

The default tracking algorithm of Apollo is MlfEngine,which cloud be easily changed or replaced by other algorithms. This document will introduce how to add a new lidar tracker algorithm, the basic task sequence is listed below:

1. Define a class that inherits `base_multi_target_tracker`
Expand Down Expand Up @@ -37,6 +45,48 @@ class NewLidarTracker : public BaseMultiTargetTracker {
} // namespace apollo
```
The function signature of `base_multi_target_tracker` is pre-defined:
```c++
struct MultiTargetTrackerInitOptions {};
struct MultiTargetTrackerOptions {};
struct LidarFrame {
// point cloud
std::shared_ptr<base::AttributePointCloud<base::PointF>> cloud;
// world point cloud
std::shared_ptr<base::AttributePointCloud<base::PointD>> world_cloud;
// timestamp
double timestamp = 0.0;
// lidar to world pose
Eigen::Affine3d lidar2world_pose = Eigen::Affine3d::Identity();
// lidar to world pose
Eigen::Affine3d novatel2world_pose = Eigen::Affine3d::Identity();
// hdmap struct
std::shared_ptr<base::HdmapStruct> hdmap_struct = nullptr;
// segmented objects
std::vector<std::shared_ptr<base::Object>> segmented_objects;
// tracked objects
std::vector<std::shared_ptr<base::Object>> tracked_objects;
// point cloud roi indices
base::PointIndices roi_indices;
// point cloud non ground indices
base::PointIndices non_ground_indices;
// secondary segmentor indices
base::PointIndices secondary_indices;
// sensor info
base::SensorInfo sensor_info;
// reserve string
std::string reserve;
void Reset();
void FilterPointCloud(base::PointCloud<base::PointF> *filtered_cloud,
const std::vector<uint32_t> &indices);
};
```

## Implement the class `NewLidarTracker`

To ensure the new tracker could function properly, `NewLidarTracker` should at least override the interface Init(), Track(), Name() defined in `base_multi_target_tracker`. Init() is resposible for config loading, class member initialization, etc. And Track() will implement the basic logic of algorithm. A concrete `NewLidarTracker.cc` example is shown:
Expand Down
Binary file added docs/howto/images/lidar_recognition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 539f1a5

Please sign in to comment.