$darkmode
ego_sensor_canon.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 #ifndef CLOE_COMPONENT_UTILITY_EGO_SENSOR_CANON_HPP_
27 #define CLOE_COMPONENT_UTILITY_EGO_SENSOR_CANON_HPP_
28 
29 #include <math.h> // for fabs
30 #include <memory> // for shared_ptr<>
31 
32 #include <cloe/component/ego_sensor.hpp> // for EgoSensor, Object
33 
34 namespace cloe {
35 namespace utility {
36 
48 class EgoSensorCanon : public EgoSensor {
49  public:
50  explicit EgoSensorCanon(std::shared_ptr<const EgoSensor> ego) : ego_(ego) {}
51  const Object& sensed_state() const override { return ego_->sensed_state(); }
52  double wheel_steering_angle() const override { return ego_->wheel_steering_angle(); }
53  double steering_wheel_speed() const override { return ego_->steering_wheel_speed(); }
54  double vehicle_length() const { return sensed_state().dimensions.x(); }
55  double vehicle_width() const { return sensed_state().dimensions.y(); }
56  double vehicle_height() const { return sensed_state().dimensions.z(); }
57 
70  double velocity_as_mps() const { return sensed_state().velocity.norm(); }
71 
75  double velocity_as_kmph() const { return velocity_as_mps() * (60 * 60 / 1000.0); }
76 
80  double acceleration_as_mpss() const { return sensed_state().acceleration.norm(); }
81 
82  protected:
83  std::shared_ptr<const EgoSensor> ego_;
84 };
85 
89 inline double distance_forward(const Object& o) { return o.pose.translation().x(); }
90 
94 inline double distance_starboard(const Object& o) { return -o.pose.translation().y(); }
95 
101 inline bool is_object_fore(const Object& o) { return distance_forward(o) > 1.0E-9; }
102 
108 inline bool is_object_aft(const Object& o) { return distance_forward(o) < 1.0E-9; }
109 
127 inline bool is_same_lane(const Object& o) { return fabs(distance_starboard(o)) < 2.5; }
128 
132 std::shared_ptr<Object> closest_forward(const Objects objects);
133 
134 } // namespace utility
135 } // namespace cloe
136 
137 #endif // CLOE_COMPONENT_UTILITY_EGO_SENSOR_CANON_HPP_
double distance_starboard(const Object &o)
Definition: ego_sensor_canon.hpp:94
Eigen::Isometry3d pose
Pose in [m] and [rad].
Definition: object.hpp:69
Definition: ego_sensor.hpp:31
bool is_same_lane(const Object &o)
Definition: ego_sensor_canon.hpp:127
double velocity_as_mps() const
Definition: ego_sensor_canon.hpp:70
const Object & sensed_state() const override
Definition: ego_sensor_canon.hpp:51
bool is_object_aft(const Object &o)
Definition: ego_sensor_canon.hpp:108
Definition: object.hpp:51
Definition: ego_sensor_canon.hpp:48
double steering_wheel_speed() const override
Definition: ego_sensor_canon.hpp:53
Eigen::Vector3d acceleration
Absolute acceleration in [m/(s*s)].
Definition: object.hpp:81
std::shared_ptr< Object > closest_forward(const Objects objects)
Definition: ego_sensor_canon.cpp:31
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:111
Definition: coordinator.hpp:36
Eigen::Vector3d dimensions
Dimensions in [m].
Definition: object.hpp:72
double wheel_steering_angle() const override
Definition: ego_sensor_canon.hpp:52
double acceleration_as_mpss() const
Definition: ego_sensor_canon.hpp:80
Eigen::Vector3d velocity
Absolute velocity in [m/s].
Definition: object.hpp:78
double distance_forward(const Object &o)
Definition: ego_sensor_canon.hpp:89
bool is_object_fore(const Object &o)
Definition: ego_sensor_canon.hpp:101
double velocity_as_kmph() const
Definition: ego_sensor_canon.hpp:75