cob_dashboard.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 roslib
19 import rospy
20 
21 from cob_msgs.msg import DashboardState
22 
23 from rqt_robot_dashboard.dashboard import Dashboard
24 from rqt_robot_dashboard.widgets import MonitorDashWidget, ConsoleDashWidget
25 
26 from python_qt_binding.QtCore import QSize
27 try:
28  from python_qt_binding.QtWidgets import QMessageBox # Qt 5
29 except ImportError:
30  from python_qt_binding.QtGui import QMessageBox # Qt 4
31 
32 from .cob_battery import COBBattery
33 from .cob_runstops import COBRunstops
34 
35 
37  """
38  Dashboard for Care-O-bots
39 
40  :param context: the plugin context
41  :type context: qt_gui.plugin.Plugin
42  """
43  def setup(self, context):
44  self.name = 'CobDashboard'
45  self.max_icon_size = QSize(50, 30)
46  self.message = None
47 
48  self._dashboard_message = None
50 
51  self._raw_byte = None
52  self.digital_outs = [0, 0, 0]
53 
54  self._console = ConsoleDashWidget(self.context, minimal=False)
55  self._monitor = MonitorDashWidget(self.context)
56  self._runstop = COBRunstops('RunStops')
57  self._battery = COBBattery(self.context)
58 
59  self._dashboard_agg_sub = rospy.Subscriber("/dashboard_agg", DashboardState, self.db_agg_cb)
60 
61  def get_widgets(self):
62  return [[self._monitor, self._console], [self._runstop], [self._battery]]
63 
64  def db_agg_cb(self, msg):
65  self._last_dashboard_message_time = rospy.get_time()
66  self._battery.set_power_state(msg.power_state)
67 
68  if(msg.emergency_stop_state.emergency_state == 0):
69  self._runstop.set_ok()
70  self._runstop.setToolTip(self.tr("Button stop: OK\nScanner stop: OK"))
71  else:
72  if msg.emergency_stop_state.emergency_button_stop:
73  self._runstop.set_button_stop()
74  elif msg.emergency_stop_state.scanner_stop:
75  self._runstop.set_scanner_stop()
76  else:
77  rospy.logerr("reason for emergency stop not known")
78  self._runstop.setToolTip(self.tr("Button stop: %s\nScanner stop: %s" %(str(msg.emergency_stop_state.emergency_button_stop), str(msg.emergency_stop_state.scanner_stop))))
79 
80  def shutdown_dashboard(self):
81  self._dashboard_agg_sub.unregister()
82 
83  def save_settings(self, plugin_settings, instance_settings):
84  self._console.save_settings(plugin_settings, instance_settings)
85  self._monitor.save_settings(plugin_settings, instance_settings)
86 
87  def restore_settings(self, plugin_settings, instance_settings):
88  self._console.restore_settings(plugin_settings, instance_settings)
89  self._monitor.restore_settings(plugin_settings, instance_settings)
def save_settings(self, plugin_settings, instance_settings)
def restore_settings(self, plugin_settings, instance_settings)


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