12. Robot Force Control

12.1. Configure Force Sensor

1/**
2* @brief  Configure force sensor
3* @param  config company: Force sensor manufacturer, 17-Kunwei Technology, 19-Aerospace 11th Academy, 20-ATI Sensor, 21-Zhongke Midian, 22-Weihang Minxin, 23-NBIT, 24-Xinjingcheng (XJC), 26-NSR
4* @param  config device: Device number, Kunwei (0-KWR75B), Aerospace 11th Academy (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  config softvesion: Software version number, not currently used, default is 0
6* @param  config bus: Device bus location, not currently used, default is 0
7* @return  Error code
8*/
9int FT_SetConfig(DeviceConfig config);

12.2. Get Force Sensor Configuration

1/**
2* @brief Get force sensor configuration
3* @param [out] config company: Force sensor manufacturer, 17-Kunwei Technology, 19-Aerospace 11th Academy, 20-ATI Sensor, 21-Zhongke Midian, 22-Weihang Minxin
4* @param [out] config device: Device number, Kunwei (0-KWR75B), Aerospace 11th Academy (0-MCS6A-200-4), ATI (0-AXIA80-M8), Zhongke Midian (0-MST2010), Weihang Minxin (0-WHC6L-YB-10A)
5* @param [out] config softvesion: Software version number, not currently used, default is 0
6* @param [out] config bus: Device bus location, not currently used, default is 0
7* @return Error code
8*/
9int FT_GetConfig(DeviceConfig config);

12.3. Activate Force Sensor

1/**
2* @brief  Activate force sensor
3* @param  [in] act  0-Reset, 1-Activate
4* @return  Error code
5*/
6int FT_Activate(int act);

12.4. Zero Calibration for Force Sensor

1/**
2* @brief  Zero calibration for force sensor
3* @param  [in] act  0-Remove zero point, 1-Zero calibration
4* @return  Error code
5*/
6int FT_SetZero(int act);

12.5. Set Force Sensor Reference Coordinate System

1/**
2* @brief  Set force sensor reference coordinate system
3* @param  [in] type  0-Tool coordinate system, 1-Base coordinate system, 2-Free coordinate system
4* @param  [in] coord  Free coordinate system value
5* @return  Error code
6*/
7int FT_SetRCS(int type, DescPose coord);

12.6. Set Load Weight Under Force Sensor

1/**
2* @brief Set load weight under force sensor
3* @param [in] weight Load weight in kg
4* @return Error code
5*/
6int SetForceSensorPayLoad(double weight);

12.7. Set Load Center of Gravity Under Force Sensor

1/**
2* @brief Set load center of gravity under force sensor
3* @param [in] cog Load center of gravity in mm
4* @return Error code
5*/
6int SetForceSensorPayLoadCog(DescTran cog);

12.8. Get Load Weight Under Force Sensor

1/**
2* @brief Get load weight under force sensor
3* @return List[0]: Error code; List[1]: weight Load weight in kg
4*/
5List<Number> GetForceSensorPayLoad();

12.9. Get Load Center of Gravity Under Force Sensor

1/**
2* @brief Get load center of gravity under force sensor
3* @param [out] cog Load center of gravity in mm
4* @return Error code
5*/
6int GetForceSensorPayLoadCog(DescTran cog);

12.10. Automatic Zero Calibration for Force Sensor

1/**
2* @brief Automatic zero calibration for force sensor
3* @param [in] massCenter Sensor mass (kg) and center of gravity (mm)
4* @return Error code
5*/
6int ForceSensorAutoComputeLoad(MassCenter massCenter);

12.11. Get Force/Torque Data in Reference Coordinate System

1/**
2* @brief  Get force/torque data in reference coordinate system
3* @param  [in] flag 0-Blocking, 1-Non-blocking
4* @param  [out] ft  Force/torque, fx,fy,fz,tx,ty,tz
5* @return  Error code
6*/
7int FT_GetForceTorqueRCS(int flag, 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  [in] flag 0-Blocking, 1-Non-blocking
4* @param  [out] ft  Force/torque, fx,fy,fz,tx,ty,tz
5* @return  Error code
6*/
7int FT_GetForceTorqueOrigin(int flag, ForceTorque ft);

12.13. Force Sensor Configuration and Automatic Zero Calibration Example

 1public static int TestFTInit(Robot robot)
 2{
 3    DescTran tr1=new DescTran(0,0,0);
 4    robot.SetForceSensorPayload(0);
 5    robot.SetForceSensorPayloadCog(tr1);
 6
 7    int company = 24;
 8    int device = 0;
 9    int softversion = 0;
10    int bus = 1;
11    int index = 1;
12
13    DeviceConfig con=new DeviceConfig(company,device,softversion,bus);
14    robot.FT_SetConfig(con);
15    robot.Sleep(1000);
16    robot.FT_GetConfig(con);
17    robot.Sleep(1000);
18
19    robot.FT_Activate(0);
20    robot.Sleep(1000);
21    robot.FT_Activate(1);
22    robot.Sleep(1000);
23
24    robot.Sleep(1000);
25    robot.FT_SetZero(0);
26    robot.Sleep(1000);
27
28    ForceTorque ft=new ForceTorque(0,0,0,0,0,0);
29    robot.FT_GetForceTorqueOrigin(0, ft);
30    robot.FT_SetZero(1);
31    robot.Sleep(1000);
32
33    DescPose ftCoord = new DescPose();
34    robot.FT_SetRCS(0, ftCoord);
35
36    robot.SetForceSensorPayload(0.824);
37
38    DescTran tr=new DescTran(0.778, 2.554, 48.765);
39    robot.SetForceSensorPayloadCog(tr);
40    List<Number> weight = new ArrayList<>();
41    double x = 0, y = 0, z = 0;
42    weight=robot.GetForceSensorPayload();
43    robot.GetForceSensorPayloadCog(tr);
44    tr.x=0;
45    tr.y=0;
46    tr.z=0;
47    robot.SetForceSensorPayload(0);
48    robot.SetForceSensorPayloadCog(tr);
49
50    double computeWeight = 0;
51    DescTran tran = new DescTran();
52    MassCenter mass=new MassCenter();
53    mass.weight=weight.get(1).doubleValue();
54    mass.cog=tran;
55    robot.ForceSensorAutoComputeLoad(mass);
56    return 0;
57}

12.14. Load Weight Identification Record

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

12.15. Load Weight Identification Calculation

1/**
2* @brief  Load weight identification calculation
3* @return  List[0]: Error code; List[1]: double weight Load weight in kg
4*/
5List<Number> FT_PdIdenCompute();

12.16. Load Center of Gravity Identification Record

1/**
2* @brief  Load center of gravity 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*/
7int FT_PdCogIdenRecord(int id, int index);

12.17. Load Center of Gravity Identification Calculation

1/**
2* @brief  Load center of gravity identification calculation
3* @param  [out] cog  Load center of gravity in mm
4* @return  Error code
5*/
6int FT_PdCogIdenCompute(DescTran cog);

12.18. Force Sensor Load Identification Example

 1public static int TestFTLoadCompute(Robot robot)
 2{
 3    DescTran tr1=new DescTran(0,0,0);
 4    robot.SetForceSensorPayload(0);
 5    robot.SetForceSensorPayloadCog(tr1);
 6
 7    int company = 24;
 8    int device = 0;
 9    int softversion = 0;
10    int bus = 1;
11    int index = 1;
12
13    DeviceConfig con=new DeviceConfig(company, device, softversion, bus);
14    robot.FT_SetConfig(con);
15    robot.Sleep(1000);
16    robot.FT_GetConfig(con);
17    robot.Sleep(1000);
18
19    robot.FT_Activate(0);
20    robot.Sleep(1000);
21    robot.FT_Activate(1);
22    robot.Sleep(1000);
23
24    robot.Sleep(1000);
25    robot.FT_SetZero(0);
26    robot.Sleep(1000);
27
28    ForceTorque ft=new ForceTorque(0,0,0,0,0,0);
29    robot.FT_GetForceTorqueOrigin(0, ft);
30    robot.FT_SetZero(1);
31    robot.Sleep(1000);
32
33    DescPose tcoord = new DescPose();
34    tcoord.tran.z = 35.0;
35    robot.SetToolCoord(10, tcoord, 1, 0, 0, 0);
36
37    robot.FT_PdIdenRecord(10);
38    robot.Sleep(1000);
39
40    List<Number> weight =new ArrayList<>();
41    weight=robot.FT_PdIdenCompute();
42
43    DescPose desc_p1=new DescPose(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
44    DescPose desc_p2=new DescPose(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
45    DescPose desc_p3=new DescPose(-327.622, 402.230, 320.402, -178.067, 2.127, -46.207);
46
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=new DescTran(0,0,0);
58    robot.FT_PdCogIdenCompute(cog);
59
60    robot.CloseRPC();
61    return 0;
62}

12.19. Collision Guard

 1/**
 2* @brief  Collision guard
 3* @param  [in] flag 0-Disable collision guard, 1-Enable collision guard
 4* @param  [in] sensor_id Force sensor number
 5* @param  [in] select  Select which degrees of freedom to detect collision, 0-Disable, 1-Enable
 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*/
12int FT_Guard(int flag, int sensor_id, Object[] select, ForceTorque ft, Object[] max_threshold, Object[] min_threshold);

12.20. Collision Guard Example

 1public static void main(String[] args)
 2{
 3    Robot robot = new Robot();
 4    robot.SetReconnectParam(true,20,500);//Set reconnection times and interval
 5    robot.LoggerInit(FrLogType.DIRECT, FrLogLevel.INFO, "D://log", 10, 10);
 6    int rtn = robot.RPC("192.168.58.2");
 7    if(rtn == 0)
 8    {
 9        System.out.println("rpc connection success");
10    }
11    else
12    {
13        System.out.println("rpc connection fail");
14        return ;
15    }
16    byte flag = 1;
17    byte sensor_id = 8;
18    Object[] select = { 1, 0, 0, 0, 0, 0 };//Only enable collision guard on x-axis
19    Object[] max_threshold = { 5.0, 0.01, 0.01, 0.01, 0.01, 0.01 };
20    Object[] min_threshold = { 3.0, 0.01, 0.01, 0.01, 0.01, 0.01 };
21
22    ForceTorque ft = new ForceTorque(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
23    DescPose  desc_p1, desc_p2, desc_p3;
24    desc_p1 = new DescPose(-14.404,-455.283,319.847,-172.935,25.141,-68.097);
25    desc_p2 = new DescPose(-107.999,-599.174,285.939,153.472,12.686,-71.284);
26    desc_p3 = new DescPose(6.586,-704.897,309.638,178.909,-27.759,-70.479);
27
28    int rtn =  robot.FT_Guard(flag, sensor_id, select, ft, max_threshold, min_threshold);
29    System.out.println("FT_Guard start rtn {rtn}");
30    robot.MoveCart(desc_p1, 0, 0, 20, 100.0f, 100.0f, -1.0f, -1);
31    robot.MoveCart(desc_p2, 0, 0, 20, 100.0f, 100.0f, -1.0f, -1);
32    robot.MoveCart(desc_p3, 0, 0, 20, 100.0f, 100.0f, -1.0f, -1);
33}

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 number
 5* @param  [in] select  Select which degrees of freedom to detect, 0-Disable, 1-Enable
 6* @param  [in] ft  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-Operation
10* @param  [in] max_dis Maximum adjustment distance in mm
11* @param  [in] max_ang Maximum adjustment angle in deg
12* @param  [in] filter_Sign Filter enable flag, 0-Disable, 1-Enable, default is disabled
13* @param  [in] posAdapt_sign Posture compliance enable flag, 0-Disable, 1-Enable, default is disabled
14* @param  [in] isNoBlock Blocking flag, 0-Blocking, 1-Non-blocking
15* @return  Error code
16*/
17int FT_Control(int flag, int sensor_id, Object[] select, ForceTorque ft, Object[] ft_pid, int adj_sign, int ILC_sign, double max_dis, double max_ang, int filter_Sign, int posAdapt_sign, int isNoBlock);

12.22. Constant Force Control

 1/**
 2* @brief Constant Force Control
 3* @param  flag 0-Disable constant force control, 1-Enable constant force control
 4* @param  sensor_id Force sensor ID
 5* @param  select  Collision detection for six degrees of freedom, 0-Disable, 1-Enable
 6* @param  ft  Collision force/torque, fx, fy, fz, tx, ty, tz
 7* @param  ft_pid Force PID parameters, Torque PID parameters
 8* @param  adj_sign Adaptive start/stop control, 0-Disable, 1-Enable
 9* @param  ILC_sign ILC start/stop control: 0-Stop, 1-Training, 2-Operational
10* @param  max_dis Maximum adjustment distance, unit mm
11* @param  max_ang Maximum adjustment angle, unit deg
12* @param  M Mass parameter for rx, ry [0.1-10], default 2
13* @param  B Damping parameter for rx, ry [0.1-50], default 8
14* @param  threshold Activation threshold for rx, ry [0-10], default 0.2
15* @param  adjustCoeff Torque adjustment coefficient for rx, ry [0-1], default 1
16* @param  polishRadio Polishing radius, in mm
17* @param  filter_Sign Filter enable flag: 0-Off; 1-On (default off)
18* @param  posAdapt_sign Pose adaptation enable flag: 0-Off; 1-On (default off)
19* @param  isNoBlock Blocking flag: 0-Blocking; 1-Non-blocking
20* @return Error code
21*/
22public int FT_Control(int flag, int sensor_id, int[] select, ForceTorque ft, double[] ft_pid, int adj_sign, int ILC_sign, double max_dis, double max_ang,double[] M,double[] B, double[] threshold, double[] adjustCoeff, double polishRadio,int filter_Sign, int posAdapt_sign, int isNoBlock)

12.23. Example Code for Constant Force Control with Damping

 1public static int TestFTControlWithAdjustCoeff(Robot robot)
 2{
 3    int sensor_id = 10;
 4    int[] select = { 0,0,1,0,0,0 };
 5    double[] ft_pid = { 0.0008, 0.0, 0.0, 0.0, 0.0, 0.0 };
 6    int adj_sign = 0;
 7    int ILC_sign = 0;
 8    double max_dis = 1000.0;
 9    double max_ang = 20;
10    ForceTorque ft = new ForceTorque(0.0,0,0,0,0,0);
11    ExaxisPos epos=new ExaxisPos(0, 0, 0, 0);
12    JointPos j1=new JointPos(80.765, -98.795, 106.548, -97.734, -89.999, 94.842);
13    JointPos j2=new JointPos(43.067, -84.429, 92.620, -98.175, -90.011, 57.144);
14    DescPose desc_p1=new DescPose(5.009, -547.463, 262.053, -179.999, -0.019, 75.923);
15    DescPose desc_p2=new DescPose(-347.966, -547.463, 262.048, -180.000, -0.019, 75.923);
16    DescPose offset_pos=new DescPose(0, 0, 0, 0, 0, 0);
17    double[] M = { 2.0, 2.0 };
18    double[] B = { 15.0, 15.0 };
19    double[] threshold = {1.0, 1.0};
20    double[] adjustCoeff = {1.0, 0.8};
21    double polishRadio = 0.0;
22    int filter_Sign = 0;
23    int posAdapt_sign = 1;
24    int isNoBlock;
25    ft.fz = -10.0;
26    while(true)
27    {
28        int 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);
29        System.out.printf("FT_Control start rtn is %d\n", rtn);
30        robot.MoveL(j1, desc_p1, 1, 0, 100.0, 100.0, 100.0, -1.0, 0, epos, 0, 0, offset_pos, 0,0, 0,10);
31        robot.MoveL(j2, desc_p2, 1, 0, 100.0, 100.0, 100.0, -1.0, 0, epos, 0, 0, offset_pos, 0,0, 0,10);
32        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);
33        System.out.printf("FT_Control end rtn is %d\n", rtn);
34    }
35}

12.24. Rotational Insertion

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

12.25. Robot Force Sensor Rotational Insertion Code Example

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

12.26. Constant Force Control Example

 1public static int TestFTControl(Robot robot)
 2{
 3    DescTran tr1=new DescTran(0,0,0);
 4    robot.SetForceSensorPayload(0);
 5    robot.SetForceSensorPayloadCog(tr1);
 6
 7    int company = 24;
 8    int device = 0;
 9    int softversion = 0;
10    int bus = 1;
11    int index = 1;
12    DeviceConfig con=new DeviceConfig(company, device, softversion, bus);
13
14    robot.FT_SetConfig(con);
15    robot.Sleep(1000);
16    robot.FT_GetConfig(con);
17    robot.Sleep(1000);
18
19    robot.FT_Activate(0);
20    robot.Sleep(1000);
21    robot.FT_Activate(1);
22    robot.Sleep(1000);
23
24    robot.Sleep(1000);
25    robot.FT_SetZero(0);
26    robot.Sleep(1000);
27
28    int sensor_id = 1;
29    Object[] select =new Object[] { 0,0,1,0,0,0 };
30    Object[] ft_pid =new Object[]{ 0.0005,0.0,0.0,0.0,0.0,0.0 };
31    int adj_sign = 0;
32    int ILC_sign = 0;
33    double max_dis = 100.0;
34    double max_ang = 0.0;
35
36    ForceTorque ft=new ForceTorque(0,0,0,0,0,0);
37    ExaxisPos epos=new ExaxisPos(0, 0, 0, 0);
38    JointPos j1=new JointPos(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
39    JointPos j2=new JointPos(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
40    DescPose desc_p1=new DescPose(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
41    DescPose desc_p2=new DescPose(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
42    DescPose offset_pos=new DescPose(0, 0, 0, 0, 0, 0);
43
44    ft.fz = -10.0;
45
46    int rtn = robot.MoveJ(j1, desc_p1, 0, 0, 100.0, 180.0, 100.0, epos, -1.0, 0, offset_pos);
47    robot.FT_Control(1, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang,0,0,0);
48    rtn = robot.MoveJ(j2, desc_p2, 0, 0, 100.0, 180.0, 100.0, epos, -1.0, 0, offset_pos);
49    robot.FT_Control(0, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang,0,0,0);
50    return 0;
51}

12.27. Compliance Control Start

1/**
2* @brief  Compliance control start
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*/
7int FT_ComplianceStart(double p, double force);

12.28. Compliance Control Stop

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

12.29. Compliance Control Example

 1public static int TestCompliance(Robot robot)
 2{
 3    DescTran tr1=new DescTran(0,0,0);
 4    robot.SetForceSensorPayload(0);
 5    robot.SetForceSensorPayloadCog(tr1);
 6
 7    int company = 24;
 8    int device = 0;
 9    int softversion = 0;
10    int bus = 1;
11    int index = 1;
12
13    DeviceConfig con=new DeviceConfig(company, device, softversion, bus);
14    robot.FT_SetConfig(con);
15    robot.Sleep(1000);
16    robot.FT_GetConfig(con);
17
18    robot.Sleep(1000);
19
20    robot.FT_Activate(0);
21    robot.Sleep(1000);
22    robot.FT_Activate(1);
23    robot.Sleep(1000);
24
25    robot.Sleep(1000);
26    robot.FT_SetZero(0);
27    robot.Sleep(1000);
28
29    int flag = 1;
30    int sensor_id = 1;
31    Object[] select =new Object[] { 1,1,1,0,0,0 };
32    Object[] ft_pid =new Object[] { 0.0005,0.0,0.0,0.0,0.0,0.0 };
33    int adj_sign = 0;
34    int ILC_sign = 0;
35    double max_dis = 100.0;
36    double max_ang = 0.0;
37
38    ForceTorque ft=new ForceTorque(0,0,0,0,0,0);
39    DescPose  offset_pos=new DescPose(0, 0, 0, 0, 0, 0);
40    ExaxisPos epos=new ExaxisPos(0, 0, 0, 0);
41
42
43    JointPos j1=new JointPos(-11.904, -99.669, 117.473, -108.616, -91.726, 74.256);
44    JointPos j2=new JointPos(-45.615, -106.172, 124.296, -107.151, -91.282, 74.255);
45    DescPose desc_p1=new DescPose(-419.524, -13.000, 351.569, -178.118, 0.314, 3.833);
46    DescPose desc_p2=new DescPose(-321.222, 185.189, 335.520, -179.030, -1.284, -29.869);
47
48    ft.fx = -10.0;
49    ft.fy = -10.0;
50    ft.fz = -10.0;
51    robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
52    double p = 0.00005;
53    double force = 30.0;
54    int rtn = robot.FT_ComplianceStart(p, force);
55
56    int count = 15;
57    while (count>0)
58    {
59        robot.MoveL(j1, desc_p1, 0, 0, 100.0, 180.0, 100.0, -1.0,0, epos, 0, 1, offset_pos,0,10);
60        robot.MoveL(j2, desc_p2, 0, 0, 100.0, 180.0, 100.0, -1.0,0, epos, 0, 0, offset_pos,0,10);
61        count -= 1;
62    }
63    robot.FT_ComplianceStop();
64    flag = 0;
65    robot.FT_Control(flag, sensor_id, select, ft, ft_pid, adj_sign, ILC_sign, max_dis, max_ang, 0, 0, 0);
66
67    robot.CloseRPC();
68    return 0;
69}

12.30. Load Identification Initialization

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

12.31. Load Identification Variable Initialization

1/**
2* @brief Load identification variable initialization
3* @return Error code
4*/
5int LoadIdentifyDynVarInit();

12.32. Load Identification Main Program

1/**
2* @brief Load 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*/
8int LoadIdentifyMain(Object[] joint_torque, Object[] joint_pos, double t);

12.33. Get Load Identification Result

1/**
2* @brief Get load identification result
3* @param [in] gain
4* @return List[0]: Error code; List[1]: double weight Load weight; List[2]: x Load center of gravity X in mm; List[3]: y Load center of gravity Y in mm; List[2]: z Load center of gravity Z in mm
5*/
6List<Number> LoadIdentifyGetResult(Object[] gain);

12.34. Robot Load Identification Example

 1public static int TestIdentify(Robot robot)
 2{
 3    int retval = 0;
 4
 5    retval = robot.LoadIdentifyDynFilterInit();
 6
 7    retval = robot.LoadIdentifyDynVarInit();
 8
 9    JointPos posJ = new JointPos(0,0,0,0,0,0);
10    DescPose posDec = new DescPose(0,0,0,0,0,0);
11    List<Number> joint_toq=new ArrayList<>();
12    robot.GetActualJointPosDegree( posJ);
13    posJ.J2 = posJ.J2 + 10;
14    joint_toq=robot.GetJointTorques(0);
15
16    Object[] gain =new Object[] { 0,0.05,0,0,0,0,0,0.02,0,0,0,0 };
17    double weight = 0;
18    DescTran load_pos=new DescTran(0,0,0);
19    List<Number> num=new ArrayList<>();
20    num = robot.LoadIdentifyGetResult(gain);
21
22    robot.CloseRPC();
23    return 0;
24
25}

12.35. Force Sensor Assisted Dragging

Changed in version Java: SDK-v1.0.6-3.8.3

 1/**
 2* @brief Force sensor assisted dragging
 3* @param [in] status Control status, 0-Disable; 1-Enable
 4* @param [in] asaptiveFlag Adaptive enable flag, 0-Disable; 1-Enable
 5* @param [in] interfereDragFlag Interference zone dragging flag, 0-Disable; 1-Enable
 6* @param [in] ingularityConstraintsFlag Singularity strategy, 0-Avoid; 1-Traverse
 7* @param [in] forceCollisionFlag Robot collision detection flag during assisted dragging; 0-Disable; 1-Enable
 8* @param [in] M Inertia coefficient
 9* @param [in] B Damping coefficient
10* @param [in] K Stiffness coefficient
11* @param [in] F Dragging six-dimensional force threshold
12* @param [in] Fmax Maximum dragging force limit in Nm
13* @param [in] Vmax Maximum joint speed limit in °/s
14* @return Error code
15*/
16int EndForceDragControl(int status, int asaptiveFlag, int interfereDragFlag,int ingularityConstraintsFlag, int forceCollisionFlag, Object[] M, Object[] B, Object[] K, Object[] F, double Fmax, double Vmax)

12.36. Get Force Sensor Dragging Switch Status

1/**
2* @brief Get force sensor dragging switch status
3* @return List[0]: Error code; List[1]: dragState Force sensor assisted dragging control status, 0-Disable; 1-Enable; List[1]: sixDimensionalDragState Six-dimensional force assisted dragging control status, 0-Disable; 1-Enable
4*/
5List<Integer> GetForceAndTorqueDragState();

12.37. Force Sensor Auto-Enable After Error Clearance

1/**
2* @brief Force sensor auto-enable after error clearance
3* @param [in] status Control status, 0-Disable; 1-Enable
4* @return Error code
5*/
6int SetForceSensorDragAutoFlag(int status)

12.38. Force Sensor Assisted Dragging Example

 1public static int TestEndForceDragCtrl(Robot robot)
 2{
 3    DescTran tr1=new DescTran(0,0,0);
 4    robot.SetForceSensorPayload(0);
 5    robot.SetForceSensorPayloadCog(tr1);
 6
 7    robot.SetForceSensorDragAutoFlag(1);
 8
 9    Object[] M =new Object[] { 15.0, 15.0, 15.0, 0.5, 0.5, 0.1 };
10    Object[] B =new Object[] { 150.0, 150.0, 150.0, 5.0, 5.0, 1.0 };
11    Object[] K =new Object[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
12    Object[] F =new Object[] { 10.0, 10.0, 10.0, 1.0, 1.0, 1.0 };
13    robot.EndForceDragControl(1, 0, 0, 0, M, B, K, F, 50, 100);
14
15    robot.Sleep(10000);
16
17    int dragState = 0;
18    int sixDimensionalDragState = 0;
19    List<Integer> state=new ArrayList<>();
20    state=robot.GetForceAndTorqueDragState();
21
22    robot.EndForceDragControl(0, 0, 0, 0, M, B, K, F, 50, 100);
23    return 0;
24}

12.39. Set Six-Dimensional Force and Joint Impedance Hybrid Dragging Switch and Parameters

 1/**
 2* @brief Set six-dimensional force and joint impedance hybrid dragging switch and parameters
 3* @param [in] status Control status, 0-Disable; 1-Enable
 4* @param [in] impedanceFlag Impedance enable flag, 0-Disable; 1-Enable
 5* @param [in] lamdeGain Dragging gain
 6* @param [in] KGain Stiffness gain
 7* @param [in] BGain Damping gain
 8* @param [in] dragMaxTcpVel Maximum end-effector linear velocity limit during dragging
 9* @param [in] dragMaxTcpOriVel Maximum end-effector angular velocity limit during dragging
10* @return Error code
11*/
12int ForceAndJointImpedanceStartStop(int status, int impedanceFlag, Object[] lamdeGain, Object[] KGain, Object[] BGain, double dragMaxTcpVel, double dragMaxTcpOriVel);

12.40. Six-Dimensional Force and Joint Impedance Hybrid Dragging Example

 1public static int TestForceAndJointImpedance(Robot robot)
 2{
 3    robot.DragTeachSwitch(1);
 4    Object[] lamdeDain =new Object[] { 3.0, 2.0, 2.0, 2.0, 2.0, 3.0 };
 5    Object[] KGain = new Object[]{ 0, 0, 0, 0, 0, 0 };
 6    Object[] BGain =new Object[] { 150, 150, 150, 5.0, 5.0, 1.0 };
 7    int rtn = robot.ForceAndJointImpedanceStartStop(1, 0, lamdeDain, KGain, BGain, 1000.0, 180.0);
 8
 9    robot.Sleep(10000);
10
11    robot.DragTeachSwitch(0);
12    rtn = robot.ForceAndJointImpedanceStartStop(0, 0, lamdeDain, KGain, BGain, 1000.0, 180.0);
13
14    robot.CloseRPC();
15    return 0;
16}

12.41. Example Program

 1private static void TestUDPWireSearch(Robot robot)
 2{
 3    UDPComParam param = new UDPComParam("192.168.58.88", 2021, 2, 100, 3, 100, 1, 100, 10,0);
 4    robot.ExtDevSetUDPComParam(param);//UDP extended axis communication
 5
 6    robot.SetWireSearchExtDIONum(0, 0);
 7
 8    int rtn0, rtn1, rtn2 = 0;
 9    ExaxisPos exaxisPos = new ExaxisPos(0.0, 0.0, 0.0, 0.0);
10    DescPose offdese = new DescPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
11
12    DescPose descStart = new DescPose(-158.767, -510.596, 271.709, -179.427, -0.745, -137.349);
13    JointPos jointStart = new JointPos(61.667, -79.848, 108.639, -119.682, -89.700, -70.985);
14
15    DescPose descEnd = new DescPose(0.332, -516.427, 270.688, 178.165, 0.017, -119.989);
16    JointPos jointEnd = new JointPos(79.021, -81.839, 110.752, -118.298, -91.729, -70.981);
17
18    robot.MoveL(jointStart, descStart, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);
19    robot.MoveL(jointEnd, descEnd, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);
20
21    DescPose descREF0A = new DescPose(-66.106, -560.746, 270.381, 176.479, -0.126, -126.745);
22    JointPos jointREF0A = new JointPos(73.531, -75.588, 102.941, -116.250, -93.347, -69.689);
23
24    DescPose descREF0B = new DescPose(-66.109, -528.440, 270.407, 176.479, -0.129, -126.744);
25    JointPos jointREF0B = new JointPos(72.534, -79.625, 108.046, -117.379, -93.366, -70.687);
26
27    DescPose descREF1A = new DescPose(72.975, -473.242, 270.399, 176.479, -0.129, -126.744);
28    JointPos jointREF1A = new JointPos(87.169, -86.509, 115.710, -117.341, -92.993, -56.034);
29
30    DescPose descREF1B = new DescPose(31.355, -473.238, 270.405, 176.480, -0.130, -126.745);
31    JointPos jointREF1B = new JointPos(82.117, -87.146, 116.470, -117.737, -93.145, -61.090);
32
33    rtn0 = robot.WireSearchStart(0, 10, 100, 0, 10, 100, 0);
34    robot.MoveL(jointREF0A, descREF0A, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);  //Starting point
35    robot.MoveL(jointREF0B, descREF0B, 1, 0, 10, 100, 100, -1, exaxisPos, 1, 0, offdese, 0, 100);  //Direction point
36    rtn1 = robot.WireSearchWait("REF0");
37    rtn2 = robot.WireSearchEnd(0, 10, 100, 0, 10, 100, 0);
38
39    rtn0 = robot.WireSearchStart(0, 10, 100, 0, 10, 100, 0);
40    robot.MoveL(jointREF1A, descREF1A, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);  //Starting point
41    robot.MoveL(jointREF1B, descREF1B, 1, 0, 10, 100, 100, -1, exaxisPos, 1, 0, offdese, 0, 100);  //Direction point
42    rtn1 = robot.WireSearchWait("REF1");
43    rtn2 = robot.WireSearchEnd(0, 10, 100, 0, 10, 100, 0);
44
45    rtn0 = robot.WireSearchStart(0, 10, 100, 0, 10, 100, 0);
46    robot.MoveL(jointREF0A, descREF0A, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);  //Starting point
47    robot.MoveL(jointREF0B, descREF0B, 1, 0, 10, 100, 100, -1, exaxisPos, 1, 0, offdese, 0, 100);  //Direction point
48    rtn1 = robot.WireSearchWait("RES0");
49    rtn2 = robot.WireSearchEnd(0, 10, 100, 0, 10, 100, 0);
50
51    rtn0 = robot.WireSearchStart(0, 10, 100, 0, 10, 100, 0);
52    robot.MoveL(jointREF1A, descREF1A, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);  //Starting point
53    robot.MoveL(jointREF1B, descREF1B, 1, 0, 10, 100, 100, -1, exaxisPos, 1, 0, offdese, 0, 100);  //Direction point
54
55    rtn1 = robot.WireSearchWait("RES1");
56    rtn2 = robot.WireSearchEnd(0, 10, 100, 0, 10, 100, 0);
57
58    String[] varNameRef = {"REF0", "REF1", "#", "#", "#", "#"};
59    String[] varNameRes = {"RES0", "RES1", "#", "#", "#", "#"};
60    int offectFlag = 0;
61    //DescPose offectPos = new DescPose(0, 0, 0, 0, 0, 0);
62    DescOffset offset = new DescOffset();
63    rtn0 = robot.GetWireSearchOffset(0, 0, varNameRef, varNameRes, offset);
64    robot.PointsOffsetEnable(0, offset.offset);
65    robot.MoveL(jointStart, descStart, 1, 0, 100, 100, 100, -1, exaxisPos, 0, 0, offdese, 0, 100);
66    robot.MoveL(jointEnd, descEnd, 1, 0, 100, 100, 100, -1, exaxisPos, 1, 0, offdese, 0, 100);
67    robot.PointsOffsetDisable();
68}

12.42. Impedance Control Start/Stop

 1/**
 2* @brief Impedance Control Start/Stop
 3* @param [in] status 0: disable; 1-enable
 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 Max linear velocity (mm/s)
10* @param [in] maxVA Max linear acceleration (mm/s2)
11* @param [in] maxW Max angular velocity (°/s)
12* @param [in] maxWA Max angular acceleration (°/s2)
13* @return Error code
14*/
15public int ImpedanceControlStartStop(int status, int workSpace, double[] forceThreshold, double[] m, double[] b, double[] k, double maxV, double maxVA, double maxW, double maxWA)

12.43. Robot Impedance Control Start/Stop Code Example

 1public static int TestImpedanceControl(Robot robot)
 2{
 3    JointPos j1=new JointPos(102.622, -135.990, 120.769, -73.950, -90.848, 35.507);
 4    JointPos j2=new JointPos(93.674, -80.062, 82.947, -92.199, -90.967, 26.559);
 5    DescPose desc_pos1=new DescPose(136.552, -149.799, 449.532, 179.817, -1.172, 157.123);
 6    DescPose desc_pos2=new DescPose(136.540, -561.048, 449.542, 179.819, -1.172, 157.122);
 7    DescPose offset_pos=new DescPose(0, 0, 0, 0, 0, 0);
 8    ExaxisPos epos=new ExaxisPos(0, 0, 0, 0);
 9    int tool = 0;
10    int user = 0;
11    double vel = 100.0;
12    double acc = 200.0;
13    double ovl = 100.0;
14    double blendT = -1.0;
15    double blendR = -1.0;
16    int flag = 0;
17    int search = 0;
18    robot.SetSpeed(20);
19    int company = 17;
20    int device = 0;
21    int softversion = 0;
22    int bus = 1;
23    DeviceConfig con=new DeviceConfig(company, device, softversion, bus);
24    robot.FT_SetConfig(con);
25    robot.Sleep(1000);
26    robot.FT_GetConfig(con);
27    System.out.println("FT config:"+con.company+","+con.device+","+con.softwareVersion+"con"+ con.bus);
28    robot.Sleep(1000);
29    robot.FT_Activate(0);
30    robot.Sleep(1000);
31    robot.FT_Activate(1);
32    robot.Sleep(1000);
33    robot.Sleep(1000);
34    robot.FT_SetZero(0);
35    robot.Sleep(1000);
36    robot.FT_SetZero(1);
37    robot.Sleep(1000);
38    double[] forceThreshold = { 30,30,30,5,5,5 };
39    double[] m= { 0.1,0.1,0.1,0.02,0.02,0.02 };
40    double[] b = { 1,1,1,0.08,0.08,0.08 };
41    double[] k = { 0,0,0,0,0,0 };
42    int rtn = robot.ImpedanceControlStartStop(1, 1, forceThreshold, m, b, k, 1000, 500, 100, 100);
43    System.out.println("ImpedanceControlStartStop errcode:"+ rtn);
44    rtn = robot.MoveL(desc_pos1, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
45    rtn = robot.MoveL(desc_pos2, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
46    rtn = robot.MoveL(desc_pos1, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
47    rtn = robot.MoveL(desc_pos2, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
48    rtn = robot.MoveL(desc_pos1, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
49    rtn = robot.MoveL(desc_pos2, tool, user, vel, acc, ovl, blendR, 0, epos, search, flag, offset_pos, -1,0,-1, 1);
50    System.out.println("movel errcode:"+ rtn);
51    robot.ImpedanceControlStartStop(0, 1, forceThreshold, m, b, k, 1000, 500, 100, 100);
52    robot.CloseRPC();
53    return 0;
54}

12.44. Enable Torque Compensation Function and Compensation Coefficients

1/**
2* @brief Enable Torque Compensation Function and Compensation Coefficients
3* @param  status Switch, 0-Disable; 1-Enable
4* @param  torqueCoeff J1-J6 Torque compensation coefficients [0-1]
5* @return Error code
6*/
7public int SerCoderCompenParams(int status, double[] torqueCoeff)