reference_line_info.h 3.2 KB
Newer Older
D
Dong Li 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/******************************************************************************
 * 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
 **/

#ifndef MODULES_PLANNING_COMMON_REFERENCE_LINE_INFO_H_
#define MODULES_PLANNING_COMMON_REFERENCE_LINE_INFO_H_

24
#include <limits>
D
Dong Li 已提交
25 26 27 28 29 30
#include <list>
#include <string>
#include <vector>

#include "modules/planning/common/path/path_data.h"
#include "modules/planning/common/path_decision.h"
31
#include "modules/planning/common/planning_data.h"
D
Dong Li 已提交
32
#include "modules/planning/common/speed/speed_data.h"
33
#include "modules/planning/common/trajectory/discretized_trajectory.h"
D
Dong Li 已提交
34 35 36 37 38 39 40

namespace apollo {
namespace planning {

class ReferenceLineInfo {
 public:
  explicit ReferenceLineInfo(const ReferenceLine& reference_line);
41
  const std::string& Id() const;
D
Dong Li 已提交
42

D
Dong Li 已提交
43
  bool AddObstacles(const std::vector<const Obstacle*>& obstacles);
D
Dong Li 已提交
44 45
  PathObstacle* AddObstacle(const Obstacle* obstacle);

D
Dong Li 已提交
46 47 48
  // FIXME(all) this interface is temp. solution to make the code work.
  // remove this interface when ready.
  PathDecision* path_decision() { return &path_decision_; }
49 50
  const PathDecision& path_decision() const { return path_decision_; }
  const ReferenceLine& reference_line() const { return reference_line_; }
D
Dong Li 已提交
51

52
  // TODO remove this inteface when ready.
53 54 55
  void SetTrajectory(const DiscretizedTrajectory& trajectory) {
    discretized_trajectory_ = trajectory;
  }
56

57 58 59 60
  PlanningData* mutable_planning_data();
  const PlanningData& planning_data() const;

  const DiscretizedTrajectory& trajectory() const;
61

62 63
  double Cost() const { return cost_; }

D
Dong Li 已提交
64 65 66 67
  std::unique_ptr<Obstacle> CreateVirtualObstacle(
      const std::string& obstacle_id, const double route_s, const double length,
      const double width, const double height) const;

68 69 70
  bool CombinePathAndSpeedProfile(const double time_resolution,
                                  const double relative_time);

D
Dong Li 已提交
71 72 73 74
 private:
  std::unique_ptr<PathObstacle> CreatePathObstacle(const Obstacle* obstacle);
  bool InitPerceptionSLBoundary(PathObstacle* path_obstacle);

75 76 77 78
 private:
  static uint32_t s_reference_line_id_;

  std::string id_;
79 80 81 82 83 84
  /**
   * @brief this is the number that measures the goodness of this reference
   * line.
   * The lower the better.
   * TODO: implement trajectory cost calculation
   */
85
  double cost_ = std::numeric_limits<double>::infinity();
86

D
Dong Li 已提交
87 88
  const ReferenceLine reference_line_;
  PathDecision path_decision_;
89
  PlanningData planning_data_;
90
  DiscretizedTrajectory discretized_trajectory_;
D
Dong Li 已提交
91 92 93 94 95 96
};

}  // namespace planning
}  // namespace apollo

#endif  // MODULES_PLANNING_COMMON_REFERENCE_LINE_INFO_H_