mock_hand.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # ####################################################################
00004 # Copyright (c) 2013 Shadow Robot Company Ltd.
00005 # All rights reserved.
00006 # This program is free software: you can redistribute it and/or modify it
00007 # under the terms of the GNU General Public License as published by the Free
00008 # Software Foundation, either version 2 of the License, or (at your option)
00009 # any later version.
00010 #
00011 # This program is distributed in the hope that it will be useful, but WITHOUT
00012 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00014 # more details.
00015 #
00016 # You should have received a copy of the GNU General Public License along
00017 # with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 # ####################################################################
00019 
00020 import rospy;
00021 from pr2_mechanism_msgs.srv import *
00022 
00023 class MockHand(object):
00024     """
00025     A ros node to look enough like a shadowhand for these tests.
00026 
00027     List controller service so it looks like a ethercat hand to HandCommander.
00028     """
00029 
00030     def __init__(self, ):
00031         """
00032         @brief Construct a new MockHand, setting up ros connections.
00033         """
00034         self.list_srv = rospy.Service('pr2_controller_manager/list_controllers',
00035                 ListControllers, self.list_controllers_cb)
00036         rospy.loginfo("Started MockHand")
00037 
00038     def list_controllers_cb(self, req):
00039         res = ListControllersResponse()
00040         res.controllers = ['sh_ffj0_position_controller', 'sh_ffj3_position_controller', 'sh_ffj4_position_controller', 'sh_lfj0_position_controller', 'sh_lfj3_position_controller', 'sh_lfj4_position_controller', 'sh_lfj5_position_controller', 'sh_mfj0_position_controller', 'sh_mfj3_position_controller', 'sh_mfj4_position_controller', 'sh_rfj0_position_controller', 'sh_rfj3_position_controller', 'sh_rfj4_position_controller', 'sh_thj1_position_controller', 'sh_thj2_position_controller', 'sh_thj3_position_controller', 'sh_thj4_position_controller', 'sh_thj5_position_controller', 'sh_wrj1_position_controller', 'sh_wrj2_position_controller']
00041         res.state = ['running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running', 'running']
00042         return res
00043 
00044 
00045 if __name__ == "__main__":
00046     try:
00047         rospy.init_node("mock_hand")
00048         node = MockHand()
00049         rospy.spin();
00050     except rospy.ROSInterruptException:
00051         pass
00052 


sr_hand
Author(s): Ugo Cupcic
autogenerated on Fri Aug 28 2015 13:08:51