36 if (std::isnan(vehicle_state.
x()) || std::isnan(vehicle_state.
y()) ||
37 std::isnan(vehicle_state.
z()) || std::isnan(vehicle_state.
heading()) ||
38 std::isnan(vehicle_state.
kappa()) ||
48 if (first.has_header() && second.has_header()) {
49 const auto& first_header = first.
header();
50 const auto& second_header = second.
header();
51 return (first_header.sequence_num() != second_header.sequence_num() ||
52 first_header.module_name() != second_header.module_name());
59 const double adc_front_edge_s,
const double stop_line_s) {
61 const double max_adc_stop_speed = common::VehicleConfigHelper::Instance()
64 .max_abs_speed_when_stopped();
65 if (adc_speed < max_adc_stop_speed) {
69 double stop_distance = 0;
71 if (stop_line_s > adc_front_edge_s) {
72 stop_distance = stop_line_s - adc_front_edge_s;
74 if (stop_distance < 1e-5) {
75 return std::numeric_limits<double>::max();
77 return (adc_speed * adc_speed) / (2 * stop_distance);
84 const std::string& stop_sign_overlap_id) {
85 const std::vector<PathOverlap>& stop_sign_overlaps =
87 auto stop_sign_overlap_it =
88 std::find_if(stop_sign_overlaps.begin(), stop_sign_overlaps.end(),
89 [&stop_sign_overlap_id](
const PathOverlap& overlap) {
90 return overlap.object_id == stop_sign_overlap_id;
92 return (stop_sign_overlap_it != stop_sign_overlaps.end());
100 const std::string& traffic_light_overlap_id) {
101 const std::vector<PathOverlap>& traffic_light_overlaps =
103 auto traffic_light_overlap_it =
104 std::find_if(traffic_light_overlaps.begin(), traffic_light_overlaps.end(),
105 [&traffic_light_overlap_id](
const PathOverlap& overlap) {
106 return overlap.object_id == traffic_light_overlap_id;
108 return (traffic_light_overlap_it != traffic_light_overlaps.end());
119 reference_line_info.
GetJunction(adc_front_edge_s, &junction_overlap);
120 if (junction_overlap.
object_id.empty()) {
124 static constexpr double kIntersectionPassDist = 2.0;
125 const double distance_adc_pass_intersection =
126 adc_back_edge_s - junction_overlap.
end_s;
127 ADEBUG <<
"distance_adc_pass_intersection[" << distance_adc_pass_intersection
128 <<
"] junction_overlap[" << junction_overlap.
object_id <<
"] start_s["
129 << junction_overlap.
start_s <<
"]";
131 return distance_adc_pass_intersection < kIntersectionPassDist;
138 std::vector<std::string>* files) {
140 if (!boost::filesystem::exists(path)) {
143 if (boost::filesystem::is_regular_file(path)) {
144 AINFO <<
"Found record file: " << path.c_str();
145 files->push_back(path.c_str());
148 if (boost::filesystem::is_directory(path)) {
149 for (
auto& entry : boost::make_iterator_range(
150 boost::filesystem::directory_iterator(path), {})) {
160 double s,
bool* is_left) {
161 const auto& vehicle_param =
162 common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param();
163 double max_kappa = 1.0 / vehicle_param.min_turn_radius();
164 double half_wb = 0.5 * vehicle_param.wheel_base();
165 double front_l = vehicle_param.front_edge_to_center() - half_wb;
166 double half_w = 0.5 * vehicle_param.width();
167 double current_heading =
183 *is_left = (kappa_b < 0.0);
185 if (kappa_f * kappa_b < 0.0 || fabs(kappa_f) < 1e-6) {
189 kappa_f = std::min(fabs(kappa_f), max_kappa);
190 kappa_b = std::min(fabs(kappa_b), max_kappa);
192 double sint = std::sin(theta);
193 double cost = std::cos(theta);
194 double r_f = 1.0 / kappa_f;
197 r_f + front_l * sint + half_w * cost)
200 return std::max(eq_half_w, half_w);
205 const auto& vehicle_param =
206 common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param();
207 double max_kappa = 1.0 / vehicle_param.min_turn_radius();
208 double half_wb = 0.5 * vehicle_param.wheel_base();
209 double front_l = vehicle_param.front_edge_to_center() - half_wb;
210 double half_w = 0.5 * vehicle_param.width();
211 double current_heading = lane_info->Heading(s);
212 double heading_f = lane_info->Heading(s + front_l);
213 double heading_b = lane_info->Heading(s - half_wb);
222 *is_left = (kappa_b < 0.0);
224 if (kappa_f * kappa_b < 0.0 || fabs(kappa_f) < 1e-6) {
228 kappa_f = std::min(fabs(kappa_f), max_kappa);
229 kappa_b = std::min(fabs(kappa_b), max_kappa);
231 double sint = std::sin(theta);
232 double cost = std::cos(theta);
233 double r_f = 1.0 / kappa_f;
236 r_f + front_l * sint + half_w * cost)
239 return std::max(eq_half_w, half_w);
247 if (delta_x > r * (1.0 + std::sin(heading)) - 1e-6) {
248 *result = std::numeric_limits<double>::lowest();
252 *result = std::sqrt(r * r - std::pow(delta_x - r * std::sin(heading), 2)) -
253 r * std::cos(heading);
262 if (delta_x > r * (1.0 - std::sin(heading)) - 1e-6) {
263 *result = std::numeric_limits<double>::max();
266 *result = r * std::cos(heading) -
267 std::sqrt(r * r - std::pow(delta_x + r * std::sin(heading), 2));
278 if (heading > 0 || kappa < 0 ||
279 delta_x > r * (1.0 - std::sin(heading)) - 1e-6) {
280 *result = std::numeric_limits<double>::lowest();
283 if (delta_x < -r * std::sin(heading)) {
284 *result = r * std::cos(heading) -
285 std::sqrt(r * r - std::pow(delta_x - r * std::sin(heading), 2));
287 *result = std::sqrt(r * r - std::pow(delta_x + r * std::sin(heading), 2)) -
288 r * (2 - std::cos(heading));
300 if (heading < 0 || kappa > 0 ||
301 delta_x > r * (1.0 - std::sin(heading)) - 1e-6) {
302 *result = std::numeric_limits<double>::max();
305 if (delta_x < r * std::sin(heading)) {
306 *result = std::sqrt(r * r - std::pow(delta_x - r * std::sin(heading), 2)) -
307 r * std::cos(heading);
309 *result = r * (2 - std::cos(heading)) -
310 std::sqrt(r * r - std::pow(delta_x - r * std::sin(heading), 2));
The class of vehicle state.
double linear_velocity() const
Get the vehicle's linear velocity.
Implements a class of 2-dimensional vectors.
double Length() const
Gets the length of the vector
double Angle() const
Gets the angle between the vector and the positive x semi-axis
const std::vector< PathOverlap > & signal_overlaps() const
const std::vector< PathOverlap > & stop_sign_overlaps() const
ReferenceLineInfo holds all data for one reference line.
int GetJunction(const double s, hdmap::PathOverlap *junction_overlap) const
const ReferenceLine & reference_line() const
const SLBoundary & AdcSlBoundary() const
const hdmap::Path & map_path() const
ReferencePoint GetReferencePoint(const double s) const
Planning module main class.
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
bool left_arc_bound_with_heading(double delta_x, double r, double heading, double *result)
bool CheckInsideJunction(const ReferenceLineInfo &reference_line_info)
bool CheckStopSignOnReferenceLine(const ReferenceLineInfo &reference_line_info, const std::string &stop_sign_overlap_id)
bool right_arc_bound_with_heading(double delta_x, double r, double heading, double *result)
double CalculateEquivalentEgoWidth(const ReferenceLineInfo &reference_line_info, double s, bool *is_left)
bool left_arc_bound_with_heading_with_reverse_kappa(double delta_x, double r, double heading, double kappa, double *result)
void GetFilesByPath(const boost::filesystem::path &path, std::vector< std::string > *files)
bool IsVehicleStateValid(const VehicleState &vehicle_state)
double GetADCStopDeceleration(apollo::common::VehicleStateProvider *vehicle_state, const double adc_front_edge_s, const double stop_line_s)
bool IsDifferentRouting(const PlanningCommand &first, const PlanningCommand &second)
bool right_arc_bound_with_heading_with_reverse_kappa(double delta_x, double r, double heading, double kappa, double *result)
bool CheckTrafficLightOnReferenceLine(const ReferenceLineInfo &reference_line_info, const std::string &traffic_light_overlap_id)
optional double linear_velocity
optional double linear_acceleration
optional apollo::common::Header header