event_detector 1.0.0
Loading...
Searching...
No Matches
common.hpp
1
25#pragma once
26
27#include <cctype>
28#include <string>
29#include <tuple>
30#include <type_traits>
31#include <unordered_map>
32#include <vector>
33
34#include <rclcpp/rclcpp.hpp>
35#include <std_msgs/msg/header.hpp>
36
37#include "event_detector/datatypes.hpp"
38
39namespace event_detector {
40
41// constants
42const std::string kTransformationTopic = "/tf";
43const std::string kStaticTransformationTopic = "/tf_static";
44
50template <typename T>
51struct Stamped {
52 rclcpp::Time stamp;
53 std::shared_ptr<const T> msg;
54};
55
56// convenience data structure typedefs
57template <typename T>
58using string_map = std::unordered_map<std::string, T>;
59template <typename T>
60using string_map_2d = std::unordered_map<std::string, string_map<T>>;
61
66 std::string id;
67 std::string name;
68 std::string base_frame;
69 std::string tf_prefix;
70 bool buffer_all_tf = false;
71 bool buffer_all_tf_static = false;
72#define DATATYPE(TYPE, VAR) \
73 std::vector<std::tuple<std::string, double, int>> VAR;
74#include "event_detector/datatypes.macro"
75#undef DATATYPE
76};
77
78// definitions for distinguishing between ROS messages with/without header
79// based on SFINAE (https://fekir.info/post/detect-member-variables/)
80using HasRosHeaderNo = std::false_type;
81using HasRosHeaderYes = std::true_type;
82
83template <typename T, typename = std_msgs::msg::Header>
84struct HasRosHeader : HasRosHeaderNo {};
85
86template <typename T>
87struct HasRosHeader<T, decltype(T::header)> : HasRosHeaderYes {};
88
89template <typename T>
90bool hasRosHeader(const T&);
91
92template <typename T>
93HasRosHeader<T> getHasRosHeader(const T&);
94
95} // namespace event_detector
96
97#include "event_detector/common.tpp"
const std::string kTransformationTopic
topic for dynamic transforms
Definition common.hpp:42
const std::string kStaticTransformationTopic
topic for static transforms
Definition common.hpp:43
Struct containing all data topics from a connected client.
Definition common.hpp:65
std::string name
client name
Definition common.hpp:67
bool buffer_all_tf_static
whether to store the full /tf_static topic for this client
Definition common.hpp:71
std::string base_frame
name of base frame
Definition common.hpp:68
std::string id
client ID
Definition common.hpp:66
std::string tf_prefix
prefix of frames
Definition common.hpp:69
bool buffer_all_tf
whether to store the full /tf topic for this client
Definition common.hpp:70
Struct wrapping an object with a timestamp.
Definition common.hpp:51
std::shared_ptr< const T > msg
ROS message.
Definition common.hpp:53
rclcpp::Time stamp
timestamp
Definition common.hpp:52