9. Trajectory recurrence
9.1. Setting Track Recording Parameters
prototype |
|
|---|---|
Description |
Setting parameters for track logging |
Mandatory parameters |
|
Default parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
9.2. Start Track Recording
Prototype |
|
|---|---|
Description |
Start Track Record |
Mandatory parameters |
|
Default parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
9.3. Stop Track Recording
prototype |
|
|---|---|
Description |
Stop Track Record |
Mandatory parameters |
NULL |
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
9.4. Deleting track records
Prototype |
|
|---|---|
Description |
Delete Track Record |
Mandatory parameters |
|
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 |
|
|---|---|
Description |
Trajectory Preloading |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
9.7. Trajectory Reproduction
Prototype |
|
|---|---|
Description |
Trajectory Reproduction |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
9.8. Get the starting position of the trajectory
Prototype |
|
|---|---|
Description |
Get trajectory start position |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
|
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 |
|
|---|---|
description |
trajectory preprocessing |
Mandatory parameters |
|
Default parameter |
|
Return Value |
Error Code Success-0 Failure- errcode |
9.11. Trajectory Reproduction
Prototype |
|
|---|---|
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 |
|
|---|---|
Description |
Get trajectory starting position |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
|
9.13. Get track point number
prototype |
|
|---|---|
Description |
Get track point number |
Mandatory parameters |
NULL |
Default parameters |
NULL |
Return Value |
|
9.14. Set Speed During Trajectory Execution
Prototype |
|
|---|---|
Description |
Set the speed during trajectory execution |
Required Parameters |
|
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 |
|
|---|---|
Description |
Setting the force and torque in the trajectory run |
Mandatory parameters |
|
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 |
|
|---|---|
Description |
Set the force along the x-direction in the trajectory run |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Set the force along the y-direction in the trajectory run |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Set the force along the z-direction in the trajectory run |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Set the torque around the x-axis for the trajectory run |
Mandatory parameter |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
9.21. Setting the torque around the y-axis in trajectory operation
prototype |
|
|---|---|
Description |
Set the torque around the y-axis for the trajectory run |
Mandatory parameter |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
9.22. Setting the torque around the z-axis in trajectory operation
Prototype |
|
|---|---|
Description |
Sets the torque around the z-axis for the trajectory run |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Upload trace J file |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Delete the track J file |
Mandatory parameter |
|
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 |
|
|---|---|
Description |
Trajectory preprocessing(Trajectory foresight) |
Mandatory parameter |
|
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 |
|
|---|---|
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 |
|
|---|---|
Description |
Move to TPD trajectory recording start point |
Required Parameters |
|
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)