EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
RosPublisherSafetyLevel.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_ROSPUBLISHER_SAFETYLEVEL_HPP_
2 #define ORG_EEROS_CONTROL_ROSPUBLISHER_SAFETYLEVEL_HPP_
3 
5 #include <std_msgs/UInt32.h>
8 
9 using namespace eeros::safety;
10 
11 namespace eeros {
12  namespace control {
13 
14  class RosPublisherSafetyLevel : public Block {
15  typedef std_msgs::UInt32::Type TRosMsg;
16  public:
17  RosPublisherSafetyLevel(const std::string& topic, const uint32_t queueSize=1000) :
18  topic (topic)
19  {
20  ros::NodeHandle handle;
21  publisher = handle.advertise<TRosMsg>(topic, queueSize);
22  ROS_DEBUG_STREAM("RosPublisherSafetyLevel, reading from topic: '" << topic << "' created.");
23  }
24 
26  safetySystem = &ss;
27  }
28 
29  void run() {
30  if (safetySystem != nullptr) {
31  SafetyLevel sl = safetySystem->getCurrentLevel();
32  msg.data = sl.getLevelId();
33  publisher.publish(msg);
34  }
35  }
36 
37  protected:
38  ros::Publisher publisher;
39  const std::string& topic;
40  TRosMsg msg;
42  };
43  };
44 };
45 
46 #endif /* ORG_EEROS_CONTROL_ROSPUBLISHER_SAFETYLEVEL_HPP_ */
Safety system.
Definition: SafetySystem.hpp:19
Definition: SafetyLevel.hpp:33
void run()
Definition: RosPublisherSafetyLevel.hpp:29
void setSafetySystem(SafetySystem &ss)
Definition: RosPublisherSafetyLevel.hpp:25
SafetySystem * safetySystem
Definition: RosPublisherSafetyLevel.hpp:41
RosPublisherSafetyLevel(const std::string &topic, const uint32_t queueSize=1000)
Definition: RosPublisherSafetyLevel.hpp:17
ros::Publisher publisher
Definition: RosPublisherSafetyLevel.hpp:38
Definition: Config.hpp:14
Definition: Block.hpp:10
Type
Definition: HALFeatures.hpp:14
const std::string & topic
Definition: RosPublisherSafetyLevel.hpp:39
Definition: Executor.hpp:27
Definition: RosPublisherSafetyLevel.hpp:14
TRosMsg msg
Definition: RosPublisherSafetyLevel.hpp:40
uint32_t getLevelId()
Definition: SafetyLevel.cpp:54