25#include "modules/common_msgs/map_msgs/map_lane.pb.h"
37 const std::shared_ptr<DependencyInjector>& injector) {
42 return TrafficRule::LoadConfig<DestinationConfig>(&config_);
48 CHECK_NOTNULL(reference_line_info);
50 MakeDecisions(frame, reference_line_info);
58int Destination::MakeDecisions(
Frame* frame,
61 CHECK_NOTNULL(reference_line_info);
68 if (
nullptr == routing_end) {
69 AERROR <<
"routing_request has no end";
72 common::SLPoint dest_sl;
73 const auto& reference_line = reference_line_info->
reference_line();
74 reference_line.
XYToSL(routing_end->pose(), &dest_sl);
77 const auto& vehicle_config =
78 common::VehicleConfigHelper::Instance()->GetConfig();
79 const double ego_front_to_center =
80 vehicle_config.vehicle_param().front_edge_to_center();
81 if (dest_sl.s() + ego_front_to_center > reference_line.Length()) {
82 AWARN <<
"dest_sl.s() + ego_front_to_center > reference_line->length()"
83 <<
"may cause ego is stoped by PATH_END fence not by destination";
86 injector_->planning_context()->mutable_planning_status()->destination();
87 if (adc_sl.start_s() > dest_sl.s() && !dest.has_passed_destination()) {
88 ADEBUG <<
"Destination at back, but we have not reached destination yet";
92 const std::string stop_wall_id = FLAGS_destination_obstacle_id;
93 const std::vector<std::string> wait_for_obstacle_ids;
95 const auto& pull_over_status =
96 injector_->planning_context()->planning_status().pull_over();
97 if (pull_over_status.has_position() && pull_over_status.position().has_x() &&
98 pull_over_status.position().has_y()) {
100 ADEBUG <<
"BuildStopDecision: pull-over position";
101 common::SLPoint pull_over_sl;
102 reference_line.XYToSL(pull_over_status.position(), &pull_over_sl);
104 const double stop_line_s = pull_over_sl.s() +
110 StopReasonCode::STOP_REASON_PULL_OVER,
111 wait_for_obstacle_ids,
Getname(), frame,
112 reference_line_info);
117 ADEBUG <<
"BuildStopDecision: destination";
118 const double dest_lane_s =
119 std::fmax(0.0, routing_end->s() - FLAGS_virtual_stop_wall_length -
122 stop_wall_id, routing_end->id(), dest_lane_s, config_.
stop_distance(),
123 StopReasonCode::STOP_REASON_DESTINATION, wait_for_obstacle_ids,
Getname(),
124 frame, reference_line_info);
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
@Brief This is a helper class that can load vehicle configurations.
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
common::Status ApplyRule(Frame *const frame, ReferenceLineInfo *const reference_line_info)
bool Init(const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
Frame holds all data for one planning cycle.
const LocalView & local_view() const
const bool is_near_destination() const
ReferenceLineInfo holds all data for one reference line.
const ReferenceLine & reference_line() const
const SLBoundary & AdcSlBoundary() const
bool XYToSL(const common::math::Vec2d &xy_point, common::SLPoint *const sl_point, double warm_start_s=-1.0) const
Transvert Cartesian coordinates to Frenet.
virtual bool Init(const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
std::shared_ptr< DependencyInjector > injector_
Planning module main class.
int BuildStopDecision(const std::string &stop_wall_id, const double stop_line_s, const double stop_distance, const StopReasonCode &stop_reason_code, const std::vector< std::string > &wait_for_obstacles, const std::string &decision_tag, Frame *const frame, ReferenceLineInfo *const reference_line_info, double stop_wall_width)
optional VehicleParam vehicle_param
optional double front_edge_to_center
optional double stop_distance
std::shared_ptr< routing::LaneWaypoint > end_lane_way_point