qp_spline_st_graph.h 4.2 KB
Newer Older
Z
Zhang Liangliang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
 * @file qp_spline_st_graph.h
 **/

21 22
#ifndef MODULES_PLANNING_TASKS_QP_SPLINE_ST_SPEED_QP_SPLINE_ST_GRAPH_H_
#define MODULES_PLANNING_TASKS_QP_SPLINE_ST_SPEED_QP_SPLINE_ST_GRAPH_H_
Z
Zhang Liangliang 已提交
23

A
Aaron Xiao 已提交
24
#include <memory>
Z
Zhang Liangliang 已提交
25
#include <utility>
A
Aaron Xiao 已提交
26 27
#include <vector>

Z
Zhang Liangliang 已提交
28
#include "modules/common/configs/proto/vehicle_config.pb.h"
29
#include "modules/common/proto/pnc_point.pb.h"
Z
Zhang Liangliang 已提交
30 31
#include "modules/planning/proto/qp_spline_st_speed_config.pb.h"

32 33
#include "modules/common/status/status.h"
#include "modules/common/util/string_util.h"
Z
Zhang Liangliang 已提交
34
#include "modules/planning/common/path/path_data.h"
35
#include "modules/planning/common/planning_util.h"
Z
Zhang Liangliang 已提交
36
#include "modules/planning/common/speed/speed_data.h"
37
#include "modules/planning/common/speed/st_boundary.h"
38
#include "modules/planning/math/smoothing_spline/spline_1d_generator.h"
D
Dong Li 已提交
39
#include "modules/planning/tasks/st_graph/st_graph_data.h"
Z
Zhang Liangliang 已提交
40 41 42 43

namespace apollo {
namespace planning {

44
class QpSplineStGraph {
Z
Zhang Liangliang 已提交
45
 public:
46
  QpSplineStGraph(const QpSplineStSpeedConfig& qp_config,
D
Dong Li 已提交
47
                  const apollo::common::VehicleParam& veh_param);
Z
Zhang Liangliang 已提交
48

49 50
  void SetDebugLogger(planning_internal::STGraphDebug* st_graph_debug);

51
  common::Status Search(const StGraphData& st_graph_data,
52 53
                        SpeedData* const speed_data,
                        const std::pair<double, double>& accel_bound);
Z
Zhang Liangliang 已提交
54 55

 private:
56 57
  void Init();

Z
Zhang Liangliang 已提交
58
  // apply st graph constraint
59 60 61 62
  common::Status ApplyConstraint(const common::TrajectoryPoint& init_point,
                                 const SpeedLimit& speed_limit,
                                 const std::vector<StBoundary>& boundaries,
                                 const std::pair<double, double>& accel_bound);
Z
Zhang Liangliang 已提交
63 64

  // apply objective function
65
  common::Status ApplyKernel(const std::vector<StBoundary>& boundaries,
66
                             const SpeedLimit& speed_limit);
Z
Zhang Liangliang 已提交
67 68

  // solve
69
  common::Status Solve();
Z
Zhang Liangliang 已提交
70 71

  // extract upper lower bound for constraint;
72 73 74 75 76
  common::Status GetSConstraintByTime(const std::vector<StBoundary>& boundaries,
                                      const double time,
                                      const double total_path_s,
                                      double* const s_upper_bound,
                                      double* const s_lower_bound) const;
Z
Zhang Liangliang 已提交
77 78

  // generate reference speed profile
79
  // common::Status ApplyReferenceSpeedProfile();
80 81
  common::Status AddCruiseReferenceLineKernel(const SpeedLimit& speed_limit,
                                              const double weight);
Z
Zhang Liangliang 已提交
82

83
  common::Status AddFollowReferenceLineKernel(
84
      const std::vector<StBoundary>& boundaries, const double weight);
85

86
  common::Status EstimateSpeedUpperBound(
87
      const common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit,
88
      std::vector<double>* speed_upper_bound) const;
89

Z
Zhang Liangliang 已提交
90 91
 private:
  // qp st configuration
92
  QpSplineStSpeedConfig qp_spline_st_speed_config_;
Z
Zhang Liangliang 已提交
93 94

  // initial status
95
  common::TrajectoryPoint init_point_;
Z
Zhang Liangliang 已提交
96 97

  // solver
98
  std::unique_ptr<Spline1dGenerator> spline_generator_ = nullptr;
Z
Zhang Liangliang 已提交
99

100
  // t knots resolution
101
  double t_knots_resolution_ = 0.0;
102

103
  // knots
104
  std::vector<double> t_knots_;
105

106
  // evaluated t resolution
107
  double t_evaluated_resolution_ = 0.0;
108

109 110
  // evaluated points
  std::vector<double> t_evaluated_;
111 112 113

  // reference line kernel
  std::vector<double> cruise_;
114 115

  planning_internal::STGraphDebug* st_graph_debug_ = nullptr;
Z
Zhang Liangliang 已提交
116 117 118 119 120
};

}  // namespace planning
}  // namespace apollo

121
#endif  // MODULES_PLANNING_TASKS_QP_SPLINE_ST_SPEED_QP_SPLINE_ST_GRAPH_H_