Easy Navigation
Loading...
Searching...
No Matches
GNSSPerception.hpp
Go to the documentation of this file.
1// Copyright 2025 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
21
22#ifndef EASYNAV_SENSORS_TYPES__GNSSPERCEPTIONS_HPP_
23#define EASYNAV_SENSORS_TYPES__GNSSPERCEPTIONS_HPP_
24
25#include <string>
26#include <vector>
27
28#include "sensor_msgs/msg/nav_sat_fix.hpp"
29
30#include "rclcpp_lifecycle/lifecycle_node.hpp"
31
33
34namespace easynav
35{
36
42{
43public:
45 static constexpr std::string_view default_group_ = "gnss";
46
50 static inline bool supports_msg_type(std::string_view t)
51 {
52 return t == "sensor_msgs/msg/NavSatFix";
53 }
54
56 {
57 [[maybe_unused]] static const bool _ = [] {
59 [](const GNSSPerception & perception) {
60 std::ostringstream ret;
61 const auto & fix = perception.data;
62 ret << "{ " << perception.stamp.seconds()
63 << " } GNSSPerception lat = " << fix.latitude
64 << ", lon = " << fix.longitude
65 << ", alt = " << fix.altitude
66 << " (status: " << static_cast<int>(fix.status.status)
67 << ", service: " << fix.status.service << ")"
68 << " in frame [" << perception.frame_id
69 << "] with ts " << perception.stamp.seconds() << "\n";
70 return ret.str();
71 });
72 return true;
73 }();
74 }
75
77 sensor_msgs::msg::NavSatFix data;
78};
79
85{
86public:
90 void on_initialize() override;
91
99 bool cycle_rt([[maybe_unused]] std::shared_ptr<NavState> nav_state) override;
100
101private:
103 std::shared_ptr<GNSSPerception> perception_data_ {nullptr};
104
106 rclcpp::SubscriptionBase::SharedPtr perception_sub_;
107};
108
116 std::vector<std::shared_ptr<GNSSPerception>>;
117
121rclcpp::Time get_latest_gnss_perceptions_stamp(const GNSSPerceptions & perceptions);
122
123} // namespace easynav
124
125#endif // EASYNAV_SENSORS_TYPES__GNSSPERCEPTIONS_HPP_
Defines data structures and utilities for representing and processing sensor perceptions.
Handles the creation and updating of GNSSPerception instances from sensor_msgs::msg::NavSatFix messag...
Definition GNSSPerception.hpp:85
bool cycle_rt(std::shared_ptr< NavState > nav_state) override
Run one real-time sensor processing cycle.
Definition GNSSPerception.cpp:69
void on_initialize() override
Optional post-initialization hook for subclasses.
Definition GNSSPerception.cpp:27
sensor_msgs::msg::NavSatFix data
GNSS data received from the sensor.
Definition GNSSPerception.hpp:77
static bool supports_msg_type(std::string_view t)
Returns whether the given ROS 2 type name is supported by this perception.
Definition GNSSPerception.hpp:50
static constexpr std::string_view default_group_
Group identifier for GNSS perceptions.
Definition GNSSPerception.hpp:45
GNSSPerception()
Definition GNSSPerception.hpp:55
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
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< GNSSPerception > > GNSSPerceptions
Alias for a vector of shared pointers to GNSSPerception objects.
Definition GNSSPerception.hpp:115
rclcpp::Time get_latest_gnss_perceptions_stamp(const GNSSPerceptions &perceptions)
Retrieves the latest timestamp among a set of GNSS perceptions.
Definition GNSSPerception.cpp:79