Apollo 10.0
自动驾驶开放平台
apollo::prediction::Obstacle类 参考

Prediction obstacle. 更多...

#include <obstacle.h>

apollo::prediction::Obstacle 的协作图:

Public 成员函数

 Obstacle ()=default
 
virtual ~Obstacle ()=default
 Destructor
 
void SetJunctionAnalyzer (JunctionAnalyzer *junction_analyzer)
 
bool Insert (const perception::PerceptionObstacle &perception_obstacle, const double timestamp, const int prediction_id)
 Insert a perception obstacle with its timestamp.
 
bool InsertFeature (const Feature &feature)
 Insert a feature proto message.
 
void ClearOldInformation ()
 
void TrimHistory (const size_t remain_size)
 
perception::PerceptionObstacle::Type type () const
 Get the type of perception obstacle's type.
 
bool IsPedestrian () const
 
int id () const
 Get the obstacle's ID.
 
double timestamp () const
 Get the obstacle's timestamp.
 
bool ReceivedOlderMessage (const double timestamp) const
 
const Featurefeature (const size_t i) const
 Get the ith feature from latest to earliest.
 
Featuremutable_feature (const size_t i)
 Get a pointer to the ith feature from latest to earliest.
 
const Featurelatest_feature () const
 Get the latest feature.
 
const Featureearliest_feature () const
 Get the earliest feature.
 
Featuremutable_latest_feature ()
 Get a pointer to the latest feature.
 
void SetNearbyObstacles ()
 Set nearby obstacles.
 
size_t history_size () const
 Get the number of historical features.
 
bool IsStill ()
 Check if the obstacle is still.
 
bool IsSlow ()
 Check if the obstacle is slow.
 
bool IsOnLane () const
 Check if the obstacle is on any lane.
 
bool ToIgnore ()
 Check if the obstacle can be ignored.
 
bool IsNearJunction ()
 Check if the obstacle is near a junction.
 
bool IsInJunction (const std::string &junction_id) const
 Check if the obstacle is a junction.
 
bool IsCloseToJunctionExit () const
 Check if the obstacle is close to a junction exit.
 
bool HasJunctionFeatureWithExits () const
 Check if the obstacle has junction feature.
 
void BuildJunctionFeature ()
 Build junction feature.
 
void BuildLaneGraph ()
 Build obstacle's lane graph
 
void BuildLaneGraphFromLeftToRight ()
 Build obstacle's lane graph with lanes being ordered.
 
void SetCaution ()
 Set the obstacle as caution level
 
bool IsCaution () const
 
void SetInteractiveTag ()
 Set the obstacle as interactive obstacle.
 
void SetNonInteractiveTag ()
 Set the obstacle as noninteractive obstacle.
 
bool IsInteractiveObstacle () const
 
void SetEvaluatorType (const ObstacleConf::EvaluatorType &evaluator_type)
 
void SetPredictorType (const ObstacleConf::PredictorType &predictor_type)
 
const ObstacleConfobstacle_conf ()
 
PredictionObstacle GeneratePredictionObstacle ()
 

静态 Public 成员函数

static std::unique_ptr< ObstacleCreate (const perception::PerceptionObstacle &perception_obstacle, const double timestamp, const int prediction_id, ObstacleClusters *clusters_ptr)
 Constructor
 
static std::unique_ptr< ObstacleCreate (const Feature &feature, ObstacleClusters *clusters_ptr)
 

详细描述

Prediction obstacle.

在文件 obstacle.h52 行定义.

构造及析构函数说明

◆ Obstacle()

apollo::prediction::Obstacle::Obstacle ( )
default

◆ ~Obstacle()

virtual apollo::prediction::Obstacle::~Obstacle ( )
virtualdefault

Destructor

成员函数说明

◆ BuildJunctionFeature()

void apollo::prediction::Obstacle::BuildJunctionFeature ( )

Build junction feature.

在文件 obstacle.cc242 行定义.

242 {
243 // If obstacle has no history at all, then exit.
244 if (feature_history_.empty()) {
245 AERROR << "Obstacle [" << id_ << "] has no history";
246 return;
247 }
248 // If obstacle is not in the given junction, then exit.
249 const std::string& junction_id = junction_analyzer_->GetJunctionId();
250 if (!IsInJunction(junction_id)) {
251 ADEBUG << "Obstacle [" << id_ << "] is not in junction [" << junction_id
252 << "]";
253 return;
254 }
255
256 // Set the junction features by calling SetJunctionFeatureWithoutEnterLane.
257 Feature* latest_feature_ptr = mutable_latest_feature();
258 if (feature_history_.size() == 1) {
259 SetJunctionFeatureWithoutEnterLane(latest_feature_ptr);
260 return;
261 }
262 const Feature& prev_feature = feature(1);
263 if (prev_feature.junction_feature().has_enter_lane()) {
264 ACHECK(prev_feature.junction_feature().enter_lane().has_lane_id());
265 std::string enter_lane_id =
266 prev_feature.junction_feature().enter_lane().lane_id();
267 // TODO(all) use enter lane when tracking is better
268 SetJunctionFeatureWithoutEnterLane(latest_feature_ptr);
269 } else {
270 SetJunctionFeatureWithoutEnterLane(latest_feature_ptr);
271 }
272}
const std::string & GetJunctionId()
Get junction ID
bool IsInJunction(const std::string &junction_id) const
Check if the obstacle is a junction.
Definition obstacle.cc:223
Feature * mutable_latest_feature()
Get a pointer to the latest feature.
Definition obstacle.cc:88
const Feature & feature(const size_t i) const
Get the ith feature from latest to earliest.
Definition obstacle.cc:67
#define ACHECK(cond)
Definition log.h:80
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

◆ BuildLaneGraph()

void apollo::prediction::Obstacle::BuildLaneGraph ( )

Build obstacle's lane graph

在文件 obstacle.cc804 行定义.

804 {
805 // Sanity checks.
806 if (history_size() == 0) {
807 AERROR << "No feature found.";
808 return;
809 }
810
811 Feature* feature = mutable_latest_feature();
812 // No need to BuildLaneGraph for those non-moving obstacles.
813 if (feature->is_still() && id_ != FLAGS_ego_vehicle_id) {
814 ADEBUG << "Not build lane graph for still obstacle";
815 return;
816 }
817 if (feature->lane().lane_graph().lane_sequence_size() > 0) {
818 ADEBUG << "Not build lane graph for an old obstacle";
819 return;
820 }
821 double speed = feature->speed();
822 double t_max = FLAGS_prediction_trajectory_time_length;
823 auto estimated_move_distance = speed * t_max;
824
825 double road_graph_search_distance = std::fmax(
826 estimated_move_distance, FLAGS_min_prediction_trajectory_spatial_length);
827
828 bool is_in_junction = HasJunctionFeatureWithExits();
829 std::unordered_set<std::string> exit_lane_id_set;
830 if (is_in_junction) {
831 for (const auto& exit : feature->junction_feature().junction_exit()) {
832 exit_lane_id_set.insert(exit.exit_lane_id());
833 }
834 }
835
836 // BuildLaneGraph for current lanes:
837 // Go through all the LaneSegments in current_lane,
838 // construct up to max_num_current_lane of them.
839 int seq_id = 0;
840 int curr_lane_count = 0;
841 for (auto& lane : feature->lane().current_lane_feature()) {
842 std::shared_ptr<const LaneInfo> lane_info =
843 PredictionMap::LaneById(lane.lane_id());
844 LaneGraph lane_graph = clusters_ptr_->GetLaneGraph(
845 lane.lane_s(), road_graph_search_distance, true, lane_info);
846 if (lane_graph.lane_sequence_size() > 0) {
847 ++curr_lane_count;
848 }
849 for (const auto& lane_seq : lane_graph.lane_sequence()) {
850 if (is_in_junction && !HasJunctionExitLane(lane_seq, exit_lane_id_set)) {
851 continue;
852 }
853 LaneSequence* lane_seq_ptr =
854 feature->mutable_lane()->mutable_lane_graph()->add_lane_sequence();
855 lane_seq_ptr->CopyFrom(lane_seq);
856 lane_seq_ptr->set_lane_sequence_id(seq_id++);
857 lane_seq_ptr->set_lane_s(lane.lane_s());
858 lane_seq_ptr->set_lane_l(lane.lane_l());
859 lane_seq_ptr->set_vehicle_on_lane(true);
860 lane_seq_ptr->set_lane_type(lane.lane_type());
861 SetLaneSequenceStopSign(lane_seq_ptr);
862 ADEBUG << "Obstacle [" << id_ << "] set a lane sequence ["
863 << lane_seq.ShortDebugString() << "].";
864 }
865 if (curr_lane_count >= FLAGS_max_num_current_lane) {
866 break;
867 }
868 }
869
870 // BuildLaneGraph for neighbor lanes.
871 int nearby_lane_count = 0;
872 for (auto& lane : feature->lane().nearby_lane_feature()) {
873 std::shared_ptr<const LaneInfo> lane_info =
874 PredictionMap::LaneById(lane.lane_id());
875 LaneGraph lane_graph = clusters_ptr_->GetLaneGraph(
876 lane.lane_s(), road_graph_search_distance, false, lane_info);
877 if (lane_graph.lane_sequence_size() > 0) {
878 ++nearby_lane_count;
879 }
880 for (const auto& lane_seq : lane_graph.lane_sequence()) {
881 if (is_in_junction && !HasJunctionExitLane(lane_seq, exit_lane_id_set)) {
882 continue;
883 }
884 LaneSequence* lane_seq_ptr =
885 feature->mutable_lane()->mutable_lane_graph()->add_lane_sequence();
886 lane_seq_ptr->CopyFrom(lane_seq);
887 lane_seq_ptr->set_lane_sequence_id(seq_id++);
888 lane_seq_ptr->set_lane_s(lane.lane_s());
889 lane_seq_ptr->set_lane_l(lane.lane_l());
890 lane_seq_ptr->set_vehicle_on_lane(false);
891 lane_seq_ptr->set_lane_type(lane.lane_type());
892 SetLaneSequenceStopSign(lane_seq_ptr);
893 ADEBUG << "Obstacle [" << id_ << "] set a lane sequence ["
894 << lane_seq.ShortDebugString() << "].";
895 }
896 if (nearby_lane_count >= FLAGS_max_num_nearby_lane) {
897 break;
898 }
899 }
900
901 if (feature->has_lane() && feature->lane().has_lane_graph()) {
902 SetLanePoints(feature);
903 SetLaneSequencePath(feature->mutable_lane()->mutable_lane_graph());
904 }
905 ADEBUG << "Obstacle [" << id_ << "] set lane graph features.";
906}
LaneGraph GetLaneGraph(const double start_s, const double length, const bool consider_lane_split, std::shared_ptr< const apollo::hdmap::LaneInfo > lane_info_ptr)
Obtain a lane graph given a lane info and s
bool HasJunctionFeatureWithExits() const
Check if the obstacle has junction feature.
Definition obstacle.cc:622
size_t history_size() const
Get the number of historical features.
Definition obstacle.cc:93
static std::shared_ptr< const hdmap::LaneInfo > LaneById(const std::string &id)
Get a shared pointer to a lane by lane ID.

◆ BuildLaneGraphFromLeftToRight()

void apollo::prediction::Obstacle::BuildLaneGraphFromLeftToRight ( )

Build obstacle's lane graph with lanes being ordered.

This would be useful for lane-scanning algorithms.

在文件 obstacle.cc981 行定义.

981 {
982 // Sanity checks.
983 if (history_size() == 0) {
984 AERROR << "No feature found.";
985 return;
986 }
987
988 // No need to BuildLaneGraph for those non-moving obstacles.
989 Feature* feature = mutable_latest_feature();
990 if (feature->is_still()) {
991 ADEBUG << "Don't build lane graph for non-moving obstacle.";
992 return;
993 }
994 if (feature->lane().lane_graph_ordered().lane_sequence_size() > 0) {
995 ADEBUG << "Don't build lane graph for an old obstacle.";
996 return;
997 }
998 // double speed = feature->speed();
999 double road_graph_search_distance = 50.0 * 0.95; // (45mph for 3sec)
1000 // std::fmax(speed * FLAGS_prediction_trajectory_time_length +
1001 // 0.5 * FLAGS_vehicle_max_linear_acc *
1002 // FLAGS_prediction_trajectory_time_length *
1003 // FLAGS_prediction_trajectory_time_length,
1004 // FLAGS_min_prediction_trajectory_spatial_length);
1005
1006 // Treat the most probable lane_segment as the center, put its left
1007 // and right neighbors into a vector following the left-to-right order.
1008 if (!feature->has_lane() || !feature->lane().has_lane_feature()) {
1009 return;
1010 }
1011
1012 bool is_in_junction = HasJunctionFeatureWithExits();
1013 std::unordered_set<std::string> exit_lane_id_set;
1014 if (is_in_junction) {
1015 for (const auto& exit : feature->junction_feature().junction_exit()) {
1016 exit_lane_id_set.insert(exit.exit_lane_id());
1017 }
1018 }
1019
1020 std::shared_ptr<const LaneInfo> center_lane_info =
1021 PredictionMap::LaneById(feature->lane().lane_feature().lane_id());
1022 std::list<std::string> lane_ids_ordered_list;
1023 std::unordered_set<std::string> existing_lane_ids;
1024 GetNeighborLaneSegments(center_lane_info, true, 2, &lane_ids_ordered_list,
1025 &existing_lane_ids);
1026 lane_ids_ordered_list.push_back(feature->lane().lane_feature().lane_id());
1027 existing_lane_ids.insert(feature->lane().lane_feature().lane_id());
1028 GetNeighborLaneSegments(center_lane_info, false, 2, &lane_ids_ordered_list,
1029 &existing_lane_ids);
1030
1031 const std::vector<std::string> lane_ids_ordered(lane_ids_ordered_list.begin(),
1032 lane_ids_ordered_list.end());
1033 // TODO(all): sort the lane_segments from left to right (again)
1034 // to double-check and make sure it's well sorted.
1035 // Build lane_graph for every lane_segment and update it into proto.
1036 int seq_id = 0;
1037 for (const std::string& lane_id : lane_ids_ordered) {
1038 // Construct the local lane_graph based on the current lane_segment.
1039 bool vehicle_is_on_lane = (lane_id == center_lane_info->lane().id().id());
1040 std::shared_ptr<const LaneInfo> curr_lane_info =
1041 PredictionMap::LaneById(lane_id);
1042 LaneGraph local_lane_graph = clusters_ptr_->GetLaneGraphWithoutMemorizing(
1043 feature->lane().lane_feature().lane_s(), road_graph_search_distance,
1044 true, curr_lane_info);
1045 // Update it into the Feature proto
1046 for (const auto& lane_seq : local_lane_graph.lane_sequence()) {
1047 if (is_in_junction && !HasJunctionExitLane(lane_seq, exit_lane_id_set)) {
1048 continue;
1049 }
1050 LaneSequence* lane_seq_ptr = feature->mutable_lane()
1051 ->mutable_lane_graph_ordered()
1052 ->add_lane_sequence();
1053 lane_seq_ptr->CopyFrom(lane_seq);
1054 lane_seq_ptr->set_lane_sequence_id(seq_id++);
1055 lane_seq_ptr->set_lane_s(feature->lane().lane_feature().lane_s());
1056 lane_seq_ptr->set_lane_l(feature->lane().lane_feature().lane_l());
1057 lane_seq_ptr->set_vehicle_on_lane(vehicle_is_on_lane);
1058 ADEBUG << "Obstacle [" << id_ << "] set a lane sequence ["
1059 << lane_seq.ShortDebugString() << "].";
1060 }
1061 }
1062
1063 // Build lane_points.
1064 if (feature->lane().has_lane_graph_ordered()) {
1065 SetLanePoints(feature, 0.5, 100, true,
1066 feature->mutable_lane()->mutable_lane_graph_ordered());
1067 SetLaneSequencePath(feature->mutable_lane()->mutable_lane_graph_ordered());
1068 }
1069 ADEBUG << "Obstacle [" << id_ << "] set lane graph features.";
1070}
LaneGraph GetLaneGraphWithoutMemorizing(const double start_s, const double length, const bool is_on_lane, std::shared_ptr< const apollo::hdmap::LaneInfo > lane_info_ptr)
Obtain a lane graph given a lane info and s, but don't memorize it.

◆ ClearOldInformation()

void apollo::prediction::Obstacle::ClearOldInformation ( )

在文件 obstacle.cc205 行定义.

205 {
206 if (feature_history_.size() <= 1) {
207 return;
208 }
209 feature_history_[1].clear_predicted_trajectory();
210 Lane* lane = feature_history_[1].mutable_lane();
211 lane->clear_current_lane_feature();
212 lane->clear_nearby_lane_feature();
213 lane->clear_lane_graph();
214 lane->clear_lane_graph_ordered();
215}

◆ Create() [1/2]

std::unique_ptr< Obstacle > apollo::prediction::Obstacle::Create ( const Feature feature,
ObstacleClusters clusters_ptr 
)
static

在文件 obstacle.cc1417 行定义.

1418 {
1419 std::unique_ptr<Obstacle> ptr_obstacle(new Obstacle());
1420 ptr_obstacle->SetClusters(clusters_ptr);
1421 ptr_obstacle->InsertFeatureToHistory(feature);
1422 return ptr_obstacle;
1423}

◆ Create() [2/2]

std::unique_ptr< Obstacle > apollo::prediction::Obstacle::Create ( const perception::PerceptionObstacle perception_obstacle,
const double  timestamp,
const int  prediction_id,
ObstacleClusters clusters_ptr 
)
static

Constructor

在文件 obstacle.cc1406 行定义.

1408 {
1409 std::unique_ptr<Obstacle> ptr_obstacle(new Obstacle());
1410 ptr_obstacle->SetClusters(clusters_ptr);
1411 if (!ptr_obstacle->Insert(perception_obstacle, timestamp, prediction_id)) {
1412 return nullptr;
1413 }
1414 return ptr_obstacle;
1415}
double timestamp() const
Get the obstacle's timestamp.
Definition obstacle.cc:62

◆ earliest_feature()

const Feature & apollo::prediction::Obstacle::earliest_feature ( ) const

Get the earliest feature.

返回
The earliest feature.

在文件 obstacle.cc83 行定义.

83 {
84 ACHECK(!feature_history_.empty());
85 return feature_history_.back();
86}

◆ feature()

const Feature & apollo::prediction::Obstacle::feature ( const size_t  i) const

Get the ith feature from latest to earliest.

参数
iThe index of the feature.
返回
The ith feature.

在文件 obstacle.cc67 行定义.

67 {
68 ACHECK(i < feature_history_.size());
69 return feature_history_[i];
70}

◆ GeneratePredictionObstacle()

PredictionObstacle apollo::prediction::Obstacle::GeneratePredictionObstacle ( )

在文件 obstacle.cc1494 行定义.

1494 {
1495 PredictionObstacle prediction_obstacle;
1496 // TODO(kechxu) implement
1497 return prediction_obstacle;
1498}

◆ HasJunctionFeatureWithExits()

bool apollo::prediction::Obstacle::HasJunctionFeatureWithExits ( ) const

Check if the obstacle has junction feature.

返回
If the obstacle has junction feature.

在文件 obstacle.cc622 行定义.

622 {
623 if (history_size() == 0) {
624 return false;
625 }
626 return latest_feature().has_junction_feature() &&
627 latest_feature().junction_feature().junction_exit_size() > 0;
628}
const Feature & latest_feature() const
Get the latest feature.
Definition obstacle.cc:78
optional JunctionFeature junction_feature

◆ history_size()

size_t apollo::prediction::Obstacle::history_size ( ) const

Get the number of historical features.

返回
The number of historical features.

在文件 obstacle.cc93 行定义.

93{ return feature_history_.size(); }

◆ id()

int apollo::prediction::Obstacle::id ( ) const

Get the obstacle's ID.

返回
The obstacle's ID.

在文件 obstacle.cc60 行定义.

60{ return id_; }

◆ Insert()

bool apollo::prediction::Obstacle::Insert ( const perception::PerceptionObstacle perception_obstacle,
const double  timestamp,
const int  prediction_id 
)

Insert a perception obstacle with its timestamp.

参数
perception_obstacleThe obstacle from perception.
timestampThe timestamp when the perception obstacle was detected.

在文件 obstacle.cc140 行定义.

142 {
143 if (!perception_obstacle.has_id() || !perception_obstacle.has_type()) {
144 AERROR << "Perception obstacle has incomplete information; "
145 "skip insertion";
146 return false;
147 }
148
150 AERROR << "Obstacle [" << id_ << "] received an older frame ["
151 << std::setprecision(20) << timestamp
152 << "] than the most recent timestamp [ " << this->timestamp()
153 << "].";
154 return false;
155 }
156
157 // Set ID, Type, and Status of the feature.
158 Feature feature;
159 if (!SetId(perception_obstacle, &feature, prediction_obstacle_id)) {
160 return false;
161 }
162
163 SetType(perception_obstacle, &feature);
164
165 SetStatus(perception_obstacle, timestamp, &feature);
166
167 // Set obstacle lane features
168 if (type_ != PerceptionObstacle::PEDESTRIAN) {
169 SetCurrentLanes(&feature);
170 SetNearbyLanes(&feature);
171 }
172
173 if (FLAGS_prediction_offline_mode ==
175 SetSurroundingLaneIds(&feature, FLAGS_surrounding_lane_search_radius);
176 }
177
178 if (FLAGS_adjust_vehicle_heading_by_lane &&
180 AdjustHeadingByLane(&feature);
181 }
182
183 // Insert obstacle feature to history
184 InsertFeatureToHistory(feature);
185
186 // Set obstacle motion status
187 if (FLAGS_use_navigation_mode) {
188 SetMotionStatusBySpeed();
189 } else {
190 SetMotionStatus();
191 }
192
193 // Trim historical features
194 DiscardOutdatedHistory();
195 return true;
196}
bool ReceivedOlderMessage(const double timestamp) const
Definition obstacle.cc:1425

◆ InsertFeature()

bool apollo::prediction::Obstacle::InsertFeature ( const Feature feature)

Insert a feature proto message.

参数
featureproto message.

在文件 obstacle.cc198 行定义.

198 {
199 InsertFeatureToHistory(feature);
200 type_ = feature.type();
201 id_ = feature.id();
202 return true;
203}
optional apollo::perception::PerceptionObstacle::Type type

◆ IsCaution()

bool apollo::prediction::Obstacle::IsCaution ( ) const

在文件 obstacle.cc1453 行定义.

1453 {
1454 if (feature_history_.empty()) {
1455 return false;
1456 }
1457 const Feature& feature = latest_feature();
1459}
optional ObstaclePriority priority

◆ IsCloseToJunctionExit()

bool apollo::prediction::Obstacle::IsCloseToJunctionExit ( ) const

Check if the obstacle is close to a junction exit.

返回
If the obstacle is closed to a junction exit.

在文件 obstacle.cc274 行定义.

274 {
276 AERROR << "No junction feature found";
277 return false;
278 }
279 CHECK_GT(history_size(), 0U);
280 const Feature& latest_feature = feature_history_.front();
281 double position_x = latest_feature.position().x();
282 double position_y = latest_feature.position().y();
283 double raw_velocity_heading = std::atan2(latest_feature.raw_velocity().y(),
285 for (const JunctionExit& junction_exit :
286 latest_feature.junction_feature().junction_exit()) {
287 double exit_x = junction_exit.exit_position().x();
288 double exit_y = junction_exit.exit_position().y();
289 double exit_heading = junction_exit.exit_heading();
290 if (IsClosed(position_x, position_y, raw_velocity_heading, exit_x, exit_y,
291 exit_heading)) {
292 return true;
293 }
294 }
295 return false;
296}
optional apollo::common::Point3D raw_velocity
Definition feature.proto:91
optional apollo::common::Point3D position
Definition feature.proto:88

◆ IsInJunction()

bool apollo::prediction::Obstacle::IsInJunction ( const std::string &  junction_id) const

Check if the obstacle is a junction.

参数
junctionID
返回
If the obstacle is in a junction.

在文件 obstacle.cc223 行定义.

223 {
224 // TODO(all) Consider if need to use vehicle front rather than position
225 if (feature_history_.empty()) {
226 AERROR << "Obstacle [" << id_ << "] has no history";
227 return false;
228 }
229 if (junction_id.empty()) {
230 return false;
231 }
232 std::shared_ptr<const JunctionInfo> junction_info_ptr =
233 PredictionMap::JunctionById(junction_id);
234 if (junction_info_ptr == nullptr) {
235 return false;
236 }
237 const auto& position = latest_feature().position();
238 return PredictionMap::IsPointInJunction(position.x(), position.y(),
239 junction_info_ptr);
240}
static bool IsPointInJunction(const double x, const double y, const std::shared_ptr< const hdmap::JunctionInfo > junction_info_ptr)
Check if a point with coord x and y is in the junction.
static std::shared_ptr< const hdmap::JunctionInfo > JunctionById(const std::string &id)
Get a shared pointer to a junction by junction ID.

◆ IsInteractiveObstacle()

bool apollo::prediction::Obstacle::IsInteractiveObstacle ( ) const

在文件 obstacle.cc1475 行定义.

1475 {
1476 if (feature_history_.empty()) {
1477 return false;
1478 }
1479 const Feature& feature = latest_feature();
1482}
optional ObstacleInteractiveTag interactive_tag
optional InteractiveTag interactive_tag
Definition feature.proto:74

◆ IsNearJunction()

bool apollo::prediction::Obstacle::IsNearJunction ( )

Check if the obstacle is near a junction.

返回
If the obstacle is near a junction.

在文件 obstacle.cc130 行定义.

130 {
131 if (feature_history_.empty()) {
132 return false;
133 }
134 double pos_x = latest_feature().position().x();
135 double pos_y = latest_feature().position().y();
136 return PredictionMap::NearJunction({pos_x, pos_y},
137 FLAGS_junction_search_radius);
138}
static bool NearJunction(const Eigen::Vector2d &point, const double radius)
Check if there are any junctions within the range centered at a certain point with a radius.

◆ IsOnLane()

bool apollo::prediction::Obstacle::IsOnLane ( ) const

Check if the obstacle is on any lane.

返回
If the obstacle is on any lane.

在文件 obstacle.cc107 行定义.

107 {
108 if (feature_history_.empty() || !latest_feature().has_lane() ||
109 latest_feature().lane().current_lane_feature().empty()) {
110 return false;
111 }
112 for (const auto& curr_lane : latest_feature().lane().current_lane_feature()) {
113 if (curr_lane.lane_type() != hdmap::Lane::CITY_DRIVING &&
114 curr_lane.lane_type() != hdmap::Lane::BIKING) {
115 return false;
116 }
117 }
118
119 ADEBUG << "Obstacle [" << id_ << "] is on lane.";
120 return true;
121}

◆ IsPedestrian()

bool apollo::prediction::Obstacle::IsPedestrian ( ) const

在文件 obstacle.cc56 行定义.

56 {
57 return type_ == PerceptionObstacle::PEDESTRIAN;
58}

◆ IsSlow()

bool apollo::prediction::Obstacle::IsSlow ( )

Check if the obstacle is slow.

返回
If the obstacle is slow.

在文件 obstacle.cc102 行定义.

102 {
103 const Feature& feature = latest_feature();
104 return feature.speed() < FLAGS_slow_obstacle_speed_threshold;
105}

◆ IsStill()

bool apollo::prediction::Obstacle::IsStill ( )

Check if the obstacle is still.

返回
If the obstacle is still.

在文件 obstacle.cc95 行定义.

95 {
96 if (feature_history_.size() > 0) {
97 return feature_history_.front().is_still();
98 }
99 return true;
100}

◆ latest_feature()

const Feature & apollo::prediction::Obstacle::latest_feature ( ) const

Get the latest feature.

返回
The latest feature.

在文件 obstacle.cc78 行定义.

78 {
79 ACHECK(!feature_history_.empty());
80 return feature_history_.front();
81}

◆ mutable_feature()

Feature * apollo::prediction::Obstacle::mutable_feature ( const size_t  i)

Get a pointer to the ith feature from latest to earliest.

参数
iThe index of the feature.
返回
A pointer to the ith feature.

在文件 obstacle.cc72 行定义.

72 {
73 ACHECK(!feature_history_.empty());
74 ACHECK(i < feature_history_.size());
75 return &feature_history_[i];
76}

◆ mutable_latest_feature()

Feature * apollo::prediction::Obstacle::mutable_latest_feature ( )

Get a pointer to the latest feature.

返回
A pointer to the latest feature.

在文件 obstacle.cc88 行定义.

88 {
89 ACHECK(!feature_history_.empty());
90 return &(feature_history_.front());
91}

◆ obstacle_conf()

const ObstacleConf & apollo::prediction::Obstacle::obstacle_conf ( )
inline

在文件 obstacle.h246 行定义.

246{ return obstacle_conf_; }

◆ ReceivedOlderMessage()

bool apollo::prediction::Obstacle::ReceivedOlderMessage ( const double  timestamp) const

在文件 obstacle.cc1425 行定义.

1425 {
1426 if (feature_history_.empty()) {
1427 return false;
1428 }
1429 auto last_timestamp_received = feature_history_.front().timestamp();
1430 return timestamp <= last_timestamp_received;
1431}

◆ SetCaution()

void apollo::prediction::Obstacle::SetCaution ( )

Set the obstacle as caution level

在文件 obstacle.cc1447 行定义.

1447 {
1448 CHECK_GT(feature_history_.size(), 0U);
1449 Feature* feature = mutable_latest_feature();
1450 feature->mutable_priority()->set_priority(ObstaclePriority::CAUTION);
1451}

◆ SetEvaluatorType()

void apollo::prediction::Obstacle::SetEvaluatorType ( const ObstacleConf::EvaluatorType evaluator_type)

在文件 obstacle.cc1484 行定义.

1485 {
1486 obstacle_conf_.set_evaluator_type(evaluator_type);
1487}

◆ SetInteractiveTag()

void apollo::prediction::Obstacle::SetInteractiveTag ( )

Set the obstacle as interactive obstacle.

在文件 obstacle.cc1461 行定义.

1461 {
1462 CHECK_GT(feature_history_.size(), 0U);
1463 Feature* feature = mutable_latest_feature();
1464 feature->mutable_interactive_tag()
1465 ->set_interactive_tag(ObstacleInteractiveTag::INTERACTION);
1466}

◆ SetJunctionAnalyzer()

void apollo::prediction::Obstacle::SetJunctionAnalyzer ( JunctionAnalyzer junction_analyzer)
inline

在文件 obstacle.h72 行定义.

72 {
73 junction_analyzer_ = junction_analyzer;
74 }

◆ SetNearbyObstacles()

void apollo::prediction::Obstacle::SetNearbyObstacles ( )

Set nearby obstacles.

在文件 obstacle.cc1279 行定义.

1279 {
1280 // This function runs after all basic features have been set up
1281 Feature* feature_ptr = mutable_latest_feature();
1282
1283 LaneGraph* lane_graph = feature_ptr->mutable_lane()->mutable_lane_graph();
1284 for (int i = 0; i < lane_graph->lane_sequence_size(); ++i) {
1285 LaneSequence* lane_sequence = lane_graph->mutable_lane_sequence(i);
1286 if (lane_sequence->lane_segment_size() == 0) {
1287 AERROR << "Empty lane sequence found.";
1288 continue;
1289 }
1290 double obstacle_s = lane_sequence->lane_s();
1291 double obstacle_l = lane_sequence->lane_l();
1292 NearbyObstacle forward_obstacle;
1293 if (clusters_ptr_->ForwardNearbyObstacle(*lane_sequence, id_, obstacle_s,
1294 obstacle_l, &forward_obstacle)) {
1295 lane_sequence->add_nearby_obstacle()->CopyFrom(forward_obstacle);
1296 }
1297 NearbyObstacle backward_obstacle;
1298 if (clusters_ptr_->BackwardNearbyObstacle(*lane_sequence, id_, obstacle_s,
1299 obstacle_l, &backward_obstacle)) {
1300 lane_sequence->add_nearby_obstacle()->CopyFrom(backward_obstacle);
1301 }
1302 }
1303}
bool ForwardNearbyObstacle(const LaneSequence &lane_sequence, const double s, LaneObstacle *const lane_obstacle)
Get the nearest obstacle on lane sequence at s
bool BackwardNearbyObstacle(const LaneSequence &lane_sequence, const int obstacle_id, const double obstacle_s, const double obstacle_l, NearbyObstacle *const nearby_obstacle_ptr)
Get the backward nearest obstacle on lane sequence at s

◆ SetNonInteractiveTag()

void apollo::prediction::Obstacle::SetNonInteractiveTag ( )

Set the obstacle as noninteractive obstacle.

在文件 obstacle.cc1468 行定义.

1468 {
1469 CHECK_GT(feature_history_.size(), 0U);
1470 Feature* feature = mutable_latest_feature();
1471 feature->mutable_interactive_tag()
1472 ->set_interactive_tag(ObstacleInteractiveTag::NONINTERACTION);
1473}

◆ SetPredictorType()

void apollo::prediction::Obstacle::SetPredictorType ( const ObstacleConf::PredictorType predictor_type)

在文件 obstacle.cc1489 行定义.

1490 {
1491 obstacle_conf_.set_predictor_type(predictor_type);
1492}

◆ timestamp()

double apollo::prediction::Obstacle::timestamp ( ) const

Get the obstacle's timestamp.

返回
The obstacle's timestamp.

在文件 obstacle.cc62 行定义.

62 {
63 ACHECK(!feature_history_.empty());
64 return feature_history_.front().timestamp();
65}

◆ ToIgnore()

bool apollo::prediction::Obstacle::ToIgnore ( )

Check if the obstacle can be ignored.

返回
If the obstacle can be ignored.

在文件 obstacle.cc123 行定义.

123 {
124 if (feature_history_.empty()) {
125 return true;
126 }
128}

◆ TrimHistory()

void apollo::prediction::Obstacle::TrimHistory ( const size_t  remain_size)

在文件 obstacle.cc217 行定义.

217 {
218 if (feature_history_.size() > remain_size) {
219 feature_history_.resize(remain_size);
220 }
221}

◆ type()

PerceptionObstacle::Type apollo::prediction::Obstacle::type ( ) const

Get the type of perception obstacle's type.

返回
The type pf perception obstacle.

在文件 obstacle.cc54 行定义.

54{ return type_; }

该类的文档由以下文件生成: