cob_dashboard_aggregator.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import time
19 import rospy
20 from cob_msgs.msg import EmergencyStopState, PowerState, DashboardState
21 from diagnostic_msgs.msg import DiagnosticStatus
22 
24  def __init__(self):
25  self.msg = DashboardState()
26 
27  # Create publisher
28  self.pub = rospy.Publisher("dashboard_agg", DashboardState, queue_size=1)
29 
30  # Create subscribers
31  # Diagnostics
32  rospy.Subscriber("diagnostics_toplevel_state", DiagnosticStatus, self.DiagnosticStatusCB)
33  # Power state
34  rospy.Subscriber("power_state", PowerState, self.PowerStateCB)
35  # Emergency stop state
36  rospy.Subscriber("emergency_stop_state", EmergencyStopState, self.EmergencyStopStateCB)
37 
38  def DiagnosticStatusCB(self, msg):
39  self.msg.diagnostics_toplevel_state = msg
40 
41  def PowerStateCB(self, msg):
42  self.msg.power_state = msg
43 
44  def EmergencyStopStateCB(self, msg):
45  self.msg.emergency_stop_state = msg
46 
47  def publish(self):
48  self.pub.publish(self.msg)
49 
50 if __name__ == "__main__":
51  rospy.init_node("cob_dashboard_aggregator")
52  rospy.sleep(1)
54  r = rospy.Rate(1)
55  while not rospy.is_shutdown():
56  da.publish()
57  try:
58  r.sleep()
59  except rospy.exceptions.ROSInterruptException as e:
60  pass


cob_dashboard
Author(s): Alexander Bubeck
autogenerated on Wed Apr 7 2021 03:03:02