16. Other Interfaces

16.1. Get SSH Public Key

1/**
2* @brief Get SSH public key
3* @param [out] keygen Public key
4* @return Error code
5*/
6errno_t GetSSHKeygen(char keygen[1024]);

16.2. Send SCP Command

 1/**
 2* @brief Send SCP command
 3* @param [in] mode 0-Upload (host->controller), 1-Download (controller->host)
 4* @param [in] sshname Host username
 5* @param [in] sship Host IP address
 6* @param [in] usr_file_url Host file path
 7* @param [in] robot_file_url Robot controller file path
 8* @return Error code
 9*/
10errno_t SetSSHScpCmd(int mode, char sshname[32], char sship[32], char usr_file_url[128], char robot_file_url[128]);

16.3. Calculate MD5 Value of Specified File

1/**
2* @brief Calculate MD5 value of specified file
3* @param [in] file_path File path including filename, default Traj folder path: "/fruser/traj/", e.g. "/fruser/traj/trajHelix_aima_1.txt"
4* @param [out] md5 File MD5 value
5* @return Error code
6*/
7errno_t ComputeFileMD5(char file_path[256], char md5[256]);

16.4. Robot SSH/MD5 Command Code Example

 1int TestSSHMd5(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  char file_path[256] = "/fruser/airlab.lua";
14  char md5[256] = { 0 };
15  uint8_t emerg_state = 0;
16  uint8_t si0_state = 0;
17  uint8_t si1_state = 0;
18  int sdk_com_state = 0;
19  char ssh_keygen[1024] = { 0 };
20  int retval = robot.GetSSHKeygen(ssh_keygen);
21  printf("GetSSHKeygen retval is: %d\n", retval);
22  printf("ssh key is: %s \n", ssh_keygen);
23  char ssh_name[32] = "fr";
24  char ssh_ip[32] = "192.168.58.45";
25  char ssh_route[128] = "/home/fr";
26  char ssh_robot_url[128] = "/root/robot/dhpara.config";
27  retval = robot.SetSSHScpCmd(1, ssh_name, ssh_ip, ssh_route, ssh_robot_url);
28  printf("SetSSHScpCmd retval is: %d\n", retval);
29  printf("robot url is: %s\n", ssh_robot_url);
30  robot.ComputeFileMD5(file_path, md5);
31  printf("md5 is: %s \n", md5);
32  robot.CloseRPC();
33  return 0;
34}

16.5. Set Robot Port 20004 Feedback Cycle

New in version C++SDK-v2.1.5.0.

1/**
2* @brief Set robot port 20004 feedback cycle
3* @param [in] period Robot port 20004 feedback cycle (ms)
4* @return Error code
5*/
6errno_t SetRobotRealtimeStateSamplePeriod(int period);

16.6. Get Robot Port 20004 Feedback Cycle

New in version C++SDK-v2.1.5.0.

1/**
2* @brief Get robot port 20004 feedback cycle
3* @param [out] period Robot port 20004 feedback cycle (ms)
4* @return Error code
5*/
6errno_t GetRobotRealtimeStateSamplePeriod(int& period);

16.7. Robot Port 20004 State Feedback Cycle Configuration Example

 1int TestRealtimePeriod(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  robot.SetRobotRealtimeStateSamplePeriod(10);
14  int getPeriod = 0;
15  robot.GetRobotRealtimeStateSamplePeriod(getPeriod);
16  cout << "period is " << getPeriod << endl;
17  robot.Sleep(1000);
18  robot.CloseRPC();
19  return 0;
20}

16.8. Robot Software Upgrade

New in version C++SDK-v2.1.5.0.

1/**
2* @brief Robot software upgrade
3* @param [in] filePath Full path of software upgrade package
4* @param [in] block Whether to block until upgrade completes (true: block; false: non-block)
5* @return Error code
6*/
7errno_t SoftwareUpgrade(std::string filePath, bool block);

16.9. Get Robot Software Upgrade Status

New in version C++SDK-v2.1.5.0.

1/**
2* @brief Get robot software upgrade status
3* @param [out] state Robot software upgrade status (0-Idle or uploading upgrade package; 1~100: Upgrade completion percentage; -1: Upgrade failed; -2: Verification failed; -3: Version verification failed; -4: Decompression failed; -5: User configuration upgrade failed; -6: Peripheral configuration upgrade failed; -7: Extended axis configuration upgrade failed; -8: Robot configuration upgrade failed; -9: DH parameter configuration upgrade failed)
4* @return Error code
5*/
6errno_t GetSoftwareUpgradeState(int &state);

16.10. Robot Software Upgrade Code Example

 1int TestUpgrade(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(3);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  robot.SoftwareUpgrade("D://zUP/QNX/software.tar.gz", false);
14  while (true)
15  {
16    int curState = -1;
17    robot.GetSoftwareUpgradeState(curState);
18    printf("upgrade state is %d\n", curState);
19    robot.Sleep(300);
20  }
21  robot.CloseRPC();
22  return 0;
23}

16.11. Download Point Table Database

New in version C++SDK-v2.1.1.0.

1/**
2* @brief Download point table database
3* @param [in] pointTableName Point table name to download    pointTable1.db
4* @param [in] saveFilePath Storage path for downloaded point table   C://test/
5* @return Error code
6*/
7errno_t PointTableDownLoad(const std::string &pointTableName, const std::string &saveFilePath);

16.12. Upload Point Table Database

New in version C++SDK-v2.1.1.0.

1/**
2* @brief Upload point table database
3* @param [in] pointTableFilePath Full path name of point table to upload   C://test/pointTable1.db
4* @return Error code
5*/
6errno_t PointTableUpLoad(const std::string &pointTableFilePath);

16.13. Update Lua File for Point Table

New in version C++SDK-v2.1.1.0.

1/**
2* @brief Update Lua file for point table
3* @param [in] pointTableName Point table name to switch to   "pointTable1.db", when empty (""), means updating Lua program to initial program without applied point table
4* @param [in] luaFileName Lua file name to update   "testPointTable.lua"
5* @param [out] errorStr Error message for switching point table
6* @return Error code
7*/
8errno_t PointTableUpdateLua(const std::string &pointTableName, const std::string &luaFileName);

16.14. Robot Point Table Operation Code Example

 1int TestPointTable(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  string save_path = "D://zDOWN/";
14  string point_table_name = "point_table_FR5.db";
15  rtn = robot.PointTableDownLoad(point_table_name, save_path);
16  cout << "download : " << point_table_name << " fail: " << rtn << endl;
17  string upload_path = "D://zUP/point_table_FR5.db";
18  rtn = robot.PointTableUpLoad(upload_path);
19  cout << "retval is: " << rtn << endl;
20  string point_tablename = "point_table_FR5.db";
21  string lua_name = "airlab.lua";
22  rtn = robot.PointTableUpdateLua(point_tablename, lua_name);
23  cout << "retval is: " << rtn << endl;
24  robot.CloseRPC();
25  return 0;
26}

16.15. Controller Log Download

New in version C++SDK-v2.2.1-3.8.1.

1/**
2* @brief Controller log download
3* @param [in] savePath Save file path "D://zDown/"
4* @return Error code
5*/
6errno_t RbLogDownload(std::string savePath);

16.16. All Data Source Download

New in version C++SDK-v2.2.1-3.8.1.

1/**
2* @brief All data source download
3* @param [in] savePath Save file path "D://zDown/"
4* @return Error code
5*/
6errno_t AllDataSourceDownload(std::string savePath);

16.17. Data Backup Package Download

New in version C++SDK-v2.2.1-3.8.1.

1/**
2* @brief Data backup package download
3* @param [in] savePath Save file path "D://zDown/"
4* @return Error code
5*/
6errno_t DataPackageDownload(std::string savePath);

16.18. Download Controller Data Code Example

 1int TestDownLoadRobotData(void)
 2{
 3  ROBOT_STATE_PKG pkg = {};
 4  FRRobot robot;
 5  robot.LoggerInit();
 6  robot.SetLoggerLevel(1);
 7  int rtn = robot.RPC("192.168.58.2");
 8  if (rtn != 0)
 9  {
10    return -1;
11  }
12  robot.SetReConnectParam(true, 30000, 500);
13  rtn = robot.RbLogDownload("D://zDOWN/");
14  cout << "RbLogDownload rtn is " << rtn << endl;
15  rtn = robot.AllDataSourceDownload("D://zDOWN/");
16  cout << "AllDataSourceDownload rtn is " << rtn << endl;
17  rtn = robot.DataPackageDownload("D://zDOWN/");
18  cout << "DataPackageDownload rtn is " << rtn << endl;
19  robot.CloseRPC();
20  return 0;
21}

16.19. Set Joint Firmware Upgrade

1/**
2* @brief Set joint firmware upgrade
3* @param [in] type Upgrade file type: 1-Firmware upgrade (requires boot mode); 2-Slave config file upgrade (requires robot disable)
4* @param [in] path Full local upgrade package path (D://zUP/XXXXX.bin)
5* @return Error code
6*/
7errno_t SetJointFirmwareUpgrade(int type, std::string path);

16.20. Set Controller Firmware Upgrade

1/**
2* @brief Set controller firmware upgrade
3* @param [in] type Upgrade file type: 1-Firmware upgrade (requires boot mode); 2-Slave config file upgrade (requires robot disable)
4* @param [in] path Full local upgrade package path (D://zUP/XXXXX.bin)
5* @return Error code
6*/
7errno_t SetCtrlFirmwareUpgrade(int type, std::string path);

16.21. Set End-Effector Firmware Upgrade

1/**
2* @brief Set end-effector firmware upgrade
3* @param [in] type Upgrade file type: 1-Firmware upgrade (requires boot mode); 2-Slave config file upgrade (requires robot disable)
4* @param [in] path Full local upgrade package path (D://zUP/XXXXX.bin)
5* @return Error code
6*/
7errno_t SetEndFirmwareUpgrade(int type, std::string path);

16.22. Joint Full Parameter Configuration Upgrade

1/**
2* @brief Joint full parameter configuration upgrade (requires robot disable)
3* @param [in] path Full local upgrade package path (D://zUP/XXXXX.bin)
4* @return Error code
5*/
6errno_t JointAllParamUpgrade(std::string path);

16.23. Robot Slave Firmware Upgrade Code Example

 1int TestFirmWareUpgrade()
 2{
 3ROBOT_STATE_PKG pkg = {};
 4FRRobot robot;
 5robot.LoggerInit();
 6robot.SetLoggerLevel(1);
 7int rtn = robot.RPC("192.168.58.2");
 8if (rtn != 0)
 9{
10return -1;
11}
12robot.SetReConnectParam(true, 30000, 500);
13robot.RobotEnable(0);
14robot.Sleep(200);
15rtn = robot.JointAllParamUpgrade("D://zUP/upgrade/jointallparameters.db");
16printf("robot JointAllParamUpgrade rtn is %d\n", rtn);
17rtn = robot.SetCtrlFirmwareUpgrade(2, "D://zUP/upgrade/FAIR_Cobot_Cbd_Asix_V2.0.bin");
18printf("robot SetCtrlFirmwareUpgrade config param rtn is %d\n", rtn);
19rtn = robot.SetEndFirmwareUpgrade(2, "D://zUP/upgrade/FAIR_Cobot_Axle_Asix_V2.4.bin");
20printf("robot SetEndFirmwareUpgrade config param rtn is %d\n", rtn);
21robot.SetSysServoBootMode();
22rtn = robot.SetCtrlFirmwareUpgrade(1, "D://zUP/upgrade/FR_CTRL_PRIMCU_FV201212_MAIN_U4_T01_20250428(MT).bin");
23printf("robot SetCtrlFirmwareUpgrade rtn is %d\n", rtn);
24rtn = robot.SetEndFirmwareUpgrade(1, "D://zUP/upgrade/FR_END_FV201009_MAIN_U1_T01_20250428.bin");
25printf("robot SetEndFirmwareUpgrade rtn is %d\n", rtn);
26rtn = robot.SetJointFirmwareUpgrade(1, "D://zUP/upgrade/FR_SERVO_FV504214_MAIN_U7_T07_20250519.bin");
27printf("robot SetJointFirmwareUpgrade rtn is %d\n", rtn);
28robot.CloseRPC();
29return 0;
30}

16.24. Robot Operating System Upgrade (LA Control Box)

New in version C++SDK-v3.8.6.

1/**
2* @brief Robot Operating System Upgrade (LA Control Box)
3* @param [in] filePath Full path of the operating system upgrade package
4* @return Error code
5*/
6errno_t KernelUpgrade(std::string filePath);

16.25. Get Robot Operating System Upgrade Result (LA Control Box)

New in version C++SDK-v3.8.6.

1/**
2* @brief Get Robot Operating System Upgrade Result (LA Control Box)
3* @param [out] result Upgrade result: 0: Success; -1: Failure
4* @return Error code
5*/
6errno_t GetKernelUpgradeResult(int& result);

16.26. Robot MCU log generation

1/**
2* @brief robot MCU log generation
3* @return error code
4*/
5Errno RobotMCULogCollect();

16.27. Set Robot to Stop Running When Port Communication is Disconnected

1/**
2* @brief Set robot to stop running when port communication is disconnected
3* @param [in] portID Port number 0-8080; 1-8083; 2-20002; 3-20004
4* @param [in] enable 0-disable; 1-enable
5* @param [in] confirmTime Communication disconnection confirmation duration (ms)[0-5000]
6* @return Error code
7*/
8errno_t SetRobotStopOnComDisc(int portID, bool enable, int confirmTime);

16.28. Get Robot Stop on Communication Disconnection Parameters

1/**
2* @brief Get robot stop on communication disconnection parameters
3* @param [in] portID Port number 0-8080; 1-8083; 2-20002; 3-20004
4* @param [out] enable 0-disable; 1-enable
5* @param [out] confirmTime Communication disconnection confirmation duration (ms)[0-5000]
6* @return Error code
7*/
8errno_t GetRobotStopOnComDisc(int portID, bool &enable, int &confirmTime);

16.29. Robot Stop on Communication Disconnection Parameter Code Example

 1int TestRobotStopOnComDisc()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    robot.LoggerInit();
 6    robot.SetLoggerLevel(1);
 7    int rtn = robot.RPC("192.168.58.2");
 8    if (rtn != 0)
 9    {
10        return -1;
11    }
12    robot.SetReConnectParam(true, 30000, 500);
13    bool enable = false;
14    int confirmTime = 0;
15    rtn = robot.SetRobotStopOnComDisc(0, true, 330);
16    rtn = robot.SetRobotStopOnComDisc(1, true, 550);
17    rtn = robot.SetRobotStopOnComDisc(2, true, 110);
18    rtn = robot.SetRobotStopOnComDisc(3, true, 220);
19    printf("SetRobotStopOnComDisc %d\n", rtn);
20    robot.GetRobotStopOnComDisc(0, enable, confirmTime);
21    printf("GetRobotStopOnComDisc 8080 rtn %d; enable is %d; confirm time is %d\n", rtn, enable, confirmTime);
22    robot.GetRobotStopOnComDisc(1, enable, confirmTime);
23    printf("GetRobotStopOnComDisc 80803 rtn %d; enable is %d; confirm time is %d\n", rtn, enable, confirmTime);
24    robot.GetRobotStopOnComDisc(2, enable, confirmTime);
25    printf("GetRobotStopOnComDisc 20002 rtn %d; enable is %d; confirm time is %d\n", rtn, enable, confirmTime);
26    robot.GetRobotStopOnComDisc(3, enable, confirmTime);
27    printf("GetRobotStopOnComDisc 20004 rtn %d; enable is %d; confirm time is %d\n", rtn, enable, confirmTime);
28    robot.CloseRPC();
29    robot.Sleep(1000);
30    return 0;
31}

16.30. Send UDP Instruction Frame

1/**
2* @brief Send UDP instruction frame
3* @param [in] frame Data frame string to send, e.g., /f/bIII20III303III7IIIMode(0)III/b/f
4* @return Error code
5*/
6errno_t SendUDPFrame(std::string frame);

16.31. Set Callback Function for Execution Results of Instructions Sent by SDK via UDP

1/**
2* @brief Set callback function for execution results of instructions sent by SDK via UDP
3* @param [in] CallBack Callback function; comType-instruction result communication reply type 0-TCP, 1-UDP; count-instruction reply frame count; cmdID-instruction ID; contentLen-data length; content-data content
4* @return Error code
5*/
6errno_t SetCmdRpyCallback(void (*CallBack)(int comType, int count, int cmdID, int contentLen, std::string content));

16.32. UDP Instruction Sending Code Example

 1int TestSendUDPFrame()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    robot.LoggerInit();
 6    robot.SetLoggerLevel(1);
 7    int rtn = robot.SetCmdRpyCallback(UDPFrameCallBack);
 8    printf("SetCmdRpyCallback rtn is %d\n", rtn);
 9    rtn = robot.RPC("192.168.58.2");
10    if (rtn != 0)
11    {
12        return -1;
13    }
14    robot.SetReConnectParam(true, 30000, 500);
15    rtn = robot.SendUDPFrame("/f/bIII20III303III7IIIMode(0)III/b/f");
16    printf("SendUDPFrame Mode(0) rtn is %d\n", rtn);
17    robot.Sleep(1000);
18    rtn = robot.SendUDPFrame("/f/bIII21III303III7IIIMode(1)III/b/f");
19    printf("SendUDPFrame Mode(1) rtn is %d\n", rtn);
20    robot.Sleep(1000);
21    rtn = robot.SendUDPFrame("/f/bIII49III201III184IIIMoveJ(-15.625, -82.680, 101.654, -110.950, -88.290, 0.017, -383.012, -2.325, 242.655, -178.024, 1.710, 74.416, 0, 0, 100, 100, 100, 0.000, 0.000, 0.000, 0.000, -1, 0, 0, 0, 0, 0, 0, 0)III/b/f");
22    printf("SendUDPFrame MoveJ(-15.625 rtn is %d\n", rtn);
23    robot.Sleep(1000);
24    rtn = robot.SendUDPFrame("/f/bIII48III203III199IIIMoveL(-75.622, -82.680, 101.654, -110.950, -88.290, 0.017, -193.537, 330.525, 242.657, -178.024, 1.710, 14.420, 0, 0, 100, 100, 100, -1, 0, 0.000, 0.000, 0.000, 0.000, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0)III/b/f");
25    printf("SendUDPFrame MoveL(-75.622 rtn is %d\n", rtn);
26    robot.Sleep(1000);
27    rtn = robot.SendUDPFrame("/f/bIII4III905III20IIIGetSoftwareVersion()III/b/f");
28    printf("SendUDPFrame GetSoftwareVersion() rtn is %d\n", rtn);
29    robot.Sleep(1000);
30    rtn = robot.SendUDPFrame("/f/bIII20III303III7IIIMode(0)III/b/f");
31    printf("SendUDPFrame rtn is %d\n", rtn);
32    rtn = robot.SendUDPFrame("III20III303III7IIIMode(0)III/b/f");
33    printf("SendUDPFrame rtn is %d\n", rtn);
34    rtn = robot.SendUDPFrame("/f/bIII20III303III7IIIMode(0)");
35    printf("SendUDPFrame rtn is %d\n", rtn);
36    rtn = robot.SendUDPFrame("/f/bIII20III303III6IIIMode(0)III/b/f");
37    printf("SendUDPFrame rtn is %d\n", rtn);
38    rtn = robot.SendUDPFrame("/f/b|||20|||303|||7|||Mode(0)|||/b/f");
39    printf("SendUDPFrame rtn is %d\n", rtn);
40    rtn = robot.SendUDPFrame("/f/bII20II303II7IIMode(0)II/b/f");
41    printf("SendUDPFrame rtn is %d\n", rtn);
42    robot.CloseRPC();
43    robot.Sleep(1000);
44    return 0;
45}

16.33. Set User-Defined Robot End-Effector LED Color

1/**
2* @brief Set user-defined robot end-effector LED color
3* @param [in] r End red LED control; 0-off; 1-on
4* @param [in] g End green LED control; 0-off; 1-on
5* @param [in] b End blue LED control; 0-off; 1-on
6* @return Error code
7*/
8errno_t SetUserLEDColor(bool r, bool g, bool b);

16.34. Code Example for Setting User-Defined Robot End-Effector LED Color

 1int TestUserLedColor()
 2{
 3    ROBOT_STATE_PKG pkg = {};
 4    FRRobot robot;
 5    robot.LoggerInit();
 6    robot.SetLoggerLevel(1);
 7    int rtn = robot.RPC("192.168.58.2");
 8    if (rtn != 0)
 9    {
10        return 0;
11    }
12    robot.SetReConnectParam(true, 30000, 500);
13    robot.SetUserLEDColor(true, true, true);
14    robot.Sleep(1000);
15    robot.SetUserLEDColor(false, false, false);
16    robot.Sleep(1000);
17    robot.SetUserLEDColor(true, false, false);
18    robot.Sleep(1000);
19    robot.SetUserLEDColor(false, true, false);
20    robot.Sleep(1000);
21    robot.SetUserLEDColor(false, false, true);
22    robot.Sleep(1000);
23    robot.CloseRPC();
24    robot.Sleep(1000);
25    return 0;
26}