TinyRobotics
Loading...
Searching...
No Matches
MessageHandler.h
1#pragma once
2#include <vector>
3
4#include "Message.h"
5#include "TinyRobotics/coordinates/Coordinates.h"
6#include "TinyRobotics/coordinates/GPSCoordinate.h"
7#include "TinyRobotics/control/MotionState3D.h"
8
9namespace tinyrobotics {
10
11/**
12 * @brief Interface for handling messages in the TinyRobotics framework.
13 *
14 * MessageHandler provides a base interface for classes that process messages.
15 * It also supports chaining multiple handlers for flexible message routing.
16 * @ingroup communication
17 */
18class MessageHandler {
19 public:
20 /**
21 * @brief Handle an incoming message (pure virtual).
22 *
23 * This method should be implemented by derived classes to process messages.
24 * @param msg The message to handle.
25 * @return true if the message was handled successfully, false otherwise.
26 */
27 virtual bool onMessage(const Message<float>& msg) = 0;
28
29 virtual bool onMessage(const Message<Coordinate<float>>& msg) {
30 TRLogger.warn("MessageHandler: Received unhandled Coordinate message");
31 return false; // Default implementation does not handle Coordinate messages
32 };
33 virtual bool onMessage(const Message<GPSCoordinate>& msg) {
34 TRLogger.warn("MessageHandler: Received unhandled GPSCoordinate message");
35 return false; // Default implementation does not handle Coordinate messages
36 };
37
38 virtual bool onMessage(const Message<MotionState3D>& msg) {
39 TRLogger.warn("MessageHandler: Received unhandled MotionState3D message");
40 return false; // Default implementation does not handle MotionState3D
41 // messages
42 }
43};
44
45} // namespace tinyrobotics
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
virtual bool onMessage(const Message< float > &msg)=0
Handle an incoming message (pure virtual).
Represents the full 3D motion state of a robot or vehicle.
Definition: MotionState3D.h:53
Generic message structure for communication, parameterized by value type.
Definition: Message.h:72