Apollo 10.0
自动驾驶开放平台
apollo::hdmap::LaneInfo类 参考

#include <hdmap_common.h>

apollo::hdmap::LaneInfo 的协作图:

Public 类型

using SampledWidth = std::pair< double, double >
 

Public 成员函数

 LaneInfo (const Lane &lane)
 
const Idid () const
 
const Idroad_id () const
 
const Idsection_id () const
 
const Lanelane () const
 
const std::vector< apollo::common::math::Vec2d > & points () const
 
const std::vector< apollo::common::math::Vec2d > & unit_directions () const
 
double Heading (const double s) const
 
double Curvature (const double s) const
 
const std::vector< double > & headings () const
 
const std::vector< apollo::common::math::LineSegment2d > & segments () const
 
const std::vector< double > & accumulate_s () const
 
const std::vector< OverlapInfoConstPtr > & overlaps () const
 
const std::vector< OverlapInfoConstPtr > & cross_lanes () const
 
const std::vector< OverlapInfoConstPtr > & signals () const
 
const std::vector< OverlapInfoConstPtr > & barrier_gates () const
 
const std::vector< OverlapInfoConstPtr > & yield_signs () const
 
const std::vector< OverlapInfoConstPtr > & stop_signs () const
 
const std::vector< OverlapInfoConstPtr > & crosswalks () const
 
const std::vector< OverlapInfoConstPtr > & junctions () const
 
const std::vector< OverlapInfoConstPtr > & clear_areas () const
 
const std::vector< OverlapInfoConstPtr > & speed_bumps () const
 
const std::vector< OverlapInfoConstPtr > & parking_spaces () const
 
const std::vector< OverlapInfoConstPtr > & pnc_junctions () const
 
const std::vector< OverlapInfoConstPtr > & areas () const
 
double total_length () const
 
const std::vector< SampledWidth > & sampled_left_width () const
 
const std::vector< SampledWidth > & sampled_right_width () const
 
void GetWidth (const double s, double *left_width, double *right_width) const
 
double GetWidth (const double s) const
 
double GetEffectiveWidth (const double s) const
 
const std::vector< SampledWidth > & sampled_left_road_width () const
 
const std::vector< SampledWidth > & sampled_right_road_width () const
 
void GetRoadWidth (const double s, double *left_width, double *right_width) const
 
double GetRoadWidth (const double s) const
 
bool IsOnLane (const apollo::common::math::Vec2d &point) const
 
bool IsOnLane (const apollo::common::math::Box2d &box) const
 
apollo::common::PointENU GetSmoothPoint (double s) const
 
double DistanceTo (const apollo::common::math::Vec2d &point) const
 
double DistanceTo (const apollo::common::math::Vec2d &point, apollo::common::math::Vec2d *map_point, double *s_offset, int *s_offset_index) const
 
apollo::common::PointENU GetNearestPoint (const apollo::common::math::Vec2d &point, double *distance) const
 
bool GetProjection (const apollo::common::math::Vec2d &point, double *accumulate_s, double *lateral) const
 
bool GetProjection (const apollo::common::math::Vec2d &point, const double heading, double *accumulate_s, double *lateral) const
 

友元

class HDMapImpl
 
class RoadInfo
 

详细描述

在文件 hdmap_common.h148 行定义.

成员类型定义说明

◆ SampledWidth

using apollo::hdmap::LaneInfo::SampledWidth = std::pair<double, double>

在文件 hdmap_common.h203 行定义.

构造及析构函数说明

◆ LaneInfo()

apollo::hdmap::LaneInfo::LaneInfo ( const Lane lane)
explicit

在文件 hdmap_common.cc106 行定义.

106: lane_(lane) { Init(); }
const Lane & lane() const

成员函数说明

◆ accumulate_s()

const std::vector< double > & apollo::hdmap::LaneInfo::accumulate_s ( ) const
inline

在文件 hdmap_common.h168 行定义.

168{ return accumulated_s_; }

◆ areas()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::areas ( ) const
inline

在文件 hdmap_common.h201 行定义.

201{ return areas_; }

◆ barrier_gates()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::barrier_gates ( ) const
inline

在文件 hdmap_common.h174 行定义.

174 {
175 return barrier_gates_;
176 }

◆ clear_areas()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::clear_areas ( ) const
inline

在文件 hdmap_common.h189 行定义.

189 {
190 return clear_areas_;
191 }

◆ cross_lanes()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::cross_lanes ( ) const
inline

在文件 hdmap_common.h170 行定义.

170 {
171 return cross_lanes_;
172 }

◆ crosswalks()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::crosswalks ( ) const
inline

在文件 hdmap_common.h183 行定义.

183 {
184 return crosswalks_;
185 }

◆ Curvature()

double apollo::hdmap::LaneInfo::Curvature ( const double  s) const

在文件 hdmap_common.cc217 行定义.

217 {
218 if (points_.size() < 2U) {
219 AERROR << "Not enough points to compute curvature.";
220 return 0.0;
221 }
222 const double kEpsilon = 0.001;
223 if (s + kEpsilon < accumulated_s_.front()) {
224 AERROR << "s:" << s << " should be >= " << accumulated_s_.front();
225 return 0.0;
226 }
227 if (s > accumulated_s_.back() + kEpsilon) {
228 AERROR << "s:" << s << " should be <= " << accumulated_s_.back();
229 return 0.0;
230 }
231
232 auto iter = std::lower_bound(accumulated_s_.begin(), accumulated_s_.end(), s);
233 if (iter == accumulated_s_.end()) {
234 ADEBUG << "Reach the end of lane.";
235 return 0.0;
236 }
237 int index = static_cast<int>(std::distance(accumulated_s_.begin(), iter));
238 if (index == 0) {
239 ADEBUG << "Reach the beginning of lane";
240 return 0.0;
241 }
242 return (headings_[index] - headings_[index - 1]) /
243 (accumulated_s_[index] - accumulated_s_[index - 1] + kEpsilon);
244}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

◆ DistanceTo() [1/2]

double apollo::hdmap::LaneInfo::DistanceTo ( const apollo::common::math::Vec2d point) const

在文件 hdmap_common.cc361 行定义.

361 {
362 const auto segment_box = lane_segment_kdtree_->GetNearestObject(point);
363 RETURN_VAL_IF_NULL(segment_box, 0.0);
364 return segment_box->DistanceTo(point);
365}
#define RETURN_VAL_IF_NULL(ptr, val)
Definition log.h:98

◆ DistanceTo() [2/2]

double apollo::hdmap::LaneInfo::DistanceTo ( const apollo::common::math::Vec2d point,
apollo::common::math::Vec2d map_point,
double *  s_offset,
int *  s_offset_index 
) const

在文件 hdmap_common.cc367 行定义.

368 {
369 RETURN_VAL_IF_NULL(map_point, 0.0);
370 RETURN_VAL_IF_NULL(s_offset, 0.0);
371 RETURN_VAL_IF_NULL(s_offset_index, 0.0);
372
373 const auto segment_box = lane_segment_kdtree_->GetNearestObject(point);
374 RETURN_VAL_IF_NULL(segment_box, 0.0);
375 int index = segment_box->id();
376 double distance = segments_[index].DistanceTo(point, map_point);
377 *s_offset_index = index;
378 *s_offset =
379 accumulated_s_[index] + segments_[index].start().DistanceTo(*map_point);
380 return distance;
381}

◆ GetEffectiveWidth()

double apollo::hdmap::LaneInfo::GetEffectiveWidth ( const double  s) const

在文件 hdmap_common.cc253 行定义.

253 {
254 double left_width = 0.0;
255 double right_width = 0.0;
256 GetWidth(s, &left_width, &right_width);
257 return 2 * std::min(left_width, right_width);
258}
void GetWidth(const double s, double *left_width, double *right_width) const

◆ GetNearestPoint()

PointENU apollo::hdmap::LaneInfo::GetNearestPoint ( const apollo::common::math::Vec2d point,
double *  distance 
) const

在文件 hdmap_common.cc383 行定义.

383 {
384 PointENU empty_point;
385 RETURN_VAL_IF_NULL(distance, empty_point);
386
387 const auto segment_box = lane_segment_kdtree_->GetNearestObject(point);
388 RETURN_VAL_IF_NULL(segment_box, empty_point);
389 int index = segment_box->id();
390 Vec2d nearest_point;
391 *distance = segments_[index].DistanceTo(point, &nearest_point);
392
393 return PointFromVec2d(nearest_point);
394}

◆ GetProjection() [1/2]

bool apollo::hdmap::LaneInfo::GetProjection ( const apollo::common::math::Vec2d point,
const double  heading,
double *  accumulate_s,
double *  lateral 
) const

在文件 hdmap_common.cc440 行定义.

441 {
443 RETURN_VAL_IF_NULL(lateral, false);
444
445 if (segments_.empty()) {
446 return false;
447 }
448 double min_dist = std::numeric_limits<double>::infinity();
449 int seg_num = static_cast<int>(segments_.size());
450 int min_index = 0;
451 for (int i = 0; i < seg_num; ++i) {
452 if (abs(common::math::AngleDiff(segments_[i].heading(), heading)) >= M_PI_2)
453 continue;
454 const double distance = segments_[i].DistanceSquareTo(point);
455 if (distance < min_dist) {
456 min_index = i;
457 min_dist = distance;
458 }
459 }
460 min_dist = std::sqrt(min_dist);
461 const auto &nearest_seg = segments_[min_index];
462 const auto prod = nearest_seg.ProductOntoUnit(point);
463 const auto proj = nearest_seg.ProjectOntoUnit(point);
464 if (min_index == 0) {
465 *accumulate_s = std::min(proj, nearest_seg.length());
466 if (proj < 0) {
467 *lateral = prod;
468 } else {
469 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
470 }
471 } else if (min_index == seg_num - 1) {
472 *accumulate_s = accumulated_s_[min_index] + std::max(0.0, proj);
473 if (proj > 0) {
474 *lateral = prod;
475 } else {
476 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
477 }
478 } else {
479 *accumulate_s = accumulated_s_[min_index] +
480 std::max(0.0, std::min(proj, nearest_seg.length()));
481 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
482 }
483 return true;
484}
const std::vector< double > & accumulate_s() const
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to
Definition math_utils.cc:61

◆ GetProjection() [2/2]

bool apollo::hdmap::LaneInfo::GetProjection ( const apollo::common::math::Vec2d point,
double *  accumulate_s,
double *  lateral 
) const

在文件 hdmap_common.cc396 行定义.

397 {
399 RETURN_VAL_IF_NULL(lateral, false);
400
401 if (segments_.empty()) {
402 return false;
403 }
404 double min_dist = std::numeric_limits<double>::infinity();
405 int seg_num = static_cast<int>(segments_.size());
406 int min_index = 0;
407 for (int i = 0; i < seg_num; ++i) {
408 const double distance = segments_[i].DistanceSquareTo(point);
409 if (distance < min_dist) {
410 min_index = i;
411 min_dist = distance;
412 }
413 }
414 min_dist = std::sqrt(min_dist);
415 const auto &nearest_seg = segments_[min_index];
416 const auto prod = nearest_seg.ProductOntoUnit(point);
417 const auto proj = nearest_seg.ProjectOntoUnit(point);
418 if (min_index == 0) {
419 *accumulate_s = std::min(proj, nearest_seg.length());
420 if (proj < 0) {
421 *lateral = prod;
422 } else {
423 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
424 }
425 } else if (min_index == seg_num - 1) {
426 *accumulate_s = accumulated_s_[min_index] + std::max(0.0, proj);
427 if (proj > 0) {
428 *lateral = prod;
429 } else {
430 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
431 }
432 } else {
433 *accumulate_s = accumulated_s_[min_index] +
434 std::max(0.0, std::min(proj, nearest_seg.length()));
435 *lateral = (prod > 0.0 ? 1 : -1) * min_dist;
436 }
437 return true;
438}

◆ GetRoadWidth() [1/2]

double apollo::hdmap::LaneInfo::GetRoadWidth ( const double  s) const

在文件 hdmap_common.cc270 行定义.

270 {
271 double left_width = 0.0;
272 double right_width = 0.0;
273 GetRoadWidth(s, &left_width, &right_width);
274 return left_width + right_width;
275}
void GetRoadWidth(const double s, double *left_width, double *right_width) const

◆ GetRoadWidth() [2/2]

void apollo::hdmap::LaneInfo::GetRoadWidth ( const double  s,
double *  left_width,
double *  right_width 
) const

在文件 hdmap_common.cc260 行定义.

261 {
262 if (left_width != nullptr) {
263 *left_width = GetWidthFromSample(sampled_left_road_width_, s);
264 }
265 if (right_width != nullptr) {
266 *right_width = GetWidthFromSample(sampled_right_road_width_, s);
267 }
268}

◆ GetSmoothPoint()

PointENU apollo::hdmap::LaneInfo::GetSmoothPoint ( double  s) const

在文件 hdmap_common.cc336 行定义.

336 {
337 PointENU point;
338 RETURN_VAL_IF(points_.size() < 2, point);
339 if (s <= 0.0) {
340 return PointFromVec2d(points_[0]);
341 }
342
343 if (s >= total_length()) {
344 return PointFromVec2d(points_.back());
345 }
346
347 const auto low_itr =
348 std::lower_bound(accumulated_s_.begin(), accumulated_s_.end(), s);
349 RETURN_VAL_IF(low_itr == accumulated_s_.end(), point);
350 size_t index = low_itr - accumulated_s_.begin();
351 double delta_s = *low_itr - s;
353 return PointFromVec2d(points_[index]);
354 }
355
356 auto smooth_point = points_[index] - unit_directions_[index - 1] * delta_s;
357
358 return PointFromVec2d(smooth_point);
359}
double total_length() const
#define RETURN_VAL_IF(condition, val)
Definition log.h:114
constexpr double kMathEpsilon
Definition vec2d.h:35

◆ GetWidth() [1/2]

double apollo::hdmap::LaneInfo::GetWidth ( const double  s) const

在文件 hdmap_common.cc246 行定义.

246 {
247 double left_width = 0.0;
248 double right_width = 0.0;
249 GetWidth(s, &left_width, &right_width);
250 return left_width + right_width;
251}

◆ GetWidth() [2/2]

void apollo::hdmap::LaneInfo::GetWidth ( const double  s,
double *  left_width,
double *  right_width 
) const

在文件 hdmap_common.cc184 行定义.

185 {
186 if (left_width != nullptr) {
187 *left_width = GetWidthFromSample(sampled_left_width_, s);
188 }
189 if (right_width != nullptr) {
190 *right_width = GetWidthFromSample(sampled_right_width_, s);
191 }
192}

◆ Heading()

double apollo::hdmap::LaneInfo::Heading ( const double  s) const

在文件 hdmap_common.cc194 行定义.

194 {
195 if (accumulated_s_.empty()) {
196 return 0.0;
197 }
198 const double kEpsilon = 0.001;
199 if (s + kEpsilon < accumulated_s_.front()) {
200 AWARN << "s:" << s << " should be >= " << accumulated_s_.front();
201 return headings_.front();
202 }
203 if (s - kEpsilon > accumulated_s_.back()) {
204 AWARN << "s:" << s << " should be <= " << accumulated_s_.back();
205 return headings_.back();
206 }
207
208 auto iter = std::lower_bound(accumulated_s_.begin(), accumulated_s_.end(), s);
209 int index = static_cast<int>(std::distance(accumulated_s_.begin(), iter));
210 if (index == 0 || *iter - s <= common::math::kMathEpsilon) {
211 return headings_[index];
212 }
213 return common::math::slerp(headings_[index - 1], accumulated_s_[index - 1],
214 headings_[index], accumulated_s_[index], s);
215}
#define AWARN
Definition log.h:43
double slerp(const double a0, const double t0, const double a1, const double t1, const double t)
Spherical linear interpolation between two angles.

◆ headings()

const std::vector< double > & apollo::hdmap::LaneInfo::headings ( ) const
inline

在文件 hdmap_common.h164 行定义.

164{ return headings_; }

◆ id()

const Id & apollo::hdmap::LaneInfo::id ( ) const
inline

在文件 hdmap_common.h152 行定义.

152{ return lane_.id(); }

◆ IsOnLane() [1/2]

bool apollo::hdmap::LaneInfo::IsOnLane ( const apollo::common::math::Box2d box) const

在文件 hdmap_common.cc325 行定义.

325 {
326 std::vector<Vec2d> corners;
327 box.GetAllCorners(&corners);
328 for (const auto &corner : corners) {
329 if (!IsOnLane(corner)) {
330 return false;
331 }
332 }
333 return true;
334}
void GetAllCorners(std::vector< Vec2d > *const corners) const
Getter of the corners of the box
Definition box2d.cc:140
bool IsOnLane(const apollo::common::math::Vec2d &point) const

◆ IsOnLane() [2/2]

bool apollo::hdmap::LaneInfo::IsOnLane ( const apollo::common::math::Vec2d point) const

在文件 hdmap_common.cc304 行定义.

304 {
305 double accumulate_s = 0.0;
306 double lateral = 0.0;
307 if (!GetProjection(point, &accumulate_s, &lateral)) {
308 return false;
309 }
310
311 if (accumulate_s > (total_length() + kEpsilon) ||
312 (accumulate_s + kEpsilon) < 0.0) {
313 return false;
314 }
315
316 double left_width = 0.0;
317 double right_width = 0.0;
318 GetWidth(accumulate_s, &left_width, &right_width);
319 if (lateral < left_width && lateral > -right_width) {
320 return true;
321 }
322 return false;
323}
bool GetProjection(const apollo::common::math::Vec2d &point, double *accumulate_s, double *lateral) const

◆ junctions()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::junctions ( ) const
inline

在文件 hdmap_common.h186 行定义.

186 {
187 return junctions_;
188 }

◆ lane()

const Lane & apollo::hdmap::LaneInfo::lane ( ) const
inline

在文件 hdmap_common.h155 行定义.

155{ return lane_; }

◆ overlaps()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::overlaps ( ) const
inline

在文件 hdmap_common.h169 行定义.

169{ return overlaps_; }

◆ parking_spaces()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::parking_spaces ( ) const
inline

在文件 hdmap_common.h195 行定义.

195 {
196 return parking_spaces_;
197 }

◆ pnc_junctions()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::pnc_junctions ( ) const
inline

在文件 hdmap_common.h198 行定义.

198 {
199 return pnc_junctions_;
200 }

◆ points()

const std::vector< apollo::common::math::Vec2d > & apollo::hdmap::LaneInfo::points ( ) const
inline

在文件 hdmap_common.h156 行定义.

156 {
157 return points_;
158 }

◆ road_id()

const Id & apollo::hdmap::LaneInfo::road_id ( ) const
inline

在文件 hdmap_common.h153 行定义.

153{ return road_id_; }

◆ sampled_left_road_width()

const std::vector< SampledWidth > & apollo::hdmap::LaneInfo::sampled_left_road_width ( ) const
inline

在文件 hdmap_common.h214 行定义.

214 {
215 return sampled_left_road_width_;
216 }

◆ sampled_left_width()

const std::vector< SampledWidth > & apollo::hdmap::LaneInfo::sampled_left_width ( ) const
inline

在文件 hdmap_common.h204 行定义.

204 {
205 return sampled_left_width_;
206 }

◆ sampled_right_road_width()

const std::vector< SampledWidth > & apollo::hdmap::LaneInfo::sampled_right_road_width ( ) const
inline

在文件 hdmap_common.h217 行定义.

217 {
218 return sampled_right_road_width_;
219 }

◆ sampled_right_width()

const std::vector< SampledWidth > & apollo::hdmap::LaneInfo::sampled_right_width ( ) const
inline

在文件 hdmap_common.h207 行定义.

207 {
208 return sampled_right_width_;
209 }

◆ section_id()

const Id & apollo::hdmap::LaneInfo::section_id ( ) const
inline

在文件 hdmap_common.h154 行定义.

154{ return section_id_; }

◆ segments()

const std::vector< apollo::common::math::LineSegment2d > & apollo::hdmap::LaneInfo::segments ( ) const
inline

在文件 hdmap_common.h165 行定义.

165 {
166 return segments_;
167 }

◆ signals()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::signals ( ) const
inline

在文件 hdmap_common.h173 行定义.

173{ return signals_; }

◆ speed_bumps()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::speed_bumps ( ) const
inline

在文件 hdmap_common.h192 行定义.

192 {
193 return speed_bumps_;
194 }

◆ stop_signs()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::stop_signs ( ) const
inline

在文件 hdmap_common.h180 行定义.

180 {
181 return stop_signs_;
182 }

◆ total_length()

double apollo::hdmap::LaneInfo::total_length ( ) const
inline

在文件 hdmap_common.h202 行定义.

202{ return total_length_; }

◆ unit_directions()

const std::vector< apollo::common::math::Vec2d > & apollo::hdmap::LaneInfo::unit_directions ( ) const
inline

在文件 hdmap_common.h159 行定义.

159 {
160 return unit_directions_;
161 }

◆ yield_signs()

const std::vector< OverlapInfoConstPtr > & apollo::hdmap::LaneInfo::yield_signs ( ) const
inline

在文件 hdmap_common.h177 行定义.

177 {
178 return yield_signs_;
179 }

友元及相关函数文档

◆ HDMapImpl

friend class HDMapImpl
friend

在文件 hdmap_common.h241 行定义.

◆ RoadInfo

friend class RoadInfo
friend

在文件 hdmap_common.h242 行定义.


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