15 #ifndef BELUGA_SENSOR_BEARING_SENSOR_MODEL_HPP
16 #define BELUGA_SENSOR_BEARING_SENSOR_MODEL_HPP
19 #include <range/v3/range/conversion.hpp>
20 #include <range/v3/view/all.hpp>
21 #include <range/v3/view/transform.hpp>
59 template <
class LandmarkMap,
class StateType>
79 template <
class... Args>
93 if constexpr (std::is_same_v<state_type, Sophus::SE3d>) {
95 robot_pose_in_world =
state;
103 Eigen::Vector3d{
state.translation().x(),
state.translation().y(), 0.0}};
109 const auto detection_weight = [
this, &sensor_pose_in_world](
const auto& detection) {
112 detection.detection_bearing_in_sensor, detection.category, sensor_pose_in_world);
115 if (!opt_landmark_bearing_in_sensor) {
120 const auto detection_bearing_in_sensor = detection.detection_bearing_in_sensor.normalized();
123 const auto& landmark_bearing_in_sensor = *opt_landmark_bearing_in_sensor;
126 const auto cos_aperture = detection_bearing_in_sensor.dot(landmark_bearing_in_sensor);
127 const auto sin_aperture = detection_bearing_in_sensor.cross(landmark_bearing_in_sensor).norm();
130 const auto bearing_error = std::atan2(sin_aperture, cos_aperture);
133 const auto bearing_error_prob =
136 return bearing_error_prob;
139 return std::transform_reduce(detections.cbegin(), detections.cend(), 1.0, std::multiplies{}, detection_weight);
152 template <
class LandmarkMap>
156 template <
class LandmarkMap>