qp_spline_st_graph.h 3.8 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 36
#include "modules/planning/common/speed/speed_data.h"
#include "modules/planning/math/smoothing_spline/spline_1d_generator.h"
37
#include "modules/planning/common/speed/st_boundary.h"
D
Dong Li 已提交
38
#include "modules/planning/tasks/st_graph/st_graph_data.h"
Z
Zhang Liangliang 已提交
39 40 41

namespace apollo {
namespace planning {
42
using ::apollo::planning_internal::STGraphDebug;
Z
Zhang Liangliang 已提交
43

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
  common::Status Search(const StGraphData& st_graph_data,
50 51
                        const PathData& path_data, SpeedData* const speed_data,
                        STGraphDebug* st_graph_debug);
Z
Zhang Liangliang 已提交
52 53

 private:
54 55
  void Init();

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

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

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

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

  // generate reference speed profile
76
  // common::Status ApplyReferenceSpeedProfile();
77
  common::Status AddCruiseReferenceLineKernel(
78 79
      const std::vector<double>& evaluate_t, const SpeedLimit& speed_limit,
      const double weight);
Z
Zhang Liangliang 已提交
80

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

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

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

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

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

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

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

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

108 109
  // evaluated points
  std::vector<double> t_evaluated_;
Z
Zhang Liangliang 已提交
110 111 112 113 114
};

}  // namespace planning
}  // namespace apollo

115
#endif  // MODULES_PLANNING_TASKS_QP_SPLINE_ST_SPEED_QP_SPLINE_ST_GRAPH_H_