$darkmode
esmini_world_data.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 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  */
24 #pragma once
25 
26 #include <memory> // for shared_ptr<>, unique_ptr<>
27 #include <string> // for string
28 
29 #include <cloe/component/frustum.hpp> // for Frustum
30 #include <cloe/component/lane_boundary.hpp> // for LaneBoundary
31 #include <cloe/component/object.hpp> // for Object
32 #include <cloe/sync.hpp> // for Sync
33 
34 namespace cloe_esmini {
35 
37  public:
38  ESMiniEnvData() = delete;
39  virtual ~ESMiniEnvData() = default;
40 
44  explicit ESMiniEnvData(const std::string& name, double filter_dist) : name_(name) {
45  // Set object sensor into the ego vehicle origin.
46  mount_.setIdentity();
47  // Only set frustum far range and keep all other parameters as default (=surrround view).
48  frustum_.clip_far = filter_dist;
49  }
50 
54  virtual void step(const cloe::Sync& s) = 0;
55 
59  virtual cloe::Duration time() const { return env_data_time_; }
60 
66  virtual void set_name(const std::string& name) { name_ = name; }
67 
73  virtual void reset() = 0;
74 
81  virtual void set_reset_state() { restart_ = true; }
82 
83  // Accessors
84  const cloe::Object& get_ego_object() const { return *ego_object_; }
85 
86  const cloe::Objects& get_world_objects() const { return world_objects_; }
87 
88  double get_ego_steering_angle() const { return ego_steering_angle_; }
89 
90  const cloe::Frustum& get_frustum() const { return frustum_; }
91 
92  const Eigen::Isometry3d& get_mount_pose() const { return mount_; }
93 
94  const cloe::LaneBoundaries& get_lane_boundaries() { return lanes_; }
95 
96  // As defined in `cloe/component.hpp`
97  void clear_cache() {
98  world_objects_.clear();
99  ego_object_ = std::make_shared<cloe::Object>();
100  ego_steering_angle_ = 0.0;
101  lanes_.clear();
102  }
103 
104  friend void to_json(cloe::Json& j, const ESMiniEnvData& s) {
105  j = cloe::Json{
106  {"env_data_time", s.env_data_time_}, {"restart", s.restart_},
107  {"world_objects", s.world_objects_}, {"ego_object", s.ego_object_},
108  {"ego_steering_angle", s.ego_steering_angle_}, {"lane_boundaries", s.lanes_},
109  };
110  }
111 
112  protected:
114  std::string name_ = "default_sensor";
115 
117  bool restart_ = false;
118 
121 
124 
126  Eigen::Isometry3d mount_;
127 
130 
133 
135  std::shared_ptr<cloe::Object> ego_object_;
136 
138  double ego_steering_angle_{0.0};
139 
141  cloe::LaneBoundaries lanes_;
142 };
143 
144 } // namespace esmini
Definition: sync.hpp:34
Definition: esmini_world_data.hpp:36
virtual void set_reset_state()
Definition: esmini_world_data.hpp:81
virtual void reset()=0
ESMiniEnvData(const std::string &name, double filter_dist)
Definition: esmini_world_data.hpp:44
cloe::Frustum frustum_
Sensor frustum information.
Definition: esmini_world_data.hpp:129
virtual void step(const cloe::Sync &s)=0
virtual cloe::Duration time() const
Definition: esmini_world_data.hpp:59
cloe::LaneBoundaries lanes_
Lane id-to-boundary-map.
Definition: esmini_world_data.hpp:141
double ego_steering_angle_
Ego front left wheel steering angle from last processed frame.
Definition: esmini_world_data.hpp:138
std::string name_
Human readable name.
Definition: esmini_world_data.hpp:114
cloe::Objects world_objects_
World objects from last processed frame.
Definition: esmini_world_data.hpp:132
Eigen::Isometry3d mount_
Sensor mounting position and orientation.
Definition: esmini_world_data.hpp:126
virtual void set_name(const std::string &name)
Definition: esmini_world_data.hpp:66
bool restart_
Indicates whether reset has been requested.
Definition: esmini_world_data.hpp:117
cloe::Duration env_data_time_next_
Expected simulation time for next data message.
Definition: esmini_world_data.hpp:123
cloe::Duration env_data_time_
Simulation time from last processed data message.
Definition: esmini_world_data.hpp:120
std::shared_ptr< cloe::Object > ego_object_
ego object information from last processed frame.
Definition: esmini_world_data.hpp:135
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