diff --git a/modules/planning/tasks/BUILD b/modules/planning/tasks/BUILD index 6153ac4b1f7ccf292ed033247b0fe7893999d3e2..77898f11d5c7b1bb0342951c7a0bf697e9090eb4 100644 --- a/modules/planning/tasks/BUILD +++ b/modules/planning/tasks/BUILD @@ -55,7 +55,7 @@ cc_library( "//modules/planning/common:speed_limit", "//modules/planning/common/path:path_data", "//modules/planning/common/speed:speed_data", - "//modules/planning/tasks/st_graph:st_graph_boundary", + "//modules/planning/tasks/st_graph:st_boundary", "//modules/planning/tasks/st_graph:st_graph_point", "@eigen//:eigen", ], diff --git a/modules/planning/tasks/dp_st_speed/BUILD b/modules/planning/tasks/dp_st_speed/BUILD index 638a677b94ba8887dedf681c3f2b02b92cde01f7..663a233ad902434f91e37cb51131e22267225f51 100644 --- a/modules/planning/tasks/dp_st_speed/BUILD +++ b/modules/planning/tasks/dp_st_speed/BUILD @@ -14,7 +14,7 @@ cc_library( "//modules/common/proto:pnc_point_proto", "//modules/planning/common:frame", "//modules/planning/math:double", - "//modules/planning/tasks/st_graph:st_graph_boundary", + "//modules/planning/tasks/st_graph:st_boundary", "//modules/planning/proto:dp_st_speed_config_proto", ], ) diff --git a/modules/planning/tasks/dp_st_speed/dp_st_cost.cc b/modules/planning/tasks/dp_st_speed/dp_st_cost.cc index 97f4189f98941081cba029f2681a3c58aeb0a06c..f277e0deef9fb7105550d570b82ddf68135b4260 100644 --- a/modules/planning/tasks/dp_st_speed/dp_st_cost.cc +++ b/modules/planning/tasks/dp_st_speed/dp_st_cost.cc @@ -38,9 +38,9 @@ DpStCost::DpStCost(const DpStSpeedConfig& dp_st_speed_config) // TODO(all): normalize cost with time double DpStCost::GetObstacleCost( const STPoint& point, - const std::vector& st_graph_boundaries) const { + const std::vector& st_graph_boundaries) const { double total_cost = 0.0; - for (const StGraphBoundary& boundary : st_graph_boundaries) { + for (const StBoundary& boundary : st_graph_boundaries) { if (point.s() < 0 || boundary.IsPointInBoundary(point)) { total_cost = std::numeric_limits::infinity(); break; diff --git a/modules/planning/tasks/dp_st_speed/dp_st_cost.h b/modules/planning/tasks/dp_st_speed/dp_st_cost.h index 847ba31ae0dad5148b2ffefa0b4b8cd5578e6075..708eb99b5870293acc440d54a956774caa96dd30 100644 --- a/modules/planning/tasks/dp_st_speed/dp_st_cost.h +++ b/modules/planning/tasks/dp_st_speed/dp_st_cost.h @@ -27,7 +27,7 @@ #include "modules/planning/proto/dp_st_speed_config.pb.h" #include "modules/planning/common/speed/st_point.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" namespace apollo { namespace planning { @@ -38,7 +38,7 @@ class DpStCost { double GetObstacleCost( const STPoint& point, - const std::vector& st_graph_boundaries) const; + const std::vector& st_graph_boundaries) const; double GetReferenceCost(const STPoint& point, const STPoint& reference_point) const; diff --git a/modules/planning/tasks/dp_st_speed/dp_st_graph.cc b/modules/planning/tasks/dp_st_speed/dp_st_graph.cc index a6b00edc1b1656bc2fb78f1e7f2420d38888f933..b72028258728e2fe7b8d9b8fcd273cea3d0f4eec 100644 --- a/modules/planning/tasks/dp_st_speed/dp_st_graph.cc +++ b/modules/planning/tasks/dp_st_speed/dp_st_graph.cc @@ -42,7 +42,7 @@ using Vec2d = apollo::common::math::Vec2d; namespace { -bool CheckOverlapOnDpStGraph(const std::vector boundaries, +bool CheckOverlapOnDpStGraph(const std::vector boundaries, const StGraphPoint& p1, const StGraphPoint& p2) { for (const auto& boundary : boundaries) { common::math::LineSegment2d seg(p1.point(), p2.point()); @@ -135,7 +135,7 @@ Status DpStGraph::InitCostTable() { } void DpStGraph::CalculatePointwiseCost( - const std::vector& boundaries) { + const std::vector& boundaries) { // TODO(all): extract reference line from decision first std::vector reference_points; double curr_t = 0.0; @@ -533,7 +533,7 @@ bool DpStGraph::CreateFollowDecision( } bool DpStGraph::CreateYieldDecision( - const StGraphBoundary& boundary, + const StBoundary& boundary, ObjectDecisionType* const yield_decision) const { DCHECK_NOTNULL(yield_decision); @@ -561,7 +561,7 @@ bool DpStGraph::CreateYieldDecision( } bool DpStGraph::CreateOvertakeDecision( - const PathObstacle& path_obstacle, const StGraphBoundary& boundary, + const PathObstacle& path_obstacle, const StBoundary& boundary, ObjectDecisionType* const overtake_decision) const { DCHECK_NOTNULL(overtake_decision); @@ -631,7 +631,7 @@ double DpStGraph::CalculateEdgeCostForThirdCol(const uint32_t curr_row, dp_st_cost_.GetJerkCostByThreePoints(init_speed, first, second, third); } -bool DpStGraph::CheckIsFollowByT(const StGraphBoundary& boundary) const { +bool DpStGraph::CheckIsFollowByT(const StBoundary& boundary) const { DCHECK_EQ(boundary.points().size(), 4); if (boundary.BottomLeftPoint().s() > boundary.BottomRightPoint().s()) { diff --git a/modules/planning/tasks/dp_st_speed/dp_st_graph.h b/modules/planning/tasks/dp_st_speed/dp_st_graph.h index d913b790fea02481dca887ab51238975d149e263..058d8e9ac4d04c370dab60c8e33285a1c13b2840 100644 --- a/modules/planning/tasks/dp_st_speed/dp_st_graph.h +++ b/modules/planning/tasks/dp_st_speed/dp_st_graph.h @@ -50,7 +50,7 @@ class DpStGraph { private: apollo::common::Status InitCostTable(); - void CalculatePointwiseCost(const std::vector& boundaries); + void CalculatePointwiseCost(const std::vector& boundaries); apollo::common::Status RetrieveSpeedProfile( SpeedData* const speed_data) const; @@ -76,12 +76,12 @@ class DpStGraph { /** * @brief check if the ADC should follow an obstacle by examing the - *StGraphBoundary of the obstacle. + *StBoundary of the obstacle. * @param boundary The boundary of the obstacle. * @return true if the ADC believe it should follow the obstacle, and * false otherwise. **/ - bool CheckIsFollowByT(const StGraphBoundary& boundary) const; + bool CheckIsFollowByT(const StBoundary& boundary) const; /** * @brief create follow decision based on the boundary @@ -97,7 +97,7 @@ class DpStGraph { * @return true if the yield decision is created successfully, and * false otherwise. **/ - bool CreateYieldDecision(const StGraphBoundary& boundary, + bool CreateYieldDecision(const StBoundary& boundary, ObjectDecisionType* const yield_decision) const; /** @@ -106,7 +106,7 @@ class DpStGraph { * false otherwise. **/ bool CreateOvertakeDecision( - const PathObstacle& path_obstacle, const StGraphBoundary& boundary, + const PathObstacle& path_obstacle, const StBoundary& boundary, ObjectDecisionType* const overtake_decision) const; void GetRowRange(const uint32_t curr_row, const uint32_t curr_col, diff --git a/modules/planning/tasks/dp_st_speed/dp_st_speed_optimizer.cc b/modules/planning/tasks/dp_st_speed/dp_st_speed_optimizer.cc index 9b9e6824e82e9c13df2aefd95a1e88b586886ccb..da055f8946c0fb2787ac2af9f5bbc75b74e70b76 100644 --- a/modules/planning/tasks/dp_st_speed/dp_st_speed_optimizer.cc +++ b/modules/planning/tasks/dp_st_speed/dp_st_speed_optimizer.cc @@ -71,7 +71,7 @@ Status DpStSpeedOptimizer::Process(const PathData& path_data, dp_st_speed_config_.total_time()); // step 1 get boundaries - std::vector boundaries; + std::vector boundaries; if (boundary_mapper.GetGraphBoundary(*path_decision, &boundaries).code() == ErrorCode::PLANNING_ERROR) { const std::string msg = diff --git a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.cc b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.cc index 56035fe618cdec0263310e4269bb29ec8725bde7..edbed6817430b393e149bce33f026e265710f484 100644 --- a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.cc +++ b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.cc @@ -125,7 +125,7 @@ Status QpSplineStGraph::Search(const StGraphData& st_graph_data, Status QpSplineStGraph::ApplyConstraint( const common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit, - const std::vector& boundaries) { + const std::vector& boundaries) { Spline1dConstraint* constraint = spline_generator_->mutable_spline_constraint(); // position, velocity, acceleration @@ -223,7 +223,7 @@ Status QpSplineStGraph::ApplyConstraint( } Status QpSplineStGraph::ApplyKernel( - const std::vector& boundaries, + const std::vector& boundaries, const SpeedLimit& speed_limit) { Spline1dKernel* spline_kernel = spline_generator_->mutable_spline_kernel(); @@ -297,7 +297,7 @@ Status QpSplineStGraph::AddCruiseReferenceLineKernel( Status QpSplineStGraph::AddFollowReferenceLineKernel( const std::vector& evaluate_t, - const std::vector& boundaries, const double weight) { + const std::vector& boundaries, const double weight) { auto* spline_kernel = spline_generator_->mutable_spline_kernel(); std::vector ref_s; std::vector filtered_evaluate_t; @@ -305,7 +305,7 @@ Status QpSplineStGraph::AddFollowReferenceLineKernel( double s_min = std::numeric_limits::infinity(); bool success = false; for (const auto& boundary : boundaries) { - if (boundary.boundary_type() != StGraphBoundary::BoundaryType::FOLLOW) { + if (boundary.boundary_type() != StBoundary::BoundaryType::FOLLOW) { continue; } double s_upper = 0.0; @@ -336,12 +336,12 @@ Status QpSplineStGraph::AddFollowReferenceLineKernel( } Status QpSplineStGraph::GetSConstraintByTime( - const std::vector& boundaries, const double time, + const std::vector& boundaries, const double time, const double total_path_s, double* const s_upper_bound, double* const s_lower_bound) const { *s_upper_bound = total_path_s; - for (const StGraphBoundary& boundary : boundaries) { + for (const StBoundary& boundary : boundaries) { double s_upper = 0.0; double s_lower = 0.0; @@ -349,13 +349,13 @@ Status QpSplineStGraph::GetSConstraintByTime( continue; } - if (boundary.boundary_type() == StGraphBoundary::BoundaryType::STOP || - boundary.boundary_type() == StGraphBoundary::BoundaryType::FOLLOW || - boundary.boundary_type() == StGraphBoundary::BoundaryType::YIELD) { + if (boundary.boundary_type() == StBoundary::BoundaryType::STOP || + boundary.boundary_type() == StBoundary::BoundaryType::FOLLOW || + boundary.boundary_type() == StBoundary::BoundaryType::YIELD) { *s_upper_bound = std::fmin(*s_upper_bound, s_upper); } else { DCHECK(boundary.boundary_type() == - StGraphBoundary::BoundaryType::OVERTAKE); + StBoundary::BoundaryType::OVERTAKE); *s_lower_bound = std::fmax(*s_lower_bound, s_lower); } } diff --git a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.h b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.h index 0e5948085b9396fff8ad44a6bde35c36959e3d73..0c028e9a8270cd90d3b039d72da126fce4d57162 100644 --- a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.h +++ b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_graph.h @@ -34,7 +34,7 @@ #include "modules/planning/common/planning_util.h" #include "modules/planning/common/speed/speed_data.h" #include "modules/planning/math/smoothing_spline/spline_1d_generator.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" #include "modules/planning/tasks/st_graph/st_graph_data.h" namespace apollo { @@ -54,10 +54,10 @@ class QpSplineStGraph { // apply st graph constraint common::Status ApplyConstraint( const common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit, - const std::vector& boundaries); + const std::vector& boundaries); // apply objective function - common::Status ApplyKernel(const std::vector& boundaries, + common::Status ApplyKernel(const std::vector& boundaries, const SpeedLimit& speed_limit); // solve @@ -65,7 +65,7 @@ class QpSplineStGraph { // extract upper lower bound for constraint; common::Status GetSConstraintByTime( - const std::vector& boundaries, const double time, + const std::vector& boundaries, const double time, const double total_path_s, double* const s_upper_bound, double* const s_lower_bound) const; @@ -77,7 +77,7 @@ class QpSplineStGraph { common::Status AddFollowReferenceLineKernel( const std::vector& evaluate_t, - const std::vector& boundaries, const double weight); + const std::vector& boundaries, const double weight); common::Status EstimateSpeedUpperBound( const common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit, diff --git a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc index a3108dfb4a0cbf48661becb57676bb715196f2dc..fbaa627ce745b89c101fbf46d8b9fee1612bb611 100644 --- a/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc +++ b/modules/planning/tasks/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc @@ -75,7 +75,7 @@ Status QpSplineStSpeedOptimizer::Process(const PathData& path_data, DCHECK(path_obstacle->HasLongitudinalDecision()); } // step 1 get boundaries - std::vector boundaries; + std::vector boundaries; if (boundary_mapper.GetGraphBoundary(*path_decision, &boundaries).code() == ErrorCode::PLANNING_ERROR) { return Status(ErrorCode::PLANNING_ERROR, @@ -84,7 +84,7 @@ Status QpSplineStSpeedOptimizer::Process(const PathData& path_data, for (const auto& boundary : boundaries) { ADEBUG << "QPST mapped boundary: " << boundary.DebugString() << std::endl; - DCHECK(boundary.boundary_type() != StGraphBoundary::BoundaryType::UNKNOWN); + DCHECK(boundary.boundary_type() != StBoundary::BoundaryType::UNKNOWN); } SpeedLimit speed_limits; diff --git a/modules/planning/tasks/speed_optimizer.cc b/modules/planning/tasks/speed_optimizer.cc index 3f27eab3314ad0f849d09291a606c86bacd64bb5..1399b58e4f429e7319c89585ac41056b15c70ca8 100644 --- a/modules/planning/tasks/speed_optimizer.cc +++ b/modules/planning/tasks/speed_optimizer.cc @@ -49,7 +49,7 @@ void SpeedOptimizer::RecordDebugInfo(const SpeedData& speed_data) { } void SpeedOptimizer::RecordSTGraphDebug( - const std::vector& boundaries, + const std::vector& boundaries, const SpeedLimit& speed_limits, const SpeedData& speed_data) { if (!FLAGS_enable_record_debug) { ADEBUG << "Skip record debug info"; diff --git a/modules/planning/tasks/speed_optimizer.h b/modules/planning/tasks/speed_optimizer.h index 02f3f5e9b8b1ad37ad6cc7250951ccdc8d79c203..f4b342e04b0e9d63cde87206f734d4333177f0b0 100644 --- a/modules/planning/tasks/speed_optimizer.h +++ b/modules/planning/tasks/speed_optimizer.h @@ -27,7 +27,7 @@ #include "modules/common/status/status.h" #include "modules/planning/common/speed/speed_data.h" #include "modules/planning/common/speed_limit.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" #include "modules/planning/tasks/task.h" namespace apollo { @@ -46,7 +46,7 @@ class SpeedOptimizer : public Task { const ReferenceLine& reference_line, PathDecision* const path_decision, SpeedData* const speed_data) = 0; - void RecordSTGraphDebug(const std::vector& boundaries, + void RecordSTGraphDebug(const std::vector& boundaries, const SpeedLimit& speed_limits, const SpeedData& speed_data); diff --git a/modules/planning/tasks/st_graph/BUILD b/modules/planning/tasks/st_graph/BUILD index e1f8f067879c9c6aa9ea64ac6ffec033db213803..161d7c0c441c162061761a190fdd32de39424e8c 100644 --- a/modules/planning/tasks/st_graph/BUILD +++ b/modules/planning/tasks/st_graph/BUILD @@ -17,12 +17,12 @@ cc_library( ) cc_library( - name = "st_graph_boundary", + name = "st_boundary", srcs = [ - "st_graph_boundary.cc", + "st_boundary.cc", ], hdrs = [ - "st_graph_boundary.h", + "st_boundary.h", ], deps = [ ":st_graph_point", @@ -41,7 +41,7 @@ cc_library( "st_graph_data.h", ], deps = [ - ":st_graph_boundary", + ":st_boundary", "//modules/planning/common:planning_gflags", "//modules/planning/common:speed_limit", ], @@ -56,7 +56,7 @@ cc_library( "st_boundary_mapper.h", ], deps = [ - ":st_graph_boundary", + ":st_boundary", "//modules/common/configs:vehicle_config_helper", "//modules/common/configs/proto:vehicle_config_proto", "//modules/common/proto:pnc_point_proto", @@ -98,13 +98,13 @@ cc_test( ) cc_test( - name = "st_graph_boundary_test", + name = "st_boundary_test", size = "small", srcs = [ - "st_graph_boundary_test.cc", + "st_boundary_test.cc", ], deps = [ - ":st_graph_boundary", + ":st_boundary", "//modules/common:log", "//modules/common/time", "//modules/common/util", @@ -119,7 +119,7 @@ cc_test( "st_graph_data_test.cc", ], deps = [ - ":st_graph_boundary", + ":st_boundary", ":st_graph_data", "//modules/common:log", "//modules/common/time", diff --git a/modules/planning/tasks/st_graph/st_graph_boundary.cc b/modules/planning/tasks/st_graph/st_boundary.cc similarity index 64% rename from modules/planning/tasks/st_graph/st_graph_boundary.cc rename to modules/planning/tasks/st_graph/st_boundary.cc index 632b144c85593026fbba359bab962f046aa2877e..2b524856e72c8b4ab61f5a628546b701d4cfa855 100644 --- a/modules/planning/tasks/st_graph/st_graph_boundary.cc +++ b/modules/planning/tasks/st_graph/st_boundary.cc @@ -15,10 +15,10 @@ *****************************************************************************/ /** - * @file: obstacle_st_boundary.cc + * @file **/ -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" #include @@ -29,10 +29,10 @@ namespace planning { using Vec2d = common::math::Vec2d; -StGraphBoundary::StGraphBoundary(const std::vector& points) +StBoundary::StBoundary(const std::vector& points) : Polygon2d(std::vector(points.begin(), points.end())) { CHECK_EQ(points.size(), 4) - << "StGraphBoundary must have exactly four points. Input points size: " + << "StBoundary must have exactly four points. Input points size: " << points.size(); for (const auto& point : points) { min_s_ = std::fmin(min_s_, point.s()); @@ -42,11 +42,10 @@ StGraphBoundary::StGraphBoundary(const std::vector& points) } } -StGraphBoundary::StGraphBoundary( - const std::vector<::apollo::common::math::Vec2d>& points) +StBoundary::StBoundary(const std::vector<::apollo::common::math::Vec2d>& points) : Polygon2d(points) { CHECK_EQ(points.size(), 4) - << "StGraphBoundary must have exactly four points. Input points size: " + << "StBoundary must have exactly four points. Input points size: " << points.size(); for (const auto& point : points) { min_s_ = std::fmin(min_s_, point.y()); @@ -56,57 +55,55 @@ StGraphBoundary::StGraphBoundary( } } -bool StGraphBoundary::IsPointInBoundary( - const StGraphPoint& st_graph_point) const { +bool StBoundary::IsPointInBoundary(const StGraphPoint& st_graph_point) const { return IsPointInBoundary(st_graph_point.point()); } -bool StGraphBoundary::IsPointInBoundary(const STPoint& st_point) const { +bool StBoundary::IsPointInBoundary(const STPoint& st_point) const { return IsPointIn(st_point); } -STPoint StGraphBoundary::BottomLeftPoint() const { - DCHECK(!points_.empty()) << "StGraphBoundary has zero points."; +STPoint StBoundary::BottomLeftPoint() const { + DCHECK(!points_.empty()) << "StBoundary has zero points."; return STPoint(points_.at(0).y(), points_.at(0).x()); } -STPoint StGraphBoundary::BottomRightPoint() const { - DCHECK(!points_.empty()) << "StGraphBoundary has zero points."; +STPoint StBoundary::BottomRightPoint() const { + DCHECK(!points_.empty()) << "StBoundary has zero points."; return STPoint(points_.at(1).y(), points_.at(1).x()); } -STPoint StGraphBoundary::TopRightPoint() const { - DCHECK(!points_.empty()) << "StGraphBoundary has zero points."; +STPoint StBoundary::TopRightPoint() const { + DCHECK(!points_.empty()) << "StBoundary has zero points."; return STPoint(points_.at(2).y(), points_.at(2).x()); } -STPoint StGraphBoundary::TopLeftPoint() const { - DCHECK(!points_.empty()) << "StGraphBoundary has zero points."; +STPoint StBoundary::TopLeftPoint() const { + DCHECK(!points_.empty()) << "StBoundary has zero points."; return STPoint(points_.at(3).y(), points_.at(3).x()); } -StGraphBoundary::BoundaryType StGraphBoundary::boundary_type() const { +StBoundary::BoundaryType StBoundary::boundary_type() const { return boundary_type_; } -void StGraphBoundary::SetBoundaryType(const BoundaryType& boundary_type) { +void StBoundary::SetBoundaryType(const BoundaryType& boundary_type) { boundary_type_ = boundary_type; } -const std::string& StGraphBoundary::id() const { return id_; } +const std::string& StBoundary::id() const { return id_; } -void StGraphBoundary::SetId(const std::string& id) { id_ = id; } +void StBoundary::SetId(const std::string& id) { id_ = id; } -double StGraphBoundary::characteristic_length() const { +double StBoundary::characteristic_length() const { return characteristic_length_; } -void StGraphBoundary::SetCharacteristicLength( - const double characteristic_length) { +void StBoundary::SetCharacteristicLength(const double characteristic_length) { characteristic_length_ = characteristic_length; } -bool StGraphBoundary::GetUnblockSRange(const double curr_time, double* s_upper, - double* s_lower) const { +bool StBoundary::GetUnblockSRange(const double curr_time, double* s_upper, + double* s_lower) const { const common::math::LineSegment2d segment = {Vec2d(curr_time, 0.0), Vec2d(curr_time, s_high_limit_)}; *s_upper = s_high_limit_; @@ -135,8 +132,8 @@ bool StGraphBoundary::GetUnblockSRange(const double curr_time, double* s_upper, return true; } -bool StGraphBoundary::GetBoundarySRange(const double curr_time, double* s_upper, - double* s_lower) const { +bool StBoundary::GetBoundarySRange(const double curr_time, double* s_upper, + double* s_lower) const { const common::math::LineSegment2d segment = {Vec2d(curr_time, 0.0), Vec2d(curr_time, s_high_limit_)}; *s_upper = s_high_limit_; @@ -154,10 +151,10 @@ bool StGraphBoundary::GetBoundarySRange(const double curr_time, double* s_upper, return true; } -double StGraphBoundary::min_s() const { return min_s_; } -double StGraphBoundary::min_t() const { return min_t_; } -double StGraphBoundary::max_s() const { return max_s_; } -double StGraphBoundary::max_t() const { return max_t_; } +double StBoundary::min_s() const { return min_s_; } +double StBoundary::min_t() const { return min_t_; } +double StBoundary::max_s() const { return max_s_; } +double StBoundary::max_t() const { return max_t_; } } // namespace planning } // namespace apollo diff --git a/modules/planning/tasks/st_graph/st_graph_boundary.h b/modules/planning/tasks/st_graph/st_boundary.h similarity index 90% rename from modules/planning/tasks/st_graph/st_graph_boundary.h rename to modules/planning/tasks/st_graph/st_boundary.h index 74ec1fe1bdd6ca2a8a840f4f501abe03749f4c70..6e9e756376c3eda027b7f987a2d5ac652fbd81c0 100644 --- a/modules/planning/tasks/st_graph/st_graph_boundary.h +++ b/modules/planning/tasks/st_graph/st_boundary.h @@ -15,7 +15,7 @@ *****************************************************************************/ /** - * @file: st_graph_boundary.h + * @file **/ #ifndef MODULES_PLANNING_TASKS_ST_GRAPH_ST_GRAPH_BOUNDARY_H_ @@ -34,16 +34,16 @@ namespace apollo { namespace planning { -class StGraphBoundary : public common::math::Polygon2d { +class StBoundary : public common::math::Polygon2d { public: - StGraphBoundary() = default; + StBoundary() = default; // boundary points go counter clockwise. - explicit StGraphBoundary(const std::vector& points); + explicit StBoundary(const std::vector& points); // boundary points go counter clockwise. - explicit StGraphBoundary(const std::vector& points); - ~StGraphBoundary() = default; + explicit StBoundary(const std::vector& points); + ~StBoundary() = default; // if you need to add boundary type, make sure you modify // GetUnblockSRange accordingly. diff --git a/modules/planning/tasks/st_graph/st_boundary_mapper.cc b/modules/planning/tasks/st_graph/st_boundary_mapper.cc index 1a53559d6cc024d39698af9a2de2770af436aae6..bda730644a987b8200e943870702964f9d95998e 100644 --- a/modules/planning/tasks/st_graph/st_boundary_mapper.cc +++ b/modules/planning/tasks/st_graph/st_boundary_mapper.cc @@ -79,7 +79,7 @@ StBoundaryMapper::StBoundaryMapper(const StBoundaryConfig& config, Status StBoundaryMapper::GetGraphBoundary( const PathDecision& path_decision, - std::vector* const st_graph_boundaries) const { + std::vector* const st_graph_boundaries) const { const auto& path_obstacles = path_decision.path_obstacles(); if (st_graph_boundaries == nullptr) { const std::string msg = "st_graph_boundaries is NULL."; @@ -110,7 +110,7 @@ Status StBoundaryMapper::GetGraphBoundary( for (const auto* path_obstacle : path_obstacles.Items()) { if (!path_obstacle->HasLongitudinalDecision()) { - StGraphBoundary boundary; + StBoundary boundary; const auto ret = MapWithoutDecision(*path_obstacle, &boundary); if (!ret.ok()) { std::string msg = common::util::StrCat( @@ -123,7 +123,7 @@ Status StBoundaryMapper::GetGraphBoundary( } const auto& decision = path_obstacle->LongitudinalDecision(); if (decision.has_follow()) { - StGraphBoundary follow_boundary; + StBoundary follow_boundary; const auto ret = MapFollowDecision(*path_obstacle, decision, &follow_boundary); if (!ret.ok()) { @@ -152,7 +152,7 @@ Status StBoundaryMapper::GetGraphBoundary( stop_decision = decision; } } else if (decision.has_overtake() || decision.has_yield()) { - StGraphBoundary boundary; + StBoundary boundary; const auto ret = MapWithPredictionTrajectory(*path_obstacle, decision, &boundary); if (!ret.ok()) { @@ -168,7 +168,7 @@ Status StBoundaryMapper::GetGraphBoundary( } if (stop_obstacle) { - StGraphBoundary stop_boundary; + StBoundary stop_boundary; bool success = MapStopDecision(*stop_obstacle, stop_decision, &stop_boundary); if (!success) { @@ -178,16 +178,16 @@ Status StBoundaryMapper::GetGraphBoundary( } AppendBoundary(stop_boundary, st_graph_boundaries); } - for (const auto& st_graph_boundary : *st_graph_boundaries) { - DCHECK_EQ(st_graph_boundary.points().size(), 4); - DCHECK_NE(st_graph_boundary.id().length(), 0); + for (const auto& st_boundary : *st_graph_boundaries) { + DCHECK_EQ(st_boundary.points().size(), 4); + DCHECK_NE(st_boundary.id().length(), 0); } return Status::OK(); } bool StBoundaryMapper::MapStopDecision(const PathObstacle& stop_obstacle, const ObjectDecisionType& stop_decision, - StGraphBoundary* const boundary) const { + StBoundary* const boundary) const { CHECK_NOTNULL(boundary); DCHECK(stop_decision.has_stop()) << "Must have stop decision"; @@ -222,15 +222,15 @@ bool StBoundaryMapper::MapStopDecision(const PathObstacle& stop_obstacle, planning_time_); boundary_points.emplace_back(s_max, 0.0); - *boundary = StGraphBoundary(boundary_points); - boundary->SetBoundaryType(StGraphBoundary::BoundaryType::STOP); + *boundary = StBoundary(boundary_points); + boundary->SetBoundaryType(StBoundary::BoundaryType::STOP); boundary->SetCharacteristicLength(st_boundary_config_.boundary_buffer()); boundary->SetId(stop_obstacle.Id()); return true; } Status StBoundaryMapper::MapWithoutDecision( - const PathObstacle& path_obstacle, StGraphBoundary* const boundary) const { + const PathObstacle& path_obstacle, StBoundary* const boundary) const { std::vector lower_points; std::vector upper_points; @@ -257,7 +257,7 @@ Status StBoundaryMapper::MapWithoutDecision( AWARN << "lower/upper points are reversed."; } - *boundary = StGraphBoundary(boundary_points); + *boundary = StBoundary(boundary_points); boundary->SetId(path_obstacle.Obstacle()->Id()); } return Status::OK(); @@ -344,7 +344,7 @@ bool StBoundaryMapper::GetOverlapBoundaryPoints( Status StBoundaryMapper::MapWithPredictionTrajectory( const PathObstacle& path_obstacle, const ObjectDecisionType& obj_decision, - StGraphBoundary* const boundary) const { + StBoundary* const boundary) const { DCHECK_NOTNULL(boundary); DCHECK(obj_decision.has_follow() || obj_decision.has_yield() || obj_decision.has_overtake()) @@ -387,8 +387,8 @@ Status StBoundaryMapper::MapWithPredictionTrajectory( } // change boundary according to obj_decision. - StGraphBoundary::BoundaryType b_type = - StGraphBoundary::BoundaryType::UNKNOWN; + StBoundary::BoundaryType b_type = + StBoundary::BoundaryType::UNKNOWN; double characteristic_length = 0.0; constexpr double kBoundaryEpsilon = 1e-3; if (obj_decision.has_follow()) { @@ -404,7 +404,7 @@ Status StBoundaryMapper::MapWithPredictionTrajectory( boundary_points.at(0).set_s(boundary_points.at(0).s()); boundary_points.at(1).set_s(boundary_points.at(1).s()); boundary_points.at(3).set_t(-1.0); - b_type = StGraphBoundary::BoundaryType::FOLLOW; + b_type = StBoundary::BoundaryType::FOLLOW; } else if (obj_decision.has_yield()) { const double dis = std::fabs(obj_decision.yield().distance_s()); characteristic_length = dis; @@ -422,7 +422,7 @@ Status StBoundaryMapper::MapWithPredictionTrajectory( boundary_points.at(1).set_s(boundary_points.at(1).s() - dis); } boundary_points.at(3).set_t(-kBoundaryEpsilon); - b_type = StGraphBoundary::BoundaryType::YIELD; + b_type = StBoundary::BoundaryType::YIELD; } else if (obj_decision.has_overtake()) { const double dis = std::fabs(obj_decision.overtake().distance_s()); @@ -433,12 +433,12 @@ Status StBoundaryMapper::MapWithPredictionTrajectory( const double time_buffer = obj_decision.overtake().time_buffer(); boundary_points.at(3).set_t(boundary_points.at(3).t() - time_buffer); - b_type = StGraphBoundary::BoundaryType::OVERTAKE; + b_type = StBoundary::BoundaryType::OVERTAKE; } else { DCHECK(false) << "Obj decision should be either yield or overtake: " << obj_decision.DebugString(); } - *boundary = StGraphBoundary(boundary_points); + *boundary = StBoundary(boundary_points); boundary->SetBoundaryType(b_type); boundary->SetId(path_obstacle.Obstacle()->Id()); boundary->SetCharacteristicLength(characteristic_length); @@ -448,7 +448,7 @@ Status StBoundaryMapper::MapWithPredictionTrajectory( Status StBoundaryMapper::MapFollowDecision( const PathObstacle& path_obstacle, const ObjectDecisionType& obj_decision, - StGraphBoundary* const boundary) const { + StBoundary* const boundary) const { DCHECK_NOTNULL(boundary); DCHECK(obj_decision.has_follow()) << "Map obstacle without prediction trajectory is ONLY supported when " @@ -513,7 +513,7 @@ Status StBoundaryMapper::MapFollowDecision( boundary_points.emplace_back(s_max_upper, planning_time_); boundary_points.emplace_back(s_min_upper, 0.0); - *boundary = StGraphBoundary(boundary_points); + *boundary = StBoundary(boundary_points); const double characteristic_length = std::fabs(obj_decision.follow().distance_s()) + @@ -521,7 +521,7 @@ Status StBoundaryMapper::MapFollowDecision( boundary->SetCharacteristicLength(characteristic_length); boundary->SetId(obstacle->Id()); - boundary->SetBoundaryType(StGraphBoundary::BoundaryType::FOLLOW); + boundary->SetBoundaryType(StBoundary::BoundaryType::FOLLOW); return Status::OK(); } @@ -574,8 +574,8 @@ Status StBoundaryMapper::GetSpeedLimits( } void StBoundaryMapper::AppendBoundary( - const StGraphBoundary& boundary, - std::vector* st_graph_boundaries) const { + const StBoundary& boundary, + std::vector* st_graph_boundaries) const { if (Double::Compare(boundary.area(), 0.0) <= 0) { return; } diff --git a/modules/planning/tasks/st_graph/st_boundary_mapper.h b/modules/planning/tasks/st_graph/st_boundary_mapper.h index d9f61efe6e287466177ac4f3a25becab48367c64..68e55c2c3d6559d4697a168f4bc08f9e3a8fd328 100644 --- a/modules/planning/tasks/st_graph/st_boundary_mapper.h +++ b/modules/planning/tasks/st_graph/st_boundary_mapper.h @@ -30,7 +30,7 @@ #include "modules/planning/common/path/path_data.h" #include "modules/planning/common/path_decision.h" #include "modules/planning/common/speed_limit.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" #include "modules/planning/reference_line/reference_line.h" namespace apollo { @@ -45,7 +45,7 @@ class StBoundaryMapper { apollo::common::Status GetGraphBoundary( const PathDecision& path_decision, - std::vector* const boundary) const; + std::vector* const boundary) const; virtual apollo::common::Status GetSpeedLimits( SpeedLimit* const speed_limit_data) const; @@ -62,22 +62,22 @@ class StBoundaryMapper { std::vector* lower_points) const; apollo::common::Status MapWithoutDecision( - const PathObstacle& path_obstacle, StGraphBoundary* const boundary) const; + const PathObstacle& path_obstacle, StBoundary* const boundary) const; bool MapStopDecision(const PathObstacle& stop_obstacle, const ObjectDecisionType& stop_decision, - StGraphBoundary* const boundary) const; + StBoundary* const boundary) const; apollo::common::Status MapWithPredictionTrajectory( const PathObstacle& path_obstacle, const ObjectDecisionType& obj_decision, - StGraphBoundary* const boundary) const; + StBoundary* const boundary) const; apollo::common::Status MapFollowDecision( const PathObstacle& obstacle, const ObjectDecisionType& obj_decision, - StGraphBoundary* const boundary) const; + StBoundary* const boundary) const; - void AppendBoundary(const StGraphBoundary& boundary, - std::vector* st_graph_boundaries) const; + void AppendBoundary(const StBoundary& boundary, + std::vector* st_graph_boundaries) const; private: StBoundaryConfig st_boundary_config_; diff --git a/modules/planning/tasks/st_graph/st_graph_boundary_test.cc b/modules/planning/tasks/st_graph/st_boundary_test.cc similarity index 85% rename from modules/planning/tasks/st_graph/st_graph_boundary_test.cc rename to modules/planning/tasks/st_graph/st_boundary_test.cc index 72a76f3166764d21980c8624e4f9f735c54f6dea..6fc7f2a01b15b560ff3ebf350f57cd9e1e76114e 100644 --- a/modules/planning/tasks/st_graph/st_graph_boundary_test.cc +++ b/modules/planning/tasks/st_graph/st_boundary_test.cc @@ -14,7 +14,7 @@ * limitations under the License. *****************************************************************************/ -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" #include #include @@ -27,30 +27,30 @@ namespace apollo { namespace planning { -TEST(StGraphBoundaryTest, basic_test) { +TEST(StBoundaryTest, basic_test) { std::vector st_points; st_points.emplace_back(0.0, 0.0); st_points.emplace_back(0.0, 10.0); st_points.emplace_back(5.0, 10.0); st_points.emplace_back(5.0, 0.0); - StGraphBoundary boundary(st_points); + StBoundary boundary(st_points); EXPECT_EQ(boundary.id(), ""); - EXPECT_EQ(boundary.boundary_type(), StGraphBoundary::BoundaryType::UNKNOWN); + EXPECT_EQ(boundary.boundary_type(), StBoundary::BoundaryType::UNKNOWN); EXPECT_FLOAT_EQ(0.0, boundary.min_s()); EXPECT_FLOAT_EQ(5.0, boundary.max_s()); EXPECT_FLOAT_EQ(0.0, boundary.min_t()); EXPECT_FLOAT_EQ(10.0, boundary.max_t()); } -TEST(StGraphBoundaryTest, boundary_range) { +TEST(StBoundaryTest, boundary_range) { std::vector st_points; st_points.emplace_back(1.0, 0.0); st_points.emplace_back(1.0, 10.0); st_points.emplace_back(5.0, 10.0); st_points.emplace_back(5.0, 0.0); - StGraphBoundary boundary(st_points); - boundary.SetBoundaryType(StGraphBoundary::BoundaryType::YIELD); + StBoundary boundary(st_points); + boundary.SetBoundaryType(StBoundary::BoundaryType::YIELD); double t = -10.0; const double dt = 0.01; while (t < 10.0) { diff --git a/modules/planning/tasks/st_graph/st_graph_data.cc b/modules/planning/tasks/st_graph/st_graph_data.cc index 59d91680c85526cb6bb11b301ae4b10a5fffce87..9ac7adf8476d33d51c68cac734c8fff680e35c2a 100644 --- a/modules/planning/tasks/st_graph/st_graph_data.cc +++ b/modules/planning/tasks/st_graph/st_graph_data.cc @@ -26,7 +26,7 @@ namespace planning { using apollo::common::TrajectoryPoint; StGraphData::StGraphData( - const std::vector& st_graph_boundaries, + const std::vector& st_graph_boundaries, const TrajectoryPoint& init_point, const SpeedLimit& speed_limit, const double path_data_length) : st_graph_boundaries_(st_graph_boundaries), @@ -34,7 +34,7 @@ StGraphData::StGraphData( speed_limit_(speed_limit), path_data_length_(path_data_length) {} -const std::vector& StGraphData::st_graph_boundaries() const { +const std::vector& StGraphData::st_graph_boundaries() const { return st_graph_boundaries_; } diff --git a/modules/planning/tasks/st_graph/st_graph_data.h b/modules/planning/tasks/st_graph/st_graph_data.h index a6023c1c0ad9bd06288ff653f51f6055a44b58d7..29c641a7153759a3b9f187fefe596b97a882b27b 100644 --- a/modules/planning/tasks/st_graph/st_graph_data.h +++ b/modules/planning/tasks/st_graph/st_graph_data.h @@ -27,7 +27,7 @@ #include "modules/common/proto/pnc_point.pb.h" #include "modules/planning/common/speed_limit.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" namespace apollo { namespace planning { @@ -36,11 +36,11 @@ class StGraphData { public: StGraphData() = default; - StGraphData(const std::vector& st_graph_boundaries, + StGraphData(const std::vector& st_graph_boundaries, const apollo::common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit, const double path_data_length); - const std::vector& st_graph_boundaries() const; + const std::vector& st_graph_boundaries() const; const apollo::common::TrajectoryPoint& init_point() const; @@ -49,7 +49,7 @@ class StGraphData { double path_data_length() const; private: - std::vector st_graph_boundaries_; + std::vector st_graph_boundaries_; apollo::common::TrajectoryPoint init_point_; SpeedLimit speed_limit_; diff --git a/modules/planning/tasks/st_graph/st_graph_data_test.cc b/modules/planning/tasks/st_graph/st_graph_data_test.cc index e34d36bb8612be53dfe354d8808f6bffe520b2fb..2cc994c774e4c8bc177f38a12478270e7af038aa 100644 --- a/modules/planning/tasks/st_graph/st_graph_data_test.cc +++ b/modules/planning/tasks/st_graph/st_graph_data_test.cc @@ -23,7 +23,7 @@ #include "gtest/gtest.h" #include "modules/common/log.h" -#include "modules/planning/tasks/st_graph/st_graph_boundary.h" +#include "modules/planning/tasks/st_graph/st_boundary.h" namespace apollo { namespace planning { @@ -43,8 +43,8 @@ TEST(StGraphDataTest, basic_test) { EXPECT_DOUBLE_EQ(st_graph_data.init_point().relative_time(), 0.0); EXPECT_DOUBLE_EQ(st_graph_data.path_data_length(), 0.0); - std::vector boundary_vec; - boundary_vec.push_back(StGraphBoundary()); + std::vector boundary_vec; + boundary_vec.push_back(StBoundary()); apollo::common::TrajectoryPoint traj_point; traj_point.mutable_path_point()->set_x(1.1); traj_point.mutable_path_point()->set_y(2.1);