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


Python Executor.record方法代码示例

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


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

示例1: Task

# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import record [as 别名]

#.........这里部分代码省略.........
        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)
        # close gripper
        self._executor.gripper_close()
        # retract to clear object
        self._retract()

    def place(self, pose):
        # servo above pose
        #self._approach(pose)
        # servo to pose
        self._executor.move_to_pose(pose)
        # open the gripper
        self._executor.gripper_open()
        # retract to clear object
        self._retract()

    def learning(self):
        print('Learning weights from feedback')
        feedback = self.get_feedback()
        resp = self._learningsvc(feedback)
        print('Updated weights for movement adaptation')

    def get_feedback(self):
        filename = os.getcwd() + '/trajectory_improved'
        print('Please help me improve the task.')
        self._executor.record(filename)
        print('Done')
        return filename
开发者ID:neroam,项目名称:baxter_adapt,代码行数:104,代码来源:baxter_adapt_demo.py


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