Easy Navigation
Loading...
Searching...
No Matches
ImagePerception.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_COMMON_TYPES__IMAGEPERCEPTIONS_HPP_
23#define EASYNAV_COMMON_TYPES__IMAGEPERCEPTIONS_HPP_
24
25#include <string>
26#include <vector>
27
28#include "cv_bridge/cv_bridge.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_ = "image";
46
50 static inline bool supports_msg_type(std::string_view t)
51 {
52 return t == "sensor_msgs/msg/Image";
53 }
54
59 cv::Mat data;
60};
61
68{
69public:
72 std::string group() const override {return "image";}
73
77 std::shared_ptr<PerceptionBase> create(const std::string &) override
78 {
79 return std::make_shared<ImagePerception>();
80 }
81
93 rclcpp::SubscriptionBase::SharedPtr create_subscription(
94 rclcpp_lifecycle::LifecycleNode & node,
95 const std::string & topic,
96 const std::string & type,
97 std::shared_ptr<PerceptionBase> target,
98 rclcpp::CallbackGroup::SharedPtr cb_group) override;
99};
100
108 std::vector<std::shared_ptr<ImagePerception>>;
109
113rclcpp::Time get_latest_image_perceptions_stamp(const ImagePerceptions & perceptions);
114
115} // namespace easynav
116
117#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:68
std::shared_ptr< PerceptionBase > create(const std::string &) override
Creates a new empty ImagePerception instance.
Definition ImagePerception.hpp:77
std::string group() const override
Returns the group managed by this handler.
Definition ImagePerception.hpp:72
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:31
Represents a single image perception from a sensor.
Definition ImagePerception.hpp:42
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:50
static constexpr std::string_view default_group_
Group identifier for image perceptions.
Definition ImagePerception.hpp:45
cv::Mat data
Image data received from the sensor.
Definition ImagePerception.hpp:59
Abstract base class for representing a single sensor perception.
Definition Perceptions.hpp:40
Abstract base interface for group-specific perception handlers.
Definition Perceptions.hpp:116
Definition CircularBuffer.hpp:23
std::vector< std::shared_ptr< ImagePerception > > ImagePerceptions
Alias for a vector of shared pointers to ImagePerception objects.
Definition ImagePerception.hpp:107
rclcpp::Time get_latest_image_perceptions_stamp(const ImagePerceptions &perceptions)
Retrieves the latest timestamp among a set of image-based perceptions.
Definition ImagePerception.cpp:69