Apollo 11.0
自动驾驶开放平台
open_space_info.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
20#pragma once
21
22#include <string>
23#include <utility>
24#include <vector>
25
26#include "Eigen/Dense"
27
28#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
29#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
30#include "modules/common_msgs/map_msgs/map_id.pb.h"
31#include "modules/common_msgs/planning_msgs/planning_internal.pb.h"
32
33#include "cyber/common/log.h"
43
44namespace apollo {
45namespace planning {
46
47// park-generic
49
50typedef std::pair<DiscretizedTrajectory, canbus::Chassis::GearPosition>
52
62
64 public:
65 OpenSpaceInfo() = default;
66 ~OpenSpaceInfo() = default;
67
68 const std::string target_parking_spot_id() const {
69 return target_parking_spot_id_;
70 }
71
73 return &target_parking_spot_id_;
74 }
75
77 return target_parking_spot_;
78 }
79
81 return &target_parking_spot_;
82 }
83
85 return target_parking_lane_;
86 }
87
89 target_parking_lane_ = lane_info_const_ptr;
90 }
91
93 return open_space_pre_stop_fence_s_;
94 }
95
96 void set_open_space_pre_stop_fence_s(const double s) {
97 open_space_pre_stop_fence_s_ = s;
98 }
99
100 bool pre_stop_rightaway_flag() const { return pre_stop_rightaway_flag_; }
101
102 void set_pre_stop_rightaway_flag(const bool flag) {
103 pre_stop_rightaway_flag_ = flag;
104 }
105
107 return pre_stop_rightaway_point_;
108 }
109
111 return &pre_stop_rightaway_point_;
112 }
113
115 return is_on_open_space_trajectory_;
116 }
117
118 void set_is_on_open_space_trajectory(const bool flag) {
119 is_on_open_space_trajectory_ = flag;
120 }
121
122 size_t obstacles_num() const { return obstacles_num_; }
123
124 void set_obstacles_num(const size_t obstacles_num) {
125 obstacles_num_ = obstacles_num;
126 }
127
128 const Eigen::MatrixXi &obstacles_edges_num() const {
129 return obstacles_edges_num_;
130 }
131
132 Eigen::MatrixXi *mutable_obstacles_edges_num() {
133 return &obstacles_edges_num_;
134 }
135
136 const std::vector<std::vector<common::math::Vec2d>> &obstacles_vertices_vec()
137 const {
138 return obstacles_vertices_vec_;
139 }
140
141 std::vector<std::vector<common::math::Vec2d>> *
143 return &obstacles_vertices_vec_;
144 }
145
146 const Eigen::MatrixXd &obstacles_A() const { return obstacles_A_; }
147
148 Eigen::MatrixXd *mutable_obstacles_A() { return &obstacles_A_; }
149
150 const Eigen::MatrixXd &obstacles_b() const { return obstacles_b_; }
151
152 Eigen::MatrixXd *mutable_obstacles_b() { return &obstacles_b_; }
153
154 double origin_heading() const { return origin_heading_; }
155
156 void set_origin_heading(const double original_heading) {
157 origin_heading_ = original_heading;
158 }
159
160 const common::math::Vec2d &origin_point() const { return origin_point_; }
161
162 common::math::Vec2d *mutable_origin_point() { return &origin_point_; }
163
164 const std::vector<double> &ROI_xy_boundary() const {
165 return ROI_xy_boundary_;
166 }
167
168 std::vector<double> *mutable_ROI_xy_boundary() { return &ROI_xy_boundary_; }
169
170 const std::vector<double> &open_space_end_pose() const {
171 return open_space_end_pose_;
172 }
173
174 std::vector<double> *mutable_open_space_end_pose() {
175 return &open_space_end_pose_;
176 }
177
179 return optimizer_trajectory_data_;
180 }
181
183 return &optimizer_trajectory_data_;
184 }
185
186 const std::vector<common::TrajectoryPoint> &stitching_trajectory_data()
187 const {
188 return stitching_trajectory_data_;
189 }
190
191 std::vector<common::TrajectoryPoint> *mutable_stitching_trajectory_data() {
192 return &stitching_trajectory_data_;
193 }
194
196 return stitched_trajectory_result_;
197 }
198
200 return &stitched_trajectory_result_;
201 }
202
204 return open_space_provider_success_;
205 }
206
207 void set_open_space_provider_success(const bool flag) {
208 open_space_provider_success_ = flag;
209 }
210
211 bool destination_reached() const { return destination_reached_; }
212
213 void set_destination_reached(const bool flag) { destination_reached_ = flag; }
214
215 bool openspace_planning_finish() const { return openspace_planning_finish_; }
216
217 void set_openspace_planning_finish(const bool flag) {
218 openspace_planning_finish_ = flag;
219 }
220
222 return interpolated_trajectory_result_;
223 }
224
226 return &interpolated_trajectory_result_;
227 }
228
229 const std::vector<TrajGearPair> &partitioned_trajectories() const {
230 // TODO(Runxin): export to chart
231 return partitioned_trajectories_;
232 }
233
234 std::vector<TrajGearPair> *mutable_partitioned_trajectories() {
235 return &partitioned_trajectories_;
236 }
237
239 return gear_switch_states_;
240 }
241
243 return &gear_switch_states_;
244 }
245
247 // TODO(Runxin): export to chart
248 return chosen_partitioned_trajectory_;
249 }
250
252 return &chosen_partitioned_trajectory_;
253 }
254
255 bool fallback_flag() const { return fallback_flag_; }
256
257 void set_fallback_flag(const bool flag) { fallback_flag_ = flag; }
258
259 bool stop_flag() const { return stop_flag_; }
260
261 void set_stop_flag(const bool flag) { stop_flag_ = flag; }
262
263 TrajGearPair *mutable_fallback_trajectory() { return &fallback_trajectory_; }
264
266 return fallback_trajectory_;
267 }
268
269 std::pair<PublishableTrajectory, canbus::Chassis::GearPosition> *
271 return &publishable_trajectory_data_;
272 }
273
274 const std::pair<PublishableTrajectory, canbus::Chassis::GearPosition> &
276 return publishable_trajectory_data_;
277 }
278
279 // TODO(QiL, Jinyun) refactor and merge this with debug
281 return &future_collision_point_;
282 }
283
285 return future_collision_point_;
286 }
287
288 // TODO(QiL, Jinyun): refactor open_space_info vs debug
289
291
293
294 const apollo::planning_internal::Debug &debug() const { return *debug_; }
295
297 return debug_instance_;
298 }
299
301 return &debug_instance_;
302 }
303
305 // Remove existing obstacle vectors to prevent repeating obstacle
306 // vectors.
307 if (!debug_->planning_data().open_space().obstacles().empty()) {
308 debug_instance_.mutable_planning_data()
309 ->mutable_open_space()
310 ->clear_obstacles();
311 }
312 debug_instance_.MergeFrom(*debug_);
313 }
314
316
317 void set_time_latency(double time_latency) { time_latency_ = time_latency; }
318
319 private:
320 std::string target_parking_spot_id_;
321
322 hdmap::ParkingSpaceInfoConstPtr target_parking_spot_ = nullptr;
323
324 hdmap::LaneInfoConstPtr target_parking_lane_ = nullptr;
325
326 double open_space_pre_stop_fence_s_ = 0.0;
327
328 bool pre_stop_rightaway_flag_ = false;
329
330 hdmap::MapPathPoint pre_stop_rightaway_point_;
331
332 bool is_on_open_space_trajectory_ = false;
333 // @brief obstacles total num including perception obstacles and parking space
334 // boundary
335 size_t obstacles_num_ = 0;
336
337 // @brief the dimension needed for A and b matrix dimension in H
338 // representation
339 Eigen::MatrixXi obstacles_edges_num_;
340
341 // @brief in the order of [x_min, x_max, y_min, y_max];
342 std::vector<double> ROI_xy_boundary_;
343
344 // @brief open_space end configuration in order of x, y, heading and speed.
345 // Speed is set to be always zero now for parking
346 std::vector<double> open_space_end_pose_;
347
348 // @brief vector storing the vertices of obstacles in counter-clock-wise order
349 std::vector<std::vector<common::math::Vec2d>> obstacles_vertices_vec_;
350
351 // @brief Linear inequality representation of the obstacles Ax>b
352 Eigen::MatrixXd obstacles_A_;
353 Eigen::MatrixXd obstacles_b_;
354
355 // @brief origin heading for planning space rotation
356 double origin_heading_ = 0.0;
357
358 // @brief origin point for scaling down the numeric value of the optimization
359 // problem in order of x , y
360 common::math::Vec2d origin_point_;
361
362 DiscretizedTrajectory optimizer_trajectory_data_;
363
364 std::vector<common::TrajectoryPoint> stitching_trajectory_data_;
365
366 DiscretizedTrajectory stitched_trajectory_result_;
367
368 bool open_space_provider_success_ = false;
369
370 bool destination_reached_ = false;
371
372 bool openspace_planning_finish_ = false;
373
374 DiscretizedTrajectory interpolated_trajectory_result_;
375
376 std::vector<TrajGearPair> partitioned_trajectories_;
377
378 GearSwitchStates gear_switch_states_;
379
380 TrajGearPair chosen_partitioned_trajectory_;
381
382 bool fallback_flag_ = false;
383
384 bool stop_flag_ = false;
385
386 TrajGearPair fallback_trajectory_;
387
388 common::TrajectoryPoint future_collision_point_;
389
390 std::pair<PublishableTrajectory, canbus::Chassis::GearPosition>
391 publishable_trajectory_data_;
392
393 // the pointer from ADCtrajectory
395
396 // the instance inside debug,
397 // if ADCtrajectory is NULL, blank; else same to ADCtrajectory
398 apollo::planning_internal::Debug debug_instance_;
399
400 double time_latency_ = 0.0;
401
402 ParkingType parking_type_ = ParkingType::NO_PARKING;
403
404 // park-generic
405
406 public:
408 return path_planning_trajectory_result_;
409 }
410
412 return &path_planning_trajectory_result_;
413 }
414
415 bool replan_flag() const { return replan_flag_; }
416
417 void set_replan_flag(const bool flag) { replan_flag_ = flag; }
418
419 ParkingType parking_type() const { return parking_type_; }
420
421 void set_parking_type(const ParkingType type) { parking_type_ = type; }
422
423 const std::vector<std::vector<common::math::Vec2d>> &
425 return soft_boundary_vertices_vec_;
426 }
427
428 std::vector<std::vector<common::math::Vec2d>> *
430 return &soft_boundary_vertices_vec_;
431 }
432
434 trajectory_type_ = type;
435 }
436
438 return trajectory_type_;
439 }
440
441 // This function is simply used to tell the control module that the current
442 // path has a collision with an obstacle. It does not do anything about the
443 // collision!!!
444 void set_is_collision(const bool &is_collision) {
445 is_collision_ = is_collision;
446 }
447
448 bool is_collision() const { return is_collision_; }
449
450 private:
451 DiscretizedTrajectory path_planning_trajectory_result_;
452 bool replan_flag_ = false;
453
454 // @brief vector storing the vertices of obstacles in counter-clock-wise order
455 std::vector<std::vector<common::math::Vec2d>> soft_boundary_vertices_vec_;
456
457 // follow parameter is only used for precise parking
459 bool is_collision_ = false;
460};
461
462} // namespace planning
463} // namespace apollo
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
hdmap::MapPathPoint * mutable_pre_stop_rightaway_point()
void set_debug(apollo::planning_internal::Debug *debug)
const TrajGearPair & fallback_trajectory() const
std::vector< double > * mutable_ROI_xy_boundary()
void set_destination_reached(const bool flag)
std::string * mutable_target_parking_spot_id()
const std::vector< double > & ROI_xy_boundary() const
void set_is_collision(const bool &is_collision)
Eigen::MatrixXd * mutable_obstacles_b()
apollo::planning_internal::Debug * mutable_debug_instance()
void set_parking_type(const ParkingType type)
const std::vector< common::TrajectoryPoint > & stitching_trajectory_data() const
void set_open_space_pre_stop_fence_s(const double s)
common::TrajectoryPoint * mutable_future_collision_point()
void set_pre_stop_rightaway_flag(const bool flag)
void set_is_on_open_space_trajectory(const bool flag)
void set_replan_flag(const bool flag)
GearSwitchStates * mutable_gear_switch_states()
const std::vector< double > & open_space_end_pose() const
const common::math::Vec2d & origin_point() const
const std::string target_parking_spot_id() const
const hdmap::MapPathPoint & pre_stop_rightaway_point() const
Eigen::MatrixXd * mutable_obstacles_A()
const hdmap::ParkingSpaceInfoConstPtr target_parking_spot() const
const TrajGearPair & chosen_partitioned_trajectory() const
const apollo::planning_internal::Debug & debug() const
void set_target_parking_lane(hdmap::LaneInfoConstPtr lane_info_const_ptr)
ADCTrajectory::TrajectoryType trajectory_type() const
std::vector< common::TrajectoryPoint > * mutable_stitching_trajectory_data()
std::vector< double > * mutable_open_space_end_pose()
void set_trajectory_type(const ADCTrajectory::TrajectoryType type)
void set_time_latency(double time_latency)
const Eigen::MatrixXd & obstacles_A() const
void set_stop_flag(const bool flag)
const std::vector< std::vector< common::math::Vec2d > > & obstacles_vertices_vec() const
const DiscretizedTrajectory & interpolated_trajectory_result() const
TrajGearPair * mutable_fallback_trajectory()
void set_open_space_provider_success(const bool flag)
common::math::Vec2d * mutable_origin_point()
const Eigen::MatrixXd & obstacles_b() const
hdmap::ParkingSpaceInfoConstPtr * mutable_target_parking_spot()
const std::pair< PublishableTrajectory, canbus::Chassis::GearPosition > & publishable_trajectory_data() const
std::pair< PublishableTrajectory, canbus::Chassis::GearPosition > * mutable_publishable_trajectory_data()
void set_fallback_flag(const bool flag)
Eigen::MatrixXi * mutable_obstacles_edges_num()
const common::TrajectoryPoint & future_collision_point() const
DiscretizedTrajectory * mutable_path_planning_trajectory_result()
std::vector< std::vector< common::math::Vec2d > > * mutable_obstacles_vertices_vec()
DiscretizedTrajectory * mutable_interpolated_trajectory_result()
const Eigen::MatrixXi & obstacles_edges_num() const
void set_origin_heading(const double original_heading)
void set_openspace_planning_finish(const bool flag)
DiscretizedTrajectory * mutable_optimizer_trajectory_data()
const std::vector< std::vector< common::math::Vec2d > > & soft_boundary_vertices_vec() const
std::vector< std::vector< common::math::Vec2d > > * mutable_soft_boundary_vertices_vec()
const DiscretizedTrajectory & stitched_trajectory_result() const
TrajGearPair * mutable_chosen_partitioned_trajectory()
void RecordDebug(apollo::planning_internal::Debug *ptr_debug)
const DiscretizedTrajectory & path_planning_trajectory_result() const
void set_obstacles_num(const size_t obstacles_num)
std::vector< TrajGearPair > * mutable_partitioned_trajectories()
DiscretizedTrajectory * mutable_stitched_trajectory_result()
const DiscretizedTrajectory & optimizer_trajectory_data() const
const std::vector< TrajGearPair > & partitioned_trajectories() const
const GearSwitchStates & gear_switch_states() const
const apollo::planning_internal::Debug debug_instance() const
const hdmap::LaneInfoConstPtr target_parking_lane() const
apollo::planning_internal::Debug * mutable_debug()
Planning module main class.
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
std::shared_ptr< const ParkingSpaceInfo > ParkingSpaceInfoConstPtr
std::pair< DiscretizedTrajectory, canbus::Chassis::GearPosition > TrajGearPair
class register implement
Definition arena_queue.h:37
apollo::canbus::Chassis::GearPosition gear_shift_position
repeated apollo::planning_internal::ObstacleDebug obstacles
Defines the Vec2d class.