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#define DATATYPE(TYPE, VAR) \
71 std::vector<std::tuple<std::string, double, int>> VAR;
72#include "event_detector/datatypes.macro"
73#undef DATATYPE
74};
75
76// definitions for distinguishing between ROS messages with/without header
77// based on SFINAE (https://fekir.info/post/detect-member-variables/)
78using HasRosHeaderNo = std::false_type;
79using HasRosHeaderYes = std::true_type;
80
81template <typename T, typename = std_msgs::msg::Header>
82struct HasRosHeader : HasRosHeaderNo {};
83
84template <typename T>
85struct HasRosHeader<T, decltype(T::header)> : HasRosHeaderYes {};
86
87template <typename T>
88bool hasRosHeader(const T&);
89
90template <typename T>
91HasRosHeader<T> getHasRosHeader(const T&);
92
93} // namespace event_detector
94
95#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
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
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