6#include "TinyRobotics/control/MotionState3D.h"
7#include "TinyRobotics/coordinates/Coordinates.h"
8#include "TinyRobotics/coordinates/GPSCoordinate.h"
10namespace tinyrobotics {
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
60 MessageOrigin origin = MessageOrigin::Undefined,
61 MessageContent content = MessageContent::Undefined) {
63 messageHandlers_.push_back(entry);
67
68
72
73
74
75
76
78 for (
auto& entry : messageHandlers_) {
79 if (!entry.handler)
continue;
80 if ((entry.origin == MessageOrigin::Undefined ||
81 entry.origin == msg.origin) &&
82 (entry.content == MessageContent::Undefined ||
83 entry.content == msg.content)) {
84 entry.handler->onMessage(msg);
90
91
92
93
94
96 for (
auto& entry : messageHandlers_) {
97 if (!entry.handler)
continue;
98 if ((entry.origin == MessageOrigin::Undefined ||
99 entry.origin == msg.origin) &&
100 (entry.content == MessageContent::Undefined ||
101 entry.content == msg.content)) {
102 entry.handler->onMessage(msg);
108
109
110
111
112
114 for (
auto& entry : messageHandlers_) {
115 if (!entry.handler)
continue;
116 if ((entry.origin == MessageOrigin::Undefined ||
117 entry.origin == msg.origin) &&
118 (entry.content == MessageContent::Undefined ||
119 entry.content == msg.content)) {
120 entry.handler->onMessage(msg);
127 for (
auto& entry : messageHandlers_) {
128 if (!entry.handler)
continue;
129 if ((entry.origin == MessageOrigin::Undefined ||
130 entry.origin == msg.origin) &&
131 (entry.content == MessageContent::Undefined ||
132 entry.content == msg.content)) {
133 entry.handler->onMessage(msg);
141 MessageOrigin origin = MessageOrigin::Undefined;
142 MessageContent content = MessageContent::Undefined;
144 MessageHandlerEntry() =
default;
146 MessageOrigin o = MessageOrigin::Undefined,
147 MessageContent c = MessageContent::Undefined)
148 : handler(&h), origin(o), content(c) {}
151 return handler == other.handler && origin == other.origin &&
152 content == other.content;
155 std::vector<MessageHandlerEntry> messageHandlers_;
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
Definition: Coordinate.h:57
Represents a geodetic GPS coordinate with latitude, longitude, and optional altitude.
Definition: GPSCoordinate.h:52
Interface for handling messages in the TinyRobotics framework.
Definition: MessageHandler.h:18
Base class for message sources in the TinyRobotics communication framework.
Definition: MessageSource.h:35
void sendMessage(const Message< MotionState3D > &msg)
Overload for MotionState3D messages.
Definition: MessageSource.h:126
void unsubscribeAll()
Remove all registered message handlers.
Definition: MessageSource.h:69
void sendMessage(const Message< GPSCoordinate > &msg)
Publish a message to all registered handlers.
Definition: MessageSource.h:113
void sendMessage(Message< float > &msg)
Publish a message to all registered handlers.
Definition: MessageSource.h:77
void subscribe(MessageHandler &handler, MessageOrigin origin=MessageOrigin::Undefined, MessageContent content=MessageContent::Undefined)
Subscribe a message handler to this source, with optional filtering.
Definition: MessageSource.h:59
void sendMessage(const Message< Coordinate< float > > &msg)
Publish a message to all registered handlers.
Definition: MessageSource.h:95
Represents the full 3D motion state of a robot or vehicle.
Definition: MotionState3D.h:53
Definition: MessageSource.h:139
Generic message structure for communication, parameterized by value type.
Definition: Message.h:72