9. Trajectory recurrence

9.1. Setting Track Recording Parameters

prototype

SetTPDParam(name, period_ms, type=1,di_choose=0, do_choose=0)

Description

Setting parameters for track logging

Mandatory parameters

  • name: track name;

  • period_ms: sampling period, fixed value, 2ms or 4ms or 8ms;

Default parameters

  • type: data type, 1-joint position;

  • di_choose: DI choose, bit0~bit7 corresponds to control box DI0~DI7, bit8~bit9 corresponds to end DI0~DI1, 0-no choose, 1-choose Default 0.

  • do_choose: DO choose, bit0~bit7 corresponds to control box DO0~DO7, bit8~bit9 corresponds to end DO0~DO1, 0-no choose, 1-choose Default 0

Return Value

Error Code Success-0 Failure- errcode

9.2. Start Track Recording

Prototype

SetTPDStart(name, period_ms, type=1,di_choose=0, do_choose=0)

Description

Start Track Record

Mandatory parameters

  • name: track name;

  • period_ms: sampling period, fixed value, 2ms or 4ms or 8ms;

Default parameters

  • type: number datatype, 1-joint position default 1;

  • di_choose: DI choose, bit0~bit7 corresponds to control box DI0~DI7, bit8~bit9 corresponds to end DI0~DI1, 0-no choose, 1-choose Default 0.

  • do_choose: DO choose, bit0~bit7 corresponds to control box DO0~DO7, bit8~bit9 corresponds to end DO0~DO1, 0-no choose, 1-choose Default 0

Return Value

Error Code Success-0 Failure- errcode

9.3. Stop Track Recording

prototype

SetWebTPDStop()

Description

Stop Track Record

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.4. Deleting track records

Prototype

SetTPDDelete(name)

Description

Delete Track Record

Mandatory parameters

  • name: track name

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.5. code example

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5type = 1
 6name = "tpd2025"
 7period_ms = 4
 8di_choose = 0
 9do_choose = 0
10robot.SetTPDParam(name, period_ms)
11robot.Mode(1)
12time.sleep(1)
13robot.DragTeachSwitch(1)
14robot.SetTPDStart(name, period_ms)
15print("SetTPDStart")
16time.sleep(10)
17robot.SetWebTPDStop()
18robot.DragTeachSwitch(0)
19robot.CloseRPC()

9.6. Trajectory preloading

Prototype

LoadTPD(name)

Description

Trajectory Preloading

Mandatory parameters

  • name: track name

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.7. Trajectory Reproduction

Prototype

MoveTPD(name,blend,ovl)

Description

Trajectory Reproduction

Mandatory parameters

  • name: track name

  • blend: smooth or not, 0 - not smooth, 1 - smooth

  • ovl: velocity scaling factor, range [0 to 100]

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.8. Get the starting position of the trajectory

Prototype

GetTPDStartPose(name)

Description

Get trajectory start position

Mandatory parameters

  • name: track name

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • desc_pose=[x,y,z,rx,ry,rz]: trajectory start position

9.9. Example of robot TPD trajectory recording code

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5type = 1
 6name = "tpd2025"
 7period_ms = 4
 8di_choose = 0
 9do_choose = 0
10ovl = 100.0
11blend = 0
12rtn = robot.LoadTPD(name)
13print(f"LoadTPD rtn is: {rtn}")
14error,start_pose = robot.GetTPDStartPose(name)
15print(f"start pose, xyz is: {start_pose[0]},{start_pose[1]},{start_pose[2]}. "
16      f"rpy is: {start_pose[3]},{start_pose[4]},{start_pose[5]}")
17robot.MoveCart(start_pose, 0, 0, 100, 100)
18time.sleep(1)
19rtn = robot.MoveTPD(name, blend, ovl)
20print(f"MoveTPD rtn is: {rtn}")
21time.sleep(5)
22robot.SetTPDDelete(name)
23robot.CloseRPC()

9.10. Trajectory preprocessing

prototype

LoadTrajectoryJ(name,ovl,opt=1)

description

trajectory preprocessing

Mandatory parameters

  • name: track name, e.g., /fruser/traj/trajHelix_aima_1.txt.

  • ovl: percentage of speed scaling, range [0~100];

Default parameter

  • opt: 1-control point, default 1

Return Value

Error Code Success-0 Failure- errcode

9.11. Trajectory Reproduction

Prototype

MoveTrajectoryJ()

Description

Trajectory Reproduction

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.12. Getting the starting position of the trajectory

Prototype

GetTrajectoryStartPose(name)

Description

Get trajectory starting position

Mandatory parameters

name: track name

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • desc_pose=[x,y,z,rx,ry,rz]: trajectory start position

9.13. Get track point number

prototype

GetTrajectoryPointNum()

Description

Get track point number

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • pnum: track point number

9.14. Set Speed During Trajectory Execution

Prototype

SetTrajectoryJSpeed(ovl, mode)

Description

Set the speed during trajectory execution

Required Parameters

  • ovl: Speed scaling percentage, range [0~100]

  • mode: 0-speed reduction mode; 1-direct switching

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

9.15. Code Example for Setting Speed During Trajectory Execution

 1from time import sleep
 2import time
 3from fairino import Robot
 4
 5# Establish connection with robot controller
 6robot = Robot.RPC('192.168.58.2')
 7
 8
 9def TestSetTrajectoryJSpeed(self):
10    # Upload trajectory file
11    rtn = robot.TrajectoryJUpLoad("C://Users/lenovo/Desktop/trajHelix_aima_1.txt")
12    print(f"Upload TrajectoryJ A {rtn}")
13
14    traj_file_name = "/fruser/traj/trajHelix_aima_1.txt"
15    # Load trajectory file, parameters: file name, speed percentage, loop (1: loop)
16    rtn = robot.LoadTrajectoryJ(name=traj_file_name, ovl=100, opt=1)
17    print(f"LoadTrajectoryJ {traj_file_name}, rtn is: {rtn}")
18
19    # Get trajectory start pose
20    rtn, traj_start_pose = robot.GetTrajectoryStartPose(name=traj_file_name)
21    print(f"GetTrajectoryStartPose is: {rtn}")
22    print(
23        f"desc_pos:{traj_start_pose[0]},{traj_start_pose[1]},{traj_start_pose[2]},{traj_start_pose[3]},{traj_start_pose[4]},{traj_start_pose[5]}")
24
25    time.sleep(1)
26
27    # Set base speed and move to trajectory start point
28    robot.SetSpeed(50)
29    robot.MoveCart(desc_pos=traj_start_pose, tool=0, user=0, vel=100, acc=100, ovl=100, blendT=-1, config=-1)
30
31    # Get trajectory point count
32    rtn, traj_num = robot.GetTrajectoryPointNum()
33    print(f"GetTrajectoryStartPose rtn is: {rtn}, traj num is: {traj_num}")
34
35    # Start trajectory motion
36    rtn = robot.MoveTrajectoryJ()
37    print(f"MoveTrajectoryJ rtn is: {rtn}")
38
39    time.sleep(1)
40
41    # Get robot real-time status
42    trajspeedMode = 0
43    while True:
44        rtn, pkg = robot.GetRobotRealTimeState()
45        if pkg.motion_done != 0:
46            break
47
48        # Set trajectory speed to 10%
49        rtn = robot.SetTrajectoryJSpeed(ovl=10.0, mode=trajspeedMode)
50        print(f"SetTrajectoryJSpeed is: {rtn}")
51
52        time.sleep(1)
53
54        # Set trajectory speed to 80%
55        rtn = robot.SetTrajectoryJSpeed(ovl=80.0, mode=trajspeedMode)
56        print(f"SetTrajectoryJSpeed is: {rtn}")
57
58        time.sleep(1)
59
60    # Close connection
61    robot.CloseRPC()
62    time.sleep(1)
63
64
65# Call test function
66TestSetTrajectoryJSpeed(robot)

9.16. Setting the force and torque during trajectory operation

Prototype

SetTrajectoryJForceTorque(ft)

Description

Setting the force and torque in the trajectory run

Mandatory parameters

ft=[fx,fy,fz,tx,ty,tz]: units N and Nm

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.17. Setting the force along the x-direction in the trajectory run

Prototype

SetTrajectoryJForceFx(fx)

Description

Set the force along the x-direction in the trajectory run

Mandatory parameter

ft: force in x direction, in N

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.18. Setting the force along the y-direction in the trajectory run

Prototype

SetTrajectoryJForceFx(fy)

Description

Set the force along the y-direction in the trajectory run

Mandatory parameter

fy: force along y direction in N

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.19. Setting the force along the z-direction in a trajectory run

Prototype

SetTrajectoryJForceFx(fz)

Description

Set the force along the z-direction in the trajectory run

Mandatory parameter

fz: force along the z-direction, in N

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.20. Setting the torque around the x-axis in a trajectory run

Prototype

SetTrajectoryJTorqueTx(tx)

Description

Set the torque around the x-axis for the trajectory run

Mandatory parameter

tx: torque around x-axis in Nm

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.21. Setting the torque around the y-axis in trajectory operation

prototype

SetTrajectoryJTorqueTx(ty)

Description

Set the torque around the y-axis for the trajectory run

Mandatory parameter

ty: torque around y-axis in Nm

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.22. Setting the torque around the z-axis in trajectory operation

Prototype

SetTrajectoryJTorqueTx(tz)

Description

Sets the torque around the z-axis for the trajectory run

Mandatory parameter

tz: torque around z-axis in Nm

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.23. Upload trace J file

New in version python: SDK-v2.0.7

Prototype

TrajectoryJUpLoad(filePath)

Description

Upload trace J file

Mandatory parameter

  • filePath:Full path name of the uploaded trajectory file,C://test/testJ.txt

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.24. Delete the track J file

New in version python: SDK-v2.0.7

Prototype

TrajectoryJDelete(filePath)

Description

Delete the track J file

Mandatory parameter

  • filePath:Removes the full pathname of the trace file,C://test/testJ.txt

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.25. Robot trajectory J file reproduction code example

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5rtn = robot.TrajectoryJUpLoad("D://zUP/traj.txt")
 6print(f"Upload TrajectoryJ A {rtn}")
 7traj_file_name = "/fruser/traj/traj.txt"
 8rtn = robot.LoadTrajectoryJ(traj_file_name, 100, 1)
 9print(f"LoadTrajectoryJ {traj_file_name}, rtn is: {rtn}")
10rtn,traj_start_pose = robot.GetTrajectoryStartPose(traj_file_name)
11print(f"GetTrajectoryStartPose is: {rtn}")
12print(f"desc_pos:{traj_start_pose[0]},{traj_start_pose[1]},{traj_start_pose[2]},"
13      f"{traj_start_pose[3]},{traj_start_pose[4]},{traj_start_pose[5]}")
14time.sleep(1)
15robot.SetSpeed(50)
16robot.MoveCart(traj_start_pose, 0, 0, 50, 100, 100)
17rtn,traj_num = robot.GetTrajectoryPointNum()
18print(f"GetTrajectoryStartPose rtn is: {rtn}, traj num is: {traj_num}")
19rtn = robot.SetTrajectoryJSpeed(50.0)
20print(f"SetTrajectoryJSpeed is: {rtn}")
21traj_force = [0.0,0.0,0.0,0.0,0.0,0.0]
22traj_force[0] = 10  # fx = 10
23rtn = robot.SetTrajectoryJForceTorque(traj_force)
24print(f"SetTrajectoryJForceTorque rtn is: {rtn}")
25rtn = robot.SetTrajectoryJForceFx(10.0)
26print(f"SetTrajectoryJForceFx rtn is: {rtn}")
27rtn = robot.SetTrajectoryJForceFy(0.0)
28print(f"SetTrajectoryJForceFy rtn is: {rtn}")
29rtn = robot.SetTrajectoryJForceFz(0.0)
30print(f"SetTrajectoryJForceFz rtn is: {rtn}")
31rtn = robot.SetTrajectoryJTorqueTx(10.0)
32print(f"SetTrajectoryJTorqueTx rtn is: {rtn}")
33rtn = robot.SetTrajectoryJTorqueTy(10.0)
34print(f"SetTrajectoryJTorqueTy rtn is: {rtn}")
35rtn = robot.SetTrajectoryJTorqueTz(10.0)
36print(f"SetTrajectoryJTorqueTz rtn is: {rtn}")
37rtn = robot.MoveTrajectoryJ()
38print(f"MoveTrajectoryJ rtn is: {rtn}")
39robot.CloseRPC()

9.26. Trajectory preprocessing(Trajectory foresight)

New in version python: SDK-v2.1.4

Prototype

LoadTrajectoryLA(name, mode, errorLim, type, precision, vamx, amax, jmax, flag)

Description

Trajectory preprocessing(Trajectory foresight)

Mandatory parameter

  • name:track file name

  • mode: sampling mode, 0- No sampling; 1- equal data interval sampling; 2- Equal error limit sampling

  • errorLim: error limitation, effective using straight line fitting

  • type: smooth mode, 0-Bessel smooth

  • precision: smoothing accuracy, effective when using Bessel smoothing

  • vamx: set maximum speed, mm/s

  • amax: set maximum acceleration, mm/s2

  • jmax: maximum acceleration, mm/s3

  • flag: Uniform speed forward opening switch 0- No opening; 1- Start

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.27. Trajectory reproduction(Trajectory foresight)

New in version python: SDK-v2.1.0

Prototype

MoveTrajectoryLA()

Description

Trajectory reproduction(Trajectory foresight)

Mandatory parameter

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.28. Code example for trajectory reproduction

 1from fairino import Robot
 2import time
 3# A connection is established with the robot controller and a robot object is returned if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5rtn = robot.TrajectoryJUpLoad("D://zUP/traj.txt")
 6print(f"Upload TrajectoryJ A {rtn}")
 7traj_file_name = "/fruser/traj/traj.txt"
 8rtn = robot.LoadTrajectoryLA(traj_file_name, 1, 2, 0, 2, 50, 200, 1000, 0)
 9print(f"LoadTrajectoryLA {traj_file_name}, rtn is: {rtn}")
10rtn, traj_start_pose = robot.GetTrajectoryStartPose(traj_file_name)
11print(f"GetTrajectoryStartPose is: {rtn}")
12print(f"desc_pos: {traj_start_pose[0]},{traj_start_pose[1]},{traj_start_pose[2]},{traj_start_pose[3]},{traj_start_pose[4]},{traj_start_pose[5]}")
13time.sleep(1)
14robot.SetSpeed(50)
15robot.MoveCart(traj_start_pose, 0, 0, 100, 100, 100)
16rtn = robot.MoveTrajectoryLA()
17print(f"MoveTrajectoryLA rtn is: {rtn}")
18robot.CloseRPC()

9.29. Move to TPD Trajectory Recording Start Point

Prototype

MoveToTPDStart(name, moveType, ovl)

Description

Move to TPD trajectory recording start point

Required Parameters

  • name: Trajectory file name

  • moveType: Motion type; 0-PTP; 1-LIN

  • ovl: Speed scaling percentage, range [0~100]

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

9.30. SDK Code Example for Moving to TPD Trajectory Recording Start Point

 1from time import sleep
 2from fairino import Robot
 3from ctypes import sizeof
 4# Establish connection with robot controller, returns a robot object upon successful connection
 5robot = Robot.RPC('192.168.58.2')
 6import time
 7
 8def TestTPD(self):
 9    type = 1
10    name = "tpd2025"
11    period_ms = 4
12    di_choose = 0
13    do_choose = 0
14
15    robot.SetTPDParam(type=type, name=name, period_ms=period_ms, di_choose=di_choose, do_choose=do_choose)
16
17    robot.Mode(1)
18    time.sleep(1)
19    robot.DragTeachSwitch(1)
20    robot.SetTPDStart(type=type, name=name, period_ms=period_ms, di_choose=di_choose, do_choose=do_choose)
21    time.sleep(3)
22    robot.SetWebTPDStop()
23    robot.DragTeachSwitch(0)
24
25    time.sleep(1)
26    ovl = 100.0
27    blend = 0
28    start_pose = [0.0] * 6
29    rtn = robot.LoadTPD(name)
30    print(f"LoadTPD rtn is: {rtn}")
31
32    rtn, start_pose = robot.GetTPDStartPose(name)
33    print(f"start pose, xyz is: {start_pose[0]},{start_pose[1]},{start_pose[2]}. rpy is: {start_pose[3]},{start_pose[4]},{start_pose[5]}")
34    # robot.MoveCart(desc_pos=start_pose, tool=0, user=0, vel=100, acc=100, ovl=ovl, blendT=-1, config=-1)
35    #time.sleep(1)
36
37    rtn = robot.MoveToTPDStart(name, 0, 100)
38    print(f"MoveToTPDStart rtn is: {rtn}")
39
40    rtn = robot.MoveTPD(name, blend, ovl)
41    print(f"MoveTPD rtn is: {rtn}")
42    time.sleep(5)
43
44    robot.SetTPDDelete(name)
45
46    robot.CloseRPC()
47    return 0
48
49TestTPD(robot)