Easy Navigation
Loading...
Searching...
No Matches
ImagePerception.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// This file is part of the project Easy Navigation (EasyNav in short)
4// licensed under the GNU General Public License v3.0.
5// See <http://www.gnu.org/licenses/> for details.
6//
7// Easy Navigation program is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
26
27#ifndef EASYNAV_COMMON_TYPES__IMAGEPERCEPTIONS_HPP_
28#define EASYNAV_COMMON_TYPES__IMAGEPERCEPTIONS_HPP_
29
30#include <string>
31#include <vector>
32
33#include "cv_bridge/cv_bridge.hpp"
34
35#include "rclcpp_lifecycle/lifecycle_node.hpp"
36
38
39namespace easynav
40{
41
47{
48public:
50 static constexpr std::string_view default_group_ = "image";
51
55 static inline bool supports_msg_type(std::string_view t)
56 {
57 return t == "sensor_msgs/msg/Image";
58 }
59
64 cv::Mat data;
65};
66
73{
74public:
77 std::string group() const override {return "image";}
78
82 std::shared_ptr<PerceptionBase> create(const std::string &) override
83 {
84 return std::make_shared<ImagePerception>();
85 }
86
98 rclcpp::SubscriptionBase::SharedPtr create_subscription(
99 rclcpp_lifecycle::LifecycleNode & node,
100 const std::string & topic,
101 const std::string & type,
102 std::shared_ptr<PerceptionBase> target,
103 rclcpp::CallbackGroup::SharedPtr cb_group) override;
104};
105
113 std::vector<std::shared_ptr<ImagePerception>>;
114
118rclcpp::Time get_latest_image_perceptions_stamp(const ImagePerceptions & perceptions);
119
120} // namespace easynav
121
122#endif // EASYNAV_COMMON_TYPES__IMAGEPERCEPTIONS_HPP_
Defines data structures and utilities for representing and processing sensor perceptions.
Handles the creation and updating of ImagePerception instances from sensor_msgs::msg::Image messages.
Definition ImagePerception.hpp:73
std::shared_ptr< PerceptionBase > create(const std::string &) override
Creates a new empty ImagePerception instance.
Definition ImagePerception.hpp:82
std::string group() const override
Returns the group managed by this handler.
Definition ImagePerception.hpp:77
rclcpp::SubscriptionBase::SharedPtr create_subscription(rclcpp_lifecycle::LifecycleNode &node, const std::string &topic, const std::string &type, std::shared_ptr< PerceptionBase > target, rclcpp::CallbackGroup::SharedPtr cb_group) override
Creates a subscription to an image topic that updates a target ImagePerception.
Definition ImagePerception.cpp:36
Represents a single image perception from a sensor.
Definition ImagePerception.hpp:47
static bool supports_msg_type(std::string_view t)
Returns whether the given ROS 2 type name is supported by this perception.
Definition ImagePerception.hpp:55
static constexpr std::string_view default_group_
Group identifier for image perceptions.
Definition ImagePerception.hpp:50
cv::Mat data
Image data received from the sensor.
Definition ImagePerception.hpp:64
Abstract base class for representing a single sensor perception.
Definition Perceptions.hpp:45
Abstract base interface for group-specific perception handlers.
Definition Perceptions.hpp:121
Definition CircularBuffer.hpp:28
std::vector< std::shared_ptr< ImagePerception > > ImagePerceptions
Alias for a vector of shared pointers to ImagePerception objects.
Definition ImagePerception.hpp:112
rclcpp::Time get_latest_image_perceptions_stamp(const ImagePerceptions &perceptions)
Retrieves the latest timestamp among a set of image-based perceptions.
Definition ImagePerception.cpp:74