$darkmode
vtd_sensor_components.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  */
22 #include <cloe/component/driver_request.hpp> // for DriverRequest
23 #include <cloe/component/ego_sensor.hpp> // for EgoSensor
24 #include <cloe/component/lane_sensor.hpp> // for LaneBoundarySensor
25 #include <cloe/component/object_sensor.hpp> // for ObjectSensor
26 
27 #include "task_control.hpp" // for TaskControl
28 #include "vtd_sensor_data.hpp" // for VtdSensorData
29 
30 namespace vtd {
31 
32 class VtdEgoSensor : public cloe::EgoSensor {
33  public:
34  VtdEgoSensor(uint64_t id, std::shared_ptr<VtdSensorData> data,
35  std::shared_ptr<TaskControl> task_control)
36  : EgoSensor("vtd/ego_sensor"), id_(id), data_{data}, task_control_{task_control} {}
37  virtual ~VtdEgoSensor() = default;
38 
39  const cloe::Object& sensed_state() const override { return data_->get_ego_object(); }
40  double wheel_steering_angle() const override { return data_->get_ego_steering_angle(); }
41  virtual double steering_wheel_speed() const override {
42  return task_control_->get_steering_wheel_speed(id_);
43  }
44 
45  private:
46  uint64_t id_;
47  std::shared_ptr<VtdSensorData> data_;
48  std::shared_ptr<TaskControl> task_control_;
49 };
50 
52  public:
53  explicit VtdWorldSensor(std::shared_ptr<VtdSensorData> data)
54  : ObjectSensor("vtd/world_sensor"), data_{data} {}
55  virtual ~VtdWorldSensor() = default;
56 
57  const cloe::Objects& sensed_objects() const override { return data_->get_world_objects(); }
58  const cloe::Frustum& frustum() const override { return data_->get_frustum(); }
59  const Eigen::Isometry3d& mount_pose() const override { return data_->get_mount_pose(); }
60 
61  private:
62  std::shared_ptr<VtdSensorData> data_;
63 };
64 
66  public:
67  explicit VtdLaneBoundarySensor(std::shared_ptr<VtdSensorData> data)
68  : LaneBoundarySensor("vtd/lane_boundary_sensor"), data_{data} {}
69  virtual ~VtdLaneBoundarySensor() = default;
70 
71  const cloe::LaneBoundaries& sensed_lane_boundaries() const override {
72  return data_->get_lane_boundaries();
73  }
74  const cloe::Frustum& frustum() const override { return data_->get_frustum(); }
75  const Eigen::Isometry3d& mount_pose() const override { return data_->get_mount_pose(); }
76 
77  private:
78  std::shared_ptr<VtdSensorData> data_;
79  std::shared_ptr<TaskControl> task_control_;
80 };
81 
83  public:
84  explicit VtdDriverRequest(uint64_t id, std::shared_ptr<TaskControl> task_control)
85  : DriverRequest("vtd/driver_request"), id_(id), task_control_{task_control} {}
86 
87  virtual ~VtdDriverRequest() = default;
88 
89  bool has_acceleration() const override {
90  return task_control_->has_driver_request_acceleration(id_);
91  }
92 
93  boost::optional<double> acceleration() const override {
94  boost::optional<double> accel;
95  if (this->has_acceleration()) {
96  accel = task_control_->get_driver_request_acceleration(id_);
97  }
98  return accel;
99  }
100 
101  bool has_steering_angle() const override {
102  return task_control_->has_driver_request_steering_angle(id_);
103  }
104 
105  boost::optional<double> steering_angle() const override {
106  boost::optional<double> angle;
107  if (this->has_steering_angle()) {
108  angle = task_control_->get_driver_request_steering_angle(id_);
109  }
110  return angle;
111  }
112 
113  private:
114  uint64_t id_;
115  std::shared_ptr<TaskControl> task_control_;
116 };
117 
118 } // namespace vtd
Definition: driver_request.hpp:31
Definition: ego_sensor.hpp:31
Definition: lane_sensor.hpp:33
Definition: object_sensor.hpp:33
Definition: vtd_sensor_components.hpp:82
bool has_steering_angle() const override
Definition: vtd_sensor_components.hpp:101
boost::optional< double > acceleration() const override
Definition: vtd_sensor_components.hpp:93
bool has_acceleration() const override
Definition: vtd_sensor_components.hpp:89
boost::optional< double > steering_angle() const override
Definition: vtd_sensor_components.hpp:105
Definition: vtd_sensor_components.hpp:32
const cloe::Object & sensed_state() const override
Definition: vtd_sensor_components.hpp:39
double wheel_steering_angle() const override
Definition: vtd_sensor_components.hpp:40
virtual double steering_wheel_speed() const override
Definition: vtd_sensor_components.hpp:41
Definition: vtd_sensor_components.hpp:65
const Eigen::Isometry3d & mount_pose() const override
Definition: vtd_sensor_components.hpp:75
const cloe::LaneBoundaries & sensed_lane_boundaries() const override
Definition: vtd_sensor_components.hpp:71
const cloe::Frustum & frustum() const override
Definition: vtd_sensor_components.hpp:74
Definition: vtd_sensor_components.hpp:51
const cloe::Objects & sensed_objects() const override
Definition: vtd_sensor_components.hpp:57
const Eigen::Isometry3d & mount_pose() const override
Definition: vtd_sensor_components.hpp:59
const cloe::Frustum & frustum() const override
Definition: vtd_sensor_components.hpp:58
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:128
Definition: frustum.hpp:37
Definition: object.hpp:51