$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 
27 #include <math.h> // for fabs
28 #include <memory> // for shared_ptr<>
29 
30 #include <cloe/component/ego_sensor.hpp> // for EgoSensor, Object
31 
32 namespace cloe {
33 namespace utility {
34 
46 class EgoSensorCanon : public EgoSensor {
47  public:
48  explicit EgoSensorCanon(std::shared_ptr<const EgoSensor> ego) : ego_(ego) {}
49  const Object& sensed_state() const override { return ego_->sensed_state(); }
50  double wheel_steering_angle() const override { return ego_->wheel_steering_angle(); }
51  double steering_wheel_speed() const override { return ego_->steering_wheel_speed(); }
52  double vehicle_length() const { return sensed_state().dimensions.x(); }
53  double vehicle_width() const { return sensed_state().dimensions.y(); }
54  double vehicle_height() const { return sensed_state().dimensions.z(); }
55 
68  double velocity_as_mps() const { return sensed_state().velocity.norm(); }
69 
73  double velocity_as_kmph() const { return velocity_as_mps() * (60 * 60 / 1000.0); }
74 
78  double acceleration_as_mpss() const { return sensed_state().acceleration.norm(); }
79 
80  protected:
81  std::shared_ptr<const EgoSensor> ego_;
82 };
83 
87 inline double distance_forward(const Object& o) { return o.pose.translation().x(); }
88 
92 inline double distance_starboard(const Object& o) { return -o.pose.translation().y(); }
93 
99 inline bool is_object_fore(const Object& o) { return distance_forward(o) > 1.0E-9; }
100 
106 inline bool is_object_aft(const Object& o) { return distance_forward(o) < 1.0E-9; }
107 
125 inline bool is_same_lane(const Object& o) { return fabs(distance_starboard(o)) < 2.5; }
126 
130 std::shared_ptr<Object> closest_forward(const Objects objects);
131 
132 } // namespace utility
133 } // namespace cloe
Definition: ego_sensor.hpp:31
Definition: ego_sensor_canon.hpp:46
const Object & sensed_state() const override
Definition: ego_sensor_canon.hpp:49
double wheel_steering_angle() const override
Definition: ego_sensor_canon.hpp:50
double steering_wheel_speed() const override
Definition: ego_sensor_canon.hpp:51
double acceleration_as_mpss() const
Definition: ego_sensor_canon.hpp:78
double velocity_as_mps() const
Definition: ego_sensor_canon.hpp:68
double velocity_as_kmph() const
Definition: ego_sensor_canon.hpp:73
bool is_object_fore(const Object &o)
Definition: ego_sensor_canon.hpp:99
double distance_starboard(const Object &o)
Definition: ego_sensor_canon.hpp:92
bool is_same_lane(const Object &o)
Definition: ego_sensor_canon.hpp:125
bool is_object_aft(const Object &o)
Definition: ego_sensor_canon.hpp:106
double distance_forward(const Object &o)
Definition: ego_sensor_canon.hpp:87
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:128
Definition: object.hpp:51
Eigen::Vector3d dimensions
Dimensions in [m].
Definition: object.hpp:72
Eigen::Vector3d acceleration
Absolute acceleration in [m/(s*s)].
Definition: object.hpp:81
Eigen::Isometry3d pose
Pose in [m] and [rad].
Definition: object.hpp:69
Eigen::Vector3d velocity
Absolute velocity in [m/s].
Definition: object.hpp:78