sample_rpc.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 # Copyright 2016 TORK (Tokyo Opensource Robotics Kyokai Association)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #     http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
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         # Start an action server that handles various ROS Actions.
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'  # Must be the same name defined in ActionServiceNameDict.
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                     #z=0.0388609422173,
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


baxter_rpc_server
Author(s): TORK , Isaac I. Y. Saito
autogenerated on Thu Jun 6 2019 21:55:39