Easy Navigation
Loading...
Searching...
No Matches
OdometryPerception.hpp
Go to the documentation of this file.
1// Copyright 2026 Intelligent Robotics Lab
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
22
23#ifndef EASYNAV_SENSORS_TYPES__ODOMETRYPERCEPTIONS_HPP_
24#define EASYNAV_SENSORS_TYPES__ODOMETRYPERCEPTIONS_HPP_
25
26#include <string_view>
27#include <vector>
28
29#include "nav_msgs/msg/odometry.hpp"
30
32
33namespace easynav
34{
35
41{
42public:
44 static constexpr std::string_view default_group_ = "odom";
45
49 static inline bool supports_msg_type(std::string_view t)
50 {
51 return t == "nav_msgs/msg/Odometry";
52 }
53
55 {
56 [[maybe_unused]] static const bool _ = [] {
58 [](const OdometryPerception & perception) {
59 std::ostringstream ret;
60 const auto & pose = perception.data.pose.pose;
61 const auto & twist = perception.data.twist.twist;
62 ret << "{ " << perception.stamp.seconds()
63 << " } OdometryPerception pose = ("
64 << pose.position.x << ", "
65 << pose.position.y << ", "
66 << pose.position.z << "), twist = ("
67 << twist.linear.x << ", "
68 << twist.linear.y << ", "
69 << twist.linear.z
70 << ") in frame [" << perception.frame_id
71 << "] with ts " << perception.stamp.seconds() << "\n";
72 return ret.str();
73 });
74 return true;
75 }();
76 }
77
79 nav_msgs::msg::Odometry data;
80};
81
87{
88public:
92 void on_initialize() override;
93
101 bool cycle_rt([[maybe_unused]] std::shared_ptr<NavState> nav_state) override;
102
103private:
105 std::shared_ptr<OdometryPerception> perception_data_ {nullptr};
106
108 rclcpp::SubscriptionBase::SharedPtr perception_sub_;
109
111 std::string odom_ns_key_;
112};
113
121 std::vector<std::shared_ptr<OdometryPerception>>;
122
126rclcpp::Time get_latest_odometry_perceptions_stamp(const OdometryPerceptions & perceptions);
127
128} // namespace easynav
129
130#endif // EASYNAV_SENSORS_TYPES__ODOMETRYPERCEPTIONS_HPP_
Defines data structures and utilities for representing and processing sensor perceptions.
static void register_printer(std::function< std::string(const T &)> printer)
Registers a pretty-printer for type T used by debug_string().
Definition NavState.hpp:384
Handles the creation and updating of OdometryPerception instances from nav_msgs::msg::Odometry messag...
Definition OdometryPerception.hpp:87
bool cycle_rt(std::shared_ptr< NavState > nav_state) override
Run one real-time sensor processing cycle.
Definition OdometryPerception.cpp:73
void on_initialize() override
Optional post-initialization hook for subclasses.
Definition OdometryPerception.cpp:27
static bool supports_msg_type(std::string_view t)
Returns whether the given ROS 2 type name is supported by this perception.
Definition OdometryPerception.hpp:49
static constexpr std::string_view default_group_
Group identifier for odometry perceptions.
Definition OdometryPerception.hpp:44
OdometryPerception()
Definition OdometryPerception.hpp:54
nav_msgs::msg::Odometry data
Odometry data received from the sensor.
Definition OdometryPerception.hpp:79
Abstract base class for representing a single sensor perception.
Definition Perceptions.hpp:44
rclcpp::Time stamp
Timestamp of the perception (ROS time).
Definition Perceptions.hpp:49
std::string frame_id
Coordinate frame associated with the perception.
Definition Perceptions.hpp:52
Abstract base class for pluginlib-based sensor perception handlers.
Definition Perceptions.hpp:108
Definition CircularBuffer.hpp:23
std::vector< std::shared_ptr< OdometryPerception > > OdometryPerceptions
Alias for a vector of shared pointers to OdometryPerception objects.
Definition OdometryPerception.hpp:120
rclcpp::Time get_latest_odometry_perceptions_stamp(const OdometryPerceptions &perceptions)
Retrieves the latest timestamp among a set of odometry perceptions.
Definition OdometryPerception.cpp:85