playpen_server.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright (c) 2009, Georgia Tech Research Corporation
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions are met:
00008 #     * Redistributions of source code must retain the above copyright
00009 #       notice, this list of conditions and the following disclaimer.
00010 #     * Redistributions in binary form must reproduce the above copyright
00011 #       notice, this list of conditions and the following disclaimer in the
00012 #       documentation and/or other materials provided with the distribution.
00013 #     * Neither the name of the Georgia Tech Research Corporation nor the
00014 #       names of its contributors may be used to endorse or promote products
00015 #       derived from this software without specific prior written permission.
00016 #
00017 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00018 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00021 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00025 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00026 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 #
00028 
00029 #Author: Marc Killpack
00030 
00031 
00032 import roslib; roslib.load_manifest('pr2_playpen')
00033 import rospy
00034 from pr2_playpen.srv import *
00035 from robotis.lib_robotis import *
00036 
00037 
00038 class Play:
00039 
00040     def __init__(self):
00041         dyn = USB2Dynamixel_Device('/dev/ttyUSB0')
00042         self.playpen = Robotis_Servo(dyn, 31)
00043         self.conveyor = Robotis_Servo(dyn,32)
00044         self.conveyor.init_cont_turn()
00045         rospy.init_node('playpen_server')
00046         s_play = rospy.Service('playpen', Playpen, self.move_playpen)
00047         s_conv = rospy.Service('conveyor', Conveyor, self.move_conveyor)    
00048         rospy.spin()
00049 
00050     def move_conveyor(self, data):
00051         delt_time = abs(data.distance)/2.39/0.685/0.0483*2/0.75
00052         if data.distance > 0:
00053             self.conveyor.set_angvel(-5)
00054         else:
00055             self.conveyor.set_angvel(5)
00056         rospy.sleep(delt_time)
00057         self.conveyor.set_angvel(0)
00058         print "move conveyor"
00059         return ConveyorResponse(1)
00060 
00061     def move_playpen(self, data):
00062         if data.command == 0:
00063             self.playpen.move_angle(0.28)
00064             print "closing playpen"
00065         elif data.command == 1:
00066             self.playpen.move_angle(1.90)
00067             print "opening playpen...releasing object"
00068         return PlaypenResponse(1)
00069 
00070 
00071 if __name__== "__main__":
00072     go = Play()


pr2_playpen
Author(s): Marc Killpack / mkillpack3@gatech.edu, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:18:32