Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 from geometry_msgs.msg import (
00019 PoseStamped,
00020 Pose,
00021 Point,
00022 Quaternion,
00023 )
00024 import rospy
00025
00026 from baxter_rpc_msgs.srv import (
00027 SolvePositionIkParts
00028 )
00029 from baxter_rpc_server import BaxterRpcServer
00030
00031
00032 class SampleRpcBaxter(object):
00033 '''
00034 RPC sample methods for Baxter. Intended to be called from main method
00035 within this same python file.
00036 '''
00037
00038 def __init__(self):
00039 ''' '''
00040
00041 rospy.init_node('baxter_rpc_sample')
00042
00043 def sample_cartesian_move(self, limb):
00044 '''
00045 @param limb: 'left' or 'right'
00046 @rtype: bool
00047 @return: If the service call returns, true.
00048 '''
00049 _srv_name = 'srv_cartesian_move'
00050 poses = {
00051 'left': Pose(
00052 position=Point(
00053 x=0.657579481614,
00054 y=0.851981417433,
00055 z=0.0388352386502,
00056 ),
00057 orientation=Quaternion(
00058 x=-0.366894936773,
00059 y=0.885980397775,
00060 z=0.108155782462,
00061 w=0.262162481772,
00062 ),
00063 ),
00064 'right': Pose(
00065 position=Point(
00066 x=0.656982770038,
00067 y=-0.852598021641,
00068
00069 z=0.05,
00070 ),
00071 orientation=Quaternion(
00072 x=0.367048116303,
00073 y=0.885911751787,
00074 z=-0.108908281936,
00075 w=0.261868353356,
00076 )
00077 )
00078 }
00079 rospy.loginfo('limb: {}, poses[limb]:\n{}'.format(limb, poses[limb]))
00080
00081 rospy.wait_for_service(_srv_name)
00082 try:
00083 _srv_proxy = rospy.ServiceProxy(_srv_name, SolvePositionIkParts)
00084 _response = _srv_proxy(limb, poses[limb])
00085 return _response.result
00086 except rospy.ServiceException, e:
00087 raise e