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