decision_making_graph.py
Go to the documentation of this file.
00001 """
00002 Copyright (c) 2013, Cogniteam
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 *   Redistributions of source code must retain the above copyright
00009     notice, this list of conditions and the following disclaimer.
00010 
00011 *   Redistributions in binary form must reproduce the above copyright
00012     notice, this list of conditions and the following disclaimer in the
00013     documentation and/or other materials provided with the distribution.
00014 
00015 *   Neither the name of the Cogniteam nor the
00016     names of its contributors may be used to endorse or promote products
00017     derived from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00023 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 """
00030 
00031 from python_qt_binding.QtGui import QWidget
00032 import rospkg
00033 import rospy
00034 from diagnostic_msgs.msg import DiagnosticArray
00035 from rqt_gui_py.plugin import Plugin
00036 from .graph_widget import GraphWidget
00037 
00038 
00039 class DecisionMakingGraph(Plugin):
00040 
00041     def __init__(self, context):
00042         super(DecisionMakingGraph, self).__init__(context)
00043 
00044         self.initialized = False
00045         self.setObjectName('DecisionMakingGraph')
00046 
00047         self._widget = GraphWidget(rospkg.RosPack())
00048         self._widget.setWindowTitle(GraphWidget.get_unique_name(context))
00049 
00050         context.add_widget(self._widget)
00051 
00052         self._filter = 'decision_making'
00053 
00054         self._subscriber = None
00055         self._subscribe('/decision_making/monitoring')
00056 
00057     def _on_message(self, message):
00058         if not message.status[0].name[-len(self._filter):] == self._filter:
00059             return
00060 
00061         self._widget.update(message)
00062 
00063     def _subscribe(self, topic):
00064         if self._subscriber:
00065             self._subscriber.unregister()
00066 
00067         self._subscriber = rospy.Subscriber(topic, DiagnosticArray, self._on_message)
00068 
00069     def shutdown_plugin(self):
00070         if self._subscriber is not None:
00071             self._subscriber.unregister()


rqt_decision_graph
Author(s):
autogenerated on Wed Aug 26 2015 11:16:47