11. Peripherals

11.1. Configuration of jaws

Prototype

SetGripperConfig(company,device,softversion=0,bus=0)

Description

Configuration jaws

Required Parameters

  • company: gripper claw manufacturer, 1-Robotiq, 2-Huiling, 3-Tianji, 4-Dahuan, 5-Knowledge;

  • device: device number, Robotiq (0-2F-85 series), Huiling (0-NK series, 1-Z-EFG-100), Tianji (0-TEG-110), Dahuan (0-PGI-140), Zhixing (0-CTPM2F20)

Default parameters

  • softversion: software version number, not used for now, default is 0;

  • bus: device mount end bus location, not used yet, default is 0;

Return Value

Error Code Success-0 Failure- errcode

11.2. Get Jaw Configuration

Prototype

GetGripperConfig()

Description

Get Jaw Configuration

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • [number,company,device,softversion]: number, jaw number; company, jaw manufacturer, 1-Robotiq, 2-Huiling, 3-Tianji, 4-Dahuan, 5-Zhixing ;device, device number, Robotiq (0-2F-85 series), Huiling (0 -NK series,1-Z-EFG-100), Tianji(0-TEG-110), Dahuan(0-PGI-140), Zhixing(0-CTPM2F20) ;softvesion, software version number, not in use for the time being, default is 0.

11.3. Activate jaws

Prototype

ActGripper(index,action)

Description

Activate the jaws.

Mandatory parameter

  • index: jaw number;

  • action: 0-reset, 1-activate

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.4. Control jaws

Prototype

MoveGripper(index,pos,vel,force,maxtime,block,type,rotNum,rotVel,rotTorque)

Description

Control jaws

Mandatory parameter

  • index: jaw number;

  • pos: percentage of position, range [0~100];

  • vel: percentage of speed, in the range [0 to 100]; vel: percentage of speed, in the range [0 to 100].

  • force: percentage of torque, range [0 to 100];

  • maxtime: maximum wait time, range [0~30000], unit [ms];

  • block: 0-blocking, 1-non-blocking;

  • type: type of jaws, 0-parallel jaws; 1-rotary jaws;

  • rotNum:rotNum The number of rotations;

  • rotVel: Percentage of rotational velocity [0-100];

  • rotTorque: percentage of rotational torque [0-100].

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.5. Getting the jaw movement status

Prototype

GetGripperMotionDone()

Description

Get the gripper motion status (since version 401, the end-effector protocol and the gripper motion status feedback definition of adapted devices are unified)

Required parameters

None

Default parameters

None

Return value

  • Error code Success-0 Failure- errcode

  • [fault,status]: Gripper motion status, fault: 0-No error, other-Error; status: 0-Motion not completed, 1-Motion completed but no object detected, 2-Motion completed and object detected, 3-Motion completed and object dropped detected

11.6. Obtain the activated status of the gripper

Added in version python: SDK-v2.1.2

Prototype

GetGripperActivateStatus()

Description

Obtain the activated status of the gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • gripper_active:bit0 to bit15 correspond to the claw numbers 0 to 15. bit=0 indicates not activated, and bit=1 indicates activated

11.7. Obtain the position of the gripper

Added in version python: SDK-v2.1.2

Prototype

GetGripperCurPosition()

Description

Obtain the position of the gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • position:Position percentage, ranging from 0 to 100%

11.8. Obtain the gripper speed

Added in version python: SDK-v2.1.2

Prototype

GetGripperCurSpeed()

Description

Obtain the gripper speed

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • speed:Speed percentage, range 0 to 100%

11.9. Obtain the gripper current

Added in version python: SDK-v2.1.2

Prototype

GetGripperCurCurrent()

Description

Obtain the gripper current

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • current:Current percentage, range 0 to 100%

11.10. Obtain the gripper voltage

Added in version python: SDK-v2.1.2

Prototype

GetGripperVoltage()

Description

Obtain the gripper voltage

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • voltage:Voltage, unit: 0.1V

11.11. Obtain the temperature of the gripper

Added in version python: SDK-v2.1.2

Prototype

GetGripperTemp()

Description

Obtain the temperature of the gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • temp:Temperature, unit: 0.1V

11.12. Calculate pre-capture point-visual

Prototype

ComputePrePick(desc_pos, zlength, zangle)

Description

Calculate pre-capture point-visual

Mandatory parameter

  • desc_pos: clip grab point Cartesian position.

  • zlength: z-axis offset.

  • zangle: rotational offset around the z-axis

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • pre_pos: pre-grip point Cartesian position

11.13. Calculate retreat point-visual

Prototype

ComputePostPick(desc_pos, zlength, zangle)

Description

Computing Retreat Point-Vision

Mandatory parameters

  • desc_pos: grab point Cartesian position;

  • zlength: z-axis offset.

  • zangle: rotational offset around the z-axis

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • post_pos: retreat point Cartesian poses

11.14. Robot claw operation code example

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4company = 4
 5device = 0
 6softversion = 0
 7bus = 2
 8index = 2
 9act = 0
10max_time = 30000
11block = 0
12status = 0
13fault = 0
14active_status = 0
15current_pos = 0
16current = 0
17voltage = 0
18temp = 0
19speed = 0
20robot.SetGripperConfig(company, device, softversion, bus)
21time.sleep(1)
22error,[company, device, softversion, bus] = robot.GetGripperConfig()
23print(f"gripper config:{company},{device},{softversion},{bus}")
24robot.ActGripper(index, act)
25time.sleep(1)
26act = 1
27robot.ActGripper(index, act)
28time.sleep(1)
29error = robot.MoveGripper(index, 90, 50, 50, max_time, block, 0, 0, 0, 0)
30print(f"MoveGripper retval is:{error}")
31time.sleep(1)
32error = robot.MoveGripper(index, 30, 50, 0, max_time, block, 0, 0, 0, 0)
33print(f"MoveGripper retval is:{error}")
34error, [fault, status] = robot.GetGripperMotionDone()
35print(f"motion status:{fault},{status}")
36error, [fault, active_status] = robot.GetGripperActivateStatus()
37print(f"gripper active fault is:{fault},status is:{active_status}")
38error, [fault, current_pos] = robot.GetGripperCurPosition()
39print(f"fault is:{fault},current position is:{current_pos}")
40error, [fault, current] = robot.GetGripperCurCurrent()
41print(f"fault is:{fault},current current is:{current}")
42error, [fault, voltage] = robot.GetGripperVoltage()
43print(f"fault is:{fault},current voltage is:{voltage}")
44error, [fault, temp] = robot.GetGripperTemp()
45print(f"fault is:{fault},current temperature is:{temp}")
46error, [fault, speed] = robot.GetGripperCurSpeed()
47print(f"fault is:{fault},current speed is:{speed}")
48retval = 0
49prepick_pose = [0.0]*6
50postpick_pose = [0.0]*6
51p1Desc = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
52p2Desc = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
53retval, prepick_pose = robot.ComputePrePick(p1Desc, 10, 0)
54print(f"ComputePrePick retval is:{retval}")
55print(f"xyz is:{prepick_pose[0]},{prepick_pose[1]},{prepick_pose[2]};rpy is:{prepick_pose[3]},{prepick_pose[4]},{prepick_pose[5]}")
56retval, postpick_pose = robot.ComputePostPick(p2Desc, -10, 0)
57print(f"ComputePostPick retval is:{retval}")
58print(f"xyz is:{postpick_pose[0]},{postpick_pose[1]},{postpick_pose[2]};rpy is:{postpick_pose[3]},{postpick_pose[4]},{postpick_pose[5]}")
59robot.CloseRPC()

11.15. Get the number of rotation turns of the rotary gripper

Added in version python: SDK-v2.0.7

Prototype

GetGripperRotNum()

Description

Get the number of rotation turns of the rotary gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • num:Number of turns

11.16. Gets the percentage of rotation speed of the rotating gripper

Added in version python: SDK-v2.0.7

Prototype

GetGripperRotSpeed()

Description

Gets the percentage of rotation speed of the rotating gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • speed:Percent rotation speed

11.17. Obtains the percentage of rotating torque of the rotating gripper

Added in version python: SDK-v2.0.7

Prototype

GetGripperRotTorque()

Description

Obtains the percentage of rotating torque of the rotating gripper

Mandatory parameter

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • fault:0-correct,1-error

  • torque:Percent torque of rotation

11.18. Get the rotary gripper status code example

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4fault = 0
 5rotNum = 0.0
 6rotSpeed = 0
 7rotTorque = 0
 8error,fault, rotNum = robot.GetGripperRotNum()
 9error,fault, rotSpeed = robot.GetGripperRotSpeed()
10error,fault, rotTorque = robot.GetGripperRotTorque()
11print(f"gripper rot num:{rotNum},gripper rotSpeed:{rotSpeed},gripper rotTorque:{rotTorque}")
12robot.CloseRPC()

11.19. Drive belt start and stop

Prototype

ConveyorStartEnd(status)

Description

Drive belt start, stop

Mandatory parameters

  • status: status of the drive belt, 1-start, 0-stop

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.20. Record IO detection points

Prototype

ConveyorPointIORecord()

Description

Record IO detection points

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.21. Record point A

Prototype

ConveyorPointARecord()

Description

Record point A.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.22. Recording reference points

Prototype

ConveyorRefPointRecord()

Description

Record reference point

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.23. Record point B

Prototype

ConveyorPointBRecord()

Description

Record point B.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.24. Conveyorized workpiece IO inspection

Prototype

ConveyorIODetect(max_t)

Description

Conveyorized workpiece IO detection

Mandatory parameter

  • max_t: Maximum detection time in ms

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.25. Get the current position of the object

Prototype

ConveyorGetTrackData(mode)

Description

Get the current position of the object.

Mandatory Parameters

  • mode: 1-Tracking Capture 2-Tracking Motion 3-TPD Tracking

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.26. Drive belt tracking started

Prototype

ConveyorTrackStart(status)

Description

Drive belt tracking started

Mandatory parameters

  • status: status, 1-start, 0-stop

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.27. Belt tracking stop

Prototype

ConveyorTrackEnd()

Description

Drive belt tracking stop

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.28. Drive Belt Parameter Configuration

Prototype

ConveyorSetParam(param, followType, startDis, endDis)

Description

Configuration of drive belt parameters

Mandatory parameters

  • param= [encChannel,resolution,lead,wpAxis,vision,speedRadio]:
    • encChannel: encoder channels 1-2

    • resolution: encoder resolution Number of pulses per encoder revolution

    • lead: Mechanical transmission ratio Distance traveled by the conveyor belt in one revolution of the encoder

    • wpAxis: Workpiece coordinate system number Select the coordinate system number of the workpiece for the tracking motion function, and set the tracking gripping and TPD tracking to 0.

    • vision: whether or not to match vision 0 - no 1 - match,

    • speedRadio: speed ratio For conveyor tracking gripping speed range (1-100) Tracking motion, TPD tracking set to 1

Return Value

Error Code Success-0 Failure- errcode

11.29. Belt Grip Point Compensation

Prototype

ConveyorCatchPointComp(cmp)

Description

Drive belt grip point compensation

Mandatory parameters

  • cmp: Compensate for position [x,y,z]

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.30. linear motion

prototype

ConveyorTrackMoveL(name,tool,wobj,vel=20,acc=100,ovl=100,blendR=-1.0)

Description

Linear motion

Mandatory parameters

  • name: cvrCatchPoint or cvrRaisePoint

  • tool: tool number

  • wobj: workpiece number

Default Parameters

  • vel: speed default 20

  • acc: acceleration default 100

  • ovl: velocity scaling factor default 100

  • blendR: [-1.0]-motion in place (blocking), [0~1000]-smoothing radius (non-blocking) in [mm] default -1.0

Return Value

Error Code Success-0 Failure- errcode

11.31. Conveyor communication input detection

Added in version python: SDK-v2.1.1

Prototype

ConveyorComDetect(timeout)

Description

Conveyor communication input detection

Mandatory parameters

  • timeout: Wait timeout duration ms

Default Parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.32. Conveyor communication input detection triggered

Added in version python: SDK-v2.1.1

Prototype

ConveyorComDetectTrigger()

Description

Conveyor communication input detection triggered

Mandatory parameters

NULL

Default Parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.33. Robot conveyor operation code example

 1from fairino import Robot
 2import time
 3import threading
 4# Establish a connection with the robot controller and return a robot object if the connection is successful
 5robot = Robot.RPC('192.168.58.2')
 6retval = robot.ConveyorStartEnd(1)
 7print(f"ConveyorStartEnd retval is:{retval}")
 8retval = robot.ConveyorPointIORecord()
 9print(f"ConveyorPointIORecord retval is:{retval}")
10retval = robot.ConveyorPointARecord()
11print(f"ConveyorPointARecord retval is:{retval}")
12retval = robot.ConveyorRefPointRecord()
13print(f"ConveyorRefPointRecord retval is:{retval}")
14retval = robot.ConveyorPointBRecord()
15print(f"ConveyorPointBRecord retval is:{retval}")
16retval = robot.ConveyorStartEnd(0)
17print(f"ConveyorStartEnd retval is:{retval}")
18param = [1.0, 10000.0, 200.0, 0.0, 0.0, 20.0]
19retval = robot.ConveyorSetParam(param,0)
20print(f"ConveyorSetParam retval is:{retval}")
21cmp = [0.0, 0.0, 0.0]
22retval = robot.ConveyorCatchPointComp(cmp)
23print(f"ConveyorCatchPointComp retval is:{retval}")
24index = 1
25max_time = 30000
26block = 0
27retval = 0
28p1Desc = [-419.524, -13.000, 351.569, -178.118, 0.314, 3.833]
29p2Desc = [-321.222, 185.189, 335.520, -179.030, -1.284, -29.869]
30retval = robot.MoveCart(p1Desc, 1, 0, 100.0)
31print(f"MoveCart retval is:{retval}")
32retval = robot.WaitMs(1)
33print(f"WaitMs retval is:{retval}")
34retval = robot.ConveyorIODetect(10000)
35print(f"ConveyorIODetect retval is:{retval}")
36retval = robot.ConveyorGetTrackData(1)
37print(f"ConveyorGetTrackData retval is:{retval}")
38retval = robot.ConveyorTrackStart(1)
39print(f"ConveyorTrackStart retval is:{retval}")
40retval = robot.ConveyorTrackMoveL("cvrCatchPoint", 1, 0, 100)
41print(f"TrackMoveL retval is:{retval}")
42retval = robot.MoveGripper(index, 51, 40, 30, max_time, block, 0, 0, 0, 0)
43print(f"MoveGripper retval is:{retval}")
44retval = robot.ConveyorTrackMoveL("cvrRaisePoint", 1, 0, 100)
45print(f"TrackMoveL retval is:{retval}")
46retval = robot.ConveyorTrackEnd()
47print(f"ConveyorTrackEnd retval is:{retval}")
48robot.MoveCart(p2Desc, 1, 0, 100.0, 100.0)
49retval = robot.MoveGripper(index, 100, 40, 10, max_time, block, 0, 0, 0, 0)
50print(f"MoveGripper retval is:{retval}")
51robot.CloseRPC()

11.34. Conveyor Belt In-Place Tracking Parameter Configuration

Added in version python: SDK-V3.9.8

Prototype

SetStationaryTrackPara(self, trackMode, trackTime, trackDis)

Description

Configure conveyor belt in-place tracking parameters

Required Parameters

  • trackMode: 0-time; 1-distance; 2-time and distance, either condition satisfied

  • trackTime: Tracking time, unit s

  • trackDis: Tracking distance

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.35. Wait for In-Place Idle Motion to Complete

Added in version python: SDK-V3.9.8

Prototype

WaitStationaryMotionDone(self)

Description

Wait for in-place idle motion to complete

Required Parameters

None

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.36. Conveyor Belt In-Place Tracking Motion Code Example

Added in version python: SDK-V3.9.8

 1from fairino import Robot
 2import time
 3
 4
 5def main():
 6    robot = Robot.RPC('192.168.58.2')
 7    time.sleep(0.5)
 8    j1 = [-35.146, -102.684, 120.805, -100.401, -90.295, 150.105]
 9    d1 = [-121.814, -348.341, 209.978, -173.152, -3.585, -5.446]
10
11    ex = [0.0, 0.0, 0.0, 0.0]
12    zeroOff = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
13
14    tool = 1
15    workpiece = 1
16
17    para = [0, 10000, 200, 0, 0, 10]
18
19    rtn = robot.ConveyorSetParam(para= para)
20    print(f"ConveyorSetParam rtn is {rtn}")
21
22    robot.MoveJ(joint_pos=j1, desc_pos=d1, tool=tool, user=workpiece,
23                vel=100, acc=100, ovl=100, exaxis_pos=ex,
24                blendT=-1, offset_flag=0, offset_pos=zeroOff)
25
26    print("--- Step 1: SetDO(6,1) ---")
27    rtn = robot.SetDO(6, 1, 0, 0)
28    print(f"  SetDO(6,1) rtn={rtn}")
29
30    print("--- Step 2: ConveyorTrackStart(2) ---")
31    rtn = robot.ConveyorTrackStart(2)
32    print(f"  ConveyorTrackStart(2) rtn={rtn}")
33
34    print("--- Step 3: ConveyorIODetect(10000) ---")
35    rtn = robot.ConveyorIODetect(10000)
36    print(f"  ConveyorIODetect(10000) rtn={rtn}")
37
38    print("--- Step 4: ConveyorGetTrackData(2) ---")
39    rtn = robot.ConveyorGetTrackData(2)
40    print(f"  ConveyorGetTrackData(2) rtn={rtn}")
41
42    print("--- Step 5: SetStationaryTrackPara(0,5,5) ---")
43    rtn = robot.SetStationaryTrackPara(0, 5, 5)
44    print(f"  SetStationaryTrackPara(0,5,5) rtn={rtn}")
45
46    print("--- Step 6: MoveStationary() ---")
47    rtn = robot.MoveStationary()
48    print(f"  MoveStationary() rtn={rtn}")
49
50    rtn = robot.WaitStationaryMotionDone()
51    print(f"  WaitStationaryMotionDone() rtn={rtn}")
52
53    print("--- Step 7: ConveyorTrackEnd() ---")
54    rtn = robot.ConveyorTrackEnd()
55    print(f"  ConveyorTrackEnd() rtn={rtn}")
56
57    print("--- Step 8: SetDO(6,0) ---")
58    rtn = robot.SetDO(6, 0, 0, 0)
59    print(f"  SetDO(6,0) rtn={rtn}")
60
61    robot.CloseRPC()
62
63
64if __name__ == "__main__":
65    main()

11.37. End Sensor Configuration

Added in version python: SDK-v2.0.5

Prototype

AxleSensorConfig(idCompany, idDevice, idSoftware, idBus)

Description

End Sensor Configuration

Mandatory parameters

  • idCompany: manufacturer, 18-Junkong; 25-Huide

  • idDevice: type, 0-JUNKONG/RYR6T.V1.0

  • idSoftware: software version, 0-J1.0/HuiDe1.0 (not yet available)

  • idBus: mount location, 1-end port 1; 2-end port 2… ..8-end port 8 (not open yet)

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.38. Get End Sensor Configuration

Added in version python: SDK-v2.0.5

Prototype

AxleSensorConfigGet()

Description

Get end sensor configuration

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • idCompany: manufacturer, 18-Junkong; 25-Huide

  • idDevice: type, 0-JUNKONG/RYR6T.V1.0

11.39. End sensor activation

Added in version python: SDK-v2.0.5

Prototype

AxleSensorActivate(actFlag)

Description

End sensor activation

Mandatory parameters

actFlag: 0-reset; 1-activate

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • coord: coordinate system values [x,y,z,rx,ry,rz]

11.40. End Sensor Register Write

Added in version python: SDK-v2.0.5

Prototype

AxleSensorRegWrite(devAddr, regHAddr, regLAddr, regNum, data1, data2, isNoBlock)

Description

End Sensor Register Write

Mandatory parameters

  • devAddr: device address number 0-255

  • regHAddr: register address high 8 bits

  • regLAddr: register address lower 8 bits

  • regNum: number of registers 0-255

  • data1: write to register value 1

  • data2: write register value 2

  • isNoBlock: whether blocking 0 - blocking; 1 - non-blocking

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.41. End sensor code example

 1from fairino import Robot
 2import time
 3import threading
 4# Establish a connection with the robot controller and return a robot object if the connection is successful
 5robot = Robot.RPC('192.168.58.2')
 6robot.AxleSensorConfig(18, 0, 0, 1)
 7error, company, type = robot.AxleSensorConfigGet()
 8print(f"company is:{company},type is:{type}")
 9rtn = robot.AxleSensorActivate(1)
10print(f"AxleSensorActivate rtn is:{rtn}")
11time.sleep(1)
12rtn = robot.AxleSensorRegWrite(1, 4, 6, 1, 0, 0, 0)
13print(f"AxleSensorRegWrite rtn is:{rtn}")
14robot.CloseRPC()

11.42. Obtaining Robot Peripheral Protocols

Added in version python: SDK-v2.0.3

Prototype

GetExDevProtocol()

Description

Get robot peripheral protocol

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode.

  • protocol: Robot peripheral protocol number 4096-Extended Axis Control Card; 4097-ModbusSlave; 4098-ModbusMaster

11.43. Setting up robot peripheral protocols

Added in version python: SDK-v2.0.3

Prototype

SetExDevProtocol(protocol)

Description

Setting the robot peripheral protocol

Mandatory parameters

  • protocol: robot peripheral protocol number 4096 - Extended Axis Control Card; 4097 - ModbusSlave; 4098 - ModbusMaster

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.44. Example of setup robot peripheral protocol code

1from fairino import Robot
2# Establish a connection with the robot controller and return a robot object if the connection is successful
3robot = Robot.RPC('192.168.58.2')
4protocol = 4096
5rtn = robot.SetExDevProtocol(protocol)
6print(f"SetExDevProtocol rtn:{rtn}")
7rtn, protocol = robot.GetExDevProtocol()
8print(f"GetExDevProtocol rtn:{rtn},protocol is:{protocol}")
9robot.CloseRPC()

11.45. Getting end communication parameters

Added in version python: SDK-v2.0.5

Prototype

GetAxleCommunicationParam()

Description

Get end communication parameters

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • baudRate: baud rate: support 1-9600, 2-14400, 3-19200, 4-38400, 5-56000, 6-67600, 7-115200, 8-128000

  • dataBit: data bit: data bit support (8,9), currently commonly used 8

  • stopBit: stop bit: 1-1, 2-0.5, 3-2, 4-1.5, currently 1 is commonly used.

  • verify: check digit: 0-None, 1-Odd, 2-Even, currently 0.

  • timeout: timeout time: 1~1000ms, this value needs to be combined with the peripheral with the setting of reasonable time parameters

  • timeoutTimes: timeout times: 1~10, mainly for timeout retransmission, reduce occasional exceptions to improve user experience

  • period: periodic instruction time interval:1~1000ms, mainly used for the time interval between each issuance of periodic instructions

11.46. Setting the end communication parameters

Added in version python: SDK-v2.0.5

Prototype

SetAxleCommunicationParam(baudRate, dataBit, stopBit, verify, timeout, timeoutTimes, period)

description

set end communication parameters

Required Parameters

  • baudRate: baud rate: supports 1-9600, 2-14400, 3-19200, 4-38400, 5-56000, 6-67600, 7-115200, 8-128000

  • dataBit: data bit: data bit support (8,9), currently commonly used 8

  • stopBit: stop bit: 1-1, 2-0.5, 3-2, 4-1.5, currently 1 is commonly used.

  • verify: check digit: 0-None, 1-Odd, 2-Even, currently 0.

  • timeout: timeout time: 1~1000ms, this value needs to be combined with the peripheral with the setting of reasonable time parameters

  • timeoutTimes: timeout times: 1~10, mainly for timeout retransmission, reduce occasional exceptions to improve user experience

  • period: periodic instruction time interval:1~1000ms, mainly used for the time interval between each issuance of periodic instructions

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.47. Setting the end file transfer type

Added in version python: SDK-v2.0.5

Prototype

SetAxleFileType(type)

Description

Set the end file transfer type

Mandatory parameters

  • type: 1-MCU upgrade file, 2-LUA file

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.48. Setting Enable End LUA Execution

Added in version python: SDK-v2.0.5

Prototype

SetAxleLuaEnable(enable)

Description

Set Enable End LUA Enforcement

Mandatory parameters

  • enable: 0 - not enabled; 1 - enabled

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.49. End LUA file exception error recovery

Added in version python: SDK-v2.0.5

Prototype

SetRecoverAxleLuaErr(enable)

Description

End LUA File Exception Error Recovery

Mandatory parameters

  • status: 0 - no recovery; 1 - recovery

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.50. Get end LUA execution enable status

Added in version python: SDK-v2.0.5

Prototype

GetAxleLuaEnableStatus()

description

Get end LUA execution enable state

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • enable: 0-don’t enable; 1-enable

11.51. Set End LUA End Device Enable Type

Prototype

SetAxleLuaEnableDeviceType(self, forceSensorEnable, gripperEnable, IOEnable, dexhandEnable, suckerEnable=-1)

Description

Set the end LUA end device enable type

Required Parameters

  • forceSensorEnable: Force sensor enable status, 0-not enabled; 1-enabled

  • gripperEnable: Gripper enable status, 0-not enabled; 1-enabled

  • IOEnable: IO device enable status, 0-not enabled; 1-enabled

  • dexhandEnable: Dexterous hand enable status, 0-not enabled; 1-enabled

  • suckerEnable: End suction cup device enable status, 0-not enabled; 1-enabled; default -1: when not passed or passed as -1, it is sent with the original four parameters, compatible with unupgraded controllers

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.52. Get End LUA End Device Enable Type

Prototype

GetAxleLuaEnableDeviceType()

Description

Get the end LUA end device enable type

Required Parameters

None

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • forceSensorEnable: Force sensor enable status, 0-not enabled; 1-enabled

  • gripperEnable: Gripper enable status, 0-not enabled; 1-enabled

  • IOEnable: IO device enable status, 0-not enabled; 1-enabled

  • dexhandEnable: Dexterous hand enable status, 0-not enabled; 1-enabled

  • suckerEnable: End suction cup device enable status, 0-not enabled; 1-enabled;

11.53. Get Currently Configured End Devices

Prototype

GetAxleLuaEnableDevice()

Description

Get the currently configured end devices

Required Parameters

None

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • forceSensorEnable[8]: Force sensor enable status, 0-not enabled; 1-enabled

  • gripperEnable[8]: Gripper enable status, 0-not enabled; 1-enabled

  • IOEnable[8]: IO device enable status, 0-not enabled; 1-enabled

  • dexhandEnable: Dexterous hand enable status, 0-not enabled; 1-enabled

  • suckerEnable: End suction cup enabled device number, 0-not enabled; 1-enabled (items 40~47 of the comma string)

11.54. Set the enabled gripper action control functions

Added in version python: SDK-v2.0.5

Prototype

SetAxleLuaGripperFunc(id, func)

Description

Set the enabled gripper action control functions

Required Parameters

  • id: Gripper device number

  • func: 0-gripper enable; 1-gripper initialization; 2-position setting; 3-speed setting; 4-torque setting; 6-read gripper status; 7-read initialization status; 8-read fault code; 9-read position; 10-read speed; 11-read torque; 12-set rotation count for rotary gripper; 13-set rotation speed for rotary gripper; 14-set rotation torque for rotary gripper; 15-read rotary gripper status; 16-read rotary gripper initialization status; 17-read rotary gripper rotation count; 18-read rotary gripper speed; 19-read rotary gripper torque; 20-multi-axis synchronous motion setting; 21-fault clear command; 22-single-axis running status; 23-all-axis running status;

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.55. Get the enabled gripper action control functions

Added in version python: SDK-v2.0.5

Prototype

GetAxleLuaGripperFunc(id)

Description

Get the enabled gripper action control functions

Required Parameters

  • id: Gripper device number

Default Parameters

None

Return Value

  • Error code, 0-success; non-zero-error

  • func: 0-gripper enable; 1-gripper initialization; 2-position setting; 3-speed setting; 4-torque setting; 6-read gripper status; 7-read initialization status; 8-read fault code; 9-read position; 10-read speed; 11-read torque; 12-set rotation count for rotary gripper; 13-set rotation speed for rotary gripper; 14-set rotation torque for rotary gripper; 15-read rotary gripper status; 16-read rotary gripper initialization status; 17-read rotary gripper rotation count; 18-read rotary gripper speed; 19-read rotary gripper torque; 20-multi-axis synchronous motion setting; 21-fault clear command; 22-single-axis running status; 23-all-axis running status;

11.56. The Ethercat slave file is written by the robot

Added in version python: SDK-v2.0.5

Prototype

SlaveFileWrite(type,slaveID,fileName)

Description

The Ethercat slave file is written by the robot

Mandatory parameter

  • type:Slave file type, 1- Upgrade slave file; 2- Upgrade the slave station configuration file

  • slaveID:From the station number

  • fileName:Upload the file name

Default parameters

NULL

Return Value

errorcode Success-0 Failure- errcode

11.57. Upload the end Lua open protocol file

Added in version python: SDK-v2.0.5

Prototype

AxleLuaUpload(filePath)

Description

Upload the end Lua open protocol file

Mandatory parameter

  • filePath:Local lua file path name …/AXLE_LUA_End_DaHuan.lua

Default parameters

NULL

Return Value

errorcode Success-0 Failure- errcode

11.58. The robot Ethercat enters boot mode from the station

Added in version python: SDK-v2.0.5

Prototype

SetSysServoBootMode(filePath)

Description

The robot Ethercat enters boot mode from the station

Mandatory parameter

NULL

Default parameters

NULL

Return Value

errorcode Success-0 Failure- errcode

11.59. Example of LUA file manipulation code at the end of the robot

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4robot.AxleLuaUpload("D://zUP/AXLE_LUA_End_DaHuan.lua")
 5param = [7, 8, 1, 0, 5, 3, 1]  # 对应AxleComParam参数
 6robot.SetAxleCommunicationParam(7, 8, 1, 0, 5, 3, 1)
 7error,getParam0,getParam1,getParam2,getParam3,getParam4,getParam5,getParam6 = robot.GetAxleCommunicationParam()
 8print(f"GetAxleCommunicationParam param is:{getParam0} {getParam1} {getParam2} {getParam3} {getParam4} {getParam5} {getParam6}")
 9robot.SetAxleLuaEnable(1)
10error,luaEnableStatus = robot.GetAxleLuaEnableStatus()
11robot.SetAxleLuaEnableDeviceType(0, 1, 0)
12error,forceEnable, gripperEnable, ioEnable = robot.GetAxleLuaEnableDeviceType()
13print(f"GetAxleLuaEnableDeviceType param is:{forceEnable} {gripperEnable} {ioEnable}")
14func = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
15robot.SetAxleLuaGripperFunc(1, func)
16error,getFunc = robot.GetAxleLuaGripperFunc(1)
17error,getforceEnable, getgripperEnable, getioEnable = robot.GetAxleLuaEnableDevice()
18print("\ngetforceEnable status:", end=" ")
19for i in range(8):
20    print(f"{getforceEnable[i]},", end="")
21print("\ngetgripperEnable status:", end=" ")
22for i in range(8):
23    print(f"{getgripperEnable[i]},", end="")
24print("\ngetioEnable status:", end=" ")
25for i in range(8):
26    print(f"{getioEnable[i]},", end="")
27print()
28robot.ActGripper(1, 0)
29time.sleep(2)
30robot.ActGripper(1, 1)
31time.sleep(2)
32robot.MoveGripper(1, 90, 10, 100, 50000, 0, 0, 0, 0, 0)
33while True:
34    error,pkg = robot.GetRobotRealTimeState()
35    print(f"gripper pos is:{pkg.gripper_position}")
36    time.sleep(0.1)
37robot.CloseRPC()

11.60. Obtain the status of the SmartTool button

Added in version python: SDK-v2.1.2

Prototype

GetSmarttoolBtnState()

Description

Obtain the status of the SmartTool button

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • Error Code Success-0 Failure- errcode

  • state: SmartTool handle button status (bit0:0- Communication is normal; 1- Communication disconnection; bit1- Undo operation bit2- Clear the program; bit3-A key bit4-B key bit5-C key bit6-D key bit7-E key bit8-IO key bit9- Manual automatic Starting from bit10

11.61. SmartTool button 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')
5while True:
6    error,state = robot.GetSmarttoolBtnState()
7    print(f"{state:016b}")
8    time.sleep(0.1)

11.62. Set the load detection before drag is started

Added in version python: SDK-v2.1.6

Prototype

SetTorqueDetectionSwitch(flag)

Description

Set the load detection before drag is started

Mandatory parameters

  • flag:0- closed; 1- On

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.63. Laser peripheral open and close function

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingLaserOnOff(OnOff, weldId)

Description

Laser peripheral open and close function

Mandatory parameters

  • OnOff:0- closed; 1- On

Default parameters

  • weldId:The default weld ID is 0

Return Value

Error Code Success-0 Failure- errcode

11.64. Laser tracking start-end function

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingTrackOnOff(OnOff, coordId)

Description

Laser tracking start-end function

Mandatory parameters

  • OnOff:0- closed; 1- On

  • coordId:Laser peripheral tool coordinate system No

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.65. Laser positioning - Fixed direction

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingSearchStart_xyz(direction, vel, distance, timeout, posSensorNum)

Description

Laser positioning - Fixed direction

Mandatory parameters

  • direction:0-x+ 1-x- 2-y+ 3-y- 4-z+ 5-z-

  • vel:Unit of speed %

  • distance:The maximum positioning distance unit is mm

  • timeout:The unit of seek timeout time is ms

  • posSensorNum:The coordinate number of the tool calibrated by laser

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.66. Laser positioning - in any direction

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingSearchStart_point(directionPoint, vel, distance, timeout, posSensorNum)

Description

Laser positioning - in any direction

Mandatory parameters

  • directionPoint:To the left of the xyz of the input point for positioning,[x,y,z]

  • vel:Unit of speed %

  • distance:The maximum positioning distance unit is mm

  • timeout:The unit of seek timeout time is ms

  • posSensorNum:The coordinate number of the tool calibrated by laser

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.67. Laser IP configuration

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingSensorConfig(ip, port)

Description

Laser IP configuration

Mandatory parameters

  • ip:The ip address of the laser peripheral

  • port:The port number of the laser peripheral

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.68. Configuration of sampling period for laser peripherals

Added in version python: SDK-v2.1.6

Prototype

LaserTrackingSensorSamplePeriod(period)

Description

Configuration of sampling period for laser peripherals

Mandatory parameters

  • period:The unit of sampling period for laser peripherals is ms

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.69. Laser peripheral driver loading

Added in version python: SDK-v2.1.6

Prototype

LoadPosSensorDriver(type)

Description

Laser peripheral driver loading

Mandatory parameters

  • type:Protocol type of the laser device driver: 101-Ruineng 102-Chuangxiang 103-Quanshi 104-Tongzhou 105-Aotai

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.70. Laser peripheral driver unloading

Added in version python: SDK-v2.1.6

Prototype

UnLoadPosSensorDriver()

Description

Laser peripheral driver unloading

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.71. Laser weld seam trajectory recording

Added in version python: SDK-v2.1.6

Prototype

LaserSensorRecord1(status, delayTime)

Description

Laser weld seam trajectory recording

Mandatory parameters

  • status:0- Stop recording 1- Real-time tracking 2- Start recording

  • delayTime:The delay time unit is ms

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.72. Laser weld seam trajectory reproduction

Added in version python: SDK-v2.1.6

Prototype

LaserSensorReplay(delayTime, speed)

Description

Laser weld seam trajectory reproduction

Mandatory parameters

  • delayTime:The delay time unit is ms

  • speed:Unit of speed %

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.73. Laser tracking reproduction

Added in version python: SDK-v2.1.6

Prototype

MoveLTR()

Description

Laser tracking reproduction

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.74. Laser weld seam trajectory reproduction

Added in version python: SDK-v2.1.6

Prototype

LaserSensorRecordandReplay(delayMode, delayTime, delayDisExAxisNum, delayDis, sensitivePara, int trackMode, int triggerMode, double runTime, speed)

Description

Laser Weld Seam Trajectory Replay

Required Parameters

  • delayMode: Mode 0-Delay Time 1-Delay Distance

  • delayTime: Delay time in milliseconds (ms)

  • delayDisExAxisNum: Extended Axis Number

  • delayDis: Delay distance in millimeters (mm)

  • sensitivePara: Compensation Sensitivity Coefficient

  • trackMode: Fixed-point Tracking Type. 0-Extended Axis Asynchronous Motion; 1-Robot

  • triggerMode: Fixed-point Tracking Trigger Method. 0-Tracking Duration; 1-IO

  • runTime: Robot Fixed-point Tracking Duration in seconds (s)

  • speed: Speed in percentage (%)

Default Parameters

None

Return Value

Error Code. Success - 0, Failure - errcode

11.75. Movement to the starting point of weld record

Added in version python: SDK-v2.1.6

Prototype

MoveToLaserRecordStart(moveType, ovl)

Description

Movement to the starting point of weld record

Mandatory parameters

  • moveType:0-PTP 1-LIN

  • ovl:Speed unit %

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.76. Movement to the end of the weld record

Added in version python: SDK-v2.1.6

Prototype

MoveToLaserRecordEnd(moveType, ovl)

Description

Movement to the end of the weld record

Mandatory parameters

  • moveType:0-PTP 1-LIN

  • ovl:Speed unit %

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.77. Move to the laser sensor to find the site

Added in version python: SDK-v2.1.6

Prototype

MoveToLaserSeamPos(moveFlag, ovl, dataFlag, plateType, trackOffectType, offset)

Description

Move to the laser sensor to find the site

Mandatory parameters

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

  • ovl:Speed scaling factor, 0-100

  • dataFlag:Weld cache data selection: 0-execution planning data; 1- Perform logging data

  • plateType:Plate type: 0-corrugated plate; 1- Corrugated board; 2- Fence board; 3- oil barrel; 4- Corrugated shell steel

  • trackOffectType:Laser sensor offset type: 0-no offset; 1-base coordinate shift; 2- Tool coordinate offset; 3-Laser sensor raw data offset

  • offset:Offset value

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.78. Obtain the coordinate information of the laser sensor location

Added in version python: SDK-v2.1.6

Prototype

GetLaserSeamPos(trackOffectType, offset)

Description

Obtain the coordinate information of the laser sensor location

Mandatory parameters

  • trackOffectType:Laser sensor offset type: 0-no offset; 1-base coordinate shift; 2- Tool coordinate offset; 3-Laser sensor raw data offset

  • offset:Offset value

Default parameters

NULL

Return Value

  • Error Code Success-0 Failure- errcode

  • jPos:Joint position[°]

  • descPos:Cartesian position[mm]

  • tool:Tool coordinate system

  • user:Workpiece coordinate system

  • exaxis:Extension axis position[mm]

11.79. Example of laser peripheral sensor parameter configuration and debugging code

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4robot.LaserTrackingSensorConfig("192.168.58.20", 5020)
 5robot.LaserTrackingSensorSamplePeriod(20)
 6robot.LoadPosSensorDriver(101)
 7robot.LaserTrackingLaserOnOff(0, 0)
 8time.sleep(3)
 9robot.LaserTrackingLaserOnOff(1, 0)
10robot.CloseRPC()

11.80. Code example of laser trajectory scanning and trajectory reproduction

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4robot.OpenLuaUpload("D://zUP/CtrlDev_laser_ruiniu-0117.lua")
 5time.sleep(2)
 6robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua")
 7robot.UnloadCtrlOpenLUA(0)
 8robot.LoadCtrlOpenLUA(0)
 9time.sleep(8)
10i = 0
11while i<10:
12    startjointPos = [56.205, -117.951, 141.872, -118.149, -94.217, -122.176]
13    startdescPose = [-97.552, -282.855, 26.675, 174.182, -1.338, -91.707]
14    exaxisPos = [0.0] * 4
15    offdese = [0.0] * 6
16    robot.MoveL(desc_pos=startdescPose,tool= 1,user= 0,vel= 100,acc= 100,ovl= 100,blendR= -1,exaxis_pos= exaxisPos,search= 0,offset_flag= 0, offset_pos= offdese,overSpeedStrategy= 1,speedPercent= 1)
17    robot.LaserSensorRecord1(2, 10)
18    endjointPos = [68.809, -87.100, 121.120, -127.233, -95.038, -109.555]
19    enddescPose = [-103.555, -464.234, 13.076, 174.179, -1.344, -91.709]
20    robot.MoveL(desc_pos=enddescPose,tool= 1,user= 0,vel= 50,acc= 100,ovl= 100,blendR= -1,exaxis_pos= exaxisPos,search= 0,offset_flag= 0, offset_pos= offdese,overSpeedStrategy= 1,speedPercent= 1)
21    robot.LaserSensorRecord1(0, 10)
22    robot.MoveToLaserRecordStart(1, 30)
23    robot.LaserSensorReplay(10, 100)
24    robot.MoveLTR()
25    robot.LaserSensorRecord1(0, 10)
26    i = i+1
27robot.CloseRPC()

11.81. Code examples for laser locating and real-time tracking

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4robot.OpenLuaUpload("D://zUP/CtrlDev_laser_ruiniu-0117.lua")
 5time.sleep(2)
 6robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua")
 7robot.UnloadCtrlOpenLUA(0)
 8robot.LoadCtrlOpenLUA(0)
 9time.sleep(8)
10time.sleep(8)
11i = 0
12while i < 10:
13    startjointPos = [56.205, -117.951, 141.872, -118.149, -94.217, -122.176]
14    startdescPose = [-97.552, -282.855, 26.675, 174.182, -1.338, -91.707]
15    exaxisPos = [0.0] * 4
16    offdese = [0.0] * 6
17    directionPoint = [0.0] * 3
18    robot.MoveL(desc_pos=startdescPose,tool= 1,user= 0,vel= 100,acc= 100,ovl= 100,blendR= -1,exaxis_pos= exaxisPos,search= 0,offset_flag= 0, offset_pos= offdese,overSpeedStrategy= 1,speedPercent= 1)
19    robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 3)
20    robot.LaserTrackingSearchStop()
21    robot.MoveToLaserSeamPos(1, 30, 0, 0, 0, offdese)
22    robot.LaserTrackingTrackOnOff(1, 3)
23    endjointPos = [68.809, -87.100, 121.120, -127.233, -95.038, -109.555]
24    enddescPose = [-103.555, -464.234, 13.076, 174.179, -1.344, -91.709]
25    robot.MoveL(desc_pos=enddescPose,tool= 1,user= 0,vel= 20,acc= 100,ovl= 100,blendR= -1,exaxis_pos= exaxisPos,search= 0,offset_flag= 0, offset_pos= offdese,overSpeedStrategy= 1,speedPercent= 1)
26    robot.LaserTrackingTrackOnOff(0, 3)
27    i = i + 1
28    print(i)
29robot.CloseRPC()

11.82. Code example of the extended axis synchronized with the robot for laser tracking

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4startexaxisPos = [0.0, 0.0, 0.0, 0.0]
 5seamexaxisPos = [-10.0, 0.0, 0.0, 0.0]
 6endexaxisPos = [-30.0, 0.0, 0.0, 0.0]
 7offdese = [0.0] * 6
 8seamjointPos = [0.0] * 6
 9seamdescPose = [0.0] * 6
10i=0
11while i < 10:
12    startjointPos = [58.337, -119.628, 146.037, -116.358, -92.224, -117.654]
13    startdescPose = [-53.375, -255.363, 0.919, 178.054, 1.077, -94.026]
14    robot.ExtAxisSyncMoveJ(joint_pos=startjointPos, tool=1,user= 0,vel= 100,acc= 100, ovl=100,exaxis_pos= startexaxisPos,blendT= -1,offset_flag= 0,offset_pos= offdese)
15    ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2)
16    robot.LaserTrackingSearchStop()
17    tool = 0
18    user = 0
19    rnte, seamjointPos, seamdescPose, tool, user, startexaxisPos = robot.GetLaserSeamPos(0, offdese)
20    print(f"{seamjointPos[0]},{seamjointPos[1]},{seamjointPos[2]},{seamjointPos[3]},{seamjointPos[4]},{seamjointPos[5]},{seamdescPose[0]},{seamdescPose[1]},{seamdescPose[2]},{seamdescPose[3]},{seamdescPose[4]},{seamdescPose[5]}")
21    if ret == 0:
22        robot.ExtAxisSyncMoveJ(joint_pos=seamjointPos, tool=1,user= 0,vel= 100,acc= 100, ovl=100,exaxis_pos= seamexaxisPos,blendT= -1,offset_flag= 0,offset_pos= offdese)
23        robot.LaserTrackingTrackOnOff(1, 2)
24        endjointPos = [70.580, -90.918, 126.593, -125.154, -92.162, -105.403]
25        enddescPose = [-53.375, -419.020, 0.920, 178.054, 1.076, -94.026]
26        robot.ExtAxisSyncMoveL(desc_pos=enddescPose, tool=1,user= 0,vel= 20,acc= 100, ovl=100,blendR= -1,exaxis_pos= endexaxisPos,offset_pos= offdese)
27        robot.LaserTrackingTrackOnOff(0, 2)
28    i = i+1
29    print(i)
30robot.CloseRPC()

11.83. Control Array Suction Cup

Added in version python: SDK-v2.1.5

Prototype

SetSuckerCtrl(slaveID, len, ctrlValue)

Description

Control array suction cup

Required Parameters

  • slaveID: Slave station number

  • len: Length

  • ctrlValue: Control value 1-Suction at maximum vacuum 2-Suction at set vacuum 3-Stop suction

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.84. Get Array Suction Cup Status

Added in version python: SDK-v2.1.5

Prototype

GetSuckerState(slaveID)

Description

Get array suction cup status

Required Parameters

  • slaveID: Slave station number

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • state: Suction status 0-Object released 1-Workpiece suction successful 2-No object suctioned 3-Object detached

  • pressValue: Current vacuum pressure unit kPa

  • error: Current error code of the suction cup

11.85. Wait for Suction Cup Status

Added in version python: SDK-v2.1.5

Prototype

WaitSuckerState(slaveID, state, ms)

Description

Wait for suction cup status

Required Parameters

  • slaveID: Slave station number

  • state: Suction status 0-Object released 1-Workpiece suction successful 2-No object suctioned 3-Object detached

  • ms: Maximum waiting time

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.86. Array Suction Cup Control Command Code Example

Added in version python: SDK-v2.1.5

 1from fairino import Robot
 2# Establish connection with robot controller, returns a robot object upon successful connection
 3robot = Robot.RPC('192.168.58.2')
 4robot.OpenLuaUpload("C://Project/PeripheralSDK/CtrlDev_sucker.lua")
 5time.sleep(2)
 6robot.UnloadCtrlOpenLUA(1)
 7robot.LoadCtrlOpenLUA(1)
 8time.sleep(1)
 9ctrl = bytearray(20)
10ctrl[0] = 1
11robot.SetSuckerCtrl(0, 1, ctrl)
12for i in range(100):
13    rtn, state, press_value, error = robot.GetSuckerState(1)
14    print(f"sucker1 state is {state}, pressValue is {press_value}, error num is {error}")
15    rtn, state, press_value, error = robot.GetSuckerState(12)
16    print(f"sucker12 state is {state}, pressValue is {press_value}, error num is {error}")
17    time.sleep(0.1)
18ret = robot.WaitSuckerState(1, 1, 100)
19print(f"WaitSuckerState result is {ret}")
20ctrl[0] = 3
21robot.SetSuckerCtrl(1, 1, ctrl)
22robot.SetSuckerCtrl(12, 1, ctrl)
23robot.CloseRPC()

11.87. Upload Open Protocol Lua File

Added in version python: SDK-v2.1.5

Prototype

OpenLuaUpload(filePath)

Description

Upload open protocol Lua file

Required Parameters

  • filePath: Local open protocol Lua file path name

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.88. Get Slave Station Board Parameters

Added in version python: SDK-v2.1.5

Prototype

GetFieldBusConfig()

Description

Get slave station board parameters

Required Parameters

None

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • type: 0-Ethercat, 1-CClink, 3-Ethercat, 4-EIP

  • version: Protocol version

  • connState: 0-Not connected 1-Connected

11.89. Write Slave Station DO

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveWriteDO(DOIndex, writeNum, status)

Description

Write slave station DO

Required Parameters

  • DOIndex: DO number

  • writeNum: Number to write

  • status: Value to write, maximum 8

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.90. Write Slave Station AO

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveWriteAO(AOIndex, writeNum, status)

Description

Write slave station AO

Required Parameters

  • AOIndex: AO number

  • writeNum: Number to write

  • status: Value to write, maximum 8

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.91. Read Slave Station DI

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveReadDI(DIIndex, readNum)

Description

Read slave station DI

Required Parameters

  • DIIndex: DI number

  • readNum: Number to read

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • status[8]: Read values, maximum 8

11.92. Read Slave Station AI

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveReadAI(AIIndex, readNum)

Description

Read slave station AI

Required Parameters

  • AIIndex: AI number

  • readNum: Number to read

Default Parameters

None

Return Value

  • Error code Success-0 Failure-errcode

  • status[8]: Read values, maximum 8

11.93. Wait for Extended DI Input

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveWaitDI(DIIndex, status, waitMs)

Description

Wait for extended DI input

Required Parameters

  • DIIndex: DI number

  • status: 0-Low level; 1-High level

  • waitMs: Maximum waiting time (ms)

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.94. Wait for Extended AI Input

Added in version python: SDK-v2.1.5

Prototype

FieldBusSlaveWaitAI(AIIndex, waitType, value, waitMs)

Description

Wait for extended AI input

Required Parameters

  • AIIndex: AI number

  • waitType: 0-Greater than; 1-Less than

  • value: AI value

  • waitMs: Maximum waiting time (ms)

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.96. End-Effector Transparent Transmission Function Enable/Disable SDK Interface

Prototype

SetAxleGenComEnable(mode)

Description

Enable end-effector general transparent transmission function

Required Parameters

  • mode: Enable, 0-disable, 1-enable

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.97. End-Effector Transparent Transmission Function Non-Periodic Data Transmission and Reception SDK Interface

Prototype

SndRcvAxleGenComCmdData(len_snd, sndBuff, len_rcv)

Description

End-effector sends non-periodic data and waits for response

Required Parameters

  • len_snd: Length of data to send;

  • sndBuff[]: Data to send;

  • len_rcv: Length of data to receive;

  • rcvBuff[]: Response data;

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.98. Code Example for Non-Periodic Data Communication of DIO Health Care Moxibustion Head Based on End-Effector Transparent Transmission Function

 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')
 6
 7import time
 8
 9
10def testAxleGenCom(self):
11
12    led_on = [0xAB, 0xBA, 0x12, 0x01, 0x01, 0x79]
13    led_off = [0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78]
14    version = [0xAB, 0xBA, 0x11, 0x00, 0x76]
15    state = [0xAB, 0xBA, 0x1B, 0x01, 0xAA, 0x2B]
16    cycleState = [0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78]
17    cnt = 1
18
19    p1Joint = [88.708, -86.178, 140.989, -141.825, -89.162, -49.879]
20    p1Desc = [188.007, -377.850, 260.207, 178.715, 2.823, -131.466]
21    p2Joint = [112.131, -75.554, 126.989, -139.027, -88.044, -26.477]
22    p2Desc = [368.003, -377.848, 260.211, 178.715, 2.823, -131.465]
23
24    exaxisPos = [0, 0, 0, 0]
25    offdese = [0, 0, 0, 0, 0, 0]
26
27    # Enable end-effector transparent transmission function
28    robot.SetAxleGenComEnable(1)
29    robot.SetAxleLuaEnable(1)
30
31    while cnt <= 10000:
32        # Read version number
33        ret,rcvdata = robot.SndRcvAxleGenComCmdData(len_snd=5, sndBuff=version, len_rcv=10)
34        print(ret)
35        print(rcvdata)
36        print(f"hard version : {rcvdata[4]},hard code:{rcvdata[5]}, soft version:{rcvdata[6]} {rcvdata[7]}, soft code:{rcvdata[8]}")
37        if ret != 0:
38            break
39        time.sleep(1)
40        # Read moxibustion head presence status
41        ret,rcvdata = robot.SndRcvAxleGenComCmdData(6, state, 6)
42        print(f"state : {rcvdata[4]} ")
43        time.sleep(1)
44        # Turn on moxibustion head laser
45        ret,rcvdata = robot.SndRcvAxleGenComCmdData(6, led_on, 6)
46        print(f"led on rcv data is: {rcvdata[0]}, {rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}")
47        robot.MoveJ(joint_pos=p1Joint, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=exaxisPos, blendT=-1,
48                        offset_flag=0, offset_pos=offdese)
49        time.sleep(4)
50        # Turn off moxibustion head laser
51        ret, rcvdata = robot.SndRcvAxleGenComCmdData(6, led_off, 6)
52        print(f"led off rcv data is: {rcvdata[0]}, {rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}")
53        robot.MoveJ(joint_pos=p2Joint, tool=0, user=0, vel=100, acc=100, ovl=100, exaxis_pos=exaxisPos, blendT=-1,offset_flag=0, offset_pos=offdese)
54        time.sleep(1)
55        print(f"***********************complate No. {cnt} SDK test*****************************")
56        cnt = cnt + 1
57
58    robot.CloseRPC()
59    return 0
60
61testAxleGenCom(robot)

11.99. Download Open Protocol Lua File

Prototype

OpenLuaDownload(fileName, savePath)

Description

Download open protocol Lua file

Required Parameters

  • fileName: Open protocol file name CtrlDev_XXX.lua;

  • savePath: Path to save the open protocol file;

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.100. Delete Specified Open Protocol Lua File

Prototype

OpenLuaDelete(fileName)

Description

Delete specified open protocol Lua file

Required Parameters

  • fileName: Name of the open protocol Lua file to delete CtrlDev_XXX.lua

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.101. Delete All Open Protocol Lua Files

Prototype

AllOpenLuaDelete()

Description

Delete all open protocol Lua files

Required Parameters

None

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.102. Open Protocol Lua File Operation SDK Code Example

 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 TestCtrlOpenLuaOperate(self):
10    # Upload Lua file to robot
11    rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_WELDING_A.lua")
12    print(f"OpenLuaUpload rtn is {rtn}")
13
14    rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_SWDPOLISH.lua")
15    print(f"OpenLuaUpload rtn is {rtn}")
16
17    # Download Lua file from robot
18    rtn = robot.OpenLuaDownload("CtrlDev_WELDING_A.lua", "D://zDOWN/")
19    print(f"OpenLuaDownload rtn is {rtn}")
20
21    rtn = robot.OpenLuaDownload("CtrlDev_SWDPOLISH.lua", "D://zDOWN/")
22    print(f"OpenLuaDownload rtn is {rtn}")
23
24    # Set control open protocol Lua name
25    rtn = robot.SetCtrlOpenLUAName(0, "CtrlDev_WELDING_A.lua")
26    print(f"SetCtrlOpenLUAName rtn is {rtn}")
27
28    rtn = robot.SetCtrlOpenLUAName(1, "CtrlDev_SWDPOLISH.lua")
29    print(f"SetCtrlOpenLUAName rtn is {rtn}")
30
31    # Get control open protocol Lua name
32    rtn, name = robot.GetCtrlOpenLUAName()
33    print(f"ctrl open lua names : {name[0]}, {name[1]}, {name[2]}, {name[3]}")
34
35    # Load control open protocol Lua
36    rtn = robot.LoadCtrlOpenLUA(1)
37    print(f"LoadCtrlOpenLUA rtn is {rtn}")
38    time.sleep(2)
39
40    # Unload control open protocol Lua
41    rtn = robot.UnloadCtrlOpenLUA(1)
42    print(f"UnloadCtrlOpenLUA rtn is {rtn}")
43
44    # Delete specified Lua file
45    rtn = robot.OpenLuaDelete("CtrlDev_WELDING_A.lua")
46    print(f"OpenLuaDelete rtn is {rtn}")
47
48    # Delete all Lua files
49    rtn = robot.AllOpenLuaDelete()
50    print(f"AllOpenLuaDelete rtn is {rtn}")
51
52    # Close connection
53    robot.CloseRPC()
54    time.sleep(1)
55
56
57# Call test function
58TestCtrlOpenLuaOperate(robot)

11.103. Control Dexterous Hand Motion

Prototype

SetDexterousHandsMove(self, idstart, slaveNum, pos, speed, force, max_time)

Description

Control dexterous hand motion

Required Parameters

  • idstart: Starting slave station number;

  • slaveNum: Number of slaves;

  • pos[16]: Position (-360~360);

  • speed[16]: Speed percentage, range [0~100];

  • force[16]: Torque percentage, range [0~100];

  • max_time: Maximum wait time, range [0~30000], unit ms;

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.104. Control Dexterous Hand Reset and Activation

Prototype

SetDexterousHandsAct(self, id, act)

Description

Control dexterous hand reset and activation

Required Parameters

  • id: Slave station number;

  • act: 0-reset 1-activate

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.105. Clear Dexterous Hand Error

Prototype

ClearDexterousHandsError(self)

Description

Clear dexterous hand error

Required Parameters

None

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.106. Set Enabled Dexterous Hand Action Control Functions

Prototype

SetDexterousHandsFunc(self, id, func)

Description

Set enabled dexterous hand action control functions

Required Parameters

  • id: Dexterous hand slave station number;

  • func: Function array, 32 elements

    0-grip trigger, 1-gripper initialization, 2-position setting, 3-speed setting, 4-torque setting, 6-read gripper status, 7-read initialization status, 8-read fault code, 9-read position, 10-read speed, 11-read torque, 12-rotation count setting, 13-rotation speed setting, 14-rotation torque setting, 15-read rotary gripper status, 16-read rotary initialization status, 17-read rotation count, 18-read rotation speed, 19-read rotation torque, 20-multi-axis synchronous motion setting, 21-fault clear command, 22-single-axis running status, 23-all-axis running status

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.107. Get Enabled Dexterous Hand Action Control Functions

Prototype

GetDexterousHandsFunc(self, id)

Description

Get enabled dexterous hand action control functions

Required Parameters

  • id: Dexterous hand slave station number;

  • func: Function array, 32 elements

    0-grip trigger, 1-gripper initialization, 2-position setting, 3-speed setting, 4-torque setting, 6-read gripper status, 7-read initialization status, 8-read fault code, 9-read position, 10-read speed, 11-read torque, 12-rotation count setting, 13-rotation speed setting, 14-rotation torque setting, 15-read rotary gripper status, 16-read rotary initialization status, 17-read rotation count, 18-read rotation speed, 19-read rotation torque, 20-multi-axis synchronous motion setting, 21-fault clear command, 22-single-axis running status, 23-all-axis running status

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.108. End-Effector Dexterous Hand Configuration and Motion Code Example

 1from fairino import Robot
 2import time
 3robot = Robot.RPC('192.168.58.2')
 4
 5def main(self):
 6
 7    id = 1
 8    slaveNum = 4
 9    max_time = 8000
10    speed = [0] * 16
11    force = [0] * 16
12
13    for i in range(16):
14        force[i] = 50 if i < 4 else 0
15
16    def set_positions(v1, v2, v3, v4):
17        pos = [0.0] * 16
18        pos[0] = v1
19        pos[1] = v2
20        pos[2] = v3
21        pos[3] = v4
22        return pos
23
24    j1 = [-53.426,-85.916,109.280,-86.236,-96.663,-28.560]
25    j2 = [-91.877,-85.917,109.281,-86.236,-96.663,-28.560]
26    epos = [0, 0, 0, 0]
27    offset_pos = [0, 0, 0, 0, 0, 0]
28
29    ret = robot.ClearDexterousHandsError()
30    print(f"ClearDexterousHandsError -> {ret}")
31
32    setFunc = [0] * 32
33    setFunc[2] = 1
34    setFunc[4] = 1
35    setFunc[9] = 1
36    setFunc[10] = 1
37    setFunc[11] = 1
38    setFunc[22] = 1
39
40    ret = robot.SetDexterousHandsFunc(id, setFunc)
41    print(f"SetDexterousHandsFunc(enable + init + position/torque functions enabled) -> {ret}")
42
43    ret, getFunc = robot.GetDexterousHandsFunc(id)
44    print(f"GetDexterousHandsFunc -> {ret}")
45    if ret == 0:
46        print("GetDexterousHandsFunc :")
47        for i in range(len(getFunc)):
48            print(f"  [{i}]={getFunc[i]}", end="")
49            if (i + 1) % 8 == 0:
50                print()
51            elif i < len(getFunc) - 1:
52                print(", ", end="")
53        if len(getFunc) % 8 != 0:
54
55    ret = robot.SetDexterousHandsAct(id, 1)
56    print(f"SetDexterousHandsAct() -> {ret}")
57    if ret != 0:
58        return
59        pos = set_positions(20, 20, 20, 20)
60    ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time)
61    print(f"ret: {ret}")
62    time.sleep(5)
63
64    for iteration in range(1, 11):
65        robot.MoveJ(joint_pos=j1, tool=1, user=0, vel=100, acc=100, ovl=100,
66                    exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
67
68        pos = set_positions(10, 10, 10, 10)
69        ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time)
70        time.sleep(1)
71
72        robot.MoveJ(joint_pos=j2, tool=1, user=0, vel=100, acc=100, ovl=100,
73                    exaxis_pos=epos, blendT=-1, offset_flag=0, offset_pos=offset_pos)
74
75        pos = set_positions(50, 50, 50, 50)
76        ret = robot.SetDexterousHandsMove(id, slaveNum, pos, speed, force, max_time)
77        time.sleep(1)
78
79main(robot)

11.109. Wait for Gripper Motion Status

Prototype

GripperWaitMotionDone(self, status, timeout, strategy, type)

Description

Wait for gripper motion status

Required Parameters

  • status:0-motion not completed, 1-motion completed with no object detected, 2-motion completed with object detected 3-Motion completed and object dropped detected

  • timeout:Timeout (ms), -1 for infinite wait

  • strategy:0-stop with error, 1-continue running

  • type:0-parallel gripper, 1-rotary gripper

Default Parameters

None

Return Value

Error code, 0-success; non-zero-error

11.110. Wait for Gripper Motion Status Code Example

 1from fairino import Robot
 2import time
 3
 4def main():
 5    # Establish connection with the robot controller
 6    robot = Robot.RPC('192.168.58.2')
 7    time.sleep(0.5)  # Wait for connection and data reception
 8
 9    print("========== Gripper Motion Done Test ==========")
10
11    # Open the gripper
12    rtn = robot.MoveGripper(2, 50, 50, 100, 30000, 0, 0, 0, 0, 0)
13    print(f"MoveGripper(open) ret={rtn}")
14    time.sleep(2)
15    rtn, pkg = robot.GetRobotRealTimeState()
16    print(f"gripper_motiondone {pkg.gripper_motiondone}")
17
18    # Close the gripper
19    rtn = robot.MoveGripper(2, 90, 100, 100, 30000, 0, 0, 0, 0, 0)
20    print(f"MoveGripper(close) ret={rtn}")
21    time.sleep(2)
22    rtn, pkg = robot.GetRobotRealTimeState()
23    print(f"gripper_motiondone {pkg.gripper_motiondone}")
24
25    # Wait for motion done, no object detected, timeout 5s, stop with error
26    rtn = robot.GripperWaitMotionDone(2, 5000, 0, 0)
27    print(f"GripperWaitMotionDone(no object detected) ret={rtn}")
28
29    # Loop and query gripper motion status
30    while True:
31        rtn, status = robot.GetGripperMotionDone()
32        print(f"motion status:{status[0]},{status[1]}\n")
33
34        rtn, pkg = robot.GetRobotRealTimeState()
35        print(f"error code {pkg.main_code},{pkg.sub_code}")
36
37        time.sleep(0.5)
38
39    # Close connection (never reached due to infinite loop)
40    robot.CloseRPC()
41
42if __name__ == "__main__":
43    main()

11.111. Laser Recording Replay + Extended Axis Asynchronous Motion + Fixed-Point Weave Code Example

 1def test_laser_record_replay_exaxis_with_wave():
 2print("\n========== Laser Recording Replay + Extended Axis Asynchronous Motion + Fixed-Point Weave ==========")
 3
 4startjointPos = [105.600,-65.393,-93.638,-79.687,79.175,134.046]
 5startdescPose = [42.376,533.597,362.564,-34.957,-0.564,169.063]
 6endjointPos = [105.600,-65.393,-93.638,-79.687,79.175,134.046]
 7enddescPose = [42.376,533.597,362.564,-34.957,-0.564,169.063]
 8offdese = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 9
10# MoveJ to safe point (Extended axis 0,134.296,0,0)
11rtn = robot.MoveJ(joint_pos=startjointPos, desc_pos=startdescPose, tool=5, user=0,
12                    vel=100, acc=100, ovl=50, exaxis_pos=[0, 134.296, 0, 0],
13                    blendT=-1, offset_flag=0, offset_pos=offdese)
14print(f"MoveJ start: {rtn}")
15
16# Extended axis asynchronous motion to start point 74.335
17rtn = robot.ExtAxisMove([0, 74.335, 0, 0], 50, -1)
18print(f"ExtAxisMove 74.335: {rtn}")
19time.sleep(3)
20
21# MoveL to start point
22rtn = robot.MoveL(joint_pos=endjointPos, desc_pos=enddescPose, tool=5, user=0,
23                    vel=100, acc=100, ovl=50, blendR=-1, offset_flag=0,
24                    exaxis_pos=[0, 74.335, 0, 0], search=0,
25                    offset_pos=offdese)
26print(f"MoveL end: {rtn}")
27
28# Start laser recording
29rtn = robot.LaserSensorRecord1(2, 10)
30print(f"LaserSensorRecord start: {rtn}")
31
32# Extended axis moves to 134.296 during recording
33rtn = robot.ExtAxisMove([0, 134.296, 0, 0], 50, -1)
34print(f"ExtAxisMove 134.296: {rtn}")
35time.sleep(3)
36
37# Stop laser recording
38rtn = robot.LaserSensorRecord1(0, 10)
39print(f"LaserSensorRecord stop: {rtn}")
40
41# Extended axis returns to 74.335, MoveL back to start point
42rtn = robot.ExtAxisMove([0, 74.335, 0, 0], 50, -1)
43print(f"ExtAxisMove back: {rtn}")
44
45# MoveL to start point
46rtn = robot.MoveL(joint_pos=endjointPos, desc_pos=enddescPose, tool=5, user=0,
47                    vel=100, acc=100, ovl=50, blendR=-1, offset_flag=0,
48                    exaxis_pos=[0, 74.335, 0, 0], search=0,
49                    offset_pos=offdese)
50print(f"MoveL back: {rtn}")
51
52# PTP move to laser record weld start point
53rtn = robot.MoveToLaserRecordStart(0, 30)
54print(f"MoveToLaserRecordStart: {rtn}")
55
56# Start replay
57rtn = robot.LaserSensorRecord1(3, 10)
58print(f"LaserSensorRecord replay: {rtn}")
59
60# Start fixed-point weave
61refPoint = [49.381,533.608,362.556,-34.961,-0.564,169.062]
62rtn = robot.OriginPointWeaveStart(0, 1, refPoint, 5)
63print(f"OriginPointWeaveStart: {rtn}")
64
65# Extended axis moves to 134.296 during weaving
66rtn = robot.ExtAxisMove([0, 134.296, 0, 0], 50, -1)
67print(f"ExtAxisMove replay: {rtn}")
68
69# Stop weave
70rtn = robot.OriginPointWeaveEnd()
71print(f"OriginPointWeaveEnd: {rtn}")
72
73# Stop replay
74rtn = robot.LaserSensorRecord1(0, 10)
75print(f"LaserSensorRecord stop: {rtn}")

11.112. Laser Recording Replay + Normal Weave Code Example

 1def test_laser_reproduce_normal_weave():
 2print("\n========== Laser Recording Replay + Normal Weave ==========")
 3
 4startjointPos = [68.930,-70.217,-121.821,-75.522,91.216,137.289]
 5startdescPose = [216.097,304.517,34.164,-3.871,0.792,132.864]
 6endjointPos = [58.092,-78.843,-115.569,-73.420,91.662,126.457]
 7enddescPose = [296.276,307.453,34.803,-3.868,0.783,132.864]
 8offdese = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 9
10time.sleep(1)
11
12# MoveL to start position (Extended axis 0,174.957,0,0)
13rtn = robot.MoveL(joint_pos=startjointPos, desc_pos=startdescPose, tool=5, user=0,
14                    vel=100, acc=100, ovl=100, blendR=-1, offset_flag=0,
15                    exaxis_pos=[0, 174.957, 0, 0], search=0,
16                    offset_pos=offdese)
17print(f"MoveL start: {rtn}")
18
19# Start laser recording
20rtn = robot.LaserSensorRecord1(2, 10)
21print(f"LaserSensorRecord start: {rtn}")
22
23# MoveL to end position
24rtn = robot.MoveL(joint_pos=endjointPos, desc_pos=enddescPose, tool=5, user=0,
25                    vel=100, acc=100, ovl=100, blendR=-1, offset_flag=0,
26                    exaxis_pos=[0, 174.957, 0, 0], search=0,
27                    offset_pos=offdese)
28print(f"MoveL end: {rtn}")
29
30# Stop laser recording
31rtn = robot.LaserSensorRecord1(0, 10)
32print(f"LaserSensorRecord stop: {rtn}")
33
34# MoveL back to start position
35rtn = robot.MoveL(joint_pos=startjointPos, desc_pos=startdescPose, tool=5, user=0,
36                    vel=100, acc=100, ovl=100, blendR=-1, offset_flag=0,
37                    exaxis_pos=[0, 174.957, 0, 0], search=0,
38                    offset_pos=offdese)
39print(f"MoveL back: {rtn}")
40
41# LIN move to laser record weld start point
42rtn = robot.MoveToLaserRecordStart(1, 30)
43print(f"MoveToLaserRecordStart: {rtn}")
44
45# Start normal weave
46rtn = robot.WeaveStart(0)
47print(f"WeaveStart: {rtn}")
48
49# Start record replay
50rtn = robot.LaserSensorRecord1(3, 10)
51print(f"LaserSensorRecord replay: {rtn}")
52
53# Laser track replay motion
54rtn = robot.MoveLTR()
55print(f"MoveLTR: {rtn}")
56time.sleep(3)
57
58# Stop record replay
59rtn = robot.LaserSensorRecord1(0, 10)
60print(f"LaserSensorRecord stop: {rtn}")
61
62# Stop normal weave
63rtn = robot.WeaveEnd(0)
64print(f"WeaveEnd: {rtn}")

11.113. Set Enable End Suction Cup Action Control Function Codes

Prototype

SetAxleSuckerFunc(self, id, func)

Description

Set enable end suction cup action control function codes

Required Parameters

  • id: Station number

  • func: Function code array, length 16, indices 0~15 correspond to Bit0~Bit15, 0-suction cup initialization; 1-set channel 1 maximum vacuum; 2-set channel 1 minimum vacuum;

3-set channel 2 maximum vacuum; 4-set channel 2 minimum vacuum; 5-read channel 1 status; 6-read channel 2 status; 7-read initialization status; 8-read fault code; 9-read channel 1 actual vacuum; 10-read channel 2 actual vacuum; 11-channel 1 control enable; 12-channel 2 control enable; Each item: 0-not enabled; 1-enabled

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.114. Get End Suction Cup Action Control Function Codes

Prototype

GetAxleSuckerFunc(self, id)

Description

Get end suction cup action control function codes

Required Parameters

None

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode - id: Station number - func: Function code array, length 16, indices 0~15 correspond to Bit0~Bit15, meaning same as SetAxleSuckerFunc

11.115. Set End Suction Cup Control Parameters

Prototype

SetAxleSuckerCtrl(self, id, channel, minPress, maxPress, time)

Description

Set end suction cup control parameters

Required Parameters

  • id: Station number

  • channel: Channel enable, length 4: channel[0]=1-enabled, 0-not enabled (indices 0-3 correspond to channel 1-channel 4)

  • minPress: Minimum vacuum, length 4

  • maxPress: Maximum vacuum (suction cup error code), length 4

  • time: Timeout time (ms)

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.116. Activate/Reset Suction Cup

Prototype

SetAxleSuckerAct(self, id, act)

Description

Activate/reset suction cup

Required Parameters

  • id: Station number

  • act: 1-activate; 0-reset

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.117. Get End Suction Cup Status

Prototype

GetAxleSuckerState(self, channel)

Description

Get end suction cup status

Required Parameters

  • channel: Suction cup channel; 0-3 (corresponding to channel 1-channel 4)

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode - enable: Activation status - done: Suction completion status - vacuumValue: Vacuum value - error: Suction cup error code

11.118. Wait for End Suction Cup Suction Completion Signal

Prototype

WaitAxleSuckerState(self, channel, timeout, state, strategy)

Description

Wait for end suction cup suction completion signal

Required Parameters

  • channel: Suction cup channel; 0-3 (corresponding to channel 1-channel 4)

  • timeout: Timeout time (ms), -1 means wait forever

  • state: State: 0-no object suctioned; 1-object suctioned; 2-object detached

  • strategy: Timeout strategy: 0-error stop; 1-continue running

Default Parameters

None

Return Value

Error code Success-0 Failure-errcode

11.119. End Suction Cup Interface Code Example

  1from fairino import Robot
  2import time
  3
  4
  5def main():
  6    # Establish connection with the robot controller
  7    robot = Robot.RPC('192.168.58.2')
  8    time.sleep(0.5)  # Wait for connection and data reception
  9
 10    print("========== End Sucker Interface Test ==========")
 11
 12    # Define motion points
 13    j1 = [168.610, -49.414, 19.171, -59.520, -90.466, -9.516]
 14    j2 = [168.610, -53.606, 31.351, -67.508, -90.466, -9.516]
 15    d1 = [725.139, -42.866, 573.293, 179.690, -0.420, -91.872]
 16    d2 = [725.147, -42.866, 543.279, 179.689, -0.421, -91.872]
 17    ex = [0.0, 0.0, 0.0, 0.0]
 18    zeroOff = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 19
 20    id = 1  # Slave station number
 21
 22    # ========== Enable end device: enable sucker and read back ==========
 23    rtn, forceEn, gripEn, ioEn, dexEn, suckEn = robot.GetAxleLuaEnableDeviceType()
 24    print(f"GetAxleLuaEnableDeviceType rtn={rtn}, force={forceEn}, gripper={gripEn}, io={ioEn}, dexhand={dexEn}, sucker={suckEn}")
 25
 26    rtn = robot.SetAxleLuaEnableDeviceType(forceEn, gripEn, ioEn, dexEn, 1)
 27    print(f"SetAxleLuaEnableDeviceType(sucker=1): {rtn}")
 28
 29    rtn, forceEn, gripEn, ioEn, dexEn, suckEn = robot.GetAxleLuaEnableDeviceType()
 30    print(f"GetAxleLuaEnableDeviceType(after set) rtn={rtn}, sucker={suckEn}")
 31
 32    # ========== Get enable device arrays ==========
 33    rtn, forceArr, gripperArr, ioArr, dexArr, suckArr = robot.GetAxleLuaEnableDevice()
 34    print(f"GetAxleLuaEnableDevice rtn={rtn}, sucker={suckArr}")
 35
 36    # ========== Set sucker function codes ==========
 37    # func[0]~func[12] correspond to Bit0~Bit12, all enabled
 38    # func[11]=Bit11-channel1 control enable, func[12]=Bit12-channel2 control enable
 39    suckerFunc = [0] * 16
 40    for i in range(13):
 41        suckerFunc[i] = 1
 42
 43    rtn = robot.SetAxleSuckerFunc(id, suckerFunc)
 44    print(f"SetAxleSuckerFunc: {rtn}")
 45
 46    # Read back 16 function codes
 47    rtn, funcValue = robot.GetAxleSuckerFunc(id)
 48    print(f"GetAxleSuckerFunc rtn={rtn}, value={funcValue}")
 49
 50    # ========== Reset and activate sucker ==========
 51    rtn = robot.SetAxleSuckerAct(id, 0)  # 0-reset
 52    print(f"SetAxleSuckerAct(0): {rtn}")
 53
 54    rtn = robot.SetAxleSuckerAct(id, 1)  # 1-activate
 55    print(f"SetAxleSuckerAct(1): {rtn}")
 56
 57    time.sleep(2)
 58
 59    # ========== Move to suction position ==========
 60    rtn = robot.MoveL(desc_pos=d2, tool=0, user=0, joint_pos=j2,
 61                    vel=100, acc=100, ovl=100, blendR=-1, blendMode=0,
 62                    exaxis_pos=ex, search=0, offset_flag=0, offset_pos=zeroOff,
 63                    oacc=100, config=0, velAccParamMode=0, overSpeedStrategy=0, speedPercent=10)
 64    print(f"moveL errcode:{rtn}")
 65
 66    # ========== Set sucker control parameters ==========
 67    channel = [1, 1, 0, 0]     # 1-enable, 0-disable
 68    minPress = [60, 60, 0, 0]  # Minimum vacuum pressure
 69    maxPress = [70, 70, 0, 0]  # Maximum vacuum pressure
 70    rtn = robot.SetAxleSuckerCtrl(id, channel, minPress, maxPress, 6000)
 71    print(f"SetAxleSuckerCtrl: {rtn}")
 72
 73    # Wait channel 1 (channel=0) to pick object
 74    rtn = robot.WaitAxleSuckerState(0, 6000, 1, 0)
 75    print(f"WaitAxleSuckerState ch0 pick: {rtn}")
 76
 77    # Wait channel 2 (channel=1) to pick object
 78    rtn = robot.WaitAxleSuckerState(1, 6000, 1, 0)
 79    print(f"WaitAxleSuckerState ch1 pick: {rtn}")
 80
 81    # ========== Query sucker state for 10 cycles ==========
 82    count = 10
 83    for i in range(count):
 84        # channel 0~3 correspond to channels 1~4, print first two channels
 85        for ch in range(2):
 86            rtn, enable, done, vacuumValue, error = robot.GetAxleSuckerState(ch)
 87            print(f"[{i + 1}/{count}] Channel{ch + 1}(channel={ch}) rtn={rtn}, "
 88                f"enable={enable}, done={done}, vacuumValue={vacuumValue}, error={error}")
 89        time.sleep(0.5)
 90        print(f"00000: {rtn}")
 91
 92    print(f"11111111: {rtn}")
 93
 94    # ========== Move to lift position ==========
 95    rtn = robot.MoveL(desc_pos=d1, tool=0, user=0, joint_pos=j1,
 96                    vel=100, acc=100, ovl=100, blendR=-1, blendMode=0,
 97                    exaxis_pos=ex, search=0, offset_flag=0, offset_pos=zeroOff,
 98                    oacc=100, config=0, velAccParamMode=0, overSpeedStrategy=0, speedPercent=10)
 99    print(f"moveL errcode:{rtn}")
100
101    # ========== Close all channels after waiting ==========
102    channel = [0, 0, 0, 0]
103    rtn = robot.SetAxleSuckerCtrl(id, channel, minPress, maxPress, 8000)
104    print(f"SetAxleSuckerCtrl(close channels): {rtn}")
105
106    # Wait channel 1 (channel=0) to release object
107    rtn = robot.WaitAxleSuckerState(0, 6000, 0, 0)
108    print(f"WaitAxleSuckerState ch0 release: {rtn}")
109
110    # Wait channel 2 (channel=1) to release object
111    rtn = robot.WaitAxleSuckerState(1, 6000, 0, 0)
112    print(f"WaitAxleSuckerState ch1 release: {rtn}")
113
114    # Close connection
115    robot.CloseRPC()
116
117
118if __name__ == "__main__":
119    main()