top of page

3. Basics

3. Basics

3.1. Instantiate Robot

/**
* @brief  Robot interface class constructor
*/
FRRobot();

3.2. Establish Communication with Controller

/**
* @brief  Establish communication with robot controller
* @param  [in] ip  Controller IP address, default is 192.168.58.2
* @return Error code
*/
errno_t  RPC(const char *ip);

3.3. Close Communication with Controller

/**
 * @brief  Close communication with robot controller
 * @return Error code
 */
errno_t  CloseRPC();

3.4. Query SDK Version

/**
* @brief  Query SDK version
* @param  [out] version   SDK version
* @return  Error code
*/
errno_t  GetSDKVersion(char *version);

3.5. Get Controller IP

/**
* @brief  Get controller IP
* @param  [out] ip  Controller IP
* @return  Error code
*/
errno_t  GetControllerIP(char *ip);

3.6. Control Robot to Enter/Exit Drag Teaching Mode

/**
* @brief  Control robot to enter/exit drag teaching mode
* @param  [in] state 0-Exit drag teaching mode, 1-Enter drag teaching mode
* @return  Error code
*/
errno_t  DragTeachSwitch(uint8_t state);

3.7. Check if Robot is in Drag Mode

/**
* @brief  Check if robot is in drag teaching mode
* @param  [out] state 0-Not in drag teaching mode, 1-In drag teaching mode
* @return  Error code
*/
errno_t  IsInDragTeach(uint8_t *state);

3.8. Enable/Disable Robot

/**
* @brief  Enable/disable robot (enabled by default after power on)
* @param  [in] state  0-Disable, 1-Enable
* @return  Error code
*/
errno_t  RobotEnable(uint8_t state);

3.9. Switch Between Manual/Auto Mode

/**
* @brief Switch between manual/auto mode
* @param [in] mode 0-Auto mode, 1-Manual mode
* @return Error code
*/
errno_t  Mode(int mode);

3.10. Shut Down Robot OS

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

/**
* @brief Shut down robot operating system
* @return Error code
*/
errno_t ShutDownRobotOS();

3.11. Set Reconnection Parameters

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

/**
* @brief Set communication reconnection parameters
* @param [in] enable Enable reconnection when network fails true-enable false-disable
* @param [in] reconnectTime Reconnection time (ms)
* @param [in] period Reconnection interval (ms)
* @return Error code
*/
errno_t SetReConnectParam(bool enable, int reconnectTime = 30000, int period = 50);

3.12. Shut down the robot operating system

/**
* @brief Shut down the robot operating system
* @return Error code
*/
int ShutDownRobotOS();

3.13. Initialize Log Parameters

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

/**
* @brief Initialize log parameters;
* @param output_model:Output mode, 0-Direct output; 1-Buffered output; 2-Asynchronous output;
* @param file_path: File save path+name (max 256 chars), must be in xxx.log format, e.g. /home/fr/linux/fairino.log;
* @param file_num:Number of rolling files, 1~20. Single file size limit 50MB;
* @return errno_t Error code;
*/
errno_t LoggerInit(int output_model = 0, std::string file_path = "", int file_num = 5);

3.14. Set Log Filter Level

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

/**
* @brief Set log filter level;
* @param lvl: Filter level, smaller value means less logs, default is 1. 1-error, 2-warning, 3-info, 4-debug;
*/
void SetLoggerLevel(int lvl = 1);

3.15. Basic Robot Control Example

int TestRobotCtrl(void)
{
        ROBOT_STATE_PKG pkg = {};
        FRRobot robot;
        robot.LoggerInit();
        robot.SetLoggerLevel(1);
        int rtn = robot.RPC("192.168.58.2");
        robot.SetReConnectParam(true, 30000, 500);
        char ip[64] = "";
        char version[64] = "";
        uint8_t state;
        robot.GetSDKVersion(version);
        printf("SDK version:%s\n", version);
        robot.GetControllerIP(ip);
        printf("controller ip:%s\n", ip);
        robot.Mode(1);
        robot.Sleep(1000);
        robot.DragTeachSwitch(1);
        robot.Sleep(1000);
        robot.IsInDragTeach(&state);
        printf("drag state :%u\n", state);
        robot.Sleep(3000);
        robot.DragTeachSwitch(0);
        robot.Sleep(1000);
        robot.IsInDragTeach(&state);
        printf("drag state :%u\n", state);
        robot.Sleep(3000);
        robot.RobotEnable(0);
        robot.Sleep(3000);
        robot.RobotEnable(1);
        robot.Mode(0);
        robot.Sleep(1000);
        robot.Mode(1);
        robot.Sleep(3000);
        robot.ShutDownRobotOS();
        robot.CloseRPC();
        return 0;
}

3.16. Get Robot Software Version Example

/**
* @brief Get robot software version
* @param[out]    robotModel Robot model
* @param[out]    webversion Web version
* @param[out]    controllerVersion Controller version
* @return Error code
*/
errno_t GetSoftwareVersion(char robotModel[64], char webVersion[64], char controllerVersion[64]);

3.17. Get Robot Hardware Version

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

/**
* @brief Get robot hardware version
* @param[out] ctrlBoxBoardversion Control box board hardware version
* @param[out] driver1version Driver 1 hardware version
* @param[out] driver2version Driver 2 hardware version
* @param[out] driver3version Driver 3 hardware version
* @param[out] driver4version Driver 4 hardware version
* @param[out] driver5version Driver 5 hardware version
* @param[out] driver6version Driver 6 hardware version
* @param[out] endBoardversion End board hardware version
*/
errno_t GetHardwareVersion(char ctrlBoxBoardversion[128], char driver1version[128], char driver2version[128], char driver3version[128], char driver4version[128], char driver5version[128], char driver6version[128], char endBoardversion[128]);

3.18. Get Robot Firmware Version

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

/**
* @brief Get robot firmware version
* @param[out] ctrlBoxBoardversion Control box board firmware version
* @param[out] driver1version Driver 1 firmware version
* @param[out] driver2version Driver 2 firmware version
* @param[out] driver3version Driver 3 firmware version
* @param[out] driver4version Driver 4 firmware version
* @param[out] driver5version Driver 5 firmware version
* @param[out] driver6version Driver 6 firmware version
* @param[out] endBoardversion End board firmware version
*/
errno_t GetFirmwareVersion(char ctrlBoxBoardversion[128], char driver1version[128], char driver2version[128], char driver3version[128], char driver4version[128], char driver5version[128], char driver6version[128], char endBoardversion[128]);

3.19. Get Robot Software/Firmware Version Example

int TestGetVersions(void)
 {
     ROBOT_STATE_PKG pkg = {};
     FRRobot robot;
     robot.LoggerInit();
     robot.SetLoggerLevel(1);
     int rtn = robot.RPC("192.168.58.2");
     if (rtn != 0)
     {
         return -1;
     }
     robot.SetReConnectParam(true, 30000, 500);
     char robotModel[64] = { 0 };
     char webversion[64] = { 0 };
     char controllerVersion[64] = { 0 };
     char ctrlBoxBoardversion[128] = { 0 };
     char driver1version[128] = { 0 };
     char driver2version[128] = { 0 };
     char driver3version[128] = { 0 };
     char driver4version[128] = { 0 };
     char driver5version[128] = { 0 };
     char driver6version[128] = { 0 };
     char endBoardversion[128] = { 0 };
     rtn = robot.GetSoftwareVersion(robotModel, webversion, controllerVersion);
     printf("Getsoftwareversion rtn is: %d\n", rtn);
     printf("robotmodel is: %s, webversion is: %s, controllerVersion is: %s \n\n", robotModel, webversion, controllerVersion);
     rtn = robot.GetHardwareVersion(ctrlBoxBoardversion, driver1version, driver2version, driver3version, driver4version, driver5version, driver6version, endBoardversion);
     printf("GetHardwareversion rtn is: %d\n", rtn);
     printf("GetHardwareversion get hardware versoin is: %s, %s, %s, %s, %s, %s, %s, %s\n\n", ctrlBoxBoardversion, driver1version, driver2version, driver3version, driver4version, driver5version, driver6version, endBoardversion);
     rtn = robot.GetFirmwareVersion(ctrlBoxBoardversion, driver1version, driver2version, driver3version, driver4version, driver5version, driver6version, endBoardversion);
     printf("GetFirmwareversion rtn is: %d\n", rtn);
     printf("GetHardwareversion get hardware versoin is: %s, %s, %s, %s, %s, %s, %s, %s\n\n", ctrlBoxBoardversion, driver1version, driver2version, driver3version, driver4version, driver5version, driver6version, endBoardversion);
     robot.CloseRPC();
     return 0;
 }

robotic arm
FAIRINO ROBOTIC ARMS

Contact

Location: 10637 Scripps Summit Court,

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

© 2023 Fairino US official site Proudly created By G2T

bottom of page