def table1ToTable2(width): global numStacked GripUtils.go_to_relative_multi(0, 0, 0.2, True, 0, 0, 0.2, True, "base_footprint", None) goFromAToB("Table1", "Table2") GripUtils.go_to_relative_multi(0, 0, -0.2+0.02*numStacked, True, 0, 0, -0.2+0.02*numStacked, True, "base_footprint", None) numStacked += 1 GripUtils.open_grippers()
def table1ToTable2(width): global numStacked GripUtils.go_to_relative_multi(0, 0, 0.2, True, 0, 0, 0.2, True, "base_footprint", None) goFromAToB("Table1", "Table2") GripUtils.go_to_relative_multi(0, 0, -0.2+0.02*numStacked, True, 0, 0, -0.2+0.02*numStacked, True, "base_footprint", None) numStacked += 1 GripUtils.open_grippers()
def executeDrag(self,gripPts,endPts,color='blue'): """ drag from gripPts to endPts """ startpoints = [] for vertex in gripPts: pt_world = self.convert_to_world_frame(vertex) now = rospy.Time.now() self.listener.waitForTransform("base_footprint",pt_world.header.frame_id,now,rospy.Duration(10.0)) pt_transformed = self.listener.transformPoint("base_footprint",pt_world) startpoints.append(pt_transformed) #print "grabbed (x,y,z)",startpoints[0].point.x,startpoints[0].point.y,startpoints[0].point.z if not GripUtils.grab_points(point_l=startpoints[0],roll_l=-pi/2,yaw_l=-pi/3,pitch_l=pi/4,x_offset_l=-0.01, z_offset_l=0.005,approach= True, point_r=startpoints[1],roll_r=pi/2,yaw_r= pi/3,pitch_r=pi/4,x_offset_r=-0.01, z_offset_r=0.005): print "failure" return False else: print "grabbed (x,y,z)",startpoints[0].point.x,startpoints[0].point.y,startpoints[0].point.z print "done" midpoints = [] for vertex in endPts: pt_world = self.dupl_PointStamped(vertex)#self.convert_to_world_frame(vertex) midpoints.append(pt_world) frame_l = frame_r = midpoints[0].header.frame_id if not GripUtils.go_to_multi (x_l=midpoints[0].point.x,y_l=midpoints[0].point.y,z_l=midpoints[0].point.z,roll_l=-pi/2,yaw_l=-pi/2,pitch_l=pi/4,grip_l=True,frame_l=frame_l ,x_r=midpoints[1].point.x, y_r= midpoints[1].point.y ,z_r= midpoints[1].point.z ,roll_r=pi/2,yaw_r=pi/2,pitch_r=pi/4,grip_r=True,frame_r=frame_r,dur=5): print "failure" #return False else: print "dragging done" if (color == 'blue'): GripUtils.open_grippers() return True
def execute(self, userdata): bl = userdata.bl br = userdata.br tl = userdata.tl tr = userdata.tr center = bl center.point.x = (bl.point.x + tl.point.x + br.point.x + tr.point.x) / 4 center.point.y = (bl.point.y + tl.point.y + br.point.y + tr.point.y) / 4 center.point.z = (bl.point.z + tl.point.z + br.point.z + tr.point.z) / 4 #calculate width rightTip = PointStamped() rightTip.header.stamp = rospy.Time() rightTip.frame_id = "r_tip_frame" rFromL = self.listener.transformPoint("l_tip_frame", rightTip) width = math.sqrt(rFromL.point.x**2 + rFromL.point.y**2 + rFromL.point.z**2) #distance from right to left #set point_l and point_r (remember to set z to the height of the table) point_l = br point_l.x = center.point.x point_l.y = center.point.y + width / 2 point_l.z = TABLE_HEIGHT #is this wrong? what frame are bl, br, tl, and tr given in? point_r = tl point_r.x = center.point.x point_r.y = center.point.y - width / 2 point_r.z = TABLE_HEIGHT #is this wrong? what frame are bl, br, tl, and tr given in? if not GripUtils.go_to_pts(point_l, pi / 2, pi / 4, -pi / 2, True, point_r, -pi / 2, pi / 4, pi / 2, True, z_offset_l=0.4, z_offset_r=0.4): return FAILURE numTowelsInStack = 0 try: numTowelsInStack = userdata.stackNum except KeyError: pass z_offset = -0.4 + 0.02 * numTowelsInStack if not GripUtils.go_to_relative_multi( 0, 0, z_offset, True, 0, 0, z_offset, True, "base_footprint"): return FAILURE if not GripUtils.open_grippers(): return FAILURE userdata.stackNum = numTowelsInStack + 1 return SUCCESS
def execute(self,userdata): if not GripUtils.open_grippers(): return FAILURE return SUCCESS
def executeBiGrip(self, fold_traj): tilts = fold_traj.tilts approach_points = fold_traj.approach_points grip_points = fold_traj.grip_points quarter_points = fold_traj.quarter_points weight_points = fold_traj.weight_points vertical_points = fold_traj.vertical_points goal_points = fold_traj.goal_points rolls = [pi / 2, pi / 2] #pitches = [pi/4,pi/4] pitches = [pi / 4, pi / 4] if not fold_traj.red: self.executeSmooth(self.last_traj) self.fold_stance("b") arms = self.getArms(fold_traj) #Initially, both are in "approach" mode (target1, target2) = self.gripPoints(point=approach_points[0], grip=False, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 4, preferred_roll=rolls[0], point2=approach_points[1], grip2=False, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 4, preferred_roll2=rolls[1]) #pitches[0] = target1.pitch #Do the first pickup and nothing with the other arm self.gripPoints(point=grip_points[0], grip=False, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 4, preferred_roll=rolls[0], grab=True) StanceUtils.close_gripper(arms[0]) #Do the second pickup, with the first arm interpolated first_dx = vertical_points[0].point.x - grip_points[0].point.x first_dy = vertical_points[0].point.y - grip_points[0].point.y first_dz = vertical_points[0].point.z - grip_points[0].point.z second_dx = vertical_points[1].point.x - grip_points[1].point.x second_dy = vertical_points[1].point.y - grip_points[1].point.y second_dz = vertical_points[1].point.z - grip_points[1].point.z interp_dx = first_dx - second_dx interp_dy = first_dy - second_dy interp_dz = first_dz - second_dz interp_x = grip_points[0].point.x + interp_dx interp_y = grip_points[0].point.y + interp_dy interp_z = grip_points[0].point.z + interp_dz interp_pt = PointStamped() interp_pt.point.x = interp_x interp_pt.point.y = interp_y interp_pt.point.z = interp_z interp_pt.header.frame_id = grip_points[0].header.frame_id #Go to the second approach point (target2, nothing) = self.gripPoints(point=interp_pt, grip=True, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 4, preferred_roll=rolls[0], point2=approach_points[1], arm2=arms[1], grip2=False, tilt2=tilts[1], preferred_pitch2=pi / 4, preferred_roll2=rolls[1]) #pitches[1] = target2.pitch self.gripPoints(point=interp_pt, grip=True, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 4, preferred_roll=rolls[0], point2=grip_points[1], grip2=False, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 4, preferred_roll2=rolls[1]) self.gripPoints(point=grip_points[1], grip=False, tilt=tilts[1], arm=arms[1], preferred_pitch=pi / 4, preferred_roll=rolls[1], grab=True) StanceUtils.close_gripper(arms[1]) else: arms = self.getArms(fold_traj) #Bring both to middle self.gripPoints(point=vertical_points[0], grip=True, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 2, preferred_roll=rolls[0], point2=vertical_points[1], grip2=True, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 2, preferred_roll2=rolls[1]) #FIX pi/4 -> pi/2 #Set first one down first_dx = goal_points[0].point.x - vertical_points[0].point.x first_dy = goal_points[0].point.y - vertical_points[0].point.y first_dz = goal_points[0].point.z - vertical_points[0].point.z second_dx = goal_points[1].point.x - vertical_points[1].point.x second_dy = goal_points[1].point.y - vertical_points[1].point.y second_dz = goal_points[1].point.z - vertical_points[1].point.z interp_dx = first_dx - second_dx interp_dy = first_dy - second_dy interp_dz = first_dz - second_dz interp_x = goal_points[0].point.x - interp_dx interp_y = goal_points[0].point.y - interp_dy interp_z = goal_points[0].point.z - interp_dz interp_pt = PointStamped() interp_pt.point.x = interp_x interp_pt.point.y = interp_y interp_pt.point.z = interp_z interp_pt.header.frame_id = grip_points[0].header.frame_id self.gripPoints(point=interp_pt, grip=True, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 2, preferred_roll=rolls[0], point2=goal_points[1], grip2=True, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 2, preferred_roll2=rolls[1]) #Finally, set last one down self.gripPoints(point=goal_points[0], grip=True, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 2, preferred_roll=rolls[0], point2=goal_points[1], grip2=True, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 2, preferred_roll2=rolls[1]) GripUtils.open_grippers() goal_points[0].point.z += 0.03 goal_points[1].point.z += 0.03 self.gripPoints(point=goal_points[0], grip=False, tilt=tilts[0], arm=arms[0], preferred_pitch=pi / 2, preferred_roll=rolls[0], point2=goal_points[1], grip2=False, tilt2=tilts[1], arm2=arms[1], preferred_pitch2=pi / 2, preferred_roll2=rolls[1]) self.last_traj = fold_traj
def executeBiGrip(self, fold_traj): tilts = fold_traj.tilts approach_points = fold_traj.approach_points grip_points = fold_traj.grip_points quarter_points = fold_traj.quarter_points weight_points = fold_traj.weight_points vertical_points = fold_traj.vertical_points goal_points = fold_traj.goal_points print "hi from bigrip" rolls = [pi/2,pi/2] #rolls = [-pi/2,-pi/2] #rolls = [0,0] pitches = [pi/4,pi/4] #pitches = [0,0] if not fold_traj.red: self.executeSmooth(self.last_traj) self.fold_stance("b") arms = self.getArms(fold_traj) #Initially, both are in "approach" mode (target1,target2) = self.gripPoints(point=approach_points[0],grip=False,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/4,preferred_roll=rolls[0], point2=approach_points[1],grip2=False,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/4,preferred_roll2=rolls[1]) #pitches[0] = target1.pitch #Do the first pickup and nothing with the other arm self.gripPoints(point=grip_points[0],grip=False,tilt=tilts[0],arm=arms[0],preferred_pitch=0 ,preferred_roll=rolls[0],grab=True) StanceUtils.close_gripper(arms[0]) #Do the second pickup, with the first arm interpolated first_dx = vertical_points[0].point.x - grip_points[0].point.x first_dy = vertical_points[0].point.y - grip_points[0].point.y first_dz = vertical_points[0].point.z - grip_points[0].point.z second_dx = vertical_points[1].point.x - grip_points[1].point.x second_dy = vertical_points[1].point.y - grip_points[1].point.y second_dz = vertical_points[1].point.z - grip_points[1].point.z interp_dx = first_dx - second_dx interp_dy = first_dy - second_dy interp_dz = first_dz - second_dz interp_x = grip_points[0].point.x + interp_dx interp_y = grip_points[0].point.y + interp_dy interp_z = grip_points[0].point.z + interp_dz interp_pt = PointStamped() interp_pt.point.x = interp_x interp_pt.point.y = interp_y interp_pt.point.z = interp_z interp_pt.header.frame_id = grip_points[0].header.frame_id #Go to the second approach point (target2,nothing) = self.gripPoints(point=interp_pt,grip=True,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/4,preferred_roll=rolls[0], point2=approach_points[1],arm2=arms[1],grip2=False,tilt2=tilts[1],preferred_pitch2=pi/4,preferred_roll2=rolls[1]) #pitches[1] = target2.pitch self.gripPoints (point=interp_pt,grip=True,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/4,preferred_roll=rolls[0] ,point2=grip_points[1],grip2=False,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/4,preferred_roll2=rolls[1]) self.gripPoints(point=grip_points[1],grip=False,tilt=tilts[1],arm=arms[1],preferred_pitch=pi/4,preferred_roll=rolls[1],grab=True) StanceUtils.close_gripper(arms[1]) else: arms = self.getArms(fold_traj) #Bring both to middle self.gripPoints (point=vertical_points[0],grip=True,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/2,preferred_roll=rolls[0] ,point2=vertical_points[1],grip2=True,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/2,preferred_roll2=rolls[1]) #FIX pi/4 -> pi/2 #Set first one down first_dx = goal_points[0].point.x - vertical_points[0].point.x first_dy = goal_points[0].point.y - vertical_points[0].point.y first_dz = goal_points[0].point.z - vertical_points[0].point.z second_dx = goal_points[1].point.x - vertical_points[1].point.x second_dy = goal_points[1].point.y - vertical_points[1].point.y second_dz = goal_points[1].point.z - vertical_points[1].point.z interp_dx = first_dx - second_dx interp_dy = first_dy - second_dy interp_dz = first_dz - second_dz interp_x = goal_points[0].point.x - interp_dx interp_y = goal_points[0].point.y - interp_dy interp_z = goal_points[0].point.z - interp_dz interp_pt = PointStamped() interp_pt.point.x = interp_x interp_pt.point.y = interp_y interp_pt.point.z = interp_z interp_pt.header.frame_id = grip_points[0].header.frame_id self.gripPoints (point=interp_pt,grip=True,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/2,preferred_roll=rolls[0] ,point2=goal_points[1],grip2=True,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/2,preferred_roll2=rolls[1]) #Finally, set last one down self.gripPoints(point=goal_points[0],grip=True,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/2,preferred_roll=rolls[0] ,point2=goal_points[1],grip2=True,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/2,preferred_roll2=rolls[1]) GripUtils.open_grippers() goal_points[0].point.z += 0.03 goal_points[1].point.z += 0.03 self.gripPoints(point=goal_points[0],grip=False,tilt=tilts[0],arm=arms[0],preferred_pitch=pi/2,preferred_roll=rolls[0] ,point2=goal_points[1],grip2=False,tilt2=tilts[1],arm2=arms[1],preferred_pitch2=pi/2,preferred_roll2=rolls[1]) self.last_traj = fold_traj
def execute(self, userdata): bl = userdata.bl br = userdata.br tl = userdata.tl tr = userdata.tr center = bl center.point.x = (bl.point.x + tl.point.x + br.point.x + tr.point.x) / 4 center.point.y = (bl.point.y + tl.point.y + br.point.y + tr.point.y) / 4 center.point.z = (bl.point.z + tl.point.z + br.point.z + tr.point.z) / 4 # calculate width rightTip = PointStamped() rightTip.header.stamp = rospy.Time() rightTip.frame_id = "r_tip_frame" rFromL = self.listener.transformPoint("l_tip_frame", rightTip) width = math.sqrt( rFromL.point.x ** 2 + rFromL.point.y ** 2 + rFromL.point.z ** 2 ) # distance from right to left # set point_l and point_r (remember to set z to the height of the table) point_l = br point_l.x = center.point.x point_l.y = center.point.y + width / 2 point_l.z = TABLE_HEIGHT # is this wrong? what frame are bl, br, tl, and tr given in? point_r = tl point_r.x = center.point.x point_r.y = center.point.y - width / 2 point_r.z = TABLE_HEIGHT # is this wrong? what frame are bl, br, tl, and tr given in? if not GripUtils.go_to_pts( point_l, pi / 2, pi / 4, -pi / 2, True, point_r, -pi / 2, pi / 4, pi / 2, True, z_offset_l=0.4, z_offset_r=0.4, ): return FAILURE numTowelsInStack = 0 try: numTowelsInStack = userdata.stackNum except KeyError: pass z_offset = -0.4 + 0.02 * numTowelsInStack if not GripUtils.go_to_relative_multi(0, 0, z_offset, True, 0, 0, z_offset, True, "base_footprint"): return FAILURE if not GripUtils.open_grippers(): return FAILURE userdata.stackNum = numTowelsInStack + 1 return SUCCESS
def execute(self, userdata): if not GripUtils.open_grippers(): return FAILURE return SUCCESS