mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
node_id.h
1#pragma once
2#include <ostream>
3#include <mrs_msgs/msg/errorgraph_node_id.hpp>
4
5namespace mrs_lib
6{
7 namespace errorgraph
8 {
9 using errorgraph_node_id_msg_t = mrs_msgs::msg::ErrorgraphNodeID;
10
20 struct node_id_t
21 {
22 std::string node;
23 std::string component;
24
26 inline bool operator==(const node_id_t& other) const
27 {
28 return node == other.node && component == other.component;
29 }
30
32 static inline node_id_t from_msg(const errorgraph_node_id_msg_t& msg)
33 {
34 node_id_t ret;
35 ret.node = msg.node;
36 ret.component = msg.component;
37 return ret;
38 }
39
41 inline errorgraph_node_id_msg_t to_msg() const
42 {
43 errorgraph_node_id_msg_t ret;
44 ret.node = node;
45 ret.component = component;
46 return ret;
47 }
48 };
49
51 inline std::ostream& operator<<(std::ostream& os, const node_id_t& node_id)
52 {
53 return os << node_id.node << "." << node_id.component;
54 }
55 } // namespace errorgraph
56} // namespace mrs_lib
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Identifies a specific component within a ROS node for error reporting.
Definition node_id.h:21
errorgraph_node_id_msg_t to_msg() const
Convert to a ROS message.
Definition node_id.h:41
bool operator==(const node_id_t &other) const
Equality comparison by both node and component.
Definition node_id.h:26
std::string component
Name of the logical component within the node (e.g. "lat_gps", "main").
Definition node_id.h:23
static node_id_t from_msg(const errorgraph_node_id_msg_t &msg)
Construct from a ROS message.
Definition node_id.h:32
std::string node
Name of the ROS node (e.g. "EstimationManager", "HwApiManager").
Definition node_id.h:22