$darkmode
vtd_sensor_data.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  */
25 #pragma once
26 
27 #include <memory> // for shared_ptr<>, unique_ptr<>
28 #include <string> // for string
29 
30 #include <cloe/component/frustum.hpp> // for Frustum
31 #include <cloe/component/lane_boundary.hpp> // for LaneBoundary
32 #include <cloe/component/object.hpp> // for Object
33 #include <cloe/sync.hpp> // for Sync
34 
35 #include "vtd_logger.hpp" // for vtd_logger
36 
37 namespace vtd {
38 
40  public:
41  VtdSensorData() = delete;
42  virtual ~VtdSensorData() = default;
43 
47  explicit VtdSensorData(const std::string& name) : name_(name) {}
48 
52  virtual void step(const cloe::Sync& s) = 0;
53 
57  virtual cloe::Duration simulation_time() const { return simulation_time_; }
58 
64  virtual void set_name(const std::string& name) { name_ = name; }
65 
71  virtual void reset() = 0;
72 
79  virtual void set_reset_state() { restart_ = true; }
80 
81  // Accessors
82  const cloe::Object& get_ego_object() const { return *ego_object_; }
83 
84  const cloe::Objects& get_world_objects() const { return world_objects_; }
85 
86  double get_ego_steering_angle() const { return ego_steering_angle_; }
87 
88  const cloe::Frustum& get_frustum() const { return frustum_; }
89 
90  const Eigen::Isometry3d& get_mount_pose() const { return mount_; }
91 
92  const cloe::LaneBoundaries& get_lane_boundaries() { return lanes_; }
93 
94  // As defined in `cloe/component.hpp`
95  void clear_cache() {
96  world_objects_.clear();
97  ego_object_ = std::make_shared<cloe::Object>();
98  ego_steering_angle_ = 0.0;
99  lanes_.clear();
100  }
101 
102  friend void to_json(cloe::Json& j, const VtdSensorData& s) {
103  j = cloe::Json{
104  {"simulation_time", s.simulation_time_}, {"restart", s.restart_},
105  {"world_objects", s.world_objects_}, {"ego_object", s.ego_object_},
106  {"ego_steering_angle", s.ego_steering_angle_}, {"lane_boundaries", s.lanes_},
107  };
108  }
109 
110  protected:
112  std::string name_ = "default_sensor";
113 
115  bool restart_ = false;
116 
119 
121  Eigen::Isometry3d mount_;
122 
125 
128 
130  std::shared_ptr<cloe::Object> ego_object_;
131 
133  double ego_steering_angle_{0.0};
134 
136  cloe::LaneBoundaries lanes_;
137 
139 };
140 
141 } // namespace vtd
Definition: sync.hpp:34
Definition: vtd_sensor_data.hpp:39
Eigen::Isometry3d mount_
Sensor mounting position and orientation.
Definition: vtd_sensor_data.hpp:121
std::shared_ptr< cloe::Object > ego_object_
ego object information from last processed frame.
Definition: vtd_sensor_data.hpp:130
virtual void step(const cloe::Sync &s)=0
VtdSensorData(const std::string &name)
Definition: vtd_sensor_data.hpp:47
bool restart_
Indicates whether reset has been requested.
Definition: vtd_sensor_data.hpp:115
virtual void set_reset_state()
Definition: vtd_sensor_data.hpp:79
double ego_steering_angle_
Ego front left wheel steering angle from last processed frame.
Definition: vtd_sensor_data.hpp:133
virtual cloe::Duration simulation_time() const
Definition: vtd_sensor_data.hpp:57
cloe::Duration simulation_time_
Simulation time from last processed sensor message.
Definition: vtd_sensor_data.hpp:118
cloe::Objects world_objects_
World objects from last processed frame.
Definition: vtd_sensor_data.hpp:127
virtual void set_name(const std::string &name)
Definition: vtd_sensor_data.hpp:64
cloe::Frustum frustum_
Sensor frustum information.
Definition: vtd_sensor_data.hpp:124
cloe::LaneBoundaries lanes_
Lane id-to-boundary-map.
Definition: vtd_sensor_data.hpp:136
virtual void reset()=0
std::string name_
Human readable name.
Definition: vtd_sensor_data.hpp:112
std::chrono::nanoseconds Duration
Definition: cloe_fwd.hpp:36
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:128
Definition: frustum.hpp:37
Definition: object.hpp:51