3. Robotics Basics

3.1. Instantiated Robot

Prototype

RPC(ip)

Description

Instantiating a robot object

Required parameter

  • ip:The IP address of the robot, with a default factory IP of “192.168.58.2”

Optional parameter

NULL

Return value

  • Success: Returns a robot object

  • Failed: The created object will be destroyed

3.2. Close the RPC connection

Prototype

CloseRPC()

Description

Close RPC connection

Mandatory parameters

NULL

Default parameters

NULL

Return Value

NULL

3.3. Query SDK version number

prototype

GetSDKVersion()

Description

Query SDK version number

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • Error Code Success-0 Fail-errcode

  • sdk: SDK version number, controller version number

3.4. Get controller IP

Prototype

GetControllerIP()

Description

Query Controller IP

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • ip: controller IP

3.5. Controlling the robot into and out of drag-and-drop instructor mode

Prototype

DragTeachSwitch(state)

Description

Controls the robot into and out of drag-and-drop demonstration mode.

Mandatory parameter

  • state: 1-entry into drag-indicator mode, 0-exit from drag-indicator mode

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

3.6. Queries whether the robot is in drag mode

Prototype

IsInDragTeach()

Description

Queries whether the robot is in drag-and-drop demonstration mode.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • state: 0 - non-drag instructional mode, 1 - drag instructional mode

3.7. Control robot up-enable or down-enable

prototype

RobotEnable(state)

Description

Control robot up-enable or down-enable

Mandatory parameters

  • state: 1 - up enable, 0 - down enable

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

3.8. Control of robot hand-automatic mode switching

prototype

Mode(state)

description

control robot hand auto mode switching

Mandatory parameters

  • state: 0 - automatic mode, 1 - manual mode

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

3.9. Shut down the robot operating system

New in version python: SDK-v2.1.1

Prototype

ShutDownRobotOS()

Description

Shut down the robot operating system

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

3.10. Initialize the log parameters

New in version python: SDK-v2.1.1

Prototype

LoggerInit(output_model=1, file_path=", file_num=5)

Description

Initialize the log parameters

Mandatory parameters

NULL

Default parameters

  • output_model:Output mode, 0- Direct output; 1- Buffered output; 2- Asynchronous output, default 1

  • file_path:File path + name, the name must be XXX. The log form, such as/home/fr. / Linux/fairino log. The default path where the program is executed, with the default name fairino_year +month+data.log(e.g., fairino_2024_03_13.log);

  • file_num:The number of files for rolling storage ranges from 1 to 20, with a default value of 5. The upper limit for a single file is 50M.

Return Value

Error Code Success-0 Failure- errcode

3.11. Setting the log filter level

New in version python: SDK-v2.0.2

Prototype

SetLoggerLevel(lvl=1)

Description

Set log filter level

Mandatory parameters

NULL

Default Parameters

  • lvl: filter level value, the smaller the value the less output logs, 1-error, 2-warnning, 3-inform, 4-debug, default value is 1

Return Value

Error Code Success-0 Failure- errcode

3.12. Robot base control 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')
 4error,version = robot.GetSDKVersion()
 5print(f"SDK version: {version}")
 6error,ip = robot.GetControllerIP()
 7print(f"controller ip: {ip}")
 8robot.Mode(1)
 9time.sleep(1)
10robot.DragTeachSwitch(state=1)
11time.sleep(1)
12error,state = robot.IsInDragTeach()
13print(f"drag state: {state}")
14time.sleep(3)
15robot.DragTeachSwitch(state=0)
16time.sleep(1)
17error,state = robot.IsInDragTeach()
18print(f"drag state: {state}")
19time.sleep(3)
20robot.RobotEnable(0)
21time.sleep(3)
22robot.RobotEnable(1)
23robot.Mode(0)
24time.sleep(1)
25robot.Mode(1)
26robot.CloseRPC()

3.13. Get the software version of the robot

New in version python: SDK-v2.0.1

Prototype

GetSoftwareVersion()

Description

Get the software version of the robot

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • robotModel: robot model

  • webVersion: web version

  • controllerVersion: controller version

3.14. Getting robot hardware version information

New in version python: SDK-v2.0.1

Prototype

GetSlaveHardVersion()

Description

Get robot hardware version information

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • ctrlBoxBoardVersion: control box version

  • driver1Version

  • driver2Version

  • driver3Version

  • driver4Version

  • driver5Version

  • driver6Version

  • endBoardVersion

3.15. Getting robot firmware version information

New in version python: SDK-v2.0.1

Prototype

GetSlaveFirmVersion()

Description

Get information about the robot’s firmware version.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • ctrlBoxBoardVersion: control box version

  • driver1Version

  • driver2Version

  • driver3Version

  • driver4Version

  • driver5Version

  • driver6Version

  • endBoardVersion

3.16. Get the robot software firmware version code sample

 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')
 4rtn,robotModel, webversion, controllerVersion = robot.GetSoftwareVersion()
 5print(f"Getsoftwareversion rtn is: {rtn}")
 6print(f"robotmodel is: {robotModel}, webversion is: {webversion}, controllerVersion is: {controllerVersion}\n")
 7rtn,ctrlBoxBoardversion, driver1version, driver2version,driver3version, driver4version, driver5version,driver6version, endBoardversion = robot.GetHardwareversion()
 8print(f"GetHardwareversion rtn is: {rtn}")
 9print(f"GetHardwareversion get hardware version is: {ctrlBoxBoardversion}, {driver1version}, {driver2version}, "
10      f"{driver3version}, {driver4version}, {driver5version}, {driver6version}, {endBoardversion}\n")
11rtn,ctrlBoxBoardversion, driver1version, driver2version,driver3version, driver4version, driver5version,driver6version, endBoardversion = robot.GetFirmwareVersion()
12print(f"GetFirmwareversion rtn is: {rtn}")
13print(f"GetFirmwareversion get firmware version is: {ctrlBoxBoardversion}, {driver1version}, {driver2version}, "
14      f"{driver3version}, {driver4version}, {driver5version}, {driver6version}, {endBoardversion}\n")
15robot.CloseRPC()