Apollo 11.0
自动驾驶开放平台
environment_features.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
17
18#include "cyber/common/log.h"
19
20namespace apollo {
21namespace prediction {
22
23void EnvironmentFeatures::set_ego_position(const double x, const double y) {
24 ego_position_.set_x(x);
25 ego_position_.set_y(y);
26 ego_position_.set_z(0.0);
27}
28
30 return ego_position_;
31}
32
33void EnvironmentFeatures::set_ego_speed(const double ego_speed) {
34 ego_speed_ = ego_speed;
35}
36
37double EnvironmentFeatures::get_ego_speed() const { return ego_speed_; }
38
39void EnvironmentFeatures::set_ego_heading(const double ego_heading) {
40 ego_heading_ = ego_heading;
41}
42
43double EnvironmentFeatures::get_ego_heading() const { return ego_heading_; }
44
45void EnvironmentFeatures::set_ego_acceleration(const double ego_acceleration) {
46 ego_acceleration_ = ego_acceleration;
47}
48
50 return ego_acceleration_;
51}
52
53bool EnvironmentFeatures::has_ego_lane() const { return has_ego_lane_; }
54
56 has_ego_lane_ = false;
57 ego_lane_id_ = "";
58 ego_lane_s_ = -1.0;
59}
60
61void EnvironmentFeatures::SetEgoLane(const std::string& lane_id,
62 const double lane_s) {
63 has_ego_lane_ = true;
64 ego_lane_id_ = lane_id;
65 ego_lane_s_ = lane_s;
66}
67
68std::pair<std::string, double> EnvironmentFeatures::GetEgoLane() const {
69 ACHECK(has_ego_lane_);
70 return {ego_lane_id_, ego_lane_s_};
71}
72
74 return has_left_neighbor_lane_;
75}
76
78 has_left_neighbor_lane_ = false;
79}
80
81void EnvironmentFeatures::SetLeftNeighborLane(const std::string& lane_id,
82 const double lane_s) {
83 has_left_neighbor_lane_ = true;
84 left_neighbor_lane_id_ = lane_id;
85 left_neighbor_lane_s_ = lane_s;
86}
87
88std::pair<std::string, double> EnvironmentFeatures::GetLeftNeighborLane()
89 const {
90 ACHECK(has_left_neighbor_lane_);
91 return {left_neighbor_lane_id_, left_neighbor_lane_s_};
92}
93
95 return has_right_neighbor_lane_;
96}
97
99 has_right_neighbor_lane_ = false;
100}
101
102void EnvironmentFeatures::SetRightNeighborLane(const std::string& lane_id,
103 const double lane_s) {
104 has_right_neighbor_lane_ = true;
105 right_neighbor_lane_id_ = lane_id;
106 right_neighbor_lane_s_ = lane_s;
107}
108
109std::pair<std::string, double> EnvironmentFeatures::GetRightNeighborLane()
110 const {
111 ACHECK(has_right_neighbor_lane_);
112 return {right_neighbor_lane_id_, right_neighbor_lane_s_};
113}
114
116 return has_front_junction_;
117}
118
120 has_front_junction_ = false;
121}
122
123void EnvironmentFeatures::SetFrontJunction(const std::string& junction_id,
124 const double dist) {
125 has_front_junction_ = true;
126 front_junction_id_ = junction_id;
127 dist_to_front_junction_ = dist;
128}
129
130std::pair<std::string, double> EnvironmentFeatures::GetFrontJunction() const {
131 ACHECK(has_front_junction_);
132 return {front_junction_id_, dist_to_front_junction_};
133}
134
135void EnvironmentFeatures::AddObstacleId(const int obstacle_id) {
136 obstacle_ids_.push_back(obstacle_id);
137}
138
139const std::vector<int>& EnvironmentFeatures::get_obstacle_ids() const {
140 return obstacle_ids_;
141}
142
143const std::unordered_set<std::string>&
145 return nonneglectable_reverse_lanes_;
146}
147
149 const std::string& lane_id) {
150 nonneglectable_reverse_lanes_.insert(lane_id);
151}
152
154 const std::string& lane_id) {
155 if (nonneglectable_reverse_lanes_.find(lane_id) ==
156 nonneglectable_reverse_lanes_.end()) {
157 return false;
158 }
159 nonneglectable_reverse_lanes_.erase(lane_id);
160 return true;
161}
162
163} // namespace prediction
164} // namespace apollo
void set_ego_heading(const double ego_heading)
void SetRightNeighborLane(const std::string &lane_id, const double lane_s)
std::pair< std::string, double > GetLeftNeighborLane() const
const std::vector< int > & get_obstacle_ids() const
std::pair< std::string, double > GetRightNeighborLane() const
void SetLeftNeighborLane(const std::string &lane_id, const double lane_s)
const std::unordered_set< std::string > & nonneglectable_reverse_lanes() const
void SetEgoLane(const std::string &lane_id, const double lane_s)
const common::Point3D & get_ego_position() const
void set_ego_acceleration(const double ego_acceleration)
std::pair< std::string, double > GetEgoLane() const
std::pair< std::string, double > GetFrontJunction() const
void AddNonneglectableReverseLanes(const std::string &lane_id)
void SetFrontJunction(const std::string &junction_id, const double dist)
bool RemoveNonneglectableReverseLanes(const std::string &lane_id)
void set_ego_position(const double x, const double y)
#define ACHECK(cond)
Definition log.h:80
class register implement
Definition arena_queue.h:37