Apollo 11.0
自动驾驶开放平台
open_space_trajectory_provider.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 <vector>
26
27#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
28#include "modules/common_msgs/planning_msgs/planning.pb.h"
29
30#include "modules/planning/tasks/open_space_trajectory_provider/proto/open_space_trajectory_provider.pb.h"
37
38namespace apollo {
39namespace planning {
40
42 std::vector<common::TrajectoryPoint> stitching_trajectory;
43 std::vector<double> end_pose;
44 std::vector<double> XYbounds;
47 Eigen::MatrixXi obstacles_edges_num;
48 Eigen::MatrixXd obstacles_A;
49 Eigen::MatrixXd obstacles_b;
50 std::vector<std::vector<common::math::Vec2d>> obstacles_vertices_vec;
51};
52
54 public:
55 bool Init(const std::string& config_dir, const std::string& name,
56 const std::shared_ptr<DependencyInjector>& injector) override;
57
59
60 void Stop();
61
62 void Restart();
63
64 private:
65 apollo::common::Status Process() override;
66
67 void GenerateTrajectoryThread();
68
69 bool IsVehicleNearDestination(const common::VehicleState& vehicle_state,
70 const std::vector<double>& end_pose,
71 double rotate_angle,
72 const common::math::Vec2d& translate_origin);
73
74 bool IsVehicleStopDueToFallBack(const bool is_on_fallback,
75 const common::VehicleState& vehicle_state);
76
77 void GenerateStopTrajectory(DiscretizedTrajectory* const trajectory_data);
78
79 void LoadResult(DiscretizedTrajectory* const trajectory_data);
80
81 void ReuseLastFrameResult(const Frame* last_frame,
82 DiscretizedTrajectory* const trajectory_data);
83
84 void ReuseLastFrameDebug(const Frame* last_frame);
85
86 private:
87 double straight_trajectory_length_ = 0.0;
88 bool thread_init_flag_ = false;
89
90 std::unique_ptr<OpenSpaceTrajectoryOptimizer>
91 open_space_trajectory_optimizer_;
92
93 size_t optimizer_thread_counter = 0;
94 apollo::common::TrajectoryPoint last_trajctory_point;
95
97 std::future<void> task_future_;
98 std::atomic<bool> is_generation_thread_stop_{false};
99 std::atomic<bool> trajectory_updated_{false};
100 std::atomic<bool> data_ready_{false};
101 std::atomic<bool> trajectory_error_{false};
102 std::atomic<bool> trajectory_skipped_{false};
103 std::mutex open_space_mutex_;
104 bool is_planned_ = false;
106};
107
110
111} // namespace planning
112} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
Frame holds all data for one planning cycle.
Definition frame.h:62
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)
class register implement
Definition arena_queue.h:37
std::vector< common::TrajectoryPoint > stitching_trajectory
std::vector< std::vector< common::math::Vec2d > > obstacles_vertices_vec