teleop.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import roslib; roslib.load_manifest('axis_camera')
00004 import rospy
00005 
00006 from sensor_msgs.msg import Joy
00007 from axis_camera.msg import Axis
00008 
00009 
00010 class Teleop:
00011     def __init__(self):
00012         rospy.init_node('axis_ptz_teleop')
00013         self.enable_button = rospy.get_param('~enable_button', 1)
00014         self.state = Axis(pan=220)
00015         self.joy = None
00016 
00017         self.pub = rospy.Publisher('cmd', Axis)
00018         rospy.Subscriber("joy", Joy, self.joy_callback)
00019         # rospy.Subscriber("state", Axis, self.state_callback)
00020         
00021     def spin(self):
00022         self.state.brightness = 5000
00023         self.pub.publish(self.state)
00024         r = rospy.Rate(5)
00025         while not rospy.is_shutdown():
00026             if self.joy != None and self.joy.buttons[self.enable_button] == 1:
00027                 #and (rospy.Time.now() - self.joy.header.stamp).to_sec() < 0.2:
00028                 self.state.pan += self.joy.axes[0]*5
00029                 self.state.tilt += self.joy.axes[1]*5
00030                 if self.state.tilt > 85: self.state.tilt = 85
00031                 if self.state.tilt < 0: self.state.tilt = 0
00032                 self.pub.publish(self.state)
00033             r.sleep()
00034 
00035     def joy_callback(self, data):
00036         self.joy = data
00037 
00038 
00039 if __name__ == "__main__": Teleop().spin()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


axis_camera
Author(s): Ryan Gariepy
autogenerated on Mon May 13 2013 10:15:52