qp_spline_st_graph.h 4.1 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 25 26
#include <memory>
#include <vector>

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

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

namespace apollo {
namespace planning {

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

48
  common::Status Search(const StGraphData& st_graph_data,
49
                        const PathData& path_data, SpeedData* const speed_data,
A
Aaron Xiao 已提交
50
                        planning_internal::STGraphDebug* st_graph_debug);
Z
Zhang Liangliang 已提交
51 52

 private:
53 54
  void Init();

Z
Zhang Liangliang 已提交
55
  // apply st graph constraint
56
  common::Status ApplyConstraint(
57
      const common::TrajectoryPoint& init_point, const SpeedLimit& speed_limit,
58
      const std::vector<StBoundary>& boundaries,
A
Aaron Xiao 已提交
59
      planning_internal::STGraphDebug* st_graph_debug);
Z
Zhang Liangliang 已提交
60 61

  // apply objective function
62
  common::Status ApplyKernel(const std::vector<StBoundary>& boundaries,
63 64
                             const SpeedLimit& speed_limit,
                             planning_internal::STGraphDebug* st_graph_debug);
Z
Zhang Liangliang 已提交
65 66

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

  // extract upper lower bound for constraint;
70 71 72 73 74
  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 已提交
75 76

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

82
  common::Status AddFollowReferenceLineKernel(
83 84
      const std::vector<StBoundary>& boundaries, const double weight,
      planning_internal::STGraphDebug* st_graph_debug);
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_;
Z
Zhang Liangliang 已提交
114 115 116 117 118
};

}  // namespace planning
}  // namespace apollo

119
#endif  // MODULES_PLANNING_TASKS_QP_SPLINE_ST_SPEED_QP_SPLINE_ST_GRAPH_H_