Apollo 11.0
自动驾驶开放平台
open_space_trajectory_post_process.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
21#pragma once
22
23#include <memory>
24#include <string>
25#include <utility>
26#include <vector>
27
28#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
29
30#include "modules/planning/tasks/open_space_trajectory_post_process/proto/open_space_trajectory_post_process.pb.h"
37
38namespace apollo {
39namespace planning {
41 public:
42 bool Init(const std::string& config_dir, const std::string& name,
43 const std::shared_ptr<DependencyInjector>& injector) override;
44
46
47 private:
48 common::Status Process() override;
49
50 void InterpolateTrajectory(
51 const DiscretizedTrajectory& stitched_trajectory_result,
52 DiscretizedTrajectory* interpolated_trajectory);
53
54 void UpdateVehicleInfo();
55
56 bool EncodeTrajectory(const DiscretizedTrajectory& trajectory,
57 std::string* const encoding);
58
59 bool CheckTrajTraversed(const std::string& trajectory_encoding_to_check);
60
61 void UpdateTrajHistory(const std::string& chosen_trajectory_encoding);
62
63 void PartitionTrajectory(const DiscretizedTrajectory& trajectory,
64 std::vector<TrajGearPair>* partitioned_trajectories);
65
66 void LoadTrajectoryPoint(const common::TrajectoryPoint& trajectory_point,
67 const bool is_trajectory_last_point,
69 common::math::Vec2d* last_pos_vec,
70 double* distance_s,
71 DiscretizedTrajectory* current_trajectory);
72
73 bool CheckReachTrajectoryEnd(const DiscretizedTrajectory& trajectory,
75 const size_t trajectories_size,
76 size_t* current_trajectory_point_index);
77
78 bool UseFailSafeSearch(
79 const std::vector<TrajGearPair>& partitioned_trajectories,
80 const std::vector<std::string>& trajectories_encodings,
81 size_t* current_trajectory_index, size_t* current_trajectory_point_index);
82
83 bool InsertGearShiftTrajectory(
84 const bool flag_change_to_next, const size_t current_trajectory_index,
85 const std::vector<TrajGearPair>& partitioned_trajectories,
86 TrajGearPair* gear_switch_idle_time_trajectory);
87
88 void GenerateGearShiftTrajectory(
89 const canbus::Chassis::GearPosition& gear_position, double init_kappa,
90 TrajGearPair* gear_switch_idle_time_trajectory);
91 void GenerateStopTrajectory(
92 const canbus::Chassis::GearPosition& gear_position,
93 TrajGearPair* stop_trajectory);
94 void AdjustRelativeTimeAndS(
95 const std::vector<TrajGearPair>& partitioned_trajectories,
96 const size_t current_trajectory_index,
97 const size_t closest_trajectory_point_index,
98 TrajGearPair* current_partitioned_trajectory);
99
100 bool CheckArrivePoint(
102 const apollo::common::PathPoint& path_end_point,
103 const double& lateral_offset_to_midpoint,
104 const double& longitudinal_offset_to_midpoint,
105 const double& heading_offset_to_midpoint);
106
107 private:
109 double heading_search_range_ = 0.0;
110 double heading_track_range_ = 0.0;
111 double distance_search_range_ = 0.0;
112 double heading_offset_to_midpoint_ = 0.0;
113 double lateral_offset_to_midpoint_ = 0.0;
114 double longitudinal_offset_to_midpoint_ = 0.0;
115 double vehicle_box_iou_threshold_to_midpoint_ = 0.0;
116 double scale_destination_ = 0.0;
117 int stop_check_window_ = 0;
118 int stop_check_count_ = 0;
119
120 common::VehicleParam vehicle_param_;
121 double ego_length_ = 0.0;
122 double ego_width_ = 0.0;
123 double shift_distance_ = 0.0;
124 double wheel_base_ = 0.0;
125
126 double ego_theta_ = 0.0;
127 double ego_x_ = 0.0;
128 double ego_y_ = 0.0;
129 double ego_v_ = 0.0;
130 apollo::canbus::Chassis_GearPosition ego_gear_;
131 common::math::Box2d ego_box_;
132 double vehicle_moving_direction_ = 0.0;
133 int last_index_ = -1;
134 size_t current_trajectory_index_ = 0;
135 bool fail_search_fallback_ = false;
136 double last_time_ = 0;
137 struct pair_comp_ {
138 bool operator()(
139 const std::pair<std::pair<size_t, size_t>, double>& left,
140 const std::pair<std::pair<size_t, size_t>, double>& right) const {
141 return left.second <= right.second;
142 }
143 };
144 struct comp_ {
145 bool operator()(const std::pair<size_t, double>& left,
146 const std::pair<size_t, double>& right) {
147 return left.second <= right.second;
148 }
149 };
150};
151
154
155} // namespace planning
156} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
Rectangular (undirected) bounding box in 2-D.
Definition box2d.h:52
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
Planning module main class.
#define CYBER_PLUGIN_MANAGER_REGISTER_PLUGIN(name, base)
Linear interpolation functions.
std::pair< DiscretizedTrajectory, canbus::Chassis::GearPosition > TrajGearPair
class register implement
Definition arena_queue.h:37