本文整理汇总了Python中baxter_interface.Limb.set_joint_velocities方法的典型用法代码示例。如果您正苦于以下问题:Python Limb.set_joint_velocities方法的具体用法?Python Limb.set_joint_velocities怎么用?Python Limb.set_joint_velocities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类baxter_interface.Limb
的用法示例。
在下文中一共展示了Limb.set_joint_velocities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: vision_server
# 需要导入模块: from baxter_interface import Limb [as 别名]
# 或者: from baxter_interface.Limb import set_joint_velocities [as 别名]
#.........这里部分代码省略.........
vx, vy = self.PID()
self.v_end = np.asarray([(1-((abs(vx)+abs(vy))*5))*0.03,vy,vx,0,0,0],np.float32)
#self.v_end = np.asarray([0,0,0,0,0,0.05],np.float32)
self.v_joint = np.dot(self.J_inv,self.v_end)
self.cmd = self.list_to_dic(self.v_joint)
self.busy = False
cv2.imshow('image',image_after_process)
cv2.waitKey(1)
def image_process(self,img):
# min_r = cv2.getTrackbarPos('Min R(H)','image')
# max_r = cv2.getTrackbarPos('Max R(H)','image')
# min_g = cv2.getTrackbarPos('Min G(S)','image')
# max_g = cv2.getTrackbarPos('Max G(S)','image')
# min_b = cv2.getTrackbarPos('Min B(V)','image')
# max_b = cv2.getTrackbarPos('Max B(V)','image')
# min_r = 0
# max_r = 57
# min_g = 87
# max_g = 181
# min_b = 37
# max_b = 70
min_r = 0
max_r = 58
min_g = 86
max_g = 255
min_b = 0
max_b = 255
min_color = (min_r, min_g, min_b)
max_color = (max_r, max_g, max_b)
#img = cv2.flip(img, flipCode = -1)
hsv_img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
mask = cv2.inRange(hsv_img, min_color, max_color)
result = cv2.bitwise_and(img, img, mask = mask)
mask_bool = np.asarray(mask, bool)
label_img = morphology.remove_small_objects(mask_bool, 1000, connectivity = 1)
objects = measure.regionprops(label_img)
if objects != []:
self.found = True
target = objects[0]
box = target.bbox
cv2.rectangle(img,(box[1],box[0]),(box[3],box[2]),(0,255,0),3)
dx_pixel=target.centroid[1]-self.centerx
dy_pixel=target.centroid[0]-self.centery
dx=dx_pixel*self.coefx
dy=dy_pixel*self.coefy
angle = target.orientation
cv2.circle(img,(int(target.centroid[1]),int(target.centroid[0])),10,(0,0,255),-1)
self.dx = dx
self.dy = dy
#print self.dx,self.dy
else:
self.found = False
self.dx = 0
self.dy = 0
return img, mask_bool
def handle_vision_req(self, req):
#resp = VisionResponse(req.requestID, 0, self.avg_dx, self.avg_dy)
self.finish = 0
if self.found == True:
if self.distance > 0.07:
self.control_arm.set_joint_velocities(self.cmd)
#rospy.sleep(0.02)
else:
self.finish = 1
resp = VisionResponse(req.requestID, self.finish, self.dx, self.dy)
return resp
def clean_shutdown(self):
print "Server finished"
cv2.imwrite('box_img.png', self.blank_image)
rospy.signal_shutdown("Done")
sys.exit()