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 state of the jaw motion

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • [fault,status]: status of gripper movement, fault:0-no error, 1-with error; status:0-movement not completed, 1-movement completed

11.6. Obtain the activated status of the gripper

New 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

New 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

New 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

New 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

New 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

New 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

New 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

New 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

New 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

  • followType: Track movement type, 0- track movement; 1- Follow-up campaign

Default parameters

  • startDis: Tracking grasp needs to be set, tracking start distance, -1: automatic calculation (automatic tracking after the workpiece reaches the robot), the unit is mm, the default value is 0

  • endDis: The tracking capture needs to be set. The tracking termination distance, in mm, is 100 by default

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

New 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

New 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. End Sensor Configuration

New 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.35. Get End Sensor Configuration

New 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.36. End sensor activation

New 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.37. End Sensor Register Write

New 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.38. 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.39. Obtaining Robot Peripheral Protocols

New 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.40. Setting up robot peripheral protocols

New 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.41. 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.42. Getting end communication parameters

New 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.43. Setting the end communication parameters

New 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.44. Setting the end file transfer type

New 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.45. Setting Enable End LUA Execution

New 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.46. End LUA file exception error recovery

New 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.47. Get end LUA execution enable status

New 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.48. Setting the end LUA end device enable type

New in version python: SDK-v2.0.5

prototype

SetAxleLuaEnableDeviceType(forceSensorEnable, gripperEnable, IOEnable)

Description

Set end LUA end device enable type

Mandatory 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

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.49. Get End LUA End Device Enablement Type

New in version python: SDK-v2.0.5

Prototype

GetAxleLuaEnableDeviceType()

Description

Get End LUA End Device Enablement Type

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode 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

11.50. Get the currently configured end device

New in version python: SDK-v2.0.5

Prototype

GetAxleLuaEnableDevice()

Description

Get the currently configured end device

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • forceSensorEnable[8]: force sensor enable state, 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

11.51. Setting to enable the jaw movement control function

New in version python: SDK-v2.0.5

Prototype

SetAxleLuaGripperFunc(id, func)

Description

Set to enable the jaw motion control function

Mandatory parameters

  • id: gripper device number

  • func: 0-jaw enable; 1-jaw initialization; 2-position setting; 3-speed setting; 4-torque setting; 6-reading the jaw status; 7-reading the initialization status; 8-reading the fault code; 9-reading the position; 10-reading the speed; 11-reading the torque,12-15 reserved

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

11.52. Getting to Enable Jaw Motion Control

New in version python: SDK-v2.0.5

Prototype

GetAxleLuaGripperFunc(id)

Description

Get the Enable Jaw Motion Control function

Mandatory parameter

  • id: gripper device number

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • func: 0-jaw enable; 1-jaw initialization; 2-position setting; 3-speed setting; 4-torque setting; 6-reading the jaw status; 7-reading the initialization status; 8-reading the fault code; 9-reading the position; 10-reading the speed; 11-reading the torque,12-15 reserved

11.53. The Ethercat slave file is written by the robot

New 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.54. Upload the end Lua open protocol file

New 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.55. The robot Ethercat enters boot mode from the station

New 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.56. 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.57. Obtain the status of the SmartTool button

New 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.58. 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.59. Set the load detection before drag is started

New 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.60. Laser peripheral open and close function

New 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.61. Laser tracking start-end function

New 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.62. Laser positioning - Fixed direction

New 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.63. Laser positioning - in any direction

New 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.64. Laser IP configuration

New 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.65. Configuration of sampling period for laser peripherals

New 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.66. Laser peripheral driver loading

New 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.67. Laser peripheral driver unloading

New 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.68. Laser weld seam trajectory recording

New 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.69. Laser weld seam trajectory reproduction

New 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.70. Laser tracking reproduction

New 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.71. Laser weld seam trajectory reproduction

New 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.72. Movement to the starting point of weld record

New 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.73. Movement to the end of the weld record

New 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.74. Move to the laser sensor to find the site

New 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.75. Obtain the coordinate information of the laser sensor location

New 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.76. 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.77. 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.78. 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.79. 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.80. Control Array Suction Cup

New 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.81. Get Array Suction Cup Status

New 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.82. Wait for Suction Cup Status

New 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.83. Array Suction Cup Control Command Code Example

New 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.84. Upload Open Protocol Lua File

New 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.85. Get Slave Station Board Parameters

New 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.86. Write Slave Station DO

New 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.87. Write Slave Station AO

New 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.88. Read Slave Station DI

New 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.89. Read Slave Station AI

New 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.90. Wait for Extended DI Input

New 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.91. Wait for Extended AI Input

New 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.93. 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.94. 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.95. 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.96. 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.97. 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.98. 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.99. 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)