提交 82436ca6 编写于 作者: A Aaron Xiao 提交者: Jiangtao Hu

Planning: Simplify function names of converting between xy and sl points.

上级 1b2227d4
......@@ -158,8 +158,7 @@ bool PathData::FrenetToCartesian(const FrenetFramePath &frenet_path,
common::math::Vec2d cartesian_point;
sl_point.set_s(frenet_point.s());
sl_point.set_l(frenet_point.l());
if (!reference_line_->get_point_in_cartesian_frame(sl_point,
&cartesian_point)) {
if (!reference_line_->sl_to_xy(sl_point, &cartesian_point)) {
AERROR << "Fail to convert sl point to xy point";
return false;
}
......@@ -197,8 +196,8 @@ bool PathData::CartesianToFrenet(const DiscretizedPath &discretized_path,
for (const auto &path_point : discretized_path.path_points()) {
SLPoint sl_point;
if (!reference_line_->get_point_in_frenet_frame(
Vec2d(path_point.x(), path_point.y()), &sl_point)) {
if (!reference_line_->xy_to_sl({path_point.x(), path_point.y()},
&sl_point)) {
AERROR << "Fail to transfer cartesian point to frenet point.";
return false;
}
......
......@@ -72,7 +72,7 @@ bool PathObstacle::InitPerceptionSLBoundary(
obstacle_->PerceptionBoundingBox().GetAllCorners(&corners);
for (const auto& point : corners) {
common::SLPoint sl_point;
if (!reference_line->get_point_in_frenet_frame(point, &sl_point)) {
if (!reference_line->xy_to_sl(point, &sl_point)) {
AERROR << "failed to get projection for point: " << point.DebugString()
<< " on reference line.";
return false;
......
......@@ -79,7 +79,7 @@ bool ReferenceLineInfo::InitPerceptionSLBoundary(PathObstacle* path_obstacle) {
path_obstacle->Obstacle()->PerceptionBoundingBox().GetAllCorners(&corners);
for (const auto& point : corners) {
common::SLPoint sl_point;
if (!reference_line_.get_point_in_frenet_frame(point, &sl_point)) {
if (!reference_line_.xy_to_sl(point, &sl_point)) {
AERROR << "failed to get projection for point: " << point.DebugString()
<< " on reference line.";
return false;
......@@ -137,7 +137,7 @@ bool ReferenceLineInfo::IsStartFrom(
const auto& prev_reference_line =
previous_reference_line_info.reference_line();
common::SLPoint sl_point;
prev_reference_line.get_point_in_frenet_frame(start_point, &sl_point);
prev_reference_line.xy_to_sl(start_point, &sl_point);
return previous_reference_line_info.reference_line_.is_on_road(sl_point);
}
......
......@@ -72,8 +72,7 @@ int Decider::MakeMainStopDecision(
const auto& reference_line = reference_line_info.reference_line();
apollo::common::PointENU stop_point = object_decision.stop().stop_point();
common::SLPoint stop_line_sl;
reference_line.get_point_in_frenet_frame({stop_point.x(), stop_point.y()},
&stop_line_sl);
reference_line.xy_to_sl({stop_point.x(), stop_point.y()}, &stop_line_sl);
double stop_line_s = stop_line_sl.s();
if (stop_line_s < 0 || stop_line_s > reference_line.length()) {
......@@ -86,8 +85,7 @@ int Decider::MakeMainStopDecision(
// check stop_line_s vs adc_s
common::SLPoint adc_sl;
auto& adc_position = common::VehicleState::instance()->pose().position();
reference_line.get_point_in_frenet_frame(
{adc_position.x(), adc_position.y()}, &adc_sl);
reference_line.xy_to_sl({adc_position.x(), adc_position.y()}, &adc_sl);
const auto& vehicle_param =
common::VehicleConfigHelper::instance()->GetConfig().vehicle_param();
if (stop_line_s <= adc_sl.s() + vehicle_param.front_edge_to_center()) {
......
......@@ -190,16 +190,16 @@ std::vector<SpeedPoint> EMPlanner::GenerateInitSpeedProfile(
const auto& last_init_point = last_frame->PlanningStartPoint().path_point();
Vec2d last_xy_point(last_init_point.x(), last_init_point.y());
SLPoint last_sl_point;
if (!last_reference_line_info->reference_line().get_point_in_frenet_frame(
last_xy_point, &last_sl_point)) {
if (!last_reference_line_info->reference_line().xy_to_sl(last_xy_point,
&last_sl_point)) {
AERROR << "Fail to transfer xy to sl when init speed profile";
}
Vec2d xy_point(planning_init_point.path_point().x(),
planning_init_point.path_point().y());
SLPoint sl_point;
if (!last_reference_line_info->reference_line().get_point_in_frenet_frame(
xy_point, &last_sl_point)) {
if (!last_reference_line_info->reference_line().xy_to_sl(xy_point,
&last_sl_point)) {
AERROR << "Fail to transfer xy to sl when init speed profile";
}
double s_diff = sl_point.s() - last_sl_point.s();
......
......@@ -165,9 +165,8 @@ ReferencePoint ReferenceLine::get_reference_point(const double x,
reference_points_[index_end], s1, s);
}
bool ReferenceLine::get_point_in_cartesian_frame(
const common::SLPoint& sl_point,
common::math::Vec2d* const xy_point) const {
bool ReferenceLine::sl_to_xy(const common::SLPoint& sl_point,
common::math::Vec2d* const xy_point) const {
CHECK_NOTNULL(xy_point);
if (map_path_.num_points() < 2) {
AERROR << "The reference line has too few points.";
......@@ -181,9 +180,8 @@ bool ReferenceLine::get_point_in_cartesian_frame(
return true;
}
bool ReferenceLine::get_point_in_frenet_frame(
const common::math::Vec2d& xy_point,
common::SLPoint* const sl_point) const {
bool ReferenceLine::xy_to_sl(const common::math::Vec2d& xy_point,
common::SLPoint* const sl_point) const {
DCHECK_NOTNULL(sl_point);
double s = 0;
double l = 0;
......@@ -292,7 +290,7 @@ double ReferenceLine::GetSpeedLimitFromS(const double s) const {
double ReferenceLine::GetSpeedLimitFromPoint(
const common::math::Vec2d& point) const {
SLPoint sl;
if (!get_point_in_frenet_frame(point, &sl)) {
if (!xy_to_sl(point, &sl)) {
AWARN << "Failed to get projection for point: " << point.DebugString();
return FLAGS_planning_speed_upper_limit;
}
......
......@@ -49,10 +49,10 @@ class ReferenceLine {
ReferencePoint get_reference_point(const double s) const;
ReferencePoint get_reference_point(const double x, const double y) const;
bool get_point_in_cartesian_frame(const common::SLPoint& sl_point,
common::math::Vec2d* const xy_point) const;
bool get_point_in_frenet_frame(const common::math::Vec2d& xy_point,
common::SLPoint* const sl_point) const;
bool sl_to_xy(const common::SLPoint& sl_point,
common::math::Vec2d* const xy_point) const;
bool xy_to_sl(const common::math::Vec2d& xy_point,
common::SLPoint* const sl_point) const;
bool get_lane_width(const double s, double* const left_width,
double* const right_width) const;
......
......@@ -110,8 +110,7 @@ bool ReferenceLineSmoother::smooth(
}
common::SLPoint ref_sl_point;
if (!raw_reference_line.get_point_in_frenet_frame({xy.first, xy.second},
&ref_sl_point)) {
if (!raw_reference_line.xy_to_sl({xy.first, xy.second}, &ref_sl_point)) {
AERROR << "get sl point failed!" << std::endl;
return false;
}
......
......@@ -57,7 +57,7 @@ bool DPRoadGraph::FindPathTunnel(const common::TrajectoryPoint &init_point,
PathData *const path_data) {
CHECK_NOTNULL(path_data);
init_point_ = init_point;
if (!reference_line_.get_point_in_frenet_frame(
if (!reference_line_.xy_to_sl(
{init_point_.path_point().x(), init_point_.path_point().y()},
&init_sl_point_)) {
AERROR << "Fail to create init_sl_point from : "
......@@ -192,8 +192,7 @@ bool DPRoadGraph::MakeStaticObstacleDecision(
common::math::Vec2d{path_point.x(), path_point.y()}, path_point.theta(),
adc_length, adc_width);
common::SLPoint adc_sl;
if (!reference_line_.get_point_in_frenet_frame(
{path_point.x(), path_point.y()}, &adc_sl)) {
if (!reference_line_.xy_to_sl({path_point.x(), path_point.y()}, &adc_sl)) {
AERROR << "get_point_in_Frenet_frame error for ego vehicle "
<< path_point.x() << " " << path_point.y();
return false;
......@@ -359,8 +358,7 @@ bool DPRoadGraph::ComputeBoundingBoxesForAdc(
common::SLPoint sl_point;
sl_point.set_s(s);
sl_point.set_l(l);
reference_line_.get_point_in_cartesian_frame(sl_point,
&adc_position_cartesian);
reference_line_.sl_to_xy(sl_point, &adc_position_cartesian);
ReferencePoint reference_point = reference_line_.get_reference_point(s);
......@@ -383,8 +381,7 @@ bool DPRoadGraph::SamplePathWaypoints(
common::math::Vec2d init_cartesian_point(init_point.path_point().x(),
init_point.path_point().y());
common::SLPoint init_sl_point;
if (!reference_line_.get_point_in_frenet_frame(init_cartesian_point,
&init_sl_point)) {
if (!reference_line_.xy_to_sl(init_cartesian_point, &init_sl_point)) {
AERROR << "Failed to get sl point from point "
<< init_cartesian_point.DebugString();
return false;
......
......@@ -166,13 +166,11 @@ bool QpFrenetFrame::MapDynamicObstacleWithDecision(
obs_box.GetAllCorners(&corners);
std::vector<common::SLPoint> sl_corners;
for (uint32_t i = 0; i < corners.size(); ++i) {
for (const auto& corner_xy : corners) {
common::SLPoint cur_point;
if (!reference_line_.get_point_in_frenet_frame(
{corners[i].x(), corners[i].y()}, &cur_point)) {
AERROR << "Fail to map xy point " << corners[i].DebugString() << " to "
if (!reference_line_.xy_to_sl(corner_xy, &cur_point)) {
AERROR << "Fail to map xy point " << corner_xy.DebugString() << " to "
<< cur_point.ShortDebugString();
return false;
}
// shift box base on buffer
......@@ -259,11 +257,10 @@ bool QpFrenetFrame::MapPolygon(
std::vector<std::pair<double, double>>* const bound_map) {
std::vector<common::SLPoint> sl_corners;
for (uint32_t i = 0; i < corners.size(); ++i) {
for (const auto& corner_xy : corners) {
common::SLPoint cur_point;
common::math::Vec2d xy_point(corners[i].x(), corners[i].y());
if (!reference_line_.get_point_in_frenet_frame(xy_point, &cur_point)) {
AERROR << "Fail to map xy point " << corners[i].DebugString() << " to "
if (!reference_line_.xy_to_sl(corner_xy, &cur_point)) {
AERROR << "Fail to map xy point " << corner_xy.DebugString() << " to "
<< cur_point.DebugString();
return false;
}
......
......@@ -151,7 +151,7 @@ bool QpSplinePathGenerator::CalculateInitFrenetPoint(
const common::TrajectoryPoint& traj_point,
common::FrenetFramePoint* const frenet_frame_point) {
common::SLPoint sl_point;
if (!reference_line_.get_point_in_frenet_frame(
if (!reference_line_.xy_to_sl(
{traj_point.path_point().x(), traj_point.path_point().y()},
&sl_point)) {
return false;
......
......@@ -71,7 +71,7 @@ StBoundaryMapper::StBoundaryMapper(const StBoundaryConfig& config,
planning_time_(planning_time) {
const auto& path_start_point = path_data_.discretized_path().StartPoint();
common::SLPoint sl_point;
DCHECK(reference_line_.get_point_in_frenet_frame(
DCHECK(reference_line_.xy_to_sl(
{path_start_point.x(), path_start_point.y()}, &sl_point))
<< "Failed to get adc reference line s";
adc_front_s_ = sl_point.s() + vehicle_param_.front_edge_to_center();
......@@ -456,9 +456,9 @@ Status StBoundaryMapper::MapFollowDecision(
const auto* obstacle = path_obstacle.Obstacle();
SLPoint obstacle_sl_point;
reference_line_.get_point_in_frenet_frame(
Vec2d(obstacle->Perception().position().x(),
obstacle->Perception().position().y()),
reference_line_.xy_to_sl(
{obstacle->Perception().position().x(),
obstacle->Perception().position().y()},
&obstacle_sl_point);
const auto& ref_point = reference_line_.get_reference_point(
......@@ -477,8 +477,8 @@ Status StBoundaryMapper::MapFollowDecision(
const auto& start_point = path_data_.discretized_path().StartPoint();
SLPoint start_sl_point;
if (!reference_line_.get_point_in_frenet_frame(
Vec2d(start_point.x(), start_point.y()), &start_sl_point)) {
if (!reference_line_.xy_to_sl({start_point.x(), start_point.y()},
&start_sl_point)) {
std::string msg = "Fail to get s and l of start point.";
AERROR << msg;
return common::Status(ErrorCode::PLANNING_ERROR, msg);
......
......@@ -66,7 +66,7 @@ const Obstacle *TrafficDecider::CreateDestinationObstacle() {
// check if destination point is in planning range
common::SLPoint destination_sl;
const auto &reference_line = reference_line_info_->reference_line();
reference_line.get_point_in_frenet_frame(destination, &destination_sl);
reference_line.xy_to_sl(destination, &destination_sl);
double destination_s = destination_sl.s();
if (destination_s < 0 || destination_s > reference_line.length()) {
AINFO << "destination(s[:" << destination_sl.s()
......@@ -77,8 +77,7 @@ const Obstacle *TrafficDecider::CreateDestinationObstacle() {
// adjust destination based on adc_front_s
common::SLPoint adc_sl;
auto &adc_position = VehicleState::instance()->pose().position();
reference_line.get_point_in_frenet_frame({adc_position.x(), adc_position.y()},
&adc_sl);
reference_line.xy_to_sl({adc_position.x(), adc_position.y()}, &adc_sl);
const auto &vehicle_param =
VehicleConfigHelper::instance()->GetConfig().vehicle_param();
double adc_front_s = adc_sl.s() + vehicle_param.front_edge_to_center();
......@@ -124,7 +123,7 @@ bool TrafficDecider::MakeDestinationStopDecision() {
// check stop_posision on reference line
auto stop_position = obstacle->Perception().position();
common::SLPoint stop_line_sl;
reference_line.get_point_in_frenet_frame(
reference_line.xy_to_sl(
{stop_position.x(), stop_position.y()}, &stop_line_sl);
if (!reference_line.is_on_road(stop_line_sl)) {
return false;
......@@ -133,8 +132,7 @@ bool TrafficDecider::MakeDestinationStopDecision() {
// check stop_line_s vs adc_s. stop_line_s must be ahead of adc_front_s
common::SLPoint adc_sl;
auto &adc_position = VehicleState::instance()->pose().position();
reference_line.get_point_in_frenet_frame({adc_position.x(), adc_position.y()},
&adc_sl);
reference_line.xy_to_sl({adc_position.x(), adc_position.y()}, &adc_sl);
const auto &vehicle_param =
VehicleConfigHelper::instance()->GetConfig().vehicle_param();
double adc_front_s = adc_sl.s() + vehicle_param.front_edge_to_center();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册