swarmros/include/swarmros/example/Node.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <swarmros/SimpleEvent.h>
4 #include <swarmros/ExampleEvent.h>
5 #include <swarmros/UInt.h>
6 #include <ros/ros.h>
7 #include <string>
8 #include <thread>
9 #include <atomic>
10 #include <random>
11 
13 {
14  class Node final
15  {
16  private:
17 
22  std::random_device _random;
23 
29 
35 
41 
47 
53 
59 
65 
71 
77 
83 
88  std::thread _worker;
89 
94  std::atomic<bool> _shutdownRequested;
95 
100  std::atomic<uint64_t> _heartbeatCounter;
101 
106  std::atomic<uint64_t> _reportInterval;
107 
112  void Worker();
113 
114  public:
115 
121  Node(const std::string& name);
122 
128  void HandleSimpleEvent(const SimpleEvent& event);
129 
135  void HandleExampleEvent(const ExampleEvent& event);
136 
142  void HandleIntervalParameterChange(const UInt& value);
143 
148  ~Node();
149  };
150 }
ros::Subscriber _reportIntervalParameterSubscriber
Parameter subscription for report interval.
Node(const std::string &name)
Construct a new Node objet.
Definition: example/Node.cpp:9
std::atomic< bool > _shutdownRequested
Shutdown signal for worker thread.
void HandleIntervalParameterChange(const UInt &value)
Handle parameter changes.
std::atomic< uint64_t > _reportInterval
Report interval.
void HandleSimpleEvent(const SimpleEvent &event)
Handle an incoming SimpleEvent.
std::random_device _random
Random number generator.
~Node()
Destroy the Node object.
ros::Publisher _exampleEventSource
Event source for example events.
ros::Publisher _heartbeatCounterTelemetryPublisher
Telemetry publisher for the heartbeat counter.
ros::Publisher _complexMessageTelemetryPublisher
Telemetry publisher for the complex message.
void HandleExampleEvent(const ExampleEvent &event)
Handle an incoming ExampleEvent.
ros::Publisher _pongEventSource
Event source for pong events.
void Worker()
Entry point for worker thread.
ros::Subscriber _pingEventSink
Event sink for ping events.
std::atomic< uint64_t > _heartbeatCounter
Global heartbeat counter.
ros::Publisher _heartbeatEventSource
Event source for simple events.
ros::Subscriber _exampleEventSink
Event sink for example events.
ros::Subscriber _heartbeatEventSink
Event sink for heartbeat events.
ros::NodeHandle _handle
ROS node handle.


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48