How does apollo add a predictor to the prediction module
This article is about how apollo adds a predictor to the prediction module. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Brief introduction
The predictor generates a prediction trajectory for each obstacle. Here, suppose we want to add a new predictor to our vehicle for other types of obstacles.
To add a predictor
The following steps will guide you to add a NewPredictor to the predictor:
Define a class that inherits the base class Predictor
Implement a new class NewPredictor
Add a new predictor type to prediction_conf.proto
Update prediction_conf
Update predictor Manager (Predictor manager)
Let's use the above method to add a new predictor.
Define a class that inherits the base class Predictor
Create a file called new_predictor.h in the folder modules/prediction/predictor/vehicle with the following contents:
# 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
II. Implement the class NewPredictor
Create the file new_predictor.cc in the folder where the new_predictor.h was created. The contents of the document are as follows:
# 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
Add a new type of predictor
Add a new predictor type to prediction_conf.proto:
Enum PredictorType {LANE_SEQUENCE_PREDICTOR = 0; FREE_MOVE_PREDICTOR = 1; REGIONAL_PREDICTOR = 2; MOVE_SEQUENCE_PREDICTOR = 3; NEW_PREDICTOR = 4;}
Update prediction_conf
In modules/prediction/conf/prediction_conf.pb.txt, the update predictor_type section is as follows:
Obstacle_conf {obstacle_type: VEHICLE obstacle_status: ON_LANE evaluator_type: NEW_EVALUATOR predictor_type: NEW_PREDICTOR}
Update predictor Manager (Predictor manager)
Update CreateEvluator (...) as follows:
Case ObstacleConf::NEW_PREDICTOR: {predictor_ptr.reset (new NewPredictor ()); break;}
Update RegisterPredictors () as follows:
1RegisterPredictor (ObstacleConf::NEW_PREDICTOR): thank you for reading! This is the end of the article on "how to add a predictor to the apollo prediction module". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!