当前位置: 首页>>代码示例>>Python>>正文


Python Executor.get_current_joints方法代码示例

本文整理汇总了Python中executor.Executor.get_current_joints方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.get_current_joints方法的具体用法?Python Executor.get_current_joints怎么用?Python Executor.get_current_joints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在executor.Executor的用法示例。


在下文中一共展示了Executor.get_current_joints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Task

# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import get_current_joints [as 别名]
class Task(object):
    def __init__(self, limb, hover_distance = 0.15, verbose=True):
        self._limb_name = limb # string
        self._hover_distance = hover_distance # in meters
        self._verbose = verbose # bool
        self._executor = Executor(limb, verbose)
        trajsvc = "baxter_adapt/adaptation_server"
        learningsvc = "baxter_adapt/learning_server"
        rospy.wait_for_service(trajsvc, 5.0)
        rospy.wait_for_service(learningsvc, 5.0)
        self._trajsvc = rospy.ServiceProxy(trajsvc, Adaptation)
        self._learningsvc = rospy.ServiceProxy(learningsvc, Learning)

    def move_to_start(self, start_angles=None):
        print self._executor.get_current_joints()

        print("Moving the {0} arm to start pose...".format(self._limb_name))
        if not start_angles:
            start_angles = dict(zip(self._joint_names, [0]*7))
        self._executor.move_to_joint(start_angles)
        self._executor.gripper_open()
        rospy.sleep(1.0)

    def _approach(self, pose):
        approach = copy.deepcopy(pose)
        # approach with a pose the hover-distance above the requested pose
        approach.position.z = approach.position.z + self._hover_distance
        self._executor.move_to_pose(approach)

    def _retract(self):
        # retrieve current pose from endpoint
        retract = copy.deepcopy(self._executor.get_current_pose())
        retract.position.z = retract.position.z + self._hover_distance
        self._executor.move_to_pose(retract)

    def transfer(self, start_pose, end_pose, obstacles):

        print("Picking up the object")
        self.pick(start_pose)

        joint_names = self._executor.joint_names()
        joints = self._executor.ik_request(start_pose)
        start_joints = [joints[i] for i in joint_names]
        joints = self._executor.ik_request(end_pose)
        end_joints = [joints[i] for i in joint_names]

        print start_joints
        print end_joints

        print "Adapting Trajectory Learned from Demonstrations"
        resp = self._trajsvc(start_joints, end_joints, obstacles, True)
#         resp = AdaptationResponse()
#         resp.filename = '/home/aecins/ros_ws/src/baxter_adapt/MPC/generated/JointsTrajectory'
#         resp.response = True
        print resp

        if resp.response is True:
            while os.path.isfile(resp.filename) is False:
                print "Wait for trajectory generation"
                rospy.sleep(2.0)
            print("Perform trajectory")
            traj = open(resp.filename, 'r').readlines()
            self._executor.move_as_trajectory(traj)

    def transfer_imitation(self, start_pose, end_pose):
        print("Picking up the object")
        self.pick(start_pose)

        print("Computing imitation trajectory")
        joint_names = self._executor.joint_names()
        joints = self._executor.ik_request(start_pose)
        start_joints = [joints[i] for i in joint_names]
        joints = self._executor.ik_request(end_pose)
        end_joints = [joints[i] for i in joint_names]

        print start_joints
        print end_joints

        obstacles = []
        resp = self._trajsvc(start_joints, end_joints, obstacles, False)
        print resp

        if resp.response is True:
            print("Perform trajectory")
            traj = open(resp.filename, 'r').readlines()
            self._executor.move_as_trajectory(traj)

    def get_current_joints(self):
        return self._executor.get_current_joints()

    def get_current_pose(self):
        return self._executor.get_current_pose()

    def pick(self, pose):
        # open the gripper
        self._executor.gripper_open()
        # servo above pose
        self._approach(pose)
        # servo to pose
        self._executor.move_to_pose(pose)
#.........这里部分代码省略.........
开发者ID:neroam,项目名称:baxter_adapt,代码行数:103,代码来源:baxter_adapt_demo.py


注:本文中的executor.Executor.get_current_joints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。