上位机如何直接移动ABB机器人?
1、上位机希望实时获取当前机器人位置(笛卡尔坐标系或者关节坐标),如何实现?
可以通过pcsdk实现,如何获取pcsdk相关dll及添加dll,参考二次开发之安装pcsdk及加载dll
//获取world坐标系下的当前位置
double rx;
double ry;
double rz;
RobTarget aRobTarget = controller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.World);
txt1.Text = aRobTarget.Trans.X.ToString(format: "#0.00");
txt2.Text = aRobTarget.Trans.Y.ToString(format: "#0.00");
txt3.Text = aRobTarget.Trans.Z.ToString(format: "#0.00");
aRobTarget.Rot.ToEulerAngles(out rx, out ry, out rz);
txt4.Text = rz.ToString(format: "#0.00");
txt5.Text = ry.ToString(format: "#0.00");
txt6.Text = rx.ToString(format: "#0.00");
2、对于位置数据的赋值,可以使用如下代码double ry;
double rz;
RobTarget aRobTarget = controller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.World);
txt1.Text = aRobTarget.Trans.X.ToString(format: "#0.00");
txt2.Text = aRobTarget.Trans.Y.ToString(format: "#0.00");
txt3.Text = aRobTarget.Trans.Z.ToString(format: "#0.00");
aRobTarget.Rot.ToEulerAngles(out rx, out ry, out rz);
txt4.Text = rz.ToString(format: "#0.00");
txt5.Text = ry.ToString(format: "#0.00");
txt6.Text = rx.ToString(format: "#0.00");
using (Mastership.Request(controller.Rapid))
{
RapidData rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", "ppos100");
//获取当前位置
RobTarget rbtar = (RobTarget)rd.Value;
rbtar.Trans.X = Convert.ToSingle(txt1.Text);
rbtar.Trans.Y = Convert.ToSingle(txt2.Text);
rbtar.Trans.Z = Convert.ToSingle(txt3.Text);
//对xyz赋值,对姿态数据赋值类似
rd.Value = rbtar;
}
{
RapidData rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", "ppos100");
//获取当前位置
RobTarget rbtar = (RobTarget)rd.Value;
rbtar.Trans.X = Convert.ToSingle(txt1.Text);
rbtar.Trans.Y = Convert.ToSingle(txt2.Text);
rbtar.Trans.Z = Convert.ToSingle(txt3.Text);
//对xyz赋值,对姿态数据赋值类似
rd.Value = rbtar;
}
3、机器人侧在自动模式并不直接提供JOG接口,可以在RAPID使用如下代码进行模块指针的移动并控制机器人运动。
state:=0;
bAxis:=FALSE;
bCart:=FALSE;
ppos100:=pstart;
WHILE TRUE DO
TEST state
CASE 1:
// move in axis coordinate
if bAxis=TRUE then
bAxis:=FALSE;
MoveAbsJ jpos100\NoEOffs,v100,fine,tWeldGun\WObj:=wobj0;
endif
CASE 2:
// move in Cartesian coordinate
if bCart=TRUE THEN
bCart:=FALSE;
MoveL ppos100,v100,fine,tWeldGun\WObj:=wobj0;
ENDIF
ENDTEST
ENDWHILE
bAxis:=FALSE;
bCart:=FALSE;
ppos100:=pstart;
WHILE TRUE DO
TEST state
CASE 1:
// move in axis coordinate
if bAxis=TRUE then
bAxis:=FALSE;
MoveAbsJ jpos100\NoEOffs,v100,fine,tWeldGun\WObj:=wobj0;
endif
CASE 2:
// move in Cartesian coordinate
if bCart=TRUE THEN
bCart:=FALSE;
MoveL ppos100,v100,fine,tWeldGun\WObj:=wobj0;
ENDIF
ENDTEST
ENDWHILE
更多信息请咨询:ABB机器人