24#ifndef EASYNAV_SENSORS_TYPES__PERCEPTIONS_HPP_
25#define EASYNAV_SENSORS_TYPES__PERCEPTIONS_HPP_
29#include "rclcpp/time.hpp"
30#include "rclcpp_lifecycle/lifecycle_node.hpp"
75template<
typename T = PerceptionBase>
76inline std::vector<std::shared_ptr<T>>
79 static_assert(std::is_base_of_v<PerceptionBase, T>,
80 "T must inherit from PerceptionBase");
82 std::vector<std::shared_ptr<T>> out;
83 out.reserve(src.size());
85 for (
const auto & perception : src) {
86 if (!perception) {
continue;}
88 if (
auto p = std::dynamic_pointer_cast<T>(perception)) {
89 out.push_back(std::move(p));
120 const std::shared_ptr<rclcpp_lifecycle::LifecycleNode> parent_node,
121 const rclcpp::CallbackGroup::SharedPtr realtime_cbg,
122 const std::string & sensor_name)
142 virtual bool cycle_rt([[maybe_unused]] std::shared_ptr<NavState> nav_state) {
return false;}
A blackboard-like structure to hold the current state of the navigation system.
Abstract base class for representing a single sensor perception.
Definition Perceptions.hpp:44
virtual ~PerceptionBase()=default
bool valid
Whether the perception contains valid data.
Definition Perceptions.hpp:56
rclcpp::Time stamp
Timestamp of the perception (ROS time).
Definition Perceptions.hpp:49
bool new_data
Whether the data has changed since the last observation.
Definition Perceptions.hpp:59
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
void initialize(const std::shared_ptr< rclcpp_lifecycle::LifecycleNode > parent_node, const rclcpp::CallbackGroup::SharedPtr realtime_cbg, const std::string &sensor_name)
Initializes the handler with the parent node and sensor name.
Definition Perceptions.hpp:119
virtual bool cycle_rt(std::shared_ptr< NavState > nav_state)
Run one real-time sensor processing cycle.
Definition Perceptions.hpp:142
std::string sensor_name_
Name of the sensor (used as YAML parameter namespace prefix).
Definition Perceptions.hpp:162
std::weak_ptr< rclcpp_lifecycle::LifecycleNode > parent_node_
Shared pointer to the parent lifecycle node.
Definition Perceptions.hpp:156
rclcpp::CallbackGroup::SharedPtr realtime_cbg_
Callback group for real-time operations.
Definition Perceptions.hpp:159
const std::string & get_sensor_name() const
Returns the sensor name provided during initialize.
Definition Perceptions.hpp:146
virtual ~PerceptionHandler()=default
virtual void on_initialize()
Optional post-initialization hook for subclasses.
Definition Perceptions.hpp:133
std::shared_ptr< rclcpp_lifecycle::LifecycleNode > get_node() const
Returns the parent lifecycle node.
Definition Perceptions.hpp:150
rclcpp::CallbackGroup::SharedPtr get_realtime_cbg() const
Returns the parent lifecycle node.
Definition Perceptions.hpp:153
Definition CircularBuffer.hpp:23
std::shared_ptr< PerceptionBase > PerceptionBasePtr
Shared pointer alias to PerceptionBase.
Definition Perceptions.hpp:64
std::vector< std::shared_ptr< T > > get_perceptions(const std::vector< PerceptionBasePtr > &src)
Extracts a homogeneous collection of perceptions of type T from a heterogeneous vector.
Definition Perceptions.hpp:77