11. Robot Peripheral Devices
11.1. Configure Gripper
1/**
2* @brief Configure gripper
3* @param [in] company Gripper manufacturer (to be determined)
4* @param [in] device Device number (currently unused, default 0)
5* @param [in] softvesion Software version (currently unused, default 0)
6* @param [in] bus Device bus location at end (currently unused, default 0)
7* @return Error code
8*/
9errno_t SetGripperConfig(int company, int device, int softvesion, int bus);
11.2. Get Gripper Configuration
1/**
2* @brief Get gripper configuration
3* @param [in] company Gripper manufacturer (to be determined)
4* @param [in] device Device number (currently unused, default 0)
5* @param [in] softvesion Software version (currently unused, default 0)
6* @param [in] bus Device bus location at end (currently unused, default 0)
7* @return Error code
8*/
9errno_t GetGripperConfig(int *company, int *device, int *softvesion, int *bus);
11.3. Activate Gripper
1/**
2* @brief Activate gripper
3* @param [in] index Gripper number
4* @param [in] act 0-reset, 1-activate
5* @return Error code
6*/
7errno_t ActGripper(int index, uint8_t act);
11.4. Control Gripper
Changed in version C++SDK-v2.1.5.0.
1/**
2 * @brief Control gripper
3 * @param [in] index Gripper number
4 * @param [in] pos Position percentage [0~100]
5 * @param [in] vel Speed percentage [0~100]
6 * @param [in] force Torque percentage [0~100]
7 * @param [in] max_time Maximum wait time [0~30000], unit ms
8 * @param [in] block 0-blocking, 1-non-blocking
9 * @param [in] type Gripper type, 0-parallel gripper; 1-rotary gripper
10 * @param [in] rotNum Rotation turns
11 * @param [in] rotVel Rotation speed percentage [0-100]
12 * @param [in] rotTorque Rotation torque percentage [0-100]
13 * @return Error code
14 */
15 errno_t MoveGripper(int index, int pos, int vel, int force, int max_time, uint8_t block, int type, double rotNum, int rotVel, int rotTorque);
11.5. Get Gripper Motion Status
1/**
2 * @brief Get gripper motion status
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] staus 0-motion not completed, 1-motion completed
5 * @return Error code
6 */
7errno_t GetGripperMotionDone(uint16_t *fault, uint8_t *status);
11.6. Get Gripper Activation Status
1/**
2 * @brief Get gripper activation status
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] status bit0~bit15 correspond to gripper numbers 0~15, bit=0 not activated, bit=1 activated
5 * @return Error code
6 */
7errno_t GetGripperActivateStatus(uint16_t *fault, uint16_t *status);
11.7. Get Gripper Position
1/**
2 * @brief Get gripper position
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] position Position percentage, range 0~100%
5 * @return Error code
6 */
7errno_t GetGripperCurPosition(uint16_t *fault, uint8_t *position);
11.8. Get Gripper Speed
1/**
2 * @brief Get gripper speed
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] speed Speed percentage, range 0~100%
5 * @return Error code
6 */
7errno_t GetGripperCurSpeed(uint16_t *fault, int8_t *speed);
11.9. Get Gripper Current
1/**
2 * @brief Get gripper current
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] current Current percentage, range 0~100%
5 * @return Error code
6 */
7errno_t GetGripperCurCurrent(uint16_t *fault, int8_t *current);
11.10. Get Gripper Voltage
1/**
2 * @brief Get gripper voltage
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] voltage Voltage, unit 0.1V
5 * @return Error code
6 */
7errno_t GetGripperVoltage(uint16_t *fault, int *voltage);
11.11. Get Gripper Temperature
1/**
2 * @brief Get gripper temperature
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] temp Temperature, unit ℃
5 * @return Error code
6 */
7errno_t GetGripperTemp(uint16_t *fault, int *temp);
11.12. Calculate Pre-Pick Point - Vision
1/**
2 * @brief Calculate pre-pick point - vision
3 * @param [in] desc_pos Pick point Cartesian pose
4 * @param [in] zlength Z-axis offset
5 * @param [in] zangle Rotation offset around Z-axis
6 * @return Error code
7 */
8errno_t ComputePrePick(DescPose *desc_pos, double zlength, double zangle, DescPose *pre_pos);
11.13. Calculate Retreat Point - Vision
1/**
2 * @brief Calculate retreat point - vision
3 * @param [in] desc_pos Pick point Cartesian pose
4 * @param [in] zlength Z-axis offset
5 * @param [in] zangle Rotation offset around Z-axis
6 * @return Error code
7 */
8errno_t ComputePostPick(DescPose *desc_pos, double zlength, double zangle, DescPose *post_pos);
11.14. Robot Gripper Operation Code Example
1int TestGripper(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 int company = 4;
14 int device = 0;
15 int softversion = 0;
16 int bus = 2;
17 int index = 2;
18 int act = 0;
19 int max_time = 30000;
20 uint8_t block = 0;
21 uint8_t status;
22 uint16_t fault;
23 uint16_t active_status = 0;
24 uint8_t current_pos = 0;
25 int8_t current = 0;
26 int voltage = 0;
27 int temp = 0;
28 int8_t speed = 0;
29 robot.SetGripperConfig(company, device, softversion, bus);
30 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
31 robot.GetGripperConfig(&company, &device, &softversion, &bus);
32 printf("gripper config:%d,%d,%d,%d\n", company, device, softversion, bus);
33 robot.ActGripper(index, act);
34 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
35 act = 1;
36 robot.ActGripper(index, act);
37 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
38 robot.MoveGripper(index, 100, 50, 50, max_time, block, 0, 0, 0, 0);
39 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
40 robot.MoveGripper(index, 0, 50, 0, max_time, block, 0, 0, 0, 0);
41 robot.GetGripperMotionDone(&fault, &status);
42 printf("motion status:%u,%u\n", fault, status);
43 robot.GetGripperActivateStatus(&fault, &active_status);
44 printf("gripper active fault is: %u, status is: %u\n", fault, active_status);
45 robot.GetGripperCurPosition(&fault, ¤t_pos);
46 printf("fault is:%u, current position is: %u\n", fault, current_pos);
47 robot.GetGripperCurCurrent(&fault, ¤t);
48 printf("fault is:%u, current current is: %d\n", fault, current);
49 robot.GetGripperVoltage(&fault, &voltage);
50 printf("fault is:%u, current voltage is: %d \n", fault, voltage);
51 robot.GetGripperTemp(&fault, &temp);
52 printf("fault is:%u, current temperature is: %d\n", fault, temp);
53 robot.GetGripperCurSpeed(&fault, &speed);
54 printf("fault is:%u, current speed is: %d\n", fault, speed);
55 int retval = 0;
56 DescPose prepick_pose = {};
57 DescPose postpick_pose = {};
58 DescPose p1Desc(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
59 DescPose p2Desc(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
60 retval = robot.ComputePrePick(&p1Desc, 10, 0, &prepick_pose);
61 printf("ComputePrePick retval is: %d\n", retval);
62 printf("xyz is: %f, %f, %f; rpy is: %f, %f, %f\n", prepick_pose.tran.x, prepick_pose.tran.y, prepick_pose.tran.z, prepick_pose.rpy.rx, prepick_pose.rpy.ry, prepick_pose.rpy.rz);
63 retval = robot.ComputePostPick(&p2Desc, -10, 0, &postpick_pose);
64 printf("ComputePostPick retval is: %d\n", retval);
65 printf("xyz is: %f, %f, %f; rpy is: %f, %f, %f\n", postpick_pose.tran.x, postpick_pose.tran.y, postpick_pose.tran.z, postpick_pose.rpy.rx, postpick_pose.rpy.ry, postpick_pose.rpy.rz);
66 robot.CloseRPC();
67 return 0;
68}
11.15. Get Rotation Count of Rotary Gripper
New in version Version: 3.7.6
1/**
2 * @brief Get rotation count of rotary gripper
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] num Rotation count
5 * @return Error code
6 */
7 errno_t GetGripperRotNum(uint16_t* fault, double* num);
11.16. Get Rotation Speed of Rotary Gripper
New in version V3.7.6.
1/**
2 * @brief Get rotation speed of rotary gripper
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] speed Rotation speed percentage
5 * @return Error code
6 */
7 errno_t GetGripperRotSpeed(uint16_t* fault, int* speed);
11.17. Get Rotation Torque of Rotary Gripper
New in version V3.7.6.
1/**
2 * @brief Get rotation torque of rotary gripper
3 * @param [out] fault 0-no error, 1-error
4 * @param [out] torque Rotation torque percentage
5 * @return Error code
6 */
7 errno_t GetGripperRotTorque(uint16_t* fault, int* torque);
11.18. Rotary Gripper Status Code Example
1int TestRotGripperState(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 uint16_t fault = 0;
14 double rotNum = 0.0;
15 int rotSpeed = 0;
16 int rotTorque = 0;
17 robot.GetGripperRotNum(&fault, &rotNum);
18 robot.GetGripperRotSpeed(&fault, &rotSpeed);
19 robot.GetGripperRotTorque(&fault, &rotTorque);
20 printf("gripper rot num : %lf, gripper rotSpeed : %d, gripper rotTorque : %d\n", rotNum, rotSpeed, rotTorque);
21 robot.CloseRPC();
22 return 0;
23}
11.19. Conveyor Start/Stop
1/**
2* @brief Conveyor start/stop
3* @param [in] status State, 1-start, 0-stop
4* @return Error code
5*/
6errno_t ConveyorStartEnd(uint8_t status);
11.20. Record IO Detection Point
1/**
2* @brief Record IO detection point
3* @return Error code
4*/
5errno_t ConveyorPointIORecord();
11.21. Record Point A
1/**
2* @brief Record point A
3* @return Error code
4*/
5errno_t ConveyorPointARecord();
11.22. Record Reference Point
1/**
2* @brief Record reference point
3* @return Error code
4*/
5errno_t ConveyorRefPointRecord();
11.23. Record Point B
1/**
2* @brief Record point B
3* @return Error code
4*/
5errno_t ConveyorPointBRecord();
11.24. Conveyor Workpiece IO Detection
1/**
2* @brief Conveyor workpiece IO detection
3* @param [in] max_t Maximum detection time, unit ms
4* @return Error code
5*/
6errno_t ConveyorIODetect(int max_t);
11.25. Get Current Object Position
1/**
2* @brief Get current object position
3* @param [in] mode
4* @return Error code
5*/
6errno_t ConveyorGetTrackData(int mode);
11.26. Conveyor Tracking Start
1/**
2* @brief Conveyor tracking start
3* @param [in] status State, 1-start, 0-stop
4* @return Error code
5*/
6errno_t ConveyorTrackStart(uint8_t status);
11.27. Conveyor Tracking Stop
1/**
2* @brief Conveyor tracking stop
3* @return Error code
4*/
5errno_t ConveyorTrackEnd();
11.28. Conveyor Parameter Configuration
Changed in version C++SDK-v2.2.1-3.8.1.
1/**
2* @brief Conveyor parameter configuration
3* @param [in] para[0] Encoder channel 1~2
4* @param [in] para[1] Pulses per encoder revolution
5* @param [in] para[2] Conveyor travel distance per encoder revolution
6* @param [in] para[3] Workpiece coordinate system number (0 for tracking capture and TPD tracking)
7* @param [in] para[4] Vision configuration 0-not configured 1-configured
8* @param [in] para[5] Speed ratio for conveyor tracking capture (1-100), default 1 for other options
9* @param [in] followType Tracking motion type, 0-tracking motion; 1-chase inspection motion
10* @param [in] startDis For chase capture: tracking start distance (-1: auto calculate), unit mm, default 0
11* @param [in] endDis For chase capture: tracking end distance, unit mm, default 100
12* @return Error code
13*/
14errno_t ConveyorSetParam(float para[6], int followType = 0, int startDis = 0, int endDis = 100);
11.29. Conveyor Capture Point Compensation
Changed in version C++SDK-v2.1.2.0.
1 /**
2 * @brief Conveyor capture point compensation
3 * @param [in] cmp Compensation position double[3]{x, y, z}
4 * @return Error code
5 */
6errno_t ConveyorCatchPointComp(double cmp[3]);
11.30. Conveyor Linear Motion
1/**
2* @brief Conveyor linear motion
3* @param [in] status State, 1-start, 0-stop
4* @return Error code
5*/
6errno_t TrackMoveL(char name[32], int tool, int wobj, float vel, float acc, float ovl, float blendR, uint8_t flag, uint8_t type);
11.31. Conveyor Communication Input Detection
New in version C++SDK-v2.2.1-3.8.1.
1/**
2* @brief Conveyor communication input detection
3* @param [in] timeout Wait timeout time (ms)
4* @return Error code
5*/
6errno_t ConveyorComDetect(int timeout);
11.32. Conveyor Communication Input Detection Trigger
New in version C++SDK-v2.2.1-3.8.1.
1/**
2* @brief Conveyor communication input detection trigger
3* @return Error code
4*/
5errno_t ConveyorComDetectTrigger();
11.33. Robot Conveyor Operation Example Program
1int TestConveyor(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 int retval = 0;
14 retval = robot.ConveyorStartEnd(1);
15 printf("ConveyorStartEnd retval is: %d\n", retval);
16 retval = robot.ConveyorPointIORecord();
17 printf("ConveyorPointIORecord retval is: %d\n", retval);
18 retval = robot.ConveyorPointARecord();
19 printf("ConveyorPointARecord retval is: %d\n", retval);
20 retval = robot.ConveyorRefPointRecord();
21 printf("ConveyorRefPointRecord retval is: %d\n", retval);
22 retval = robot.ConveyorPointBRecord();
23 printf("ConveyorPointBRecord retval is: %d\n", retval);
24 retval = robot.ConveyorStartEnd(0);
25 printf("ConveyorStartEnd retval is: %d\n", retval);
26 retval = 0;
27 float param[6] = { 1,10000,200,0,0,20 };
28 retval = robot.ConveyorSetParam(param);
29 printf("ConveyorSetParam retval is: %d\n", retval);
30 double cmp[3] = { 0.0, 0.0, 0.0 };
31 retval = robot.ConveyorCatchPointComp(cmp);
32 printf("ConveyorCatchPointComp retval is: %d\n", retval);
33 int index = 1;
34 int max_time = 30000;
35 uint8_t block = 0;
36 retval = 0;
37 DescPose p1Desc(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
38 DescPose p2Desc(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
39 retval = robot.MoveCart(&p1Desc, 1, 0, 100.0, 100.0, 100.0, -1.0, -1);
40 printf("MoveCart retval is: %d\n", retval);
41 retval = robot.WaitMs(1);
42 printf("WaitMs retval is: %d\n", retval);
43 retval = robot.ConveyorIODetect(10000);
44 printf("ConveyorIODetect retval is: %d\n", retval);
45 retval = robot.ConveyorGetTrackData(1);
46 printf("ConveyorGetTrackData retval is: %d\n", retval);
47 retval = robot.ConveyorTrackStart(1);
48 printf("ConveyorTrackStart retval is: %d\n", retval);
49 retval = robot.TrackMoveL("cvrCatchPoint", 1, 0, 100, 100, 100, -1.0, 0, 0);
50 printf("TrackMoveL retval is: %d\n", retval);
51 retval = robot.MoveGripper(index, 51, 40, 30, max_time, block, 0, 0, 0, 0);
52 printf("MoveGripper retval is: %d\n", retval);
53 retval = robot.TrackMoveL("cvrRaisePoint", 1, 0, 100, 100, 100, -1.0, 0, 0);
54 printf("TrackMoveL retval is: %d\n", retval);
55 retval = robot.ConveyorTrackEnd();
56 printf("ConveyorTrackEnd retval is: %d\n", retval);
57 robot.MoveCart(&p2Desc, 1, 0, 100.0, 100.0, 100.0, -1.0, -1);
58 retval = robot.MoveGripper(index, 100, 40, 10, max_time, block, 0, 0, 0, 0);
59 printf("MoveGripper retval is: %d\n", retval);
60 rtn = robot->ConveyorComDetect(1000 * 10);
61 printf("ConveyorComDetect rtn is: %d\n", rtn);
62 robot.Sleep(2000);
63 rtn = robot->ConveyorComDetectTrigger();
64 printf("ConveyorComDetectTrigger rtn is: %d\n", rtn);
65 robot.CloseRPC();
66 return 0;
67}
11.34. End Sensor Configuration
New in version C++SDK-v2.1.5.0.
1/**
2* @brief End sensor configuration
3* @param [in] idCompany Manufacturer, 18-JUNKONG; 25-HUIDE
4* @param [in] idDevice Type, 0-JUNKONG/RYR6T.V1.0
5* @param [in] idSoftware Software version, 0-J1.0/HuiDe1.0 (not yet available)
6* @param [in] idBus Mounting position, 1-End port 1; 2-End port 2...8-End port 8 (not yet available)
7* @return Error code
8*/
9errno_t AxleSensorConfig(int idCompany, int idDevice, int idSoftware, int idBus);
11.35. Get End Sensor Configuration
New in version C++SDK-v2.1.5.0.
1/**
2 * @brief Get end sensor configuration
3 * @param [out] idCompany Manufacturer, 18-JUNKONG; 25-HUIDE
4 * @param [out] idDevice Type, 0-JUNKONG/RYR6T.V1.0
5 * @return Error code
6 */
7errno_t AxleSensorConfigGet(int& idCompany, int& idDevice);
11.36. End Sensor Activation
New in version C++SDK-v2.1.5.0.
1/**
2 * @brief End sensor activation
3 * @param [in] actFlag 0-Reset; 1-Activate
4 * @return Error code
5 */
6errno_t AxleSensorActivate(int actFlag);
11.37. End Sensor Register Write
New in version C++SDK-v2.1.5.0.
1/**
2 * @brief End sensor register write
3 * @param [in] devAddr Device address number 0-255
4 * @param [in] regHAddr Register address high 8 bits
5 * @param [in] regLAddr Register address low 8 bits
6 * @param [in] regNum Register count 0-255
7 * @param [in] data1 Write register value 1
8 * @param [in] data2 Write register value 2
9 * @param [in] isNoBlock 0-Blocking; 1-Non-blocking
10 * @return Error code
11 */
12errno_t AxleSensorRegWrite(int devAddr, int regHAddr, int regLAddr, int regNum, int data1, int data2, int isNoBlock);
11.38. End Sensor Code Example
1int TestAxleSensor(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.AxleSensorConfig(18, 0, 0, 1);
14 int company = -1;
15 int type = -1;
16 robot.AxleSensorConfigGet(company, type);
17 printf("company is %d, type is %d\n", company, type);
18 rtn = robot.AxleSensorActivate(1);
19 printf("AxleSensorActivate rtn is %d\n", rtn);
20 robot.Sleep(1000);
21 rtn = robot.AxleSensorRegWrite(1, 4, 6, 1, 0, 0, 0);
22 printf("AxleSensorRegWrite rtn is %d\n", rtn);
23 robot.CloseRPC();
24 return 0;
25}
11.39. Get Robot Peripheral Protocol
New in version C++SDK-v2.1.3.0.
1/**
2* @brief Get robot peripheral protocol
3* @param [out] protocol Robot peripheral protocol number 4096-Extended axis control card; 4097-ModbusSlave; 4098-ModbusMaster
4* @return Error code
5*/
6errno_t GetExDevProtocol(int *protocol);
11.40. Set Robot Peripheral Protocol
New in version C++SDK-v2.1.3.0.
1/**
2* @brief Set robot peripheral protocol
3* @param [in] protocol Robot peripheral protocol number 4096-Extended axis control card; 4097-ModbusSlave; 4098-ModbusMaster
4* @return Error code
5*/
6errno_t SetExDevProtocol(int protocol);
11.41. Set Robot Peripheral Protocol Example
New in version C++SDK-v2.1.3.0.
1int TestExDevProtocol(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 int protocol = 4096;
14 rtn = robot.SetExDevProtocol(protocol);
15 std::cout << "SetExDevProtocol rtn " << rtn << std::endl;
16 rtn = robot.GetExDevProtocol(&protocol);
17 std::cout << "GetExDevProtocol rtn " << rtn << " protocol is: " << protocol << std::endl;
18 robot.CloseRPC();
19 return 0;
20}
11.42. Get End Communication Parameters
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Get end communication parameters
3* @param param End communication parameters
4* @return Error code
5*/
6errno_t GetAxleCommunicationParam(AxleComParam* param);
11.43. Set End Communication Parameters
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Set end communication parameters
3* @param param End communication parameters
4* @return Error code
5*/
6errno_t SetAxleCommunicationParam(AxleComParam param);
11.44. Set End File Transfer Type
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Set end file transfer type
3* @param type 1-MCU upgrade file; 2-LUA file
4* @return Error code
5*/
6errno_t SetAxleFileType(int type);
11.45. Set Enable End LUA Execution
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Set enable end LUA execution
3* @param enable 0-Disable; 1-Enable
4* @return Error code
5*/
6errno_t SetAxleLuaEnable(int enable);
11.46. End LUA File Error Recovery
New in version C++SDK-v2.1.5.0.
1/**
2* @brief End LUA file error recovery
3* @param status 0-No recovery; 1-Recovery
4* @return Error code
5*/
6errno_t SetRecoverAxleLuaErr(int status);
11.47. Get End LUA Execution Enable Status
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Get end LUA execution enable status
3* @param status status[0]: 0-Not enabled; 1-Enabled
4* @return Error code
5*/
6errno_t GetAxleLuaEnableStatus(int status[]);
11.48. Set End LUA End Device Enable Type
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Set end LUA end device enable type
3* @param forceSensorEnable Force sensor enable status, 0-Disable; 1-Enable
4* @param gripperEnable Gripper enable status, 0-Disable; 1-Enable
5* @param IOEnable IO device enable status, 0-Disable; 1-Enable
6* @return Error code
7*/
8errno_t SetAxleLuaEnableDeviceType(int forceSensorEnable, int gripperEnable, int IOEnable);
11.49. Get End LUA End Device Enable Type
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Get end LUA end device enable type
3* @param enable enable[0]:forceSensorEnable Force sensor enable status, 0-Disable; 1-Enable
4* @param enable enable[1]:gripperEnable Gripper enable status, 0-Disable; 1-Enable
5* @param enable enable[2]:IOEnable IO device enable status, 0-Disable; 1-Enable
6* @return Error code
7*/
8errno_t GetAxleLuaEnableDeviceType(int* forceSensorEnable, int* gripperEnable, int* IOEnable);
11.50. Get Currently Configured End Devices
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Get currently configured end devices
3* @param forceSensorEnable Force sensor enable device number 0-Not enabled; 1-Enabled
4* @param gripperEnable Gripper enable device number, 0-Disable; 1-Enable
5* @param IODeviceEnable IO device enable device number, 0-Disable; 1-Enable
6* @return Error code
7*/
8errno_t GetAxleLuaEnableDevice(int forceSensorEnable[], int gripperEnable[], int IODeviceEnable[]);
11.51. Set Enable Gripper Action Control Function
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Set enable gripper action control function
3* @param id Gripper device number
4* @param func func[0]-Gripper enable; func[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
5* @return Error code
6*/
7errno_t SetAxleLuaGripperFunc(int id, int func[]);
11.52. Get Enable Gripper Action Control Function
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Get enable gripper action control function
3* @param id Gripper device number
4* @param func func[0]-Gripper enable; func[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
5* @return Error code
6*/
7errno_t GetAxleLuaGripperFunc(int id, int func[]);
11.53. Robot Ethercat Slave File Write
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Robot Ethercat slave file write
3* @param type Slave file type, 1-Upgrade slave file; 2-Upgrade slave configuration file
4* @param slaveID Slave number
5* @param fileName Upload file name
6* @return Error code
7*/
8errno_t SlaveFileWrite(int type, int slaveID, std::string fileName);
11.54. Upload End Lua Open Protocol File
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Upload end Lua open protocol file
3* @param filePath Local lua file path name ".../AXLE_LUA_End_DaHuan.lua"
4* @return Error code
5*/
6errno_t AxleLuaUpload(std::string filePath);
11.55. Robot Ethercat Slave Enter Boot Mode
New in version C++SDK-v2.1.5.0.
1/**
2* @brief Robot Ethercat slave enter boot mode
3* @return Error code
4*/
5errno_t SetSysServoBootMode();
11.56. Robot End LUA File Operation Code Example
1int TestAxleLua(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.AxleLuaUpload("D://zUP/AXLE_LUA_End_DaHuan.lua");
14 AxleComParam param(7, 8, 1, 0, 5, 3, 1);
15 robot.SetAxleCommunicationParam(param);
16 AxleComParam getParam;
17 robot.GetAxleCommunicationParam(&getParam);
18 printf("GetAxleCommunicationParam param is %d %d %d %d %d %d %d\n", getParam.baudRate, getParam.dataBit, getParam.stopBit, getParam.verify, getParam.timeout, getParam.timeoutTimes, getParam.period);
19 robot.SetAxleLuaEnable(1);
20 int luaEnableStatus = 0;
21 robot.GetAxleLuaEnableStatus(&luaEnableStatus);
22 robot.SetAxleLuaEnableDeviceType(0, 1, 0);
23 int forceEnable = 0;
24 int gripperEnable = 0;
25 int ioEnable = 0;
26 robot.GetAxleLuaEnableDeviceType(&forceEnable, &gripperEnable, &ioEnable);
27 printf("GetAxleLuaEnableDeviceType param is %d %d %d\n", forceEnable, gripperEnable, ioEnable);
28 int func[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
29 robot.SetAxleLuaGripperFunc(1, func);
30 int getFunc[16] = { 0 };
31 robot.GetAxleLuaGripperFunc(1, getFunc);
32 int getforceEnable[16] = { 0 };
33 int getgripperEnable[16] = { 0 };
34 int getioEnable[16] = { 0 };
35 robot.GetAxleLuaEnableDevice(getforceEnable, getgripperEnable, getioEnable);
36 printf("\ngetforceEnable status : ");
37 for (int i = 0; i < 16; i++)
38 {
39 printf("%d,", getforceEnable[i]);
40 }
41 printf("\ngetgripperEnable status : ");
42 for (int i = 0; i < 16; i++)
43 {
44 printf("%d,", getgripperEnable[i]);
45 }
46 printf("\ngetioEnable status : ");
47 for (int i = 0; i < 16; i++)
48 {
49 printf("%d,", getioEnable[i]);
50 }
51 printf("\n");
52 robot.ActGripper(1, 0);
53 robot.Sleep(2000);
54 robot.ActGripper(1, 1);
55 robot.Sleep(2000);
56 robot.MoveGripper(1, 90, 10, 100, 50000, 0, 0, 0, 0, 0);
57 int pos = 0;
58 while (true)
59 {
60 robot.GetRobotRealTimeState(&pkg);
61 printf("gripper pos is %u\n", pkg.gripper_position);
62 robot.Sleep(100);
63 }
64 robot.CloseRPC();
65 return 0;
66}
11.59. Control Array Suction Cup
1/**
2* @brief Control Array Suction Cup
3* @param [in] slaveID Slave Station ID
4* @param [in] len Length
5* @param [in] ctrlValue Control Value
6* @return Error Code
7*/
8errno_t FRRobot::SetSuckerCtrl(uint8_t slaveID, uint8_t len, uint8_t ctrlValue[20]);
11.60. Get Array Suction Cup Status
1/**
2* @brief Get Array Suction Cup Status
3* @param [in] slaveID Slave Station ID
4* @param [out] state Adsorption Status 0-Release Object 1-Workpiece Detected, Adsorption Successful 2-No Object Adsorbed 3-Object Detached
5* @param [out] pressValue Current Vacuum Level Unit kpa
6* @param [out] error Current Error Code of the Suction Cup
7* @return Error Code
8*/
9 errno_t FRRobot::GetSuckerState(uint8_t slaveID, uint8_t* state, int* pressValue, int* error);
11.61. Wait for Suction Cup Status
1/**
2* @brief Wait for Suction Cup Status
3* @param [in] slaveID Slave Station ID
4* @param [in] state Adsorption Status 0-Release Object 1-Workpiece Detected, Adsorption Successful 2-No Object Adsorbed 3-Object Detached
5* @param [in] ms Maximum Wait Time (ms)
6* @return Error Code
7*/
8errno_t FRRobot::WaitSuckerState(uint8_t slaveID, uint8_t state, int ms);
11.62. Array Suction Cup Control Command Code Example
1void testSucker()
2{
3 ROBOT_STATE_PKG pkg = {};
4 FRRobot robot;
5 uint8_t ctrl[20];
6 uint8_t state;
7 int pressValue; // Corrected typo from pressVlaue
8 int error;
9
10 robot.LoggerInit();
11 robot.SetLoggerLevel(1);
12 int rtn = robot.RPC("192.168.58.2");
13 if (rtn != 0)
14 {
15 return;
16 }
17 robot.SetReConnectParam(true, 30000, 500);
18 //Upload and load the open protocol file
19 robot.OpenLuaUpload("E://Project/Peripheral SDK/CtrlDev_sucker.lua");
20 robot.Sleep(2000);
21 robot.SetCtrlOpenLUAName(1, "CtrlDev_sucker.lua");
22 robot.UnloadCtrlOpenLUA(1);
23 robot.LoadCtrlOpenLUA(1);
24 robot.Sleep(1000);
25
26 //Control suction cup in broadcast mode, adsorb at maximum capacity
27 ctrl[0] = 1;
28 robot.SetSuckerCtrl(0, 1, ctrl);
29
30 //Loop to monitor the status of suction cup 1 and suction cup 12
31 for (int i = 0; i < 100; i++)
32 {
33 robot.GetSuckerState(1, &state, &pressValue, &error);
34 printf("sucker1 state is %d, pressValue is %d, error num is %d\n", state, pressValue, error);
35 robot.GetSuckerState(12, &state, &pressValue, &error);
36 printf("sucker12 state is %d, pressValue is %d, error num is %d\n", state, pressValue, error);
37 robot.Sleep(100);
38 }
39
40 //Wait for suction cup 1 to reach the state of having adsorbed an object, wait time 100ms
41 int ret = robot.WaitSuckerState(1, 1, 100);
42 printf("WaitSuckerState result is %d\n", ret);
43
44 //Turn off suction cup 1 and 12 in unicast mode
45 ctrl[0] = 3;
46 robot.SetSuckerCtrl(1, 1, ctrl);
47 robot.SetSuckerCtrl(12, 1, ctrl);
48
49 robot.CloseRPC();
50}
11.63. Upload Peripheral Open Protocol LUA File
1 /**
2 * @brief Upload Lua File
3 * @param [in] filePath Local lua file path name
4 * @return Error Code
5 */
6errno_t OpenLuaUpload(std::string filePath);
11.64. Get Slave Board Parameters
1/**
2* @brief Get Slave Board Parameters
3* @param [out] type 0-Ethercat,1-CClink, 3-Ethercat, 4-EIP
4* @param [out] version Protocol Version
5* @param [out] connState 0-Not Connected 1-Connected
6* @return Error Code
7*/
8errno_t GetFieldBusConfig(uint8_t* type, uint8_t* version, uint8_t* connState);
11.65. Write Slave DO
1/**
2* @brief Write Slave DO
3* @param [in] DOIndex DO Number
4* @param [in] writeNum Number to Write // Corrected typo from wirteNum
5* @param [in] status[8] Value to Write, maximum 8
6* @return Error Code
7*/
8errno_t FieldBusSlaveWriteDO(uint8_t DOIndex, uint8_t writeNum, uint8_t status[8]);
11.66. Write Slave AO
1/**
2* @brief Write Slave AO
3* @param [in] AOIndex AO Number
4* @param [in] writeNum Number to Write // Corrected typo from wirteNum
5* @param [in] status[8] Value to Write, maximum 8
6* @return Error Code
7*/
8errno_t FieldBusSlaveWriteAO(uint8_t AOIndex, uint8_t writeNum, double status[8]);
11.67. Read Slave DI
1/**
2* @brief Read Slave DI
3* @param [in] DIIndex DI Number // Corrected parameter name from DOIndex
4* @param [in] readNum Number to Read // Corrected typo from readeNum
5* @param [out] status[8] Value Read, maximum 8
6* @return Error Code
7*/
8errno_t FieldBusSlaveReadDI(uint8_t DIIndex, uint8_t readNum, uint8_t status[8]);
11.68. Read Slave AI
1/**
2* @brief Read Slave AI
3* @param [in] AIIndex AI Number // Corrected parameter name from AOIndex
4* @param [in] readNum Number to Read // Corrected typo from readeNum
5* @param [out] status[8] Value Read, maximum 8
6* @return Error Code
7*/
8errno_t FieldBusSlaveReadAI(uint8_t AIIndex, uint8_t readNum, double status[8]);
11.69. Wait for Extended DI Input
1/**
2* @brief Wait for Extended DI Input
3* @param [in] DIIndex DI Number
4* @param [in] status 0-Low Level; 1-High Level
5* @param [in] waitMs Maximum Wait Time (ms)
6* @return Error Code
7*/
8errno_t FRRobot::FieldBusSlaveWaitDI(uint8_t DIIndex, bool status, int waitMs);
11.70. Wait for Extended AI Input
1/**
2* @brief Wait for Extended AI Input
3* @param [in] AIIndex AI Number
4* @param [in] waitType 0-Greater Than; 1-Less Than
5* @param [in] value AI Value
6* @param [in] waitMs Maximum Wait Time (ms)
7* @return Error Code
8*/
9errno_t FRRobot::FieldBusSlaveWaitAI(uint8_t AIIndex, uint8_t waitType, double value, int waitMs);
11.72. Laser Peripheral On/Off
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Peripheral On/Off Function
3 * @param [in] OnOff 0- Off 1- On
4 * @param [in] weldId Weld ID, default is 0
5 * @return Error code
6 */
7errno_t LaserTrackingLaserOnOff(int OnOff,int weldId);
11.73. Laser Tracking Start/Stop
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Tracking Start/Stop Function
3 * @param [in] OnOff 0- Stop 1- Start
4 * @param [in] coordId Laser peripheral tool coordinate system ID
5 * @return Error code
6 */
7 errno_t LaserTrackingTrackOnOff(int OnOff, int coordId);
11.74. Laser Seam Search Start - Fixed Direction
New in version C++SDK-v3.8.6.
1/**
2* @brief Laser Seam Search - Fixed Direction
3* @param [in] direction 0- X+ 1- X- 2- Y+ 3- Y- 4- Z+ 5- Z-
4* @param [in] vel Speed, unit %
5* @param [in] distance Maximum search distance, unit mm
6* @param [in] timeout Search timeout time, unit ms
7* @param [in] posSensorNum Laser calibrated tool coordinate number
8* @return Error code
9*/
10errno_t LaserTrackingSearchStart_xyz(int direction, int vel, int distance, int timeout, int posSensorNum);
11.75. Laser Seam Search Start - Arbitrary Point Direction
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Seam Search - Arbitrary Direction
3 * @param [in] directionPoint Search input point's xyz coordinates
4 * @param [in] vel Speed, unit %
5 * @param [in] distance Maximum search distance, unit mm
6 * @param [in] timeout Search timeout time, unit ms
7 * @param [in] posSensorNum Laser calibrated tool coordinate number
8 * @return Error code
9 */
10errno_t LaserTrackingSearchStart_point(DescTran directionPoint, int vel, int distance, int timeout, int posSensorNum);
11.76. Laser Seam Search Stop
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Seam Search Stop
3 * @return Error code
4 */
5errno_t LaserTrackingSearchStop();
11.77. Laser Network Parameter Configuration
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Network Parameter Configuration
3 * @param [in] ip Laser peripheral IP address
4 * @param [in] port Laser peripheral port number
5 * @return Error code
6 */
7errno_t LaserTrackingSensorConfig(std::string ip, int port);
11.78. Laser Peripheral Sampling Period Configuration
New in version C++SDK-v3.8.6.
1/**
2* @brief Laser Peripheral Sampling Period Configuration
3* @param [in] period Laser peripheral sampling period, unit ms
4* @return Error code
5*/
6errno_t LaserTrackingSensorSamplePeriod(int period);
11.79. Laser Peripheral Driver Load
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Peripheral Driver Load
3 * @param [in] type Laser peripheral driver protocol type 101- Ruiniu 102- Chuangxiang 103- Quanshi 104- Tongzhou 105- Aotai
4 * @return Error code
5 */
6errno_t LoadPosSensorDriver(int type);
11.80. Laser Peripheral Driver Unload
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Peripheral Driver Unload
3 * @return Error code
4 */
5errno_t UnLoadPosSensorDriver();
11.81. Laser Seam Trajectory Recording
New in version C++SDK-v3.8.6.
1/**
2* @brief Laser Seam Trajectory Recording
3* @param [in] status 0- Stop recording 1- Real-time tracking 2- Start recording
4* @param [in] delayTime Delay time, unit ms
5* @return Error code
6*/
7errno_t LaserSensorRecord1(int status, int delayTime);
11.82. Laser Seam Trajectory Replay
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Seam Trajectory Replay
3 * @param [in] delayTime Delay time, unit ms
4 * @param [in] speed Speed, unit %
5 * @return Error code
6 */
7errno_t LaserSensorReplay(int delayTime, double speed);
11.83. Laser Tracking Replay
New in version C++SDK-v3.8.6.
1/**
2 * @brief Laser Tracking Replay
3 * @return Error code
4 */
5errno_t MoveLTR();
11.84. Laser Seam Trajectory Recording and Replay
New in version C++SDK-v3.8.6.
1/**
2* @brief Laser Seam Trajectory Recording and Replay
3* @param [in] delayMode Mode 0-Delay Time 1-Delay Distance
4* @param [in] delayTime Delay time in milliseconds (ms)
5* @param [in] delayDisExAxisNum Extended Axis Number
6* @param [in] delayDis Delay distance in millimeters (mm)
7* @param [in] sensitivePara Compensation Sensitivity Coefficient
8* @param [in] trackMode Fixed-point Tracking Type. 0-Extended Axis Asynchronous Motion; 1-Robot
9* @param [in] triggerMode Fixed-point Tracking Trigger Method. 0-Tracking Duration; 1-IO
10* @param [in] runTime Robot Fixed-point Tracking Duration in seconds (s)
11* @param [in] speed Speed in percentage (%)
12* @return Error Code
13*/
14errno_t LaserSensorRecordandReplay(int delayMode, int delayTime, int delayDisExAxisNum, double delayDis, double sensitivePara, int trackMode, int triggerMode, double runTime, double speed);
11.85. Move to Laser Recorded Start Point
New in version C++SDK-v3.8.6.
1/**
2* @brief Move to Laser Recorded Start Point
3* @param [in] moveType 0- moveJ 1- moveL
4* @param [in] ovl Speed, unit %
5* @return Error code
6*/
7errno_t MoveToLaserRecordStart(int moveType, double ovl);
11.86. Move to Laser Recorded End Point
New in version C++SDK-v3.8.6.
1/**
2* @brief Move to Laser Recorded End Point
3* @param [in] moveType 0- moveJ 1- moveL
4* @param [in] ovl Speed, unit %
5* @return Error code
6*/
7errno_t MoveToLaserRecordEnd(int moveType, double ovl);
11.87. Move to Laser Sensor Seam Search Point
New in version C++SDK-v3.8.6.
1/**
2* @brief Move to Laser Sensor Seam Search Point
3* @param [in] moveFlag Motion type: 0- PTP; 1- LIN
4* @param [in] ovl Speed scaling factor, 0-100
5* @param [in] dataFlag Seam buffer data selection: 0- Execute planned data; 1- Execute recorded data
6* @param [in] plateType Plate type: 0- Corrugated plate; 1- Corrugated cardboard; 2- Fence plate; 3- Oil drum; 4- Corrugated shell steel
7* @param [in] trackOffectType Laser sensor offset type: 0- No offset; 1- Base coordinate system offset; 2- Tool coordinate system offset; 3- Laser sensor raw data offset
8* @param [in] offset Offset amount
9* @return Error code
10*/
11errno_t MoveToLaserSeamPos(int moveFlag, double ovl, int dataFlag, int plateType, int trackOffectType, DescPose offset);
11.88. Get Laser Sensor Seam Search Point Coordinates
New in version C++SDK-v3.8.6.
1/**
2* @brief Get Laser Sensor Seam Search Point Coordinate Information
3* @param [in] trackOffectType Laser sensor offset type: 0- No offset; 1- Base coordinate system offset; 2- Tool coordinate system offset; 3- Laser sensor raw data offset
4* @param [in] offset Offset amount
5* @param [out] jPos Joint position [°]
6* @param [out] descPos Cartesian position [mm]
7* @param [out] tool Tool coordinate system
8* @param [out] user Work object coordinate system
9* @param [out] exaxis Extended axis position [mm]
10* @return Error code
11*/
12errno_t GetLaserSeamPos(int trackOffectType, DescPose offset, JointPos& jPos, DescPose& descPos, int& tool, int& user, ExaxisPos& exaxis);
11.89. Laser Peripheral Sensor Parameter Configuration and Debugging Code Example
New in version C++SDK-v3.8.6.
1void testLaserConfig()
2{
3 ROBOT_STATE_PKG pkg = {};
4 FRRobot robot;
5 uint8_t ctrl[20];
6 uint8_t state;
7 int pressVlaue;
8 int error;
9 robot.CloseRPC();
10 robot.LoggerInit();
11 robot.SetLoggerLevel(1);
12 int rtn = robot.RPC("192.168.58.2");
13 if (rtn != 0)
14 {
15 return;
16 }
17 robot.SetReConnectParam(true, 30000, 500);
18 //Set IP address and port number
19 robot.LaserTrackingSensorConfig("192.168.58.20", 5020);
20 //Set sampling period
21 robot.LaserTrackingSensorSamplePeriod(20);
22 //Load driver
23 robot.LoadPosSensorDriver(101);
24 //Turn off laser peripheral
25 robot.LaserTrackingLaserOnOff(0,0);
26 robot.Sleep(3000);
27 //Turn on laser peripheral
28 robot.LaserTrackingLaserOnOff(1, 0);
29 robot.CloseRPC();
30}
11.90. Laser Trajectory Scanning and Trajectory Replay Code Example
New in version C++SDK-v3.8.6.
1void testLaserRecordAndReplay()
2{
3 ROBOT_STATE_PKG pkg = {};
4 FRRobot robot;
5 uint8_t ctrl[20];
6 uint8_t state;
7 int pressVlaue;
8 int error;
9 robot.CloseRPC();
10 robot.LoggerInit();
11 robot.SetLoggerLevel(1);
12 int rtn = robot.RPC("192.168.58.2");
13 if (rtn != 0)
14 {
15 return;
16 }
17 robot.SetReConnectParam(true, 30000, 500);
18
19 //Upload and load open protocol file
20 robot.OpenLuaUpload("E://openlua/CtrlDev_laser_ruiniu-0117.lua");
21 robot.Sleep(2000);
22 robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
23 robot.UnloadCtrlOpenLUA(0);
24 robot.LoadCtrlOpenLUA(0);
25 robot.Sleep(8000);
26 int cnt = 1;
27 while(cnt<31)
28 {
29 //Move to scan start point
30 JointPos startjointPos(56.205, -117.951, 141.872, -118.149, -94.217, -122.176);
31 DescPose startdescPose(-97.552, -282.855, 26.675, 174.182, -1.338, -91.707);
32 ExaxisPos exaxisPos(0, 0, 0, 0);
33 DescPose offdese(0, 0, 0, 0, 0, 0);
34 robot.MoveL(&startjointPos, &startdescPose, 1, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
35 //Start trajectory recording
36 robot.LaserSensorRecord1(2, 10);
37 //Move to the end point to be recorded
38 JointPos endjointPos(68.809, -87.100, 121.120, -127.233, -95.038, -109.555);
39 DescPose enddescPose(-103.555, -464.234, 13.076, 174.179, -1.344, -91.709);
40 robot.MoveL(&endjointPos, &enddescPose, 1, 0, 30, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
41 //Stop recording
42 robot.LaserSensorRecord1(0, 10);
43 //Move to the recorded seam start point
44 robot.MoveToLaserRecordStart(1, 30);
45 //Start trajectory replay
46 robot.LaserSensorReplay(10, 100);
47 robot.MoveLTR();
48 //Stop trajectory replay
49 robot.LaserSensorRecord1(0, 10);
50 printf("Laser scanning + trajectory replay stability test, %dth time\n", cnt);
51 cnt++;
52 }
53 robot.CloseRPC();
54}
11.91. Laser Seam Search and Real-time Tracking Code Example
New in version C++SDK-v3.8.6.
1void testLasertrack()
2{
3 ROBOT_STATE_PKG pkg = {};
4 FRRobot robot;
5 uint8_t ctrl[20];
6 uint8_t state;
7 int pressVlaue;
8 int error;
9 robot.CloseRPC();
10 robot.LoggerInit();
11 robot.SetLoggerLevel(1);
12 int rtn = robot.RPC("192.168.58.2");
13
14 if (rtn != 0)
15 {
16 return;
17 }
18 robot.SetReConnectParam(true, 30000, 500);
19
20 //Upload and load open protocol file
21 robot.OpenLuaUpload("E://openlua/CtrlDev_laser_ruiniu-0117.lua");
22 robot.Sleep(2000);
23 robot.SetCtrlOpenLUAName(0, "CtrlDev_laser_ruiniu-0117.lua");
24 robot.UnloadCtrlOpenLUA(0);
25 robot.LoadCtrlOpenLUA(0);
26 robot.Sleep(8000);
27 int cnt = 1;
28 while (cnt < 2)
29 {
30 //Move to the starting point for seam search
31 JointPos startjointPos(58.337, -119.628, 146.037, -116.358, -92.224, -117.654);
32 DescPose startdescPose(-53.375, -255.363, 0.919, 178.054, 1.077, -94.026);
33 ExaxisPos exaxisPos(0, 0, 0, 0);
34 DescPose offdese(0, 0, 0, 0, 0, 0);
35 DescTran directionPoint;
36 robot.MoveL(&startjointPos, &startdescPose, 1, 0, 100, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
37
38 //Start search along the -Y direction
39 int ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2);
40 robot.LaserTrackingSearchStop();
41 //If search is successful
42 if (ret == 0)
43 {
44 //Move to the search point
45 robot.MoveToLaserSeamPos(1, 30, 0, 0, 0, offdese);
46 //Start laser tracking along the search point
47 robot.LaserTrackingTrackOnOff(1, 2);
48 JointPos endjointPos(70.580, -90.918, 126.593, -125.154, -92.162, -105.403);
49 DescPose enddescPose(-53.375, -419.020, 0.920, 178.054, 1.076, -94.026);
50 robot.MoveL(&endjointPos, &enddescPose, 1, 0, 20, 100, 100, -1, &exaxisPos, 0, 0, &offdese, 1, 1);
51 //Stop tracking
52 robot.LaserTrackingTrackOnOff(0, 2);
53
54 }
55 cnt++;
56 }
57 robot.CloseRPC();
58}
11.92. Extended Axis and Robot Synchronized Laser Tracking Code Example
New in version C++SDK-v3.8.6.
1void testLasertrackandExitAxis()
2{
3 ROBOT_STATE_PKG pkg = {};
4 FRRobot robot;
5 uint8_t ctrl[20];
6 uint8_t state;
7 int pressVlaue;
8 int error;
9 robot.CloseRPC();
10 robot.LoggerInit();
11 robot.SetLoggerLevel(1);
12 int rtn = robot.RPC("192.168.58.2");
13
14 if (rtn != 0)
15 {
16 return;
17 }
18 robot.SetReConnectParam(true, 30000, 500);
19
20 ExaxisPos startexaxisPos = { 0,0,0,0 };
21 ExaxisPos seamexaxisPos = { -10,0,0,0 };
22 ExaxisPos endexaxisPos = { -30, 0, 0, 0 };
23 DescPose offdese = { 0, 0, 0, 0, 0, 0 };
24 JointPos seamjointPos(0, 0, 0, 0, 0, 0);
25 DescPose seamdescPose(0, 0, 0, 0, 0, 0);
26
27 int cnt = 1;
28 while (cnt < 31)
29 {
30 //Move to the starting point for seam search
31 JointPos startjointPos(58.337, -119.628, 146.037, -116.358, -92.224, -117.654);
32 DescPose startdescPose(-53.375, -255.363, 0.919, 178.054, 1.077, -94.026);
33 robot.ExtAxisSyncMoveJ(startjointPos, startdescPose, 1, 0, 100, 100, 100, startexaxisPos, -1, 0, offdese);
34
35 //Start search along the -Y direction
36 int ret = robot.LaserTrackingSearchStart_xyz(3, 100, 300, 1000, 2);
37 robot.LaserTrackingSearchStop();
38 int tool = 0;
39 int user = 0;
40 robot.GetLaserSeamPos(0, offdese, seamjointPos, seamdescPose, tool, user, startexaxisPos);
41 printf("%f, %f, %f,%f, %f, %f,%f, %f, %f,%f, %f, %f\n", seamjointPos.jPos[0], seamjointPos.jPos[1], seamjointPos.jPos[2], seamjointPos.jPos[3], seamjointPos.jPos[4], seamjointPos.jPos[5], seamdescPose.tran.x, seamdescPose.tran.y, seamdescPose.tran.z, seamdescPose.rpy.rx, seamdescPose.rpy.ry, seamdescPose.rpy.rz);
42
43 //If search is successful
44 if (ret == 0)
45 {
46 //Robot and extended axis synchronously move to the search point
47 robot.ExtAxisSyncMoveJ(seamjointPos, seamdescPose, 1, 0, 100, 100, 100, seamexaxisPos, -1, 0, offdese);
48
49 //Start laser tracking along the search point and synchronously move with the extended axis
50 robot.LaserTrackingTrackOnOff(1, 2);
51 JointPos endjointPos(70.580, -90.918, 126.593, -125.154, -92.162, -105.403);
52 DescPose enddescPose(-53.375, -419.020, 0.920, 178.054, 1.076, -94.026);
53 robot.ExtAxisSyncMoveL(endjointPos, enddescPose, 1, 0, 20, 100, 100, -1, endexaxisPos, 0, offdese);;
54 //Stop tracking
55 robot.LaserTrackingTrackOnOff(0, 2);
56 }
57 cnt++;
58 printf("Extended axis and robot synchronized laser tracking, %dth time\n", cnt);
59 }
60 robot.CloseRPC();
61}
11.93. End-Effector Transparent Transmission Function Enable/Disable
1/**
2* @brief Enable/disable end-effector transparent transmission function
3* @param [in] enable, 0-disable, 1-enable
4* @return Error code
5*/
6errno_t SetAxleGenComEnable(int mode);
11.94. End-Effector Transparent Transmission Function Non-Periodic Data Transmission and Reception
1/**
2* @brief End-effector transparent transmission function non-periodic data transmission and reception
3* @param [in] len_snd Length of data to send
4* @param [in] sndBuff Data to send
5* @param [in] len_rcv Length of data to receive
6* @param [out] rcvBuff Response data
7* @return Error code
8*/
9errno_t SndRcvAxleGenComCmdData(int lenSnd, int sndBuff[130], int lenRcv, int rcvData[130]);
11.95. Code Example for Non-Periodic Data Communication of DIO Health Care Moxibustion Head Based on End-Effector Transparent Transmission Function
1int testAxleGenCom()
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 int led_on[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x01, 0x79 };
14 int led_off[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
15 int version[5] = { 0xAB, 0xBA, 0x11, 0x00, 0x76 };
16 int state[6] = { 0xAB, 0xBA, 0x1B, 0x01, 0xAA, 0x2B };
17 int cycleState[6] = { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
18 int rcvdata[16] = {0};
19 int ret = 0;
20 int cnt = 1;
21 JointPos p1Joint(88.708, -86.178, 140.989, -141.825, -89.162, -49.879);
22 DescPose p1Desc(188.007, -377.850, 260.207, 178.715, 2.823, -131.466);
23 JointPos p2Joint(112.131, -75.554, 126.989, -139.027, -88.044, -26.477);
24 DescPose p2Desc(368.003, -377.848, 260.211, 178.715, 2.823, -131.465);
25 ExaxisPos exaxisPos(0, 0, 0, 0);
26 DescPose offdese(0, 0, 0, 0, 0, 0);
27 //Enable end-effector transparent transmission function
28 robot.SetAxleGenComEnable(1);
29 robot.SetAxleLuaEnable(1);
30 while (cnt <= 10000)
31 {
32 //Read version number
33 ret = robot.SndRcvAxleGenComCmdData(5, version, 10, rcvdata);
34 printf(" hard version : %d,hard code:%d, soft version:%d %d, soft code:%d \n", rcvdata[4], rcvdata[5], rcvdata[6] ,rcvdata[7], rcvdata[8]);
35 if (ret != 0)
36 {
37 break;
38 }
39 robot.Sleep(1000);
40 //Read moxibustion head presence status
41 ret = robot.SndRcvAxleGenComCmdData(6, state, 6, rcvdata);
42 printf(" state : %d \n", rcvdata[4]);
43 robot.Sleep(1000);
44 //Turn on moxibustion head laser
45 ret = robot.SndRcvAxleGenComCmdData(6, led_on, 6, rcvdata);
46 printf("led on rcv data is: %d, %d, %d, %d, %d, %d \n", rcvdata[0], rcvdata[1], rcvdata[2], rcvdata[3], rcvdata[4], rcvdata[5]);
47 robot.MoveJ(&p1Joint, &p1Desc, 0, 0, 100, 100, 100, &exaxisPos, -1, 0, &offdese);
48 robot.Sleep(4000);
49 //Turn off moxibustion head laser
50 ret = robot.SndRcvAxleGenComCmdData(6, led_off, 6, rcvdata);
51 printf("led off rcv data is: %d, %d, %d, %d, %d, %d \n", rcvdata[0], rcvdata[1], rcvdata[2], rcvdata[3], rcvdata[4], rcvdata[5]);
52 robot.MoveJ(&p2Joint, &p2Desc, 0, 0, 100, 100, 100, &exaxisPos, -1, 0, &offdese);
53 robot.Sleep(1000);
54 printf("***********************complate No. %d SDK test*****************************\n", cnt);
55 cnt++;
56 }
57 robot.CloseRPC();
58}
11.96. Download Open Protocol Lua File
1/**
2* @brief Download open protocol Lua file
3* @param [in] fileName Open protocol file name "CtrlDev_XXX.lua"
4* @param [in] savePath Path to save the open protocol file
5* @return Error code
6*/
7errno_t OpenLuaDownload(std::string fileName, std::string savePath);
11.97. Delete Open Protocol Lua File
1/**
2* @brief Delete open protocol Lua file
3* @param [in] fileName Name of the open protocol Lua file to delete "CtrlDev_XXX.lua"
4* @return Error code
5*/
6errno_t OpenLuaDelete(std::string fileName);
11.98. Delete All Open Protocol Lua Files
1/**
2* @brief Delete all open protocol Lua files
3* @return Error code
4*/
5errno_t AllOpenLuaDelete();
11.99. Code Example for Controller Peripheral Open Protocol Upload, Download, and Delete
1int TestCtrlOpenLuaOperate()
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 rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_WELDING_A.lua");
14 printf("OpenLuaUpload rtn is %d\n", rtn);
15 rtn = robot.OpenLuaUpload("D://zUP/openlua/CtrlDev_SWDPOLISH.lua");
16 printf("OpenLuaUpload rtn is %d\n", rtn);
17 rtn = robot.OpenLuaDownload("CtrlDev_WELDING_A.lua", "D://zDOWN/");
18 printf("OpenLuaDownload rtn is %d\n", rtn);
19 rtn = robot.OpenLuaDownload("CtrlDev_SWDPOLISH.lua", "D://zDOWN/");
20 printf("OpenLuaDownload rtn is %d\n", rtn);
21 rtn = robot.SetCtrlOpenLUAName(0, "CtrlDev_WELDING_A.lua");
22 printf("SetCtrlOpenLUAName rtn is %d\n", rtn);
23 rtn = robot.SetCtrlOpenLUAName(1, "CtrlDev_SWDPOLISH.lua");
24 printf("SetCtrlOpenLUAName rtn is %d\n", rtn);
25 std::string name[4] = {};
26 rtn = robot.GetCtrlOpenLUAName(name);
27 printf("ctrl open lua names : %s, %s, %s, %s\n", name[0].c_str(), name[1].c_str(), name[2].c_str(), name[3].c_str());
28 rtn = robot.LoadCtrlOpenLUA(1);
29 printf("LoadCtrlOpenLUA rtn is %d\n", rtn);
30 robot.Sleep(2000);
31 rtn = robot.UnloadCtrlOpenLUA(1);
32 printf("UnloadCtrlOpenLUA rtn is %d\n", rtn);
33 rtn = robot.OpenLuaDelete("CtrlDev_WELDING_A.lua");
34 printf("OpenLuaDelete rtn is %d\n", rtn);
35 rtn = robot.AllOpenLuaDelete();
36 printf("AllOpenLuaDelete rtn is %d\n", rtn);
37 robot.CloseRPC();
38 robot.Sleep(1000);
39 return 0;
40}