Apollo  6.0
Open source self driving car software
ego_info.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <vector>
24 
25 #include "cyber/common/macros.h"
26 #include "modules/common/configs/proto/vehicle_config.pb.h"
27 #include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
31 
32 namespace apollo {
33 namespace planning {
34 
35 class EgoInfo {
36  public:
37  EgoInfo();
38 
39  ~EgoInfo() = default;
40 
41  bool Update(const common::TrajectoryPoint& start_point,
42  const common::VehicleState& vehicle_state);
43 
44  void Clear();
45 
46  common::TrajectoryPoint start_point() const { return start_point_; }
47 
48  common::VehicleState vehicle_state() const { return vehicle_state_; }
49 
50  double front_clear_distance() const { return front_clear_distance_; }
51 
52  common::math::Box2d ego_box() const { return ego_box_; }
53 
55  const std::vector<const Obstacle*>& obstacles);
56 
57  private:
58  FRIEND_TEST(EgoInfoTest, EgoInfoSimpleTest);
59 
60  void set_vehicle_state(const common::VehicleState& vehicle_state) {
61  vehicle_state_ = vehicle_state;
62  }
63 
64  void set_start_point(const common::TrajectoryPoint& start_point) {
65  start_point_ = start_point;
66  const auto& param = ego_vehicle_config_.vehicle_param();
67  start_point_.set_a(
68  std::fmax(std::fmin(start_point_.a(), param.max_acceleration()),
69  param.max_deceleration()));
70  }
71 
72  void CalculateEgoBox(const common::VehicleState& vehicle_state);
73 
74  // stitched point (at stitching mode)
75  // or real vehicle point (at non-stitching mode)
76  common::TrajectoryPoint start_point_;
77 
78  // ego vehicle state
79  common::VehicleState vehicle_state_;
80 
81  double front_clear_distance_ = FLAGS_default_front_clear_distance;
82 
83  common::VehicleConfig ego_vehicle_config_;
84 
85  common::math::Box2d ego_box_;
86 };
87 
88 } // namespace planning
89 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: ego_info.h:35
Planning module main class. It processes GPS and IMU as input, to generate planning info...
common::TrajectoryPoint start_point() const
Definition: ego_info.h:46
common::VehicleState vehicle_state() const
Definition: ego_info.h:48
Rectangular (undirected) bounding box in 2-D.
Definition: box2d.h:52
double front_clear_distance() const
Definition: ego_info.h:50
common::math::Box2d ego_box() const
Definition: ego_info.h:52
bool Update(const common::TrajectoryPoint &start_point, const common::VehicleState &vehicle_state)
void CalculateFrontObstacleClearDistance(const std::vector< const Obstacle *> &obstacles)