Template Function easynav::get_perceptions

Function Documentation

template<typename T = PerceptionBase>
inline std::vector<std::shared_ptr<T>> easynav::get_perceptions(const std::vector<PerceptionPtr> &src)

Extracts a homogeneous collection of perceptions of type T from a heterogeneous vector.

This helper iterates the input vector of PerceptionPtr and:

  • If T is exactly PerceptionBase, returns all stored pointers without casting (heterogeneous view).

  • Otherwise, attempts a std::dynamic_pointer_cast<T> and includes only those perceptions that match (homogeneous view).

Template Parameters:

T – Target perception type. Must inherit from PerceptionBase. Defaults to PerceptionBase.

Parameters:

src – Source vector containing heterogeneous perceptions and their subscriptions.

Returns:

A vector of std::shared_ptr<T> containing the matching perceptions, in the same order as src.