SMACC
Loading...
Searching...
No Matches
cb_default_multirole_sensor_behavior.h
Go to the documentation of this file.
1#pragma once
2
5
7{
8template <typename ClientType>
10{
11public:
12 typedef typename ClientType::TMessageType TMessageType;
13
14 ClientType *sensor_;
15
17 {
18 sensor_ = nullptr;
19 }
20
21 static std::string getEventLabel()
22 {
23 // show ros message type
24 return demangleSymbol(typeid(TMessageType).name());
25 }
26
27 std::function<void()> deferedEventPropagation;
28
29 template <typename TOrthogonal, typename TSourceObject>
31 {
33 // just propagate the client events from this client behavior source.
37 };
38 }
39
40 template <typename EvType>
42 {
43 this->postEvent<EvType>();
44 }
45
46 template <typename EvType>
47 void propagateEvent2(const ros::TimerEvent &tdata)
48 {
49 this->postEvent<EvType>();
50 }
51
52 virtual void onEntry() override
53 {
54 ROS_INFO("[CbDefaultMultiRoleSensorBehavior] onEntry. Requires client of type '%s'", demangleSymbol<ClientType>().c_str());
55
56 this->requiresClient(sensor_);
57
58 if (sensor_ == nullptr)
59 {
60 ROS_FATAL_STREAM("Sensor client behavior needs a client of type: " << demangleSymbol<ClientType>() << " but it is not found.");
61 }
62 else
63 {
65 ROS_INFO("[CbDefaultMultiRoleSensorBehavior] onEntry. sensor initialize");
66 sensor_->initialize();
67 }
68 }
69
70 void onExit()
71 {
72 }
73
74 virtual void onMessageCallback(const TMessageType &msg)
75 {
76 // empty to fill by sensor customization based on inheritance
77 }
78};
79} // namespace smacc
void requiresClient(SmaccClientType *&storage)
std::string demangleSymbol()
Definition: introspection.h:75