Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-mros2 example-mbed-mros2-sub-pose example-mbed-mros2-pub-twist example-mbed-mros2-mturtle-teleop
include/mros2.h@0:580aba13d1a1, 2021-12-30 (annotated)
- Committer:
- smoritaemb
- Date:
- Thu Dec 30 21:06:29 2021 +0900
- Revision:
- 0:580aba13d1a1
Updated to catch up to mros2 v2.3
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| smoritaemb | 0:580aba13d1a1 | 1 | #ifndef MROS2_MROS2_H |
| smoritaemb | 0:580aba13d1a1 | 2 | #define MROS2_MROS2_H |
| smoritaemb | 0:580aba13d1a1 | 3 | |
| smoritaemb | 0:580aba13d1a1 | 4 | #include <string> |
| smoritaemb | 0:580aba13d1a1 | 5 | #include "rtps/rtps.h" |
| smoritaemb | 0:580aba13d1a1 | 6 | #ifndef __MBED__ |
| smoritaemb | 0:580aba13d1a1 | 7 | #include "lwip.h" |
| smoritaemb | 0:580aba13d1a1 | 8 | #endif /* __MBED__ */ |
| smoritaemb | 0:580aba13d1a1 | 9 | #include "mros2/logging.h" |
| smoritaemb | 0:580aba13d1a1 | 10 | |
| smoritaemb | 0:580aba13d1a1 | 11 | /* Statement to avoid link error */ |
| smoritaemb | 0:580aba13d1a1 | 12 | #ifdef __cplusplus |
| smoritaemb | 0:580aba13d1a1 | 13 | extern void* __dso_handle; |
| smoritaemb | 0:580aba13d1a1 | 14 | #endif |
| smoritaemb | 0:580aba13d1a1 | 15 | |
| smoritaemb | 0:580aba13d1a1 | 16 | namespace mros2 |
| smoritaemb | 0:580aba13d1a1 | 17 | { |
| smoritaemb | 0:580aba13d1a1 | 18 | |
| smoritaemb | 0:580aba13d1a1 | 19 | void init(int argc, char * argv[]); |
| smoritaemb | 0:580aba13d1a1 | 20 | |
| smoritaemb | 0:580aba13d1a1 | 21 | #ifdef __cplusplus |
| smoritaemb | 0:580aba13d1a1 | 22 | extern "C" { |
| smoritaemb | 0:580aba13d1a1 | 23 | #endif |
| smoritaemb | 0:580aba13d1a1 | 24 | void mros2_init(void *arg); |
| smoritaemb | 0:580aba13d1a1 | 25 | #ifdef __cplusplus |
| smoritaemb | 0:580aba13d1a1 | 26 | } |
| smoritaemb | 0:580aba13d1a1 | 27 | #endif |
| smoritaemb | 0:580aba13d1a1 | 28 | |
| smoritaemb | 0:580aba13d1a1 | 29 | class Node; |
| smoritaemb | 0:580aba13d1a1 | 30 | class Publisher; |
| smoritaemb | 0:580aba13d1a1 | 31 | class Subscriber; |
| smoritaemb | 0:580aba13d1a1 | 32 | |
| smoritaemb | 0:580aba13d1a1 | 33 | /* TODO: move to node.h/cpp? */ |
| smoritaemb | 0:580aba13d1a1 | 34 | class Node |
| smoritaemb | 0:580aba13d1a1 | 35 | { |
| smoritaemb | 0:580aba13d1a1 | 36 | public: |
| smoritaemb | 0:580aba13d1a1 | 37 | static Node create_node( |
| smoritaemb | 0:580aba13d1a1 | 38 | std::string node_name |
| smoritaemb | 0:580aba13d1a1 | 39 | ); |
| smoritaemb | 0:580aba13d1a1 | 40 | |
| smoritaemb | 0:580aba13d1a1 | 41 | template <class T> |
| smoritaemb | 0:580aba13d1a1 | 42 | Publisher create_publisher( |
| smoritaemb | 0:580aba13d1a1 | 43 | std::string topic_name, |
| smoritaemb | 0:580aba13d1a1 | 44 | int qos |
| smoritaemb | 0:580aba13d1a1 | 45 | ); |
| smoritaemb | 0:580aba13d1a1 | 46 | |
| smoritaemb | 0:580aba13d1a1 | 47 | template <class T> |
| smoritaemb | 0:580aba13d1a1 | 48 | Subscriber create_subscription( |
| smoritaemb | 0:580aba13d1a1 | 49 | std::string topic_name, |
| smoritaemb | 0:580aba13d1a1 | 50 | int qos, |
| smoritaemb | 0:580aba13d1a1 | 51 | void (*fp)(T*) |
| smoritaemb | 0:580aba13d1a1 | 52 | ); |
| smoritaemb | 0:580aba13d1a1 | 53 | |
| smoritaemb | 0:580aba13d1a1 | 54 | std::string node_name; |
| smoritaemb | 0:580aba13d1a1 | 55 | rtps::Participant* part; |
| smoritaemb | 0:580aba13d1a1 | 56 | |
| smoritaemb | 0:580aba13d1a1 | 57 | private: |
| smoritaemb | 0:580aba13d1a1 | 58 | |
| smoritaemb | 0:580aba13d1a1 | 59 | }; |
| smoritaemb | 0:580aba13d1a1 | 60 | |
| smoritaemb | 0:580aba13d1a1 | 61 | class Publisher |
| smoritaemb | 0:580aba13d1a1 | 62 | { |
| smoritaemb | 0:580aba13d1a1 | 63 | public: |
| smoritaemb | 0:580aba13d1a1 | 64 | std::string topic_name; |
| smoritaemb | 0:580aba13d1a1 | 65 | template <class T> |
| smoritaemb | 0:580aba13d1a1 | 66 | void publish(T& msg); |
| smoritaemb | 0:580aba13d1a1 | 67 | }; |
| smoritaemb | 0:580aba13d1a1 | 68 | |
| smoritaemb | 0:580aba13d1a1 | 69 | class Subscriber |
| smoritaemb | 0:580aba13d1a1 | 70 | { |
| smoritaemb | 0:580aba13d1a1 | 71 | public: |
| smoritaemb | 0:580aba13d1a1 | 72 | std::string topic_name; |
| smoritaemb | 0:580aba13d1a1 | 73 | template <class T> |
| smoritaemb | 0:580aba13d1a1 | 74 | static void callback_handler( |
| smoritaemb | 0:580aba13d1a1 | 75 | void* callee, |
| smoritaemb | 0:580aba13d1a1 | 76 | const rtps::ReaderCacheChange& cacheChange |
| smoritaemb | 0:580aba13d1a1 | 77 | ); |
| smoritaemb | 0:580aba13d1a1 | 78 | void (*cb_fp)(intptr_t); |
| smoritaemb | 0:580aba13d1a1 | 79 | private: |
| smoritaemb | 0:580aba13d1a1 | 80 | }; |
| smoritaemb | 0:580aba13d1a1 | 81 | |
| smoritaemb | 0:580aba13d1a1 | 82 | void spin(); |
| smoritaemb | 0:580aba13d1a1 | 83 | |
| smoritaemb | 0:580aba13d1a1 | 84 | } /* namespace mros2 */ |
| smoritaemb | 0:580aba13d1a1 | 85 | |
| smoritaemb | 0:580aba13d1a1 | 86 | namespace message_traits |
| smoritaemb | 0:580aba13d1a1 | 87 | { |
| smoritaemb | 0:580aba13d1a1 | 88 | template <class T> |
| smoritaemb | 0:580aba13d1a1 | 89 | struct TypeName { |
| smoritaemb | 0:580aba13d1a1 | 90 | static const char* value(); |
| smoritaemb | 0:580aba13d1a1 | 91 | }; |
| smoritaemb | 0:580aba13d1a1 | 92 | } /* namespace message_traits */ |
| smoritaemb | 0:580aba13d1a1 | 93 | |
| smoritaemb | 0:580aba13d1a1 | 94 | #endif /* MROS2_MROS2_H */ |