Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotate tool path while keeping tool orientation
#3
Like this:

Code:
from robodk import robolink # RoboDK API
从robodk进口robomath #机器人工具箱

RDK = robolink.Robolink()

robot = RDK.Item('R1', robolink.ITEM_TYPE_ROBOT) # Get robot
T1 = RDK.Item('T1', robolink.ITEM_TYPE_TARGET) # Get target
T2 = RDK.Item('T2', robolink.ITEM_TYPE_TARGET) # Get target
T3 = RDK.Item('T3', robolink.ITEM_TYPE_TARGET) # Get target
T4 = RDK.Item('T4', robolink.ITEM_TYPE_TARGET) # Get target
T5 = RDK.Item('T5', robolink.ITEM_TYPE_TARGET) # Get target

Path1 = [T1.Pose(),T2.Pose(),T3.Pose(),T4.Pose(),T5.Pose()] # Original sequence of poses to form a path


def myMoveLPath(Path): # Move robot linearly along poses in Path:
for Pose in Path: # For each pose in Path:
robot.MoveL(Pose) # Move linearly to pose

def myRotSameOrient(PoseIn,R): # Rotate pose 'PoseIn' by rotation matrix 'R', while maintaining its orientation:
PoseOut = robomath.transl(R*PoseIn.Pos()) * PoseIn.rotationPose()
return PoseOut


Rz = robomath.rotz(robomath.pi/2) # Rotation matrix about the Z-axis, 90 deg.

Path2 = [] # New path
for Pose in Path1: # For each pose in Path:
Path2.append(myRotSameOrient(Pose,Rz)) # Add a pose rotated but with same orientation

Path3= [] # New path
for Pose in Path2: # For each pose in Path:
Path3.append(myRotSameOrient(Pose,Rz)) # Add a pose rotated but with same orientation

Path4 = [] # New path
for Pose in Path3: # For each pose in Path:
Path4.append(myRotSameOrient(Pose,Rz)) # Add a pose rotated but with same orientation


robot.MoveJ(Path1[0]) # Joint move to start of first path
myMoveLPath(Path1) # Move linearly along path
robot.MoveJ(Path2[0]) # Joint move to start of next path
myMoveLPath(Path2) # Move linearly along path
robot.MoveJ(Path3[0]) # Joint move to start of next path
myMoveLPath(Path3) # Move linearly along path
robot.MoveJ(Path4[0]) # Joint move to start of next path
myMoveLPath(Path4) # Move linearly along path
robot.MoveJ(Path1[0]) # Joint move back to start of first path

Maarten


Messages In This Thread
RE: Rotate tool path while keeping tool orientation - byMaarten- 09-23-2022, 09:26 AM



Users browsing this thread:
1 Guest(s)