ego_info.h 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/******************************************************************************
 * Copyright 2018 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 ego_info.h
 **/

21 22
#pragma once

23
#include <limits>
24 25 26 27
#include <unordered_map>
#include <utility>
#include <vector>

28 29
#include "gtest/gtest_prod.h"

G
GoLancer 已提交
30
#include "cyber/common/macros.h"
L
Liangliang Zhang 已提交
31

32
#include "modules/common/configs/proto/vehicle_config.pb.h"
33 34
#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"

35
#include "modules/planning/common/obstacle.h"
36
#include "modules/planning/common/planning_gflags.h"
37 38 39 40 41 42 43 44 45
#include "modules/planning/reference_line/reference_line.h"

namespace apollo {
namespace planning {

class EgoInfo {
 public:
  ~EgoInfo() = default;

46
  bool Update(const common::TrajectoryPoint& start_point,
47 48
              const common::VehicleState& vehicle_state);

49
  void Clear();
50

51 52
  common::TrajectoryPoint start_point() const { return start_point_; }

53
  common::VehicleState vehicle_state() const { return vehicle_state_; }
54

55
  double front_clear_distance() const { return front_clear_distance_; }
56

57 58 59 60 61
  common::math::Box2d ego_box() const { return ego_box_; }

  void CalculateFrontObstacleClearDistance(
      const std::vector<const Obstacle*>& obstacles);

62 63
 private:
  FRIEND_TEST(EgoInfoTest, EgoInfoSimpleTest);
64 65 66 67 68

  void set_vehicle_state(const common::VehicleState& vehicle_state) {
    vehicle_state_ = vehicle_state;
  }

69 70 71
  void set_start_point(const common::TrajectoryPoint& start_point) {
    start_point_ = start_point;
  }
72

73
  void CalculateEgoBox(const common::VehicleState& vehicle_state);
74 75 76 77 78 79 80 81

  // stitched point (at stitching mode)
  // or real vehicle point (at non-stitching mode)
  common::TrajectoryPoint start_point_;

  // ego vehicle state
  common::VehicleState vehicle_state_;

82
  double front_clear_distance_ = FLAGS_default_front_clear_distance;
83 84

  common::VehicleConfig ego_vehicle_config_;
85

86 87
  common::math::Box2d ego_box_;

88 89 90 91 92
  DECLARE_SINGLETON(EgoInfo);
};

}  // namespace planning
}  // namespace apollo