6. 机器人安全设置
6.1. 设置碰撞等级
1/**
2* @brief 设置碰撞等级
3* @param [in] mode 0-等级,1-百分比
4* @param [in] level 碰撞阈值,等级对应范围[],百分比对应范围[0~1]
5* @param [in] config 0-不更新配置文件,1-更新配置文件
6* @return 错误码
7*/
8int SetAnticollision(int mode, double[] level, int config);
6.2. 设置碰撞后策略
1/**
2* @brief 设置碰撞后策略
3* @param [in] strategy 0-报错停止,1-继续运行
4* @return 错误码
5*/
6int SetCollisionStrategy(int strategy);
6.3. 设置正限位
1/**
2* @brief 设置正限位
3* @param [in] limit 六个关节位置,单位deg
4* @return 错误码
5*/
6int SetLimitPositive(double[] limit);
6.4. 设置负限位
1/**
2* @brief 设置负限位
3* @param [in] limit 六个关节位置,单位deg
4* @return 错误码
5*/
6int SetLimitNegative(double[] limit);
6.5. 错误状态清除
1/**
2* @brief 错误状态清除
3* @return 错误码
4*/
5int ResetAllError();
6.6. 关节摩擦力补偿开关
1/**
2* @brief 关节摩擦力补偿开关
3* @param [in] state 0-关,1-开
4* @return 错误码
5*/
6int FrictionCompensationOnOff(byte state);
6.7. 设置关节摩擦力补偿系数-正装
1/**
2* @brief 设置关节摩擦力补偿系数-正装
3* @param [in] coeff 六个关节补偿系数,范围[0~1]
4* @return 错误码
5*/
6int SetFrictionValue_level(double[] coeff);
6.8. 设置关节摩擦力补偿系数-侧装
1/**
2* @brief 设置关节摩擦力补偿系数-侧装
3* @param [in] coeff 六个关节补偿系数,范围[0~1]
4* @return 错误码
5*/
6int SetFrictionValue_wall(double[] coeff);
6.9. 设置关节摩擦力补偿系数-倒装
1/**
2* @brief 设置关节摩擦力补偿系数-倒装
3* @param [in] coeff 六个关节补偿系数,范围[0~1]
4* @return 错误码
5*/
6int SetFrictionValue_ceiling(double[] coeff);
6.10. 设置关节摩擦力补偿系数-自由安装
1/**
2* @brief 设置关节摩擦力补偿系数-自由安装
3* @param [in] coeff 六个关节补偿系数,范围[0~1]
4* @return 错误码
5*/
6int SetFrictionValue_freedom(double[] coeff);
6.11. 代码示例
1private void btnRobotSafetySet_Click(object sender, EventArgs e)
2{
3 Robot robot = new Robot();
4 robot.RPC("192.168.58.2");
5
6 int mode = 0;
7 int config = 1;
8 double[] level1 = new double[6] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
9 double[] level2 = new double[6] { 0.5, 0.2, 0.3, 0.4, 0.5, 0.12 };
10
11 robot.SetAnticollision(mode, level1, config);
12 mode = 1;
13 robot.SetAnticollision(mode, level2, config);
14 robot.SetCollisionStrategy(2);
15
16 double[] plimit = new double[6] { 170.0, 80.0, 150.0, 80.0, 170.0, 160.0 };
17 int rtn = robot.SetLimitPositive(plimit);
18 Console.WriteLine($"SetLimitPositive rtn {rtn}");
19 double[] nlimit = new double[6] { -170.0, -260.0, -150.0, -260.0, -170.0, -160.0 };
20 rtn = robot.SetLimitNegative(nlimit);
21 Console.WriteLine($"SetLimitNegative rtn {rtn}");
22
23 robot.ResetAllError();
24
25 double[] lcoeff = new double[6] { 0.9, 0.9, 0.9, 0.9, 0.9, 0.9 };
26 double[] wcoeff = new double[6] { 0.4, 0.4, 0.4, 0.4, 0.4, 0.4 };
27 double[] ccoeff = new double[6] { 0.6, 0.6, 0.6, 0.6, 0.6, 0.6 };
28 double[] fcoeff = new double[6] { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
29 robot.FrictionCompensationOnOff(1);
30 rtn = robot.SetFrictionValue_level(lcoeff);
31 Console.WriteLine($"SetFrictionValue_level rtn {rtn}");
32 rtn = robot.SetFrictionValue_wall(wcoeff);
33 Console.WriteLine($"SetFrictionValue_wall rtn {rtn}");
34 rtn = robot.SetFrictionValue_ceiling(ccoeff);
35 Console.WriteLine($"SetFrictionValue_ceiling rtn {rtn}");
36 rtn = robot.SetFrictionValue_freedom(fcoeff);
37 Console.WriteLine($"SetFrictionValue_freedom rtn {rtn}");
38}