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
23
24#ifndef EASYNAV_SENSORS__TYPES__ODOMETRYPERCEPTION_HPP_
25#define EASYNAV_SENSORS__TYPES__ODOMETRYPERCEPTION_HPP_
26
27#include <string_view>
28#include <vector>
29#include <memory>
30#include <string>
31
32#include "nav_msgs/msg/odometry.hpp"
34
35namespace easynav
36{
37
43{
44public:
46 static constexpr std::string_view default_group_ = "odom";
47
51 static inline bool supports_msg_type(std::string_view t)
52 {
53 return t == "nav_msgs/msg/Odometry";
54 }
55
57 {
58 [[maybe_unused]] static const bool _ = [] {
60 [](const OdometryPerception & perception) {
61 std::ostringstream ret;
62 const auto & pose = perception.data.pose.pose;
63 const auto & twist = perception.data.twist.twist;
64 ret << "{ " << perception.stamp.seconds()
65 << " } OdometryPerception pose = ("
66 << pose.position.x << ", "
67 << pose.position.y << ", "
68 << pose.position.z << "), twist = ("
69 << twist.linear.x << ", "
70 << twist.linear.y << ", "
71 << twist.linear.z
72 << ") in frame [" << perception.frame_id
73 << "] with ts " << perception.stamp.seconds() << "\n";
74 return ret.str();
75 });
76 return true;
77 }();
78 }
79
81 nav_msgs::msg::Odometry data;
82};
83
91{
92public:
96 void on_initialize() override;
97
105 bool cycle_rt([[maybe_unused]] std::shared_ptr<NavState> nav_state) override;
106
108 std::shared_ptr<PerceptionBase> get_perception() const override {return perception_data_;}
109
110private:
112 std::shared_ptr<OdometryPerception> perception_data_ {nullptr};
113
115 rclcpp::SubscriptionBase::SharedPtr perception_sub_;
116
118 std::string odom_ns_key_;
119};
120
128 std::vector<std::shared_ptr<OdometryPerception>>;
129
134rclcpp::Time get_latest_odometry_perceptions_stamp(const OdometryPerceptions & perceptions);
135
136} // namespace easynav
137
138#endif // EASYNAV_SENSORS__TYPES__ODOMETRYPERCEPTION_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:458
Handles the creation and updating of OdometryPerception instances from nav_msgs::msg::Odometry messag...
Definition OdometryPerception.hpp:91
bool cycle_rt(std::shared_ptr< NavState > nav_state) override
Run one real-time sensor processing cycle.
Definition OdometryPerception.cpp:70
void on_initialize() override
Optional post-initialization hook for subclasses.
Definition OdometryPerception.cpp:28
std::shared_ptr< PerceptionBase > get_perception() const override
The perception this handler keeps up to date.
Definition OdometryPerception.hpp:108
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:51
static constexpr std::string_view default_group_
Group identifier for odometry perceptions.
Definition OdometryPerception.hpp:46
OdometryPerception()
Definition OdometryPerception.hpp:56
nav_msgs::msg::Odometry data
Odometry data received from the sensor.
Definition OdometryPerception.hpp:81
Abstract base class for representing a single sensor perception.
Definition Perceptions.hpp:48
rclcpp::Time stamp
Timestamp of the perception (ROS time).
Definition Perceptions.hpp:53
std::string frame_id
Coordinate frame associated with the perception.
Definition Perceptions.hpp:56
Abstract base class for pluginlib-based sensor perception handlers.
Definition Perceptions.hpp:117
Definition CircularBuffer.hpp:24
std::vector< std::shared_ptr< OdometryPerception > > OdometryPerceptions
Alias for a vector of shared pointers to OdometryPerception objects.
Definition OdometryPerception.hpp:127
rclcpp::Time get_latest_odometry_perceptions_stamp(const OdometryPerceptions &perceptions)
Retrieves the latest timestamp among a set of odometry perceptions.
Definition OdometryPerception.cpp:82