Apollo 10.0
自动驾驶开放平台
apollo::hdmap::MapUtil类 参考
apollo::hdmap::MapUtil 的协作图:

Public 成员函数

const OverlapInfoGetOverlap (const std::string &overlap_id) const
 
 GET_ELEMENT_BY_ID (ClearArea)
 
 GET_ELEMENT_BY_ID (Crosswalk)
 
 GET_ELEMENT_BY_ID (Junction)
 
 GET_ELEMENT_BY_ID (Lane)
 
 GET_ELEMENT_BY_ID (Signal)
 
 GET_ELEMENT_BY_ID (SpeedBump)
 
 GET_ELEMENT_BY_ID (StopSign)
 
 GET_ELEMENT_BY_ID (YieldSign)
 
template<class T >
void Print (const T &t)
 
int PointToSL (const PointENU &point, std::string *lane_id, double *s, double *l, double *heading) const
 
int SLToPoint (LaneInfoConstPtr lane_ptr, const double s, const double l, PointENU *point, double *heading) const
 
int LaneProjection (const apollo::common::math::Vec2d &vec2d, const std::string &lane_id, double *s, double *l, double *heading) const
 
void PrintOverlap (const std::string &overlap_id)
 
void PrintLane (const std::string &lane_id)
 
void PrintLane (LaneInfoConstPtr lane_ptr)
 

详细描述

在文件 map_xysl.cc78 行定义.

成员函数说明

◆ GET_ELEMENT_BY_ID() [1/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( ClearArea  )

◆ GET_ELEMENT_BY_ID() [2/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( Crosswalk  )

◆ GET_ELEMENT_BY_ID() [3/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( Junction  )

◆ GET_ELEMENT_BY_ID() [4/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( Lane  )

◆ GET_ELEMENT_BY_ID() [5/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( Signal  )

◆ GET_ELEMENT_BY_ID() [6/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( SpeedBump  )

◆ GET_ELEMENT_BY_ID() [7/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( StopSign  )

◆ GET_ELEMENT_BY_ID() [8/8]

apollo::hdmap::MapUtil::GET_ELEMENT_BY_ID ( YieldSign  )

◆ GetOverlap()

const OverlapInfo * apollo::hdmap::MapUtil::GetOverlap ( const std::string &  overlap_id) const
inline

在文件 map_xysl.cc80 行定义.

80 {
81 auto ret = HDMapUtil::BaseMap().GetOverlapById(MakeMapId(overlap_id));
82 AERROR_IF(ret == nullptr) << "failed to find overlap[" << overlap_id << "]";
83 return ret.get();
84 }
static const HDMap & BaseMap()
OverlapInfoConstPtr GetOverlapById(const Id &id) const
Definition hdmap.cc:74
#define AERROR_IF(cond)
Definition log.h:74
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
Definition hdmap_util.h:85

◆ LaneProjection()

int apollo::hdmap::MapUtil::LaneProjection ( const apollo::common::math::Vec2d vec2d,
const std::string &  lane_id,
double *  s,
double *  l,
double *  heading 
) const
inline

在文件 map_xysl.cc129 行定义.

131 {
132 QUIT_IF(s == nullptr, -1, ERROR, "arg s is nullptr");
133 const auto lane = HDMapUtil::BaseMap().GetLaneById(MakeMapId(lane_id));
134 QUIT_IF(lane == nullptr, -2, ERROR, "GetSignal_by_id[%s] failed",
135 lane_id.c_str());
136 bool ret = lane->GetProjection(vec2d, s, l);
137 QUIT_IF(!ret, -3, ERROR, "lane[%s] get projection for point[%f, %f] failed",
138 lane_id.c_str(), vec2d.x(), vec2d.y());
139 *heading = lane->Heading(*s);
140 return 0;
141 }
double y() const
Getter for y component
Definition vec2d.h:57
double x() const
Getter for x component
Definition vec2d.h:54
LaneInfoConstPtr GetLaneById(const Id &id) const
Definition hdmap.cc:34
#define QUIT_IF(CONDITION, RET, LEVEL, MSG,...)
Definition map_xysl.cc:50

◆ PointToSL()

int apollo::hdmap::MapUtil::PointToSL ( const PointENU point,
std::string *  lane_id,
double *  s,
double *  l,
double *  heading 
) const
inline

在文件 map_xysl.cc100 行定义.

101 {
102 QUIT_IF(lane_id == nullptr, -1, ERROR, "arg lane id is null");
103 QUIT_IF(s == nullptr, -2, ERROR, "arg s is null");
104 QUIT_IF(l == nullptr, -3, ERROR, "arg l is null");
105 LaneInfoConstPtr lane = nullptr;
106 int ret = HDMapUtil::BaseMap().GetNearestLane(point, &lane, s, l);
107 QUIT_IF(ret != 0, -4, ERROR, "get_nearest_lane failed with ret[%d]", ret);
108 QUIT_IF(lane == nullptr, -5, ERROR, "lane is null");
109 *lane_id = lane->id().id();
110 *heading = lane->Heading(*s);
111 return 0;
112 }
int GetNearestLane(const apollo::common::PointENU &point, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
get nearest lane from target point,
Definition hdmap.cc:170
std::shared_ptr< const LaneInfo > LaneInfoConstPtr

◆ Print()

template<class T >
void apollo::hdmap::MapUtil::Print ( const T &  t)
inline

在文件 map_xysl.cc96 行定义.

96 {
97 std::cout << t.DebugString();
98 }

◆ PrintLane() [1/2]

void apollo::hdmap::MapUtil::PrintLane ( const std::string &  lane_id)
inline

在文件 map_xysl.cc185 行定义.

185{ PrintLane(GetLane(lane_id)); }
void PrintLane(const std::string &lane_id)
Definition map_xysl.cc:185

◆ PrintLane() [2/2]

void apollo::hdmap::MapUtil::PrintLane ( LaneInfoConstPtr  lane_ptr)
inline

在文件 map_xysl.cc186 行定义.

186 {
187 const auto &lane = lane_ptr->lane();
188 PointENU start_point;
189 double start_heading = 0.0;
190 SLToPoint(lane_ptr, 0, 0, &start_point, &start_heading);
191
192 PointENU end_point;
193 double end_heading = 0.0;
194 SLToPoint(lane_ptr, lane_ptr->total_length(), 0, &end_point, &end_heading);
195
196 double left_width = 0.0;
197 double right_width = 0.0;
198 lane_ptr->GetWidth(FLAGS_s, &left_width, &right_width);
199
200 std::cout << "lane[" << FLAGS_lane << std::fixed << "] length["
201 << lane_ptr->total_length() << "] type["
202 << Lane_LaneType_Name(lane.type()) << "] turn["
203 << Lane_LaneTurn_Name(lane.turn()) << "] speed_limit["
204 << lane.speed_limit() << "] predecessor[" << lane.predecessor_id()
205 << "] successor[" << lane.successor_id() << "] left_forward["
206 << lane.left_neighbor_forward_lane_id() << "] right_forward["
207 << lane.right_neighbor_forward_lane_id() << "] left_reverse["
208 << lane.left_neighbor_reverse_lane_id() << "] right_reverse["
209 << lane.right_neighbor_reverse_lane_id() << "], "
210 << "Left Boundary: [ virtual?:" << std::boolalpha
211 << lane.left_boundary().virtual_() << ", Type: [";
212 for (const auto &boundary_type : lane.left_boundary().boundary_type()) {
213 std::cout << "s: " << boundary_type.s() << "->";
214 for (const auto t : boundary_type.types()) {
215 std::cout << LaneBoundaryType::Type_Name(
216 static_cast<LaneBoundaryType::Type>(t))
217 << ", ";
218 }
219 }
220
221 std::cout << "]; Right Boundary: [ virtual?:" << std::boolalpha
222 << lane.right_boundary().virtual_() << ", Type: ";
223 for (const auto &boundary_type : lane.left_boundary().boundary_type()) {
224 std::cout << "s: " << boundary_type.s() << "->";
225 for (const auto t : boundary_type.types()) {
226 std::cout << LaneBoundaryType::Type_Name(
227 static_cast<LaneBoundaryType::Type>(t))
228 << ", ";
229 }
230 }
231 std::cout << "] overlap[" << lane.overlap_id() << "];"
232 << " start point(x,y,heading):" << start_point.x() << ","
233 << start_point.y() << "," << start_heading
234 << " end point(x,y,heading):" << end_point.x() << ","
235 << end_point.y() << "," << end_heading
236 << " left_width:" << left_width << " right_width:" << right_width
237 << std::endl;
238 std::cout.unsetf(std::ios_base::fixed);
239
240 if (FLAGS_dump_lane_width) {
241 const auto sample_left_widthes = lane_ptr->sampled_left_width();
242 std::cout << "left width num: " << sample_left_widthes.size()
243 << std::endl;
244 int num = 0;
245 for (auto w : sample_left_widthes) {
246 std::cout << " " << w.second;
247 if (++num % 10 == 0) {
248 std::cout << std::endl;
249 }
250 }
251 std::cout << std::endl;
252 num = 0;
253 const auto sample_right_widthes = lane_ptr->sampled_right_width();
254 std::cout << "right width num: " << sample_right_widthes.size()
255 << std::endl;
256 for (auto w : sample_right_widthes) {
257 std::cout << " " << w.second;
258 if (++num % 10 == 0) {
259 std::cout << std::endl;
260 }
261 }
262 std::cout << std::endl;
263 }
264 }
int SLToPoint(LaneInfoConstPtr lane_ptr, const double s, const double l, PointENU *point, double *heading) const
Definition map_xysl.cc:114

◆ PrintOverlap()

void apollo::hdmap::MapUtil::PrintOverlap ( const std::string &  overlap_id)
inline

在文件 map_xysl.cc143 行定义.

143 {
144 const auto *overlap_ptr = GetOverlap(FLAGS_overlap);
145 if (overlap_ptr == nullptr) {
146 AERROR << "overlap_ptr is nullptr.";
147 return;
148 }
149 ADEBUG << "overlap[" << overlap_ptr->id().id() << "] info["
150 << overlap_ptr->overlap().DebugString() << "]" << std::endl;
151
152 for (const auto &object_info : overlap_ptr->overlap().object()) {
153 if (object_info.has_lane_overlap_info()) {
154 std::cout << "Lane : " << object_info.id().id() << std::endl;
155 PrintLane(GetLane(object_info.id().id()));
156 } else if (object_info.has_signal_overlap_info()) {
157 std::cout << "Signal: " << object_info.id().id() << std::endl;
158 Print(GetSignal(object_info.id().id())->signal());
159 } else if (object_info.has_stop_sign_overlap_info()) {
160 std::cout << "StopSign: " << object_info.id().id() << std::endl;
161 Print(GetStopSign(object_info.id().id())->stop_sign());
162 } else if (object_info.has_crosswalk_overlap_info()) {
163 std::cout << "Crosswalk: " << object_info.id().id() << std::endl;
164 Print(GetCrosswalk(object_info.id().id())->crosswalk());
165 } else if (object_info.has_junction_overlap_info()) {
166 std::cout << "Junction: " << object_info.id().id() << std::endl;
167 Print(GetJunction(object_info.id().id())->junction());
168 } else if (object_info.has_yield_sign_overlap_info()) {
169 std::cout << "YieldSign: " << object_info.id().id() << std::endl;
170 Print(GetYieldSign(object_info.id().id())->yield_sign());
171 } else if (object_info.has_clear_area_overlap_info()) {
172 std::cout << "ClearArea: " << object_info.id().id() << std::endl;
173 Print(GetClearArea(object_info.id().id())->clear_area());
174 } else if (object_info.has_speed_bump_overlap_info()) {
175 std::cout << "SpeedBump: " << object_info.id().id() << std::endl;
176 Print(GetSpeedBump(object_info.id().id())->speed_bump());
177 } else if (object_info.has_parking_space_overlap_info()) {
178 std::cout << "ParkingSpace: " << object_info.id().id() << std::endl;
179 } else {
180 std::cout << "Unknown overlap type: " << object_info.DebugString();
181 }
182 }
183 }
const OverlapInfo * GetOverlap(const std::string &overlap_id) const
Definition map_xysl.cc:80
void Print(const T &t)
Definition map_xysl.cc:96
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

◆ SLToPoint()

int apollo::hdmap::MapUtil::SLToPoint ( LaneInfoConstPtr  lane_ptr,
const double  s,
const double  l,
PointENU point,
double *  heading 
) const
inline

在文件 map_xysl.cc114 行定义.

115 {
116 QUIT_IF(point == nullptr, -1, ERROR, "arg point is null");
117 QUIT_IF(heading == nullptr, -2, ERROR, "arg heading is null");
118 QUIT_IF(lane_ptr == nullptr, -3, ERROR, "the provided lane_ptr is null");
119 *point = lane_ptr->GetSmoothPoint(s);
120 *heading = lane_ptr->Heading(s);
121 auto normal_vec =
122 common::math::Vec2d::CreateUnitVec2d(*heading + M_PI / 2.0) * l;
123 point->set_x(point->x() + normal_vec.x());
124 point->set_y(point->y() + normal_vec.y());
125
126 return 0;
127 }
static Vec2d CreateUnitVec2d(const double angle)
Creates a unit-vector with a given angle to the positive x semi-axis
Definition vec2d.cc:29

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