$darkmode
osi_ground_truth.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Robert Bosch GmbH
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  * SPDX-License-Identifier: Apache-2.0
17  */
23 #pragma once
24 
25 #include <Eigen/Geometry> // for Vector3d
26 
27 #include <cloe/simulator.hpp> // for ModelError
28 
29 #include "osi_groundtruth.pb.h" // for GroundTruth
30 #include "osi_object.pb.h" // for MovingObject
31 
32 #include "osi_utils.hpp" // for osi_require, ..
33 
34 namespace osii {
35 
41  public:
42  OsiGroundTruth() = default;
43 
44  virtual ~OsiGroundTruth() = default;
45 
50  void set(const osi3::GroundTruth& osi_gt) { gt_ptr_ = &osi_gt; }
51 
52  const osi3::GroundTruth& get_gt() const {
53  if (!gt_ptr_) error();
54  return *gt_ptr_;
55  }
56 
57  void store_veh_coord_sys_info(int obj_id, const osi3::MovingObject::VehicleAttributes& osi_va) {
58  // Assume that VehicleAttributes contains valid data.
59  veh_bbcenter_to_rear_[obj_id] = osi_vehicle_attrib_rear_offset_to_vector3d(osi_va);
60  }
61 
66  const Eigen::Vector3d& get_veh_coord_sys_info(int obj_id) const {
67  return veh_bbcenter_to_rear_.at(obj_id);
68  }
69 
70  void store_mov_obj_dimensions(int obj_id, const osi3::Dimension3d& obj_dim) {
71  // Assume that Dimension3d contains valid data.
73  }
74 
78  const Eigen::Vector3d& get_mov_obj_dimensions(int obj_id) const {
79  return mov_obj_dimensions_.at(obj_id);
80  }
81 
85  void reset() {
86  gt_ptr_ = nullptr;
89  }
90 
94  uint64_t get_ego_id() const {
95  osi_require("GroundTruth::host_vehicle_id", gt_ptr_->has_host_vehicle_id());
96  return gt_ptr_->host_vehicle_id().value();
97  }
98 
102  const osi3::MovingObject* get_moving_object(const uint64_t id) const;
103 
104  private:
105  void error() const { throw cloe::ModelError("OsiGroundTruth not set"); }
106 
107  protected:
109  const osi3::GroundTruth* gt_ptr_{nullptr};
110 
112  std::map<int, Eigen::Vector3d> veh_bbcenter_to_rear_;
113 
115  std::map<int, Eigen::Vector3d> mov_obj_dimensions_;
116 };
117 
118 } // namespace osii
Definition: model.hpp:62
Definition: osi_ground_truth.hpp:40
const Eigen::Vector3d & get_veh_coord_sys_info(int obj_id) const
Definition: osi_ground_truth.hpp:66
std::map< int, Eigen::Vector3d > veh_bbcenter_to_rear_
Store object coordinate system info for each object <obj_id,offset>.
Definition: osi_ground_truth.hpp:112
std::map< int, Eigen::Vector3d > mov_obj_dimensions_
Store moving object dimensions for each object <obj_id,dimensions>.
Definition: osi_ground_truth.hpp:115
const osi3::MovingObject * get_moving_object(const uint64_t id) const
Definition: osi_ground_truth.cpp:31
uint64_t get_ego_id() const
Definition: osi_ground_truth.hpp:94
void reset()
Definition: osi_ground_truth.hpp:85
void set(const osi3::GroundTruth &osi_gt)
Definition: osi_ground_truth.hpp:50
const osi3::GroundTruth * gt_ptr_
Pointer to ground truth object of the processed OSI message.
Definition: osi_ground_truth.hpp:109
const Eigen::Vector3d & get_mov_obj_dimensions(int obj_id) const
Definition: osi_ground_truth.hpp:78
Eigen::Vector3d osi_dimension3d_lwh_to_vector3d(const osi3::Dimension3d osi_dim)
Definition: osi_utils.cpp:63