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


Python Limb.joint_velocity方法代码示例

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


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

示例1: vision_server

# 需要导入模块: from baxter_interface import Limb [as 别名]
# 或者: from baxter_interface.Limb import joint_velocity [as 别名]
class vision_server():
    
    def __init__(self):

        rospy.init_node('vision_server_right')
        
        self.pub = rospy.Publisher('/robot/xdisplay', Image, latch=True)
        self.busy = False
        self.dx = 0
        self.dy = 0
        self.avg_dx = -1
        self.avg_dy = -1
        self.H = homography()
        self.framenumber = 0
        self.history_x = np.arange(0,10)*-1
        self.history_y = np.arange(0,10)*-1
        self.bowlcamera = None
        self.newPosition = True
        self.foundBowl = 0
        self.centerx = 400
        
        #self.centerx = 250
        self.centery = 150
        #self.centery = 190
        self.coefx = 0.1/(526-369)
        self.coefy = 0.1/(237-90)
        self.v_joint = np.arange(7)
        self.v_end = np.arange(6)
        self.cmd = {}
        self.found = False
        self.finish = 0
        self.distance = 10
        self.gripper = Gripper("right")
        #self.gripper.calibrate()

        cv2.namedWindow('image')
        self.np_image = np.zeros((400,640,3), np.uint8)
        cv2.imshow('image',self.np_image)
        #self._set_threshold()

        
        s = rospy.Service('vision_server_vertical', Vision, self.handle_vision_req)
        camera_topic = '/cameras/right_hand_camera/image'
        self.right_camera = rospy.Subscriber(camera_topic, Image, self._on_camera)
        ifr = rospy.Subscriber("/robot/range/right_hand_range/state", Range, self._read_distance)
        print "\nReady to use right hand vision server\n" 

        self.kin = baxter_kinematics('right')
        self.J = self.kin.jacobian()
        self.J_inv = self.kin.jacobian_pseudo_inverse()
        self.jointVelocity = np.asarray([1,2,3,4,5,6,7],np.float32)
        self.control_arm = Limb("right")
        self.control_joint_names = self.control_arm.joint_names()
        
        #print np.dot(self.J,self.jointVelocity)

    def _read_distance(self,data):

        self.distance = data.range



    def _set_threshold(self):
        
        cv2.createTrackbar('Min R(H)','image',0,255,nothing)
        cv2.createTrackbar('Max R(H)','image',255,255,nothing)
        cv2.createTrackbar('Min G(S)','image',0,255,nothing)
        cv2.createTrackbar('Max G(S)','image',255,255,nothing)
        cv2.createTrackbar('Min B(V)','image',0,255,nothing)
        cv2.createTrackbar('Max B(V)','image',255,255,nothing)

    def get_joint_velocity(self):
        cmd = {}
        velocity_list = np.asarray([1,2,3,4,5,6,7],np.float32)
        for idx, name in enumerate(self.control_joint_names):
            v = self.control_arm.joint_velocity( self.control_joint_names[idx])
            velocity_list[idx] = v
            cmd[name] = v 
        return velocity_list

    def list_to_dic(self,ls):
        cmd = {}
        for idx, name in enumerate(self.control_joint_names):
            v = ls.item(idx)
            cmd[name] = v 
        return cmd

    def PID(self):

        Kp = 0.5
        vy = -Kp*self.dx
        vx = -Kp*self.dy
        return vx,vy

    def _on_camera(self, data):

        self.busy = True
        self.framenumber += 1
        index = self.framenumber % 10
        cv2.namedWindow('image')
#.........这里部分代码省略.........
开发者ID:YZHANGFPE,项目名称:pick_challenge,代码行数:103,代码来源:vision_server_vertical.py


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