共計 1753 個字符,預計需要花費 5 分鐘才能閱讀完成。
這篇文章給大家分享的是有關 apollo 怎么在預測模塊中添加一個預測器的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
簡介
預測器為每個障礙物生成預測軌跡。在這里,假設我們想給我們的車輛增加一個新的預測器,用于其他類型的障礙。
添加預測器的步驟
如下步驟將會指導您在預測器中添加一個 NewPredictor:
定義一個繼承基類 Predictor 的類
實現新類 NewPredictor
在 prediction_conf.proto 中添加一個新的預測器類型
更新 prediction_conf
更新預測器管理器(Predictor manager)
下面讓我們用上面的方法來添加新的預測器。
一、定義一個繼承基類 Predictor 的類
在文件夾 modules/prediction/predictor/vehicle 中創建一個名為 new_predictor.h 的文件,文件內容如下:
#include modules/prediction/predictor/predictor.h
namespace apollo {
namespace prediction {
class NewPredictor : public Predictor {
public:
void Predict(Obstacle* obstacle) override;
// Other useful functions and fields.
} // namespace prediction
} // namespace apollo
二、Implement the class NewPredictor
在創建了 new_predictor.h 的文件夾中創建文件 new_predictor.cc。文件內容如下:
#include modules/prediction/predictor/vehicle/new_predictor.h
namespace apollo {
namespace prediction {NewPredictor::Predict(Obstacle* obstacle)() {
// Get the results from evaluator
// Generate the predicted trajectory
// Other functions
} // namespace prediction
} // namespace apollo
三、添加新的預測器類型
在 prediction_conf.proto 中添加新預測器類型:
enum PredictorType {
LANE_SEQUENCE_PREDICTOR = 0;
FREE_MOVE_PREDICTOR = 1;
REGIONAL_PREDICTOR = 2;
MOVE_SEQUENCE_PREDICTOR = 3;
NEW_PREDICTOR = 4;
}
四、更新 prediction_conf
在 modules/prediction/conf/prediction_conf.pb.txt 中, 更新 predictor_type 部分如下:
obstacle_conf {
obstacle_type: VEHICLE
obstacle_status: ON_LANE
evaluator_type: NEW_EVALUATOR
predictor_type: NEW_PREDICTOR
}
五、更新預測器管理器(Predictor manager)
更新 CreateEvluator(…) 如下:
case ObstacleConf::NEW_PREDICTOR: { predictor_ptr.reset(new NewPredictor());
break;
}
更新 RegisterPredictors() 如下:
1
RegisterPredictor(ObstacleConf::NEW_PREDICTOR);
感謝各位的閱讀!關于“apollo 怎么在預測模塊中添加一個預測器”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!