赞
踩
在珞石SDK二次开发的函数钟,获取当前机器人位姿的函数posture函数在输出时会发现数据不正确,与示教器数据不一致。
其中第一个数据正确 第二三各数据为相反 第四五六各数据为弧度制
转换方法为(弧度/PI)*180度
然后发现第四个数据还要加上180度
第五六各数据要取反,,所以设计了以下代码
- void(){
- ErrorCode ec;
- Lamp1.IsHighlight = robot.getDO(1, 1, out ec);
- Lamp2.IsHighlight = robot.getDO(1, 11, out ec);
- Lamp3.IsHighlight = robot.getDO(1, 12, out ec);
- Lamp4.IsHighlight = robot.getDO(1, 13, out ec);
- Lamp5.IsHighlight = robot.getDO(1, 14, out ec);
- Lamp6.IsHighlight = robot.getDO(1, 15, out ec);
- Lamp7.IsHighlight = robot.getDO(1, 16, out ec);
- //创建新数组保存数据
- double[] aa=new double[6];
- aa[0] = robot.posture(CoordinateType.endInRef, out ec)[0]*1000;//TX
- aa[1] = -robot.posture(CoordinateType.endInRef, out ec)[1] * 1000;//TY
- aa[2] = -robot.posture(CoordinateType.endInRef, out ec)[2] * 1000;//TZ
- aa[3] = robot.posture(CoordinateType.endInRef, out ec)[3];//RX
- aa[4] = robot.posture(CoordinateType.endInRef, out ec)[4];//RY
- aa[5] = robot.posture(CoordinateType.endInRef, out ec)[5];//RZ
-
- double pi = 3.14159265354;
- double rad = 180;
- //二次转换
- aa[3]= 180+(aa[3]*rad)/pi;
- aa[4]= -(aa[4]*rad)/pi;
- aa[5]= -(aa[5]*rad)/pi;
- label1.Text = "当前位置:"+aa[0].ToString("0.000")+','+aa[1].ToString("0.000") + ',' + aa[2].ToString("0.000") + ',' + aa[3].ToString("0.000") + ',' + aa[4].ToString("0.000") + ',' + aa[5].ToString("0.000");
- label2.Text = "坐标系:" + String.Join(",",robot.baseFrame(out ec));
- label3.Text = "关节位置:" + String.Join(",",robot.jointPos(out ec));
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。