~shadowrobot/sr-ros-interface/stable

« back to all changes in this revision

Viewing changes to shadow_robot/sr_control_gui/src/sr_control_gui/plugins/shadow_generic_plugin.py

  • Committer: Ugo Cupcic
  • Date: 2011-11-21 16:31:23 UTC
  • mfrom: (1.1.164 sr-ros-interface)
  • Revision ID: ugo@shadowrobot.com-20111121163123-k5q6e8l00w81f5hx
0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2011 Shadow Robot Company Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License as published by the Free
 
7
# Software Foundation, either version 2 of the License, or (at your option)
 
8
# any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful, but WITHOUT
 
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
13
# more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License along
 
16
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
#
 
18
 
 
19
import roslib; roslib.load_manifest('sr_control_gui')
 
20
import rospy
 
21
 
 
22
from shadowhand_ros import ShadowHand_ROS
 
23
from PyQt4 import QtCore, QtGui, Qt
 
24
 
 
25
from generic_plugin import GenericPlugin
 
26
from config import *
 
27
 
 
28
class ShadowGenericPlugin(GenericPlugin):  
 
29
    """
 
30
    The mother of all plugins using the shadow robot ROS interface (Hand and Arm).
 
31
    """
 
32
    name = "Shadow Robot Generic Plugin"
 
33
    
 
34
    def __init__(self):
 
35
        GenericPlugin.__init__(self)
 
36
        
 
37
    def activate(self):
 
38
        GenericPlugin.activate(self)
 
39
        # only activate the library if it hasn't been already loaded
 
40
        if self.parent.parent.libraries.get("sr_library") == None:
 
41
            self.parent.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), 
 
42
                             "Loading Shadowhand Library...")
 
43
            self.parent.parent.libraries["sr_library"] = ShadowHand_ROS()
 
44
            self.parent.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), 
 
45
                             "Shadowhand Library Loaded.")
 
46
        
 
47
    def on_close(self):
 
48
        GenericPlugin.on_close(self)
 
49
    
 
50
    def depends(self):
 
51
        return Config.shadowhand_plugin_config.dependencies