Easy Navigation
Loading...
Searching...
No Matches
DetectionsPerception.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__DETECTIONSPERCEPTIONS_HPP_
23#define EASYNAV_SENSORS_TYPES__DETECTIONSPERCEPTIONS_HPP_
24
25#include <string>
26#include <vector>
27
28#include "vision_msgs/msg/detection3_d_array.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_ = "detections";
46
50 static inline bool supports_msg_type(std::string_view t)
51 {
52 return t == "vision_msgs/msg/Detection3DArray";
53 }
54
56 {
57 [[maybe_unused]] static const bool _ = [] {
59 [](const DetectionsPerception & perception) {
60 std::ostringstream ret;
61 ret << "{ " << perception.stamp.seconds()
62 << " } DetectionsPerception with "
63 << perception.data.detections.size()
64 << " detections in frame [" << perception.frame_id
65 << "] with ts " << perception.stamp.seconds() << "\n";
66 return ret.str();
67 });
68 return true;
69 }();
70 }
71
73 vision_msgs::msg::Detection3DArray data;
74};
75
82{
83public:
87 void on_initialize() override;
88
96 bool cycle_rt([[maybe_unused]] std::shared_ptr<NavState> nav_state) override;
97
98private:
100 std::shared_ptr<DetectionsPerception> perception_data_ {nullptr};
101
103 rclcpp::SubscriptionBase::SharedPtr perception_sub_;
104};
105
113 std::vector<std::shared_ptr<DetectionsPerception>>;
114
118rclcpp::Time get_latest_detections_perceptions_stamp(const DetectionsPerceptions & perceptions);
119
120} // namespace easynav
121
122#endif // EASYNAV_SENSORS_TYPES__DETECTIONSPERCEPTIONS_HPP_
Defines data structures and utilities for representing and processing sensor perceptions.
static bool supports_msg_type(std::string_view t)
Returns whether the given ROS 2 type name is supported by this perception.
Definition DetectionsPerception.hpp:50
DetectionsPerception()
Definition DetectionsPerception.hpp:55
static constexpr std::string_view default_group_
Group identifier for image perceptions.
Definition DetectionsPerception.hpp:45
vision_msgs::msg::Detection3DArray data
Detection3DArray data received from the an external processing system.
Definition DetectionsPerception.hpp:73
Handles the creation and updating of DetectionsPerceptions instances from sensor_msgs::msg::Image mes...
Definition DetectionsPerception.hpp:82
bool cycle_rt(std::shared_ptr< NavState > nav_state) override
Run one real-time sensor processing cycle.
Definition DetectionsPerception.cpp:72
void on_initialize() override
Optional post-initialization hook for subclasses.
Definition DetectionsPerception.cpp:28
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< DetectionsPerception > > DetectionsPerceptions
Definition DetectionsPerception.hpp:112
rclcpp::Time get_latest_detections_perceptions_stamp(const DetectionsPerceptions &perceptions)
Retrieves the latest timestamp among a set of detection-based perceptions.
Definition DetectionsPerception.cpp:82