Apollo  6.0
Open source self driving car software
open_space_trajectory_provider.h
Go to the documentation of this file.
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 <vector>
25 
26 #include "modules/common/proto/pnc_point.pb.h"
32 
33 namespace apollo {
34 namespace planning {
35 
37  std::vector<common::TrajectoryPoint> stitching_trajectory;
38  std::vector<double> end_pose;
39  std::vector<double> XYbounds;
40  double rotate_angle;
42  Eigen::MatrixXi obstacles_edges_num;
43  Eigen::MatrixXd obstacles_A;
44  Eigen::MatrixXd obstacles_b;
45  std::vector<std::vector<common::math::Vec2d>> obstacles_vertices_vec;
46 };
47 
49  public:
51  const TaskConfig& config,
52  const std::shared_ptr<DependencyInjector>& injector);
53 
55 
56  void Stop();
57 
58  void Restart();
59 
60  private:
61  apollo::common::Status Process() override;
62 
63  void GenerateTrajectoryThread();
64 
65  bool IsVehicleNearDestination(const common::VehicleState& vehicle_state,
66  const std::vector<double>& end_pose,
67  double rotate_angle,
69 
70  bool IsVehicleStopDueToFallBack(const bool is_on_fallback,
71  const common::VehicleState& vehicle_state);
72 
73  void GenerateStopTrajectory(DiscretizedTrajectory* const trajectory_data);
74 
75  void LoadResult(DiscretizedTrajectory* const trajectory_data);
76 
77  void ReuseLastFrameResult(const Frame* last_frame,
78  DiscretizedTrajectory* const trajectory_data);
79 
80  void ReuseLastFrameDebug(const Frame* last_frame);
81 
82  private:
83  bool thread_init_flag_ = false;
84 
85  std::unique_ptr<OpenSpaceTrajectoryOptimizer>
86  open_space_trajectory_optimizer_;
87 
88  size_t optimizer_thread_counter = 0;
89 
90  OpenSpaceTrajectoryThreadData thread_data_;
91  std::future<void> task_future_;
92  std::atomic<bool> is_generation_thread_stop_{false};
93  std::atomic<bool> trajectory_updated_{false};
94  std::atomic<bool> data_ready_{false};
95  std::atomic<bool> trajectory_error_{false};
96  std::atomic<bool> trajectory_skipped_{false};
97  std::mutex open_space_mutex_;
98 };
99 
100 } // namespace planning
101 } // namespace apollo
Definition: open_space_trajectory_provider.h:48
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: discretized_trajectory.h:32
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: trajectory_optimizer.h:33
Frame holds all data for one planning cycle.
Definition: frame.h:61
Eigen::MatrixXd obstacles_A
Definition: open_space_trajectory_provider.h:43
Eigen::MatrixXd obstacles_b
Definition: open_space_trajectory_provider.h:44
apollo::common::math::Vec2d translate_origin
Definition: open_space_trajectory_provider.h:41
Implements a class of 2-dimensional vectors.
Definition: vec2d.h:42
std::vector< double > end_pose
Definition: open_space_trajectory_provider.h:38
Eigen::MatrixXi obstacles_edges_num
Definition: open_space_trajectory_provider.h:42
std::vector< common::TrajectoryPoint > stitching_trajectory
Definition: open_space_trajectory_provider.h:37
std::vector< double > XYbounds
Definition: open_space_trajectory_provider.h:39
Definition: open_space_trajectory_provider.h:36
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
double rotate_angle
Definition: open_space_trajectory_provider.h:40
std::vector< std::vector< common::math::Vec2d > > obstacles_vertices_vec
Definition: open_space_trajectory_provider.h:45