Go to the documentation of this file.00001 from jsk_teleop_joy.joy_plugin import JSKJoyPlugin
00002 try:
00003 from sensor_msgs.msg import Joy
00004 except:
00005 import roslib; roslib.load_manifest("jsk_teleop_joy")
00006 from sensor_msgs.msg import Joy
00007
00008 import rospy
00009 from topic_tools.srv import MuxSelect
00010
00011 class Relay(JSKJoyPlugin):
00012 def __init__(self, name, args):
00013 JSKJoyPlugin.__init__(self, name, args)
00014 self.output_topic = self.getArg("output_topic", "output")
00015 self.org_topic = self.getArg("joy_original_topic", "/joy_org")
00016 self.joy_mux_srv_name = self.getArg("joy_mux", "mux")
00017 self.joy_mux_select_srv = rospy.ServiceProxy(self.joy_mux_srv_name + "/select" , MuxSelect)
00018 def enable(self):
00019 self.pub = rospy.Publisher(self.output_topic, Joy)
00020 try:
00021 self.joy_mux_select_srv(self.output_topic)
00022 except:
00023 rospy.logerr("Missing joy mux: %s", self.joy_mux_srv_name)
00024 def disable(self):
00025 self.pub.unregister()
00026 try:
00027 self.joy_mux_select_srv(self.org_topic)
00028 except:
00029 rospy.logerr("Missing joy mux: %s", self.joy_mux_srv_name)
00030 def joyCB(self, status, history):
00031 self.pub.publish(status.orig_msg)
00032
00033
00034 class RelayAndConvertToPS3(Relay):
00035 def __init__(self, name, args):
00036 Relay.__init__(self, name, args)
00037 def joyCB(self, status, history):
00038 self.pub.publish(status.toPS3Msg())
00039
00040