Apollo 11.0
自动驾驶开放平台
open_space_trajectory_partition.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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_partition/proto/open_space_trajectory_partition.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 void Restart();
48
49 private:
50 common::Status Process() override;
51
52 void InterpolateTrajectory(
53 const DiscretizedTrajectory& stitched_trajectory_result,
54 DiscretizedTrajectory* interpolated_trajectory);
55
56 void UpdateVehicleInfo();
57
58 bool EncodeTrajectory(const DiscretizedTrajectory& trajectory,
59 std::string* const encoding);
60
61 bool CheckTrajTraversed(const std::string& trajectory_encoding_to_check);
62
63 void UpdateTrajHistory(const std::string& chosen_trajectory_encoding);
64
65 void PartitionTrajectory(const DiscretizedTrajectory& trajectory,
66 std::vector<TrajGearPair>* partitioned_trajectories);
67
68 void LoadTrajectoryPoint(const common::TrajectoryPoint& trajectory_point,
69 const bool is_trajectory_last_point,
71 common::math::Vec2d* last_pos_vec,
72 double* distance_s,
73 DiscretizedTrajectory* current_trajectory);
74
75 bool CheckReachTrajectoryEnd(const DiscretizedTrajectory& trajectory,
77 const size_t trajectories_size,
78 size_t* current_trajectory_point_index);
79
80 bool UseFailSafeSearch(
81 const std::vector<TrajGearPair>& partitioned_trajectories,
82 const std::vector<std::string>& trajectories_encodings,
83 size_t* current_trajectory_index, size_t* current_trajectory_point_index);
84
85 bool InsertGearShiftTrajectory(
86 const bool flag_change_to_next, const size_t current_trajectory_index,
87 const std::vector<TrajGearPair>& partitioned_trajectories,
88 TrajGearPair* gear_switch_idle_time_trajectory);
89
90 void GenerateGearShiftTrajectory(
91 const canbus::Chassis::GearPosition& gear_position, double init_kappa,
92 TrajGearPair* gear_switch_idle_time_trajectory);
93 void GenerateStopTrajectory(DiscretizedTrajectory* const trajectory_data,
94 double standstill_acceleration);
95 void AdjustRelativeTimeAndS(
96 const std::vector<TrajGearPair>& partitioned_trajectories,
97 const size_t current_trajectory_index,
98 const size_t closest_trajectory_point_index,
99 DiscretizedTrajectory* stitched_trajectory_result,
100 TrajGearPair* current_partitioned_trajectory);
101
102 private:
104 double heading_search_range_ = 0.0;
105 double heading_track_range_ = 0.0;
106 double distance_search_range_ = 0.0;
107 double heading_offset_to_midpoint_ = 0.0;
108 double lateral_offset_to_midpoint_ = 0.0;
109 double longitudinal_offset_to_midpoint_ = 0.0;
110 double vehicle_box_iou_threshold_to_midpoint_ = 0.0;
111 double linear_velocity_threshold_on_ego_ = 0.0;
112
113 common::VehicleParam vehicle_param_;
114 double ego_length_ = 0.0;
115 double ego_width_ = 0.0;
116 double shift_distance_ = 0.0;
117 double wheel_base_ = 0.0;
118
119 double ego_theta_ = 0.0;
120 double ego_x_ = 0.0;
121 double ego_y_ = 0.0;
122 double ego_v_ = 0.0;
123 apollo::canbus::Chassis_GearPosition ego_gear_;
124 common::math::Box2d ego_box_;
125 double vehicle_moving_direction_ = 0.0;
126 int last_index_ = -1;
127 size_t current_trajectory_index_ = 0;
128 bool fail_search_fallback_ = false;
129 double last_time_ = 0;
130 struct pair_comp_ {
131 bool operator()(
132 const std::pair<std::pair<size_t, size_t>, double>& left,
133 const std::pair<std::pair<size_t, size_t>, double>& right) const {
134 return left.second <= right.second;
135 }
136 };
137 struct comp_ {
138 bool operator()(const std::pair<size_t, double>& left,
139 const std::pair<size_t, double>& right) {
140 return left.second <= right.second;
141 }
142 };
143};
144
147
148} // namespace planning
149} // 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