top of page

Python 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

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
type = 1
name = "tpd2025"
period_ms = 4
di_choose = 0
do_choose = 0
robot.SetTPDParam(name, period_ms)
robot.Mode(1)
time.sleep(1)
robot.DragTeachSwitch(1)
robot.SetTPDStart(name, period_ms)
print("SetTPDStart")
time.sleep(10)
robot.SetWebTPDStop()
robot.DragTeachSwitch(0)
robot.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

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
type = 1
name = "tpd2025"
period_ms = 4
di_choose = 0
do_choose = 0
ovl = 100.0
blend = 0
rtn = robot.LoadTPD(name)
print(f"LoadTPD rtn is: {rtn}")
error,start_pose = robot.GetTPDStartPose(name)
print(f"start pose, xyz is: {start_pose[0]},{start_pose[1]},{start_pose[2]}. "
      f"rpy is: {start_pose[3]},{start_pose[4]},{start_pose[5]}")
robot.MoveCart(start_pose, 00100100)
time.sleep(1)
rtn = robot.MoveTPD(name, blend, ovl)
print(f"MoveTPD rtn is: {rtn}")
time.sleep(5)
robot.SetTPDDelete(name)
robot.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. Setting the speed of the trajectory in operation

Prototype

SetTrajectoryJSpeed(ovl)

Description

Sets the speed of the trajectory as it runs.

Mandatory parameter

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

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

9.15. 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.16. 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.17. 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.18. 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.19. 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.20. 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.21. 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.22. 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.23. 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.24. Robot trajectory J file reproduction code example

from fairino import Robot
import time
# Establish a connection with the robot controller and return a robot object if the connection is successful
robot = Robot.RPC('192.168.58.2')
rtn = robot.TrajectoryJUpLoad("D://zUP/traj.txt")
print(f"Upload TrajectoryJ A {rtn}")
traj_file_name = "/fruser/traj/traj.txt"
rtn = robot.LoadTrajectoryJ(traj_file_name, 1001)
print(f"LoadTrajectoryJ {traj_file_name}, rtn is: {rtn}")
rtn,traj_start_pose = robot.GetTrajectoryStartPose(traj_file_name)
print(f"GetTrajectoryStartPose is: {rtn}")
print(f"desc_pos:{traj_start_pose[0]},{traj_start_pose[1]},{traj_start_pose[2]},"
      f"{traj_start_pose[3]},{traj_start_pose[4]},{traj_start_pose[5]}")
time.sleep(1)
robot.SetSpeed(50)
robot.MoveCart(traj_start_pose, 0050100100)
rtn,traj_num = robot.GetTrajectoryPointNum()
print(f"GetTrajectoryStartPose rtn is: {rtn}, traj num is: {traj_num}")
rtn = robot.SetTrajectoryJSpeed(50.0)
print(f"SetTrajectoryJSpeed is: {rtn}")
traj_force = [0.0,0.0,0.0,0.0,0.0,0.0]
traj_force[0= 10  # fx = 10
rtn = robot.SetTrajectoryJForceTorque(traj_force)
print(f"SetTrajectoryJForceTorque rtn is: {rtn}")
rtn = robot.SetTrajectoryJForceFx(10.0)
print(f"SetTrajectoryJForceFx rtn is: {rtn}")
rtn = robot.SetTrajectoryJForceFy(0.0)
print(f"SetTrajectoryJForceFy rtn is: {rtn}")
rtn = robot.SetTrajectoryJForceFz(0.0)
print(f"SetTrajectoryJForceFz rtn is: {rtn}")
rtn = robot.SetTrajectoryJTorqueTx(10.0)
print(f"SetTrajectoryJTorqueTx rtn is: {rtn}")
rtn = robot.SetTrajectoryJTorqueTy(10.0)
print(f"SetTrajectoryJTorqueTy rtn is: {rtn}")
rtn = robot.SetTrajectoryJTorqueTz(10.0)
print(f"SetTrajectoryJTorqueTz rtn is: {rtn}")
rtn = robot.MoveTrajectoryJ()
print(f"MoveTrajectoryJ rtn is: {rtn}")
robot.CloseRPC()

9.25. 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.26. 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.27. Code example for trajectory reproduction

from fairino import Robot
import time
# A connection is established with the robot controller and a robot object is returned if the connection is successful
robot = Robot.RPC('192.168.58.2')
rtn = robot.TrajectoryJUpLoad("D://zUP/traj.txt")
print(f"Upload TrajectoryJ A {rtn}")
traj_file_name = "/fruser/traj/traj.txt"
rtn = robot.LoadTrajectoryLA(traj_file_name, 12025020010000)
print(f"LoadTrajectoryLA {traj_file_name}, rtn is: {rtn}")
rtn, traj_start_pose = robot.GetTrajectoryStartPose(traj_file_name)
print(f"GetTrajectoryStartPose is: {rtn}")
print(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]}")
time.sleep(1)
robot.SetSpeed(50)
robot.MoveCart(traj_start_pose, 00100100100)
rtn = robot.MoveTrajectoryLA()
print(f"MoveTrajectoryLA rtn is: {rtn}")
robot.CloseRPC()

robotic arm
FAIRINO ROBOTIC ARMS

Contact

Location: 10637 Scripps Summit Court,

San Diego, CA. 92131
Phone: (619) 333-FAIR
Email: hello@fairino.us

© 2023 Fairino US official site Proudly created By G2T

bottom of page