提交 b0de8330 编写于 作者: D Dong Li 提交者: Jiangtao Hu

rename hdmap::PathPoint to hdmap::MapPathPoint

to avoid name confusion with type apollo::common::PathPoint defined in
path_point.proto
上级 70bf6e26
......@@ -41,7 +41,7 @@ namespace {
const double kSampleDistance = 0.25;
bool find_lane_segment(const PathPoint& p1, const PathPoint& p2,
bool find_lane_segment(const MapPathPoint& p1, const MapPathPoint& p2,
LaneSegment* const lane_segment) {
for (const auto& wp1 : p1.lane_waypoints()) {
for (const auto& wp2 : p2.lane_waypoints()) {
......@@ -77,7 +77,7 @@ std::string LaneSegment::debug_string() const {
return sout.str();
}
std::string PathPoint::debug_string() const {
std::string MapPathPoint::debug_string() const {
std::ostringstream sout;
sout << "x = " << x_ << " y = " << y_ << " heading = " << _heading
<< " lwp = {";
......@@ -127,19 +127,19 @@ std::string PathOverlap::debug_string() const {
return sout.str();
}
Path::Path(std::vector<PathPoint> path_points)
Path::Path(std::vector<MapPathPoint> path_points)
: _path_points(std::move(path_points)) {
init();
}
Path::Path(std::vector<PathPoint> path_points,
Path::Path(std::vector<MapPathPoint> path_points,
std::vector<LaneSegment> lane_segments)
: _path_points(std::move(path_points)),
_lane_segments(std::move(lane_segments)) {
init();
}
Path::Path(std::vector<PathPoint> path_points,
Path::Path(std::vector<MapPathPoint> path_points,
std::vector<LaneSegment> lane_segments,
const double max_approximation_error)
: _path_points(std::move(path_points)),
......@@ -235,7 +235,7 @@ void Path::init_width() {
double s = 0;
for (int i = 0; i < _num_sample_points; ++i) {
const PathPoint point = get_smooth_point(s);
const MapPathPoint point = get_smooth_point(s);
if (point.lane_waypoints().empty()) {
_left_width.push_back(0.0);
_right_width.push_back(0.0);
......@@ -351,15 +351,15 @@ void Path::init_overlaps() {
*/
}
PathPoint Path::get_smooth_point(const InterpolatedIndex& index) const {
MapPathPoint Path::get_smooth_point(const InterpolatedIndex& index) const {
CHECK_GE(index.id, 0);
CHECK_LT(index.id, _num_points);
const PathPoint& ref_point = _path_points[index.id];
const MapPathPoint& ref_point = _path_points[index.id];
if (std::abs(index.offset) > kMathEpsilon) {
const Vec2d delta = _unit_directions[index.id] * index.offset;
PathPoint point({ref_point.x() + delta.x(), ref_point.y() + delta.y()},
ref_point.heading());
MapPathPoint point({ref_point.x() + delta.x(), ref_point.y() + delta.y()},
ref_point.heading());
if (index.id < _num_segments) {
const LaneSegment& lane_segment = _lane_segments_to_next_point[index.id];
if (lane_segment.lane != nullptr) {
......@@ -373,7 +373,7 @@ PathPoint Path::get_smooth_point(const InterpolatedIndex& index) const {
}
}
PathPoint Path::get_smooth_point(double s) const {
MapPathPoint Path::get_smooth_point(double s) const {
return get_smooth_point(get_index_from_s(s));
}
......
......@@ -76,18 +76,18 @@ struct PathOverlap {
std::string debug_string() const;
};
class PathPoint : public apollo::common::math::Vec2d {
class MapPathPoint : public apollo::common::math::Vec2d {
public:
PathPoint() = default;
PathPoint(const apollo::common::math::Vec2d& point, double heading)
MapPathPoint() = default;
MapPathPoint(const apollo::common::math::Vec2d& point, double heading)
: Vec2d(point.x(), point.y()), _heading(heading) {}
PathPoint(const apollo::common::math::Vec2d& point, double heading,
LaneWaypoint lane_waypoint)
MapPathPoint(const apollo::common::math::Vec2d& point, double heading,
LaneWaypoint lane_waypoint)
: Vec2d(point.x(), point.y()), _heading(heading) {
_lane_waypoints.emplace_back(std::move(lane_waypoint));
}
PathPoint(const apollo::common::math::Vec2d& point, double heading,
std::vector<LaneWaypoint> lane_waypoints)
MapPathPoint(const apollo::common::math::Vec2d& point, double heading,
std::vector<LaneWaypoint> lane_waypoints)
: Vec2d(point.x(), point.y()),
_heading(heading),
_lane_waypoints(std::move(lane_waypoints)) {}
......@@ -188,16 +188,16 @@ class Path {
Path(Path&&) = default;
Path& operator=(Path&&) = default;
explicit Path(std::vector<PathPoint> path_points);
Path(std::vector<PathPoint> path_points,
explicit Path(std::vector<MapPathPoint> path_points);
Path(std::vector<MapPathPoint> path_points,
std::vector<LaneSegment> lane_segments);
Path(std::vector<PathPoint> path_points,
Path(std::vector<MapPathPoint> path_points,
std::vector<LaneSegment> lane_segments,
const double max_approximation_error);
// Return smooth coordinate by interpolated index or accumulate_s.
PathPoint get_smooth_point(const InterpolatedIndex& index) const;
PathPoint get_smooth_point(double s) const;
MapPathPoint get_smooth_point(const InterpolatedIndex& index) const;
MapPathPoint get_smooth_point(double s) const;
// Compute accumulate s value of the index.
double get_s_from_index(const InterpolatedIndex& index) const;
......@@ -220,7 +220,7 @@ class Path {
int num_points() const { return _num_points; }
int num_segments() const { return _num_segments; }
const std::vector<PathPoint>& path_points() const { return _path_points; }
const std::vector<MapPathPoint>& path_points() const { return _path_points; }
const std::vector<LaneSegment>& lane_segments() const {
return _lane_segments;
}
......@@ -292,7 +292,7 @@ class Path {
protected:
int _num_points = 0;
int _num_segments = 0;
std::vector<PathPoint> _path_points;
std::vector<MapPathPoint> _path_points;
std::vector<LaneSegment> _lane_segments;
std::vector<LaneSegment> _lane_segments_to_next_point;
std::vector<apollo::common::math::Vec2d> _unit_directions;
......
......@@ -39,7 +39,7 @@ using ReferenceMapLine = hdmap::Path;
ReferenceLine::ReferenceLine(
const std::vector<ReferencePoint>& reference_points)
: reference_points_(reference_points) {
std::vector<hdmap::PathPoint> points(reference_points.begin(),
std::vector<hdmap::MapPathPoint> points(reference_points.begin(),
reference_points.end());
reference_map_line_ = std::move(ReferenceMapLine(std::move(points)));
}
......@@ -49,7 +49,7 @@ ReferenceLine::ReferenceLine(
const std::vector<hdmap::LaneSegment>& lane_segments,
const double max_approximation_error)
: reference_points_(reference_points) {
std::vector<hdmap::PathPoint> points(reference_points.begin(),
std::vector<hdmap::MapPathPoint> points(reference_points.begin(),
reference_points.end());
reference_map_line_ = std::move(ReferenceMapLine(
std::move(points), lane_segments, max_approximation_error));
......
......@@ -30,7 +30,7 @@ ReferencePoint::ReferencePoint(const common::math::Vec2d& point,
const double heading, const double kappa,
const double dkappa, const double lower_bound,
const double upper_bound)
: hdmap::PathPoint(point, heading),
: hdmap::MapPathPoint(point, heading),
kappa_(kappa),
dkappa_(dkappa),
lower_bound_(lower_bound),
......@@ -39,20 +39,20 @@ ReferencePoint::ReferencePoint(const common::math::Vec2d& point,
ReferencePoint::ReferencePoint(const common::math::Vec2d& point,
const double heading,
const hdmap::LaneWaypoint lane_waypoint)
: hdmap::PathPoint(point, heading, lane_waypoint) {}
: hdmap::MapPathPoint(point, heading, lane_waypoint) {}
ReferencePoint::ReferencePoint(const common::math::Vec2d& point,
const double heading, const double kappa,
const double dkappa,
const hdmap::LaneWaypoint lane_waypoint)
: hdmap::PathPoint(point, heading, lane_waypoint),
: hdmap::MapPathPoint(point, heading, lane_waypoint),
kappa_(kappa),
dkappa_(dkappa) {}
ReferencePoint::ReferencePoint(
const common::math::Vec2d& point, const double heading, const double kappa,
const double dkappa, const std::vector<hdmap::LaneWaypoint>& lane_waypoints)
: hdmap::PathPoint(point, heading, lane_waypoints),
: hdmap::MapPathPoint(point, heading, lane_waypoints),
kappa_(kappa),
dkappa_(dkappa) {}
......
......@@ -29,7 +29,7 @@
namespace apollo {
namespace planning {
class ReferencePoint : public hdmap::PathPoint {
class ReferencePoint : public hdmap::MapPathPoint {
public:
ReferencePoint() = default;
......
......@@ -14,28 +14,24 @@
* limitations under the License.
*****************************************************************************/
#include <unordered_set>
#include <string>
#include <unordered_set>
#include "modules/prediction/common/prediction_map.h"
#include "modules/prediction/common/prediction_gflags.h"
#include "modules/map/hdmap/hdmap.h"
#include "modules/map/proto/map_id.pb.h"
#include "modules/prediction/common/prediction_gflags.h"
#include "modules/prediction/common/prediction_map.h"
namespace apollo {
namespace prediction {
using apollo::hdmap::LaneInfo;
using apollo::hdmap::Id;
using apollo::hdmap::PathPoint;
using apollo::hdmap::MapPathPoint;
PredictionMap::PredictionMap() : hdmap_(nullptr) {
LoadMap();
}
PredictionMap::PredictionMap() : hdmap_(nullptr) { LoadMap(); }
PredictionMap::~PredictionMap() {
Clear();
}
PredictionMap::~PredictionMap() { Clear(); }
void PredictionMap::LoadMap() {
hdmap_.reset(new apollo::hdmap::HDMap());
......@@ -44,9 +40,7 @@ void PredictionMap::LoadMap() {
ADEBUG << "Load map file: " << FLAGS_map_file;
}
void PredictionMap::Clear() {
hdmap_.reset();
}
void PredictionMap::Clear() { hdmap_.reset(); }
Id PredictionMap::id(const std::string& str_id) {
Id id;
......@@ -54,14 +48,13 @@ Id PredictionMap::id(const std::string& str_id) {
return id;
}
Eigen::Vector2d PredictionMap::PositionOnLane(
const LaneInfo* lane_info, const double s) {
Eigen::Vector2d PredictionMap::PositionOnLane(const LaneInfo* lane_info,
const double s) {
// TODO(kechxu) implement
return Eigen::Vector2d(0.0, 0.0);
}
double PredictionMap::HeadingOnLane(
const LaneInfo* lane_info, const double s) {
double PredictionMap::HeadingOnLane(const LaneInfo* lane_info, const double s) {
// TODO(kechxu) implement
return 0.0;
}
......@@ -85,23 +78,21 @@ const LaneInfo* PredictionMap::LaneById(const std::string& str_id) {
}
void PredictionMap::GetProjection(const Eigen::Vector2d& position,
const LaneInfo* lane_info_ptr,
double* s, double* l) {
const LaneInfo* lane_info_ptr, double* s,
double* l) {
// TODO(kechxu) implement
}
bool PredictionMap::ProjectionFromLane(
const LaneInfo* lane_info_ptr, PathPoint* path_point, double* s) {
bool PredictionMap::ProjectionFromLane(const LaneInfo* lane_info_ptr,
MapPathPoint* path_point, double* s) {
// TODO(kechxu) implement
return true;
}
void PredictionMap::OnLane(
const std::vector<const LaneInfo*>& prev_lanes,
const Eigen::Vector2d& point,
const double heading,
const double radius,
std::vector<const LaneInfo*>* lanes) {
void PredictionMap::OnLane(const std::vector<const LaneInfo*>& prev_lanes,
const Eigen::Vector2d& point, const double heading,
const double radius,
std::vector<const LaneInfo*>* lanes) {
std::vector<const LaneInfo*> candidate_lanes;
// if (hdmap_->get_lanes_with_heading(
// point, radius, heading, M_PI, &candidate_lanes) != 0) {
......@@ -116,7 +107,7 @@ void PredictionMap::OnLane(
!IsRightNeighborLane(candidate_lane, prev_lanes)) {
continue;
} else {
// PathPoint nearest_point = candidate_lane->get_nearest_point(point);
// MapPathPoint nearest_point = candidate_lane->get_nearest_point(point);
// double diff = fabs(math_util::angle_diff(
// heading, nearest_point.heading()));
// if (diff <= FLAGS_max_lane_angle_diff) {
......@@ -154,8 +145,8 @@ void PredictionMap::NearbyLanesByCurrentLanes(
}
}
bool PredictionMap::IsLeftNeighborLane(
const LaneInfo* left_lane, const LaneInfo* curr_lane) {
bool PredictionMap::IsLeftNeighborLane(const LaneInfo* left_lane,
const LaneInfo* curr_lane) {
if (curr_lane == nullptr) {
return true;
}
......@@ -183,8 +174,8 @@ bool PredictionMap::IsLeftNeighborLane(
return false;
}
bool PredictionMap::IsRightNeighborLane(
const LaneInfo* right_lane, const LaneInfo* curr_lane) {
bool PredictionMap::IsRightNeighborLane(const LaneInfo* right_lane,
const LaneInfo* curr_lane) {
if (curr_lane == nullptr) {
return true;
}
......@@ -192,7 +183,7 @@ bool PredictionMap::IsRightNeighborLane(
return false;
}
for (auto& right_lane_id :
curr_lane->lane().right_neighbor_forward_lane_id()) {
curr_lane->lane().right_neighbor_forward_lane_id()) {
if (id_string(right_lane) == right_lane_id.id()) {
return true;
}
......@@ -213,8 +204,8 @@ bool PredictionMap::IsRightNeighborLane(
return false;
}
bool PredictionMap::IsSuccessorLane(
const LaneInfo* succ_lane, const LaneInfo* curr_lane) {
bool PredictionMap::IsSuccessorLane(const LaneInfo* succ_lane,
const LaneInfo* curr_lane) {
if (curr_lane == nullptr) {
return true;
}
......@@ -229,8 +220,8 @@ bool PredictionMap::IsSuccessorLane(
return false;
}
bool PredictionMap::IsSuccessorLane(
const LaneInfo* succ_lane, const std::vector<const LaneInfo*>& lanes) {
bool PredictionMap::IsSuccessorLane(const LaneInfo* succ_lane,
const std::vector<const LaneInfo*>& lanes) {
if (lanes.size() == 0) {
return true;
}
......@@ -242,8 +233,8 @@ bool PredictionMap::IsSuccessorLane(
return false;
}
bool PredictionMap::IsPredecessorLane(
const LaneInfo* pred_lane, const LaneInfo* curr_lane) {
bool PredictionMap::IsPredecessorLane(const LaneInfo* pred_lane,
const LaneInfo* curr_lane) {
if (curr_lane == nullptr) {
return true;
}
......@@ -271,16 +262,16 @@ bool PredictionMap::IsPredecessorLane(
return false;
}
bool PredictionMap::IsIdenticalLane(
const LaneInfo* other_lane, const LaneInfo* curr_lane) {
bool PredictionMap::IsIdenticalLane(const LaneInfo* other_lane,
const LaneInfo* curr_lane) {
if (curr_lane == nullptr || other_lane == nullptr) {
return false;
}
return id_string(other_lane) == id_string(curr_lane);
}
bool PredictionMap::IsIdenticalLane(
const LaneInfo* other_lane, const std::vector<const LaneInfo*>& lanes) {
bool PredictionMap::IsIdenticalLane(const LaneInfo* other_lane,
const std::vector<const LaneInfo*>& lanes) {
if (lanes.size() == 0) {
return true;
}
......
......@@ -24,8 +24,8 @@
#include "Eigen/Dense"
#include "modules/common/macro.h"
#include "modules/map/hdmap/hdmap_impl.h"
#include "modules/map/hdmap/hdmap_common.h"
#include "modules/map/hdmap/hdmap_impl.h"
#include "modules/map/pnc_map/path.h"
namespace apollo {
......@@ -55,68 +55,56 @@ class PredictionMap {
const apollo::hdmap::LaneInfo* LaneById(const std::string& str_id);
void GetProjection(const Eigen::Vector2d& position,
const apollo::hdmap::LaneInfo* lane_info_ptr,
double* s, double* l);
const apollo::hdmap::LaneInfo* lane_info_ptr, double* s,
double* l);
bool ProjectionFromLane(
const apollo::hdmap::LaneInfo* lane_info_ptr,
apollo::hdmap::PathPoint* path_point,
double* s);
bool ProjectionFromLane(const apollo::hdmap::LaneInfo* lane_info_ptr,
apollo::hdmap::MapPathPoint* path_point, double* s);
void OnLane(
const std::vector<const apollo::hdmap::LaneInfo*>& prev_lanes,
const Eigen::Vector2d& point,
const double heading,
const double radius,
std::vector<const apollo::hdmap::LaneInfo*>* lanes);
void OnLane(const std::vector<const apollo::hdmap::LaneInfo*>& prev_lanes,
const Eigen::Vector2d& point, const double heading,
const double radius,
std::vector<const apollo::hdmap::LaneInfo*>* lanes);
int SmoothPointFromLane(
const apollo::hdmap::Id& id,
const double s,
const double l,
Eigen::Vector2d* point,
double* heading);
int SmoothPointFromLane(const apollo::hdmap::Id& id, const double s,
const double l, Eigen::Vector2d* point,
double* heading);
void NearbyLanesByCurrentLanes(
const Eigen::Vector2d& point,
const std::vector<const apollo::hdmap::LaneInfo*>& lanes,
std::vector<const apollo::hdmap::LaneInfo*>* nearby_lanes);
bool IsLeftNeighborLane(
const apollo::hdmap::LaneInfo* left_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsLeftNeighborLane(const apollo::hdmap::LaneInfo* left_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsLeftNeighborLane(
const apollo::hdmap::LaneInfo* left_lane,
const std::vector<const apollo::hdmap::LaneInfo*>& lanes);
bool IsRightNeighborLane(
const apollo::hdmap::LaneInfo* right_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsRightNeighborLane(const apollo::hdmap::LaneInfo* right_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsRightNeighborLane(
const apollo::hdmap::LaneInfo* right_lane,
const std::vector<const apollo::hdmap::LaneInfo*>& lanes);
bool IsSuccessorLane(
const apollo::hdmap::LaneInfo* succ_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsSuccessorLane(const apollo::hdmap::LaneInfo* succ_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsSuccessorLane(
const apollo::hdmap::LaneInfo* succ_lane,
const std::vector<const apollo::hdmap::LaneInfo*>& lanes);
bool IsPredecessorLane(
const apollo::hdmap::LaneInfo* pred_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsPredecessorLane(const apollo::hdmap::LaneInfo* pred_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsPredecessorLane(
const apollo::hdmap::LaneInfo* pred_lane,
const std::vector<const apollo::hdmap::LaneInfo*>& lanes);
bool IsIdenticalLane(
const apollo::hdmap::LaneInfo* other_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsIdenticalLane(const apollo::hdmap::LaneInfo* other_lane,
const apollo::hdmap::LaneInfo* curr_lane);
bool IsIdenticalLane(
const apollo::hdmap::LaneInfo* other_lane,
......@@ -126,7 +114,7 @@ class PredictionMap {
int LaneTurnType(const std::string& lane_id);
template<class MapInfo>
template <class MapInfo>
std::string id_string(const MapInfo* info) {
return info->id().id();
}
......@@ -139,5 +127,4 @@ class PredictionMap {
} // namespace prediction
} // namespace apollo
#endif // MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_
......@@ -718,7 +718,7 @@ void Obstacle::SetNearbyLanes(Feature* feature) {
heading = feature->t_velocity_heading();
}
double angle_diff = 0.0;
apollo::hdmap::PathPoint nearest_point;
apollo::hdmap::MapPathPoint nearest_point;
if (!map->ProjectionFromLane(nearby_lane, &nearest_point, &s)) {
angle_diff =
apollo::common::math::AngleDiff(nearest_point.heading(), heading);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册