12. Force control

12.1. Force sensor configuration

1/**
2* @brief force sensor configuration
3* @param [in] company force sensor manufacturer, 17-Kunwei Technology, 19-Aerospace 11th Institute, 20-ATI Sensor, 21-Zhongke Midian, 22-Weihang Minxin, 23-NBIT, 24-Xinjingcheng (XJC), 26-NSR
4* @param [in] device device number, Kunwei (0-KWR75B), Aerospace 11th Institute (0-MCS6A-200-4), ATI (0-AXIA80-M8), Zhongke Midian (0-MST2010), Weihang Minxin (0-WHC6L-YB-10A), NBIT (0-XLH93003ACS), Xinjingcheng XJC (0-XJC-6F-D82), NSR (0-NSR-FTSensorA)
5* @param [in] softvesion Software version number, not used yet, default is 0
6* @param [in] bus device is hung at the end bus position, not used yet, default is 0
7* @return error code
8*/
9errno_t  FT_SetConfig(int company, int device, int softvesion, int bus);

12.2. Get the force sensor configuration

1/**
2* @brief  Get the force sensor configuration
3* @param  [in] company  Force sensor manufacturer, to be determined
4* @param  [in] device  Device number, not used yet. The default value is 0
5* @param  [in] softvesion  Software version. The value is not used. The default value is 0
6* @param  [in] bus The device is attached to the terminal bus and is not in use. The default value is 0
7* @return  Error code
8*/
9errno_t  FT_GetConfig(int *company, int *device, int *softvesion, int *bus);

12.3. Force Sensor Activation

1/**
2* @brief  Force sensor activation
3* @param  [in] act  0- reset, 1- activate
4* @return  Error code
5*/
6errno_t  FT_Activate(uint8_t act);

12.4. Force sensor calibration

1/**
2* @brief  Force sensor calibration
3* @param  [in] act  0- zero removal, 1- zero correction
4* @return  Error code
5*/
6errno_t  FT_SetZero(uint8_t act);

12.5. Set Force Sensor Reference Coordinate System

1/**
2* @brief  Set force sensor reference coordinate system
3* @param  [in] ref  0-Tool coordinate system, 1-Base coordinate system
4* @return  Error code
5*/
6errno_t  FT_SetRCS(uint8_t ref);

12.6. Set Payload Weight Under Force Sensor

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

1/**
2 * @brief Set payload weight under force sensor
3 * @param [in] weight  Payload weight in kg
4 * @return  Error code
5 */
6errno_t SetForceSensorPayload(double weight);

12.7. Set Payload Center of Gravity Under Force Sensor

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

1/**
2 * @brief Set payload center of gravity under force sensor
3 * @param [in] x  Payload COG x in mm
4 * @param [in] y  Payload COG y in mm
5 * @param [in] z  Payload COG z in mm
6 * @return  Error code
7 */
8errno_t SetForceSensorPayloadCog(double x, double y, double z);

12.8. Get Payload Weight Under Force Sensor

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

1/**
2 * @brief Get payload weight under force sensor
3 * @param [in] weight  Payload weight in kg
4 * @return  Error code
5 */
6errno_t GetForceSensorPayload(double& weight);

12.9. Get Payload Center of Gravity Under Force Sensor

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

1/**
2 * @brief Get payload center of gravity under force sensor
3 * @param [out] x  Payload COG x in mm
4 * @param [out] y  Payload COG y in mm
5 * @param [out] z  Payload COG z in mm
6 * @return  Error code
7 */
8errno_t GetForceSensorPayloadCog(double& x, double& y, double& z);

12.10. Force Sensor Auto Zero Calibration

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

1/**
2 * @brief Force sensor auto zero calibration
3 * @param [out] weight  Sensor mass in kg
4 * @param [out] pos  Sensor COG in mm
5 * @return  Error code
6 */
7errno_t ForceSensorAutoComputeLoad(double& weight, DescTran& pos);

12.11. Get Force/Torque Data in Reference Coordinate System

1/**
2* @brief  Get force/torque data in reference coordinate system
3* @param  [out] ft  Force/torque, fx, fy, fz, tx, ty, tz
4* @return  Error code
5*/
6errno_t  FT_GetForceTorqueRCS(ForceTorque *ft);

12.12. Get Raw Force/Torque Data from Force Sensor

1/**
2* @brief  Get raw force/torque data from force sensor
3* @param  [out] ft  Force/torque, fx, fy, fz, tx, ty, tz
4* @return  Error code
5*/
6errno_t  FT_GetForceTorqueOrigin(ForceTorque *ft);

12.13. Force Sensor Configuration and Auto Zero Calibration Code Example

 1int TestFTInit(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  ForceTorque ft;
31  memset(&ft, 0, sizeof(ForceTorque));
32  robot.FT_GetForceTorqueOrigin(0, &ft);
33  printf("ft origin:%f,%f,%f,%f,%f,%f\n", ft.fx, ft.fy, ft.fz, ft.tx, ft.ty, ft.tz);
34  robot.FT_SetZero(1);
35  robot.Sleep(1000);
36  DescPose ftCoord = {};
37  robot.FT_SetRCS(0, ftCoord);
38  robot.SetForceSensorPayload(0.824);
39  robot.SetForceSensorPayloadCog(0.778, 2.554, 48.765);
40  double weight = 0;
41  double x = 0, y = 0, z = 0;
42  robot.GetForceSensorPayload(weight);
43  robot.GetForceSensorPayloadCog(x, y, z);
44  printf("the FT load is %lf, %lf %lf %lf\n", weight, x, y, z);
45  robot.SetForceSensorPayload(0);
46  robot.SetForceSensorPayloadCog(0, 0, 0);
47  double computeWeight = 0;
48  DescTran tran = {};
49  robot.ForceSensorAutoComputeLoad(weight, tran);
50  cout << "the result is weight " << weight << " pos is " << tran.x << " " << tran.y << " " << tran.z << endl;
51  robot.CloseRPC();
52  return 0;
53}

12.14. Payload Weight Identification Record

1/**
2* @brief  Payload weight identification record
3* @param  [in] id  Sensor coordinate system number, range [1~14]
4* @return  Error code
5*/
6errno_t  FT_PdIdenRecord(int id);

12.15. Payload Weight Identification Calculation

1/**
2* @brief  Payload weight identification calculation
3* @param  [out] weight  Payload weight in kg
4* @return  Error code
5*/
6errno_t  FT_PdIdenCompute(float *weight);

12.16. Payload COG Identification Record

1/**
2* @brief  Payload COG identification record
3* @param  [in] id  Sensor coordinate system number, range [1~14]
4* @param  [in] index  Point number, range [1~3]
5* @return  Error code
6*/
7errno_t  FT_PdCogIdenRecord(int id, int index);

12.17. Payload COG Identification Calculation

1/**
2* @brief  Payload COG identification calculation
3* @param  [out] cog  Payload COG in mm
4* @return  Error code
5*/
6errno_t  FT_PdCogIdenCompute(DescTran *cog);

12.18. Force Sensor Payload Identification Code Example

 1int TestFTLoadCompute(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  ForceTorque ft;
31  memset(&ft, 0, sizeof(ForceTorque));
32  robot.FT_GetForceTorqueOrigin(0, &ft);
33  printf("ft origin:%f,%f,%f,%f,%f,%f\n", ft.fx, ft.fy, ft.fz, ft.tx, ft.ty, ft.tz);
34  robot.FT_SetZero(1);
35  robot.Sleep(1000);
36  DescPose tcoord = {};
37  tcoord.tran.z = 35.0;
38  robot.SetToolCoord(10, &tcoord, 1, 0, 0, 0);
39  robot.FT_PdIdenRecord(10);
40  robot.Sleep(1000);
41  float weight = 0.0;
42  robot.FT_PdIdenCompute(&weight);
43  printf("payload weight:%f\n", weight);
44  DescPose desc_p1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
45  DescPose desc_p2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
46  DescPose desc_p3(-327.622, 402.230, 320.402, -178.067, 2.127, -46.207);
47  robot.MoveCart(&desc_p1, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
48  robot.Sleep(1000);
49  robot.FT_PdCogIdenRecord(10, 1);
50  robot.MoveCart(&desc_p2, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
51  robot.Sleep(1000);
52  robot.FT_PdCogIdenRecord(10, 2);
53  robot.MoveCart(&desc_p3, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
54  robot.Sleep(1000);
55  robot.FT_PdCogIdenRecord(10, 3);
56  robot.Sleep(1000);
57  DescTran cog;
58  memset(&cog, 0, sizeof(DescTran));
59  robot.FT_PdCogIdenCompute(&cog);
60  printf("cog:%f,%f,%f\n", cog.x, cog.y, cog.z);
61  robot.CloseRPC();
62  return 0;
63}

12.19. Collision Guard

 1/**
 2* @brief  Collision guard
 3* @param  [in] flag 0-Turn off collision guard, 1-Turn on collision guard
 4* @param  [in] sensor_id  Force sensor number
 5* @param  [in] select  Select whether to detect collision in six degrees of freedom, 0-Do not detect, 1-Detect
 6* @param  [in] ft  Collision force/torque, fx, fy, fz, tx, ty, tz
 7* @param  [in] max_threshold  Maximum threshold
 8* @param  [in] min_threshold  Minimum threshold
 9* @note   Force/torque detection range: (ft-min_threshold, ft+max_threshold)
10* @return  Error code
11*/
12errno_t  FT_Guard(uint8_t flag, int sensor_id, uint8_t select[6], ForceTorque *ft, float max_threshold[6], float min_threshold[6]);

12.20. Collision Guard Code Example

 1int TestFTGuard(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  uint8_t sensor_id = 1;
31  uint8_t select[6] = { 1,1,1,1,1,1 };
32  float max_threshold[6] = { 10.0,10.0,10.0,10.0,10.0,10.0 };
33  float min_threshold[6] = { 5.0,5.0,5.0,5.0,5.0,5.0 };
34  ForceTorque ft;
35  DescPose desc_p1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
36  DescPose desc_p2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
37  DescPose desc_p3(-327.622, 402.230, 320.402, -178.067, 2.127, -46.207);
38  robot.FT_Guard(1, sensor_id, select, &ft, max_threshold, min_threshold);
39  robot.MoveCart(&desc_p1, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
40  robot.MoveCart(&desc_p2, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
41  robot.MoveCart(&desc_p3, 0, 0, 100.0, 100.0, 100.0, -1.0, -1);
42  robot.FT_Guard(0, sensor_id, select, &ft, max_threshold, min_threshold);
43  robot.CloseRPC();
44  return 0;
45}

12.21. Constant force control

 1/**
 2* @brief Constant Force Control
 3* @param [in] flag 0-disable constant force control, 1-enable constant force control
 4* @param [in] sensor_id Force sensor ID
 5* @param [in] select Select whether to detect collisions in six degrees of freedom, 0-disable detection, 1-enable detection
 6* @param [in] ft Collision force/torque: fx, fy, fz, tx, ty, tz
 7* @param [in] ft_pid Force PID parameters, torque PID parameters
 8* @param [in] adj_sign Adaptive start/stop control, 0-disable, 1-enable
 9* @param [in] ILC_sign ILC start/stop control, 0-stop, 1-training, 2-practical operation
10* @param [in] max_dis Maximum adjustment distance, unit: mm
11* @param [in] max_ang Maximum adjustment angle, unit: deg
12* @param [in] M Mass parameter for rx, ry [0.1-10], default 2
13* @param [in] B Damping parameter for rx, ry [0.1-50], default 8
14* @param [in] threshold Activation threshold for rx, ry [0-10], default 0.2
15* @param [in] adjustCoeff Torque adjustment coefficient for rx, ry [0-1], default 1
16* @param [in] polishRadio Polishing radius, unit: mm
17* @param [in] filter_Sign Filter enable flag 0-off; 1-on, default off
18* @param [in] posAdapt_sign Posture compliance enable flag 0-off; 1-on, default off
19* @param [in] isNoBlock Blocking flag, 0-blocking; 1-non-blocking
20* @return Error code
21*/
22errno_t FT_Control(uint8_t flag, int sensor_id, uint8_t select[6], ForceTorque* ft, float ft_pid[6], uint8_t adj_sign,
23uint8_t ILC_sign, float max_dis, float max_ang, double M[2], double B[2], double threshold[2], double adjustCoeff[2], double polishRadio = 0.0, int filter_Sign = 0, int posAdapt_sign = 0, int isNoBlock = 0);

12.22. Example of constant force control code with damping

 1int TestFTControlWithAdjustCoeff(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  uint8_t sensor_id = 10;
14  uint8_t select[6] = { 0,0,1,0,0,0 };
15  float ft_pid[6] = { 0.0008, 0.0, 0.0, 0.0, 0.0, 0.0 };
16  uint8_t adj_sign = 0;
17  uint8_t ILC_sign = 0;
18  float max_dis = 1000.0;
19  float max_ang = 20;
20  ForceTorque ft = {0.0};
21  ExaxisPos epos(0, 0, 0, 0);
22  JointPos j1(80.765, -98.795, 106.548, -97.734, -89.999, 94.842);
23  JointPos j2(43.067, -84.429, 92.620, -98.175, -90.011, 57.144);
24  DescPose desc_p1(5.009, -547.463, 262.053, -179.999, -0.019, 75.923);
25  DescPose desc_p2(-347.966, -547.463, 262.048, -180.000, -0.019, 75.923);
26  DescPose offset_pos(0, 0, 0, 0, 0, 0);
27  double M[2] = { 2.0, 2.0 };
28  double B[2] = { 15.0, 15.0 };
29  double threshold[2] = {1.0, 1.0};
30  double adjustCoeff[2] = {1.0, 0.8};
31  double polishRadio = 0.0;
32  int filter_Sign = 0;
33  int posAdapt_sign = 1;
34  int isNoBlock;
35  ft.fz = -10.0;
36  while(true)
37  {
38    rtn = robot.FT_Control(1, sensor_id, select, &ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, M, B, threshold, adjustCoeff, 0, 0, 1, 0);
39    printf("FT_Control start rtn is %d\n", rtn);
40    robot.MoveL(&j1, &desc_p1, 1, 0, 100, 100, 100, -1, 0, &epos, 0, 0, &offset_pos, 200.0, 0);
41    robot.MoveL(&j2, &desc_p2, 1, 0, 100, 100, 100, -1, 0, &epos, 0, 0, &offset_pos, 200.0, 0);
42    rtn = robot.FT_Control(0, sensor_id, select, &ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, M, B, threshold, adjustCoeff, 0, 0, 1, 0);
43    printf("FT_Control end rtn is %d\n", rtn);
44  }
45  robot.CloseRPC();
46  return 0;
47}

12.24. Rotary Insertion

 1/**
 2* @brief  Rotary insertion
 3* @param  [in] rcs  Reference coordinate system, 0-Tool coordinate system, 1-Base coordinate system
 4* @param  [in] angVelRot  Rotational angular velocity in deg/s
 5* @param  [in] ft  Force/torque threshold, fx, fy, fz, tx, ty, tz, range [0~100]
 6* @param  [in] max_angle  Maximum rotation angle in deg
 7* @param  [in] orn  Force/torque direction, 1-Along z-axis, 2-Around z-axis
 8* @param  [in] max_angAcc  Maximum rotational acceleration in deg/s^2, not currently used, default is 0
 9* @param  [in] rotorn  Rotation direction, 1-Clockwise, 2-Counterclockwise
10* @param  [in] strategy Processing strategy for undetected force/torque, 0-Error; 1-Warning, continue motion
11* @return  Error code
12*/
13errno_t FT_RotInsertion(int rcs, float angVelRot, float ft, float max_angle, uint8_t orn, float max_angAcc, uint8_t rotorn, int strategy = 0);

12.25. Example code for force sensor rotation insertion

 1int TestMove(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    JointPos j1(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
14    JointPos j2(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
15    JointPos j3(-29.777, -84.536, 109.275, -114.075, -86.655, 74.257);
16    JointPos j4(-31.154, -95.317, 94.276, -88.079, -89.740, 74.256);
17    DescPose desc_pos1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
18    DescPose desc_pos2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
19    DescPose desc_pos3(-487.434, 154.362, 308.576, 176.600, 0.268, -14.061);
20    DescPose desc_pos4(-443.165, 147.881, 480.951, 179.511, -0.775, -15.409);
21    DescPose offset_pos(0, 0, 0, 0, 0, 0);
22    ExaxisPos epos(0, 0, 0, 0);
23    int tool = 0;
24    int user = 0;
25    float vel = 100.0;
26    float acc = 100.0;
27    float ovl = 100.0;
28    float oacc = 100.0;
29    float blendT = 0.0;
30    float blendR = 0.0;
31    uint8_t flag = 0;
32    uint8_t search = 0;
33    int blendMode = 0;
34    int velAccMode = 0;
35    robot.SetSpeed(20);
36    rtn = robot.MoveJ(&j1, &desc_pos1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
37    printf("movej errcode:%d\n", rtn);
38    rtn = robot.MoveL(&j2, &desc_pos2, tool, user, vel, acc, ovl, blendR, blendMode, &epos, search, flag, &offset_pos, oacc, velAccMode);
39    printf("movel errcode:%d\n", rtn);
40    rtn = robot.MoveC(&j3, &desc_pos3, tool, user, vel, acc, &epos, flag, &offset_pos, &j4, &desc_pos4, tool, user, vel, acc, &epos, flag, &offset_pos, ovl, blendR, oacc, velAccMode);
41    printf("movec errcode:%d\n", rtn);
42    rtn = robot.MoveJ(&j2, &desc_pos2, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
43    printf("movej errcode:%d\n", rtn);
44    rtn = robot.Circle(&j3, &desc_pos3, tool, user, vel, acc, &epos, &j1, &desc_pos1, tool, user, vel, acc, &epos, ovl, flag, &offset_pos, oacc, -1, velAccMode);
45    printf("circle errcode:%d\n", rtn);
46    rtn = robot.MoveCart(&desc_pos4, tool, user, vel, acc, ovl, blendT, -1);
47    printf("MoveCart errcode:%d\n", rtn);
48    rtn = robot.MoveJ(&j1, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
49    printf("movej errcode:%d\n", rtn);
50    rtn = robot.MoveL(&desc_pos2, tool, user, vel, acc, ovl, blendR, blendMode, &epos, search, flag, &offset_pos, -1, velAccMode);
51    printf("movel errcode:%d\n", rtn);
52    rtn = robot.MoveC(&desc_pos3, tool, user, vel, acc, &epos, flag, &offset_pos, &desc_pos4, tool, user, vel, acc, &epos, flag, &offset_pos, ovl, blendR, -1, velAccMode);
53    printf("movec errcode:%d\n", rtn);
54    rtn = robot.MoveJ(&j2, tool, user, vel, acc, ovl, &epos, blendT, flag, &offset_pos);
55    printf("movej errcode:%d\n", rtn);
56    rtn = robot.Circle(&desc_pos3, tool, user, vel, acc, &epos, &desc_pos1, tool, user, vel, acc, &epos, ovl, flag, &offset_pos, oacc, blendR, -1, velAccMode);
57    printf("circle errcode:%d\n", rtn);
58    robot.CloseRPC();
59    return 0;
60}

12.26. Linear Insertion

 1/**
 2* @brief  Linear insertion
 3* @param  [in] rcs  Reference coordinate system, 0-Tool coordinate system, 1-Base coordinate system
 4* @param  [in] ft  Force/torque threshold, fx, fy, fz, tx, ty, tz, range [0~100]
 5* @param  [in] lin_v  Linear velocity in mm/s
 6* @param  [in] lin_a  Linear acceleration in mm/s^2, not currently used
 7* @param  [in] max_dis  Maximum insertion distance in mm
 8* @param  [in] linorn  Insertion direction, 0-Negative direction, 1-Positive direction
 9* @return  Error code
10*/
11errno_t  FT_LinInsertion(int rcs, float ft, float lin_v, float lin_a, float max_dis, uint8_t linorn);

12.27. Spiral Search, Linear Insertion and Other Instruction Code Examples

 1int TestFTSearch(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  uint8_t status = 1;
31  int sensor_num = 1;
32  float gain[6] = { 0.0001,0.0,0.0,0.0,0.0,0.0 };
33  uint8_t adj_sign = 0;
34  uint8_t ILC_sign = 0;
35  float max_dis = 100.0;
36  float max_ang = 5.0;
37  ForceTorque ft;
38  memset(&ft, 0, sizeof(ForceTorque));
39  int rcs = 0;
40  float dr = 0.7;
41  float fFinish = 1.0;
42  float t = 60000.0;
43  float vmax = 3.0;
44  float force_goal = 20.0;
45  float lin_v = 0.0;
46  float lin_a = 0.0;
47  float disMax = 100.0;
48  uint8_t linorn = 1;
49  float angVelRot = 2.0;
50  float forceInsertion = 1.0;
51  int angleMax = 45;
52  uint8_t orn = 1;
53  float angAccmax = 0.0;
54  uint8_t rotorn = 1;
55  uint8_t select1[6] = { 0,0,1,1,1,0 };
56  ft.fz = -10.0;
57  robot.FT_Control(status, sensor_num, select1, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
58  rtn = robot.FT_SpiralSearch(rcs, dr, fFinish, t, vmax);
59  printf("FT_SpiralSearch rtn is %d\n", rtn);
60  status = 0;
61  robot.FT_Control(status, sensor_num, select1, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
62  uint8_t select2[6] = { 1,1,1,0,0,0 };
63  gain[0] = 0.00005;
64  ft.fz = -30.0;
65  status = 1;
66  robot.FT_Control(status, sensor_num, select2, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
67  rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn);
68  printf("FT_LinInsertion rtn is %d\n", rtn);
69  status = 0;
70  robot.FT_Control(status, sensor_num, select2, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
71  uint8_t select3[6] = { 0,0,1,1,1,0 };
72  ft.fz = -10.0;
73  gain[0] = 0.0001;
74  status = 1;
75  robot.FT_Control(status, sensor_num, select3, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
76  rtn = robot.FT_RotInsertion(rcs, angVelRot, forceInsertion, angleMax, orn, angAccmax, rotorn);
77  printf("FT_RotInsertion rtn is %d\n", rtn);
78  status = 0;
79  robot.FT_Control(status, sensor_num, select3, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
80  uint8_t select4[6] = { 1,1,1,0,0,0 };
81  ft.fz = -30.0;
82  status = 1;
83  robot.FT_Control(status, sensor_num, select4, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
84  rtn = robot.FT_LinInsertion(rcs, force_goal, lin_v, lin_a, disMax, linorn);
85  printf("FT_LinInsertion rtn is %d\n", rtn);
86  status = 0;
87  robot.FT_Control(status, sensor_num, select4, &ft, gain, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
88  robot.CloseRPC();
89  return 0;
90}

12.28. Surface Localization

 1/**
 2* @brief  Surface localization
 3* @param  [in] rcs  Reference coordinate system, 0-Tool coordinate system, 1-Base coordinate system
 4* @param  [in] dir  Movement direction, 1-Positive direction, 2-Negative direction
 5* @param  [in] axis  Movement axis, 1-x axis, 2-y axis, 3-z axis
 6* @param  [in] lin_v  Search linear velocity in mm/s
 7* @param  [in] lin_a  Search linear acceleration in mm/s^2, not currently used, default is 0
 8* @param  [in] max_dis  Maximum search distance in mm
 9* @param  [in] ft  Action termination force/torque threshold, fx, fy, fz, tx, ty, tz
10* @return  Error code
11*/
12errno_t  FT_FindSurface(int rcs, uint8_t dir, uint8_t axis, float lin_v, float lin_a, float max_dis, float ft);

12.29. Calculate Middle Plane Position - Start

1/**
2* @brief  Calculate middle plane position - start
3* @return  Error code
4*/
5errno_t  FT_CalCenterStart();

12.30. Calculate Middle Plane Position - End

1/**
2* @brief  Calculate middle plane position - end
3* @param  [out] pos  Middle plane pose
4* @return  Error code
5*/
6errno_t  FT_CalCenterEnd(DescPose *pos);

12.31. Surface Localization Code Example

 1int TestSurface(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  int rcs = 0;
31  uint8_t dir = 1;
32  uint8_t axis = 1;
33  float lin_v = 3.0;
34  float lin_a = 0.0;
35  float maxdis = 50.0;
36  float ft_goal = 2.0;
37  DescPose desc_pos(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
38  DescPose xcenter(0, 0, 0, 0, 0, 0);
39  DescPose ycenter(0, 0, 0, 0, 0, 0);
40  ForceTorque ft;
41  memset(&ft, 0, sizeof(ForceTorque));
42  ft.fx = -2.0;
43  robot.MoveCart(&desc_pos, 9, 0, 100.0, 100.0, 100.0, -1.0, -1);
44  robot.FT_CalCenterStart();
45  robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal);
46  robot.MoveCart(&desc_pos, 9, 0, 100.0, 100.0, 100.0, -1.0, -1);
47  robot.WaitMs(1000);
48  dir = 2;
49  robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal);
50  robot.FT_CalCenterEnd(&xcenter);
51  printf("xcenter:%f,%f,%f,%f,%f,%f\n", xcenter.tran.x, xcenter.tran.y, xcenter.tran.z, xcenter.rpy.rx, xcenter.rpy.ry, xcenter.rpy.rz);
52  robot.MoveCart(&xcenter, 9, 0, 60.0, 50.0, 50.0, -1.0, -1);
53  robot.FT_CalCenterStart();
54  dir = 1;
55  axis = 2;
56  lin_v = 6.0;
57  maxdis = 150.0;
58  robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal);
59  robot.MoveCart(&desc_pos, 9, 0, 100.0, 100.0, 100.0, -1.0, -1);
60  robot.WaitMs(1000);
61  dir = 2;
62  robot.FT_FindSurface(rcs, dir, axis, lin_v, lin_a, maxdis, ft_goal);
63  robot.FT_CalCenterEnd(&ycenter);
64  printf("ycenter:%f,%f,%f,%f,%f,%f\n", ycenter.tran.x, ycenter.tran.y, ycenter.tran.z, ycenter.rpy.rx, ycenter.rpy.ry, ycenter.rpy.rz);
65  robot.MoveCart(&ycenter, 9, 0, 60.0, 50.0, 50.0, 0.0, -1);
66  robot.CloseRPC();
67  return 0;
68}

12.32. Compliance Control Activation

1/**
2* @brief  Compliance control activation
3* @param  [in] p  Position adjustment coefficient or compliance coefficient
4* @param  [in] force  Compliance activation force threshold in N
5* @return  Error code
6*/
7errno_t  FT_ComplianceStart(float p, float force);

12.33. Compliance Control Deactivation

1/**
2* @brief  Compliance control deactivation
3* @return  Error code
4*/
5errno_t  FT_ComplianceStop();

12.34. Compliance Control Code Example

 1int TestCompliance(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 = 24;
14  int device = 0;
15  int softversion = 0;
16  int bus = 1;
17  int index = 1;
18  robot.FT_SetConfig(company, device, softversion, bus);
19  robot.Sleep(1000);
20  robot.FT_GetConfig(&company, &device, &softversion, &bus);
21  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
22  robot.Sleep(1000);
23  robot.FT_Activate(0);
24  robot.Sleep(1000);
25  robot.FT_Activate(1);
26  robot.Sleep(1000);
27  robot.Sleep(1000);
28  robot.FT_SetZero(0);
29  robot.Sleep(1000);
30  uint8_t flag = 1;
31  int sensor_id = 1;
32  uint8_t select[6] = { 1,1,1,0,0,0 };
33  float ft_pid[6] = { 0.0005,0.0,0.0,0.0,0.0,0.0 };
34  uint8_t adj_sign = 0;
35  uint8_t ILC_sign = 0;
36  float max_dis = 100.0;
37  float max_ang = 0.0;
38  ForceTorque ft;
39  DescPose offset_pos(0, 0, 0, 0, 0, 0);
40  ExaxisPos epos(0, 0, 0, 0);
41  memset(&ft, 0, sizeof(ForceTorque));
42  JointPos j1(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
43  JointPos j2(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
44  DescPose desc_p1(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
45  DescPose desc_p2(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
46  ft.fx = -10.0;
47  ft.fy = -10.0;
48  ft.fz = -10.0;
49  robot.FT_Control(flag, sensor_id, select, &ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
50  float p = 0.00005;
51  float force = 30.0;
52  rtn = robot.FT_ComplianceStart(p, force);
53  printf("FT_ComplianceStart rtn is %d\n", rtn);
54  int count = 15;
55  while (count)
56  {
57    robot.MoveL(&j1, &desc_p1, 0, 0, 100.0, 180.0, 100.0, -1.0, &epos, 0, 1, &offset_pos);
58    robot.MoveL(&j2, &desc_p2, 0, 0, 100.0, 180.0, 100.0, -1.0, &epos, 0, 0, &offset_pos);
59    count -= 1;
60  }
61  robot.FT_ComplianceStop();
62  printf("FT_ComplianceStop rtn is %d\n", rtn);
63  flag = 0;
64  robot.FT_Control(flag, sensor_id, select, &ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
65  robot.CloseRPC();
66  return 0;
67}

12.35. Payload Identification Initialization

1/**
2* @brief Payload identification initialization
3* @return Error code
4*/
5errno_t LoadIdentifyDynFilterInit();

12.36. Payload Identification Initialization

1/**
2* @brief Payload identification initialization
3* @return Error code
4*/
5errno_t LoadIdentifyDynVarInit();

12.37. Payload Identification Main Program

1/**
2* @brief Payload identification main program
3* @param [in] joint_torque  Joint torque
4* @param [in] joint_pos  Joint position
5* @param [in] t  Sampling period
6* @return Error code
7*/
8errno_t LoadIdentifyMain(double joint_torque[6], double joint_pos[6], double t);

12.38. Get Payload Identification Result

1/**
2* @brief Get payload identification result
3* @param [in] gain
4* @param [out] weight  Payload weight
5* @param [out] cog  Payload COG
6* @return Error code
7*/
8errno_t LoadIdentifyGetResult(double gain[12], double *weight, DescTran *cog);

12.39. Robot Payload Identification Code Example

 1int TestIdentify(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.LoadIdentifyDynFilterInit();
15  printf("LoadIdentifyDynFilterInit retval is: %d \n", retval);
16  retval = robot.LoadIdentifyDynVarInit();
17  printf("LoadIdentifyDynVarInit retval is: %d \n", retval);
18  JointPos posJ = {};
19  DescPose posDec = {};
20  float joint_toq[6] = { 0.0 };
21  robot.GetActualJointPosDegree(0, &posJ);
22  posJ.jPos[1] = posJ.jPos[1] + 10;
23  robot.GetJointTorques(0, joint_toq);
24  joint_toq[1] = joint_toq[1] + 2;
25  double tmpTorque[6] = { 0.0 };
26  for (int i = 0; i < 6; i++)
27  {
28    tmpTorque[i] = joint_toq[i];
29  }
30  retval = robot.LoadIdentifyMain(tmpTorque, posJ.jPos, 1);
31  printf("LoadIdentifyMain retval is: %d \n", retval);
32  double gain[12] = { 0,0.05,0,0,0,0,0,0.02,0,0,0,0 };
33  double weight = 0;
34  DescTran load_pos;
35  memset(&load_pos, 0, sizeof(DescTran));
36  retval = robot.LoadIdentifyGetResult(gain, &weight, &load_pos);
37  printf("LoadIdentifyGetResult retval is: %d ; weight is %f cog is %f %f %f \n", retval, weight, load_pos.x, load_pos.y, load_pos.z);
38  robot.CloseRPC();
39  return 0;
40}

12.40. Force Sensor Assisted Drag

Changed in version C++SDK-v2.2.0-3.8.0.

 1/**
 2      * @brief  Force sensor assisted drag
 3      * @param  [in] status  Control status, 0-Off; 1-On
 4      * @param  [in] asaptiveFlag  Adaptive activation flag, 0-Off; 1-On
 5      * @param  [in] interfereDragFlag  Interference area drag flag, 0-Off; 1-On
 6      * @param  [in] ingularityConstraintsFlag  Singularity strategy, 0-Avoid; 1-Cross
 7      * @param  [in] forceCollisionFlag Robot collision detection sign for auxiliary dragging; 0-off; 1-on
 8      * @param  [in] M  Inertia coefficient
 9      * @param  [in] B  Damping coefficient
10      * @param  [in] K  Stiffness coefficient
11      * @param  [in] F  Drag six-dimensional force threshold
12      * @param  [in] Fmax  Maximum drag force limit
13      * @param  [in] Vmax  Maximum joint velocity limit
14  * @return  error code
15  */
16  errno_t EndForceDragControl(int status, int asaptiveFlag, int interfereDragFlag, int ingularityConstraintsFlag, int forceCollisionFlag, std::vector<double> M, std::vector<double> B, std::vector<double> K, std::vector<double> F, double Fmax, double Vmax);

12.41. Get Force Sensor Drag Switch Status

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

1/**
2 * @brief Get force sensor drag switch status
3 * @param [out] dragState  Force sensor assisted drag control status, 0-Off; 1-On
4 * @param [out] sixDimensionalDragState  Six-dimensional force assisted drag control status, 0-Off; 1-On
5 * @return Error code
6 */
7errno_t GetForceAndTorqueDragState(int& dragState, int& sixDimensionalDragState);

12.42. Force Sensor Auto Activation After Error Clear

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

1/**
2 * @brief Auto activate force sensor after error clear
3 * @param [in] status  Control status, 0-Off; 1-On
4 * @return Error code
5 */
6errno_t SetForceSensorDragAutoFlag(int status);

12.43. Force Sensor Assisted Drag Code Example

 1int TestEndForceDragCtrl(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.SetForceSensorDragAutoFlag(1);
14  vector <double> M = { 15.0, 15.0, 15.0, 0.5, 0.5, 0.1 };
15  vector <double> B = { 150.0, 150.0, 150.0, 5.0, 5.0, 1.0 };
16  vector <double> K = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
17  vector <double> F = { 10.0, 10.0, 10.0, 1.0, 1.0, 1.0 };
18  robot.EndForceDragControl(1, 0, 0, 0, 1, M, B, K, F, 50, 100);
19  robot.Sleep(5000);
20  int dragState = 0;
21  int sixDimensionalDragState = 0;
22  robot.GetForceAndTorqueDragState(dragState, sixDimensionalDragState);
23  printf("the drag state is %d %d \n", dragState, sixDimensionalDragState);
24  robot.EndForceDragControl(0, 0, 0, 0, 1, M, B, K, F, 50, 100);
25  robot.CloseRPC();
26  return 0;
27}

12.44. Set Six-Dimensional Force and Joint Impedance Hybrid Drag Switch and Parameters

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

 1/**
 2 * @brief Set six-dimensional force and joint impedance hybrid drag switch and parameters
 3 * @param [in] status  Control status, 0-Off; 1-On
 4 * @param [in] impedanceFlag  Impedance activation flag, 0-Off; 1-On
 5 * @param [in] lamdeDain  Drag gain
 6 * @param [in] KGain  Stiffness gain
 7 * @param [in] BGain  Damping gain
 8 * @param [in] dragMaxTcpVel  Maximum end linear velocity limit for drag
 9 * @param [in] dragMaxTcpOriVel  Maximum end angular velocity limit for drag
10 * @return Error code
11 */
12errno_t ForceAndJointImpedanceStartStop(int status, int impedanceFlag, std::vector<double> lamdeDain, std::vector<double> KGain, std::vector<double> BGain, double dragMaxTcpVel, double dragMaxTcpOriVel);

12.45. Six-Dimensional Force and Joint Impedance Hybrid Drag Code Example

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

 1int TestForceAndJointImpedance(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.DragTeachSwitch(1);
14  vector <double> lamdeDain = { 3.0, 2.0, 2.0, 2.0, 2.0, 3.0 };
15  vector <double> KGain = { 0, 0, 0, 0, 0, 0 };
16  vector <double> BGain = { 150, 150, 150, 5.0, 5.0, 1.0 };
17  rtn = robot.ForceAndJointImpedanceStartStop(1, 0, lamdeDain, KGain, BGain, 1000, 180);
18  printf("ForceAndJointImpedanceStartStop rtn is %d\n", rtn);
19  robot.Sleep(5000);
20  robot.DragTeachSwitch(0);
21  rtn = robot.ForceAndJointImpedanceStartStop(0, 0, lamdeDain, KGain, BGain, 1000, 180);
22  printf("ForceAndJointImpedanceStartStop rtn is %d\n", rtn);
23  robot.CloseRPC();
24  return 0;
25}

12.46. Impedance Start/Stop Control

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

 1/**
 2* @brief Impedance Start/Stop Control
 3* @param [in] status 0: Stop; 1- Start
 4* @param [in] workSpace 0- Joint Space; 1- Cartesian Space
 5* @param [in] forceThreshold Trigger force threshold (N)
 6* @param [in] m Mass parameter
 7* @param [in] b Damping parameter
 8* @param [in] k Stiffness parameter
 9* @param [in] maxV Maximum linear velocity (mm/s)
10* @param [in] maxVA Maximum linear acceleration (mm/s²)
11* @param [in] maxW Maximum angular velocity (°/s)
12* @param [in] maxWA Maximum angular acceleration (°/s²)
13* @return Error code
14*/
15errno_t ImpedanceControlStartStop(int status, int workSpace, double forceThreshold[6], double m[6], double b[6], double k[6], double maxV, double maxVA, double maxW, double maxWA);

12.47. Robot Impedance Start/Stop Control Code Example

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

 1int TestImpedanceControl()
 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 0;
16  }
17  robot.SetReConnectParam(true, 30000, 500);
18  JointPos j1(102.622, -135.990, 120.769, -73.950, -90.848, 35.507);
19  JointPos j2(93.674, -80.062, 82.947, -92.199, -90.967, 26.559);
20  DescPose desc_pos1(136.552, -149.799, 449.532, 179.817, -1.172, 157.123);
21  DescPose desc_pos2(136.540, -561.048, 449.542, 179.819, -1.172, 157.122);
22  DescPose offset_pos(0, 0, 0, 0, 0, 0);
23  ExaxisPos epos(0, 0, 0, 0);
24  int tool = 0;
25  int user = 0;
26  float vel = 100.0;
27  float acc = 200.0;
28  float ovl = 100.0;
29  float blendT = -1.0;
30  float blendR = -1.0;
31  uint8_t flag = 0;
32  uint8_t search = 0;
33  robot.SetSpeed(20);
34  int company = 17;
35  int device = 0;
36  int softversion = 0;
37  int bus = 1;
38  robot.FT_SetConfig(company, device, softversion, bus);
39  robot.Sleep(1000);
40  robot.FT_GetConfig(&company, &device, &softversion, &bus);
41  printf("FT config:%d,%d,%d,%d\n", company, device, softversion, bus);
42  robot.Sleep(1000);
43  robot.FT_Activate(0);
44  robot.Sleep(1000);
45  robot.FT_Activate(1);
46  robot.Sleep(1000);
47  robot.Sleep(1000);
48  robot.FT_SetZero(0);
49  robot.Sleep(1000);
50  robot.FT_SetZero(1);
51  robot.Sleep(1000);
52  double forceThreshold[6] = { 30,30,30,5,5,5 };
53  double m[6] = { 0.1,0.1,0.1,0.02,0.02,0.02 };
54  double b[6] = { 1,1,1,0.08,0.08,0.08 };
55  double k[6] = { 0,0,0,0,0,0 };
56  rtn = robot.ImpedanceControlStartStop(1, 1, forceThreshold, m, b, k, 1000, 500, 100, 100);
57  printf("ImpedanceControlStartStop errcode:%d\n", rtn);
58  rtn = robot.MoveL(&desc_pos1, tool, user, vel, acc, ovl, blendR, 0, &epos, search, flag, &offset_pos, -1, 1);
59  rtn = robot.MoveL(&desc_pos2, tool, user, vel, acc, ovl, blendR, 0, &epos, search, flag, &offset_pos, -1, 1);
60  rtn = robot.MoveL(&desc_pos1, tool, user, vel, acc, ovl, blendR, 0, &epos, search, flag, &offset_pos, -1, 1);
61  rtn = robot.MoveL(&desc_pos2, tool, user, vel, acc, ovl, blendR, 0, &epos, search, flag, &offset_pos, -1, 1);
62  printf("movel errcode:%d\n", rtn);
63  robot.ImpedanceControlStartStop(0, 1, forceThreshold, m, b, k, 1000, 500, 100, 100);
64  robot.CloseRPC();
65  return 0;
66}

12.48. Enable torque compensation function and compensation coefficient

1/**
2* @brief Enable torque compensation function and compensation coefficient
3* @param [in] status Switch, 0-Disable; 1-Enable
4* @param [in] torqueCoeff J1-J6 torque compensation coefficient [0-1]
5* @return Error code
6*/
7errno_t SerCoderCompenParams(int status, double torqueCoeff[6]);