Hi guys, noobie here,
I would like to make an application (very simple) where the robot moves around 2 points and when it receives a colision for CoordinateY (very low) the mediaflange led red is set, and when I stoped touching the robot the led is shut down.
I made a program but it's not working correctly and I would like some help please. I know I'm not definig the led shutting down because i don't know if i need another trigger or i can make it in the same.
public class ImpedanciaRobotMovimiento extends RoboticsAPIApplication {
@Inject private LBR lbr;
@Inject private MediaFlangeIOGroup ioGroup;
private Frame home, p1, p2;
private double vel;
private int stiffnessX, stiffnessY, stiffnessZ;
private ICondition colisionY;
private double damping;
CartesianImpedanceControlMode impedanceControlMode;
@Override
public void initialize() {
home = getApplicationData().getFrame("/ImpedanciaRobot").copy();
p1 = getApplicationData().getFrame("/ImpedanciaRobot/P1").copy();
p2 = getApplicationData().getFrame("/ImpedanciaRobot/P2").copy();
vel = 0.1;
stiffnessX = 100;
stiffnessY = 100;
stiffnessZ = 100;
damping = 0.7;
impedanceControlMode = new CartesianImpedanceControlMode();
impedanceControlMode.parametrize(CartDOF.ALL).setDamping(damping);
impedanceControlMode.parametrize(CartDOF.X).setStiffness(stiffnessX);
impedanceControlMode.parametrize(CartDOF.Y).setStiffness(stiffnessY);
impedanceControlMode.parametrize(CartDOF.Z).setStiffness(stiffnessZ);
colisionY = ForceCondition.createNormalForceCondition(null, CoordinateAxis.Y, 3);
ioGroup.setLEDRed(false);
ioGroup.setLEDGreen(false);
ioGroup.setLEDBlue(false);
}
@Override
public void run() {
boolean end = false;
while (!end) {
int menu = getApplicationUI().displayModalDialog(ApplicationDialogType.INFORMATION,
"El robot realizará un recorrido y el operario lo podrá mover. El robot seguirá " +
"su trayectoria",
"Ok",
"Cancelar");
switch(menu) {
case 0:
robot_impedancia_movil();
break;
default:
end = true;
}
}
}
private void robot_impedancia_movil() {
lbr.move(spl(p1).setJointVelocityRel(vel).setMode(impedanceControlMode));
while (true) {
lbr.move(circ(home, p2).setJointVelocityRel(vel).setMode(impedanceControlMode).triggerWhen(colisionY, trigger1));
lbr.move(circ(home, p1).setJointVelocityRel(vel).setMode(impedanceControlMode).triggerWhen(colisionY, trigger1));
}
}
//set trigger action
ICallbackAction trigger1 = new ICallbackAction() {
@Override
public void onTriggerFired(IFiredTriggerInfo triggerInformation) {
ioGroup.setLEDRed(true);
}
};
}
Maybe I'm not using the correct function for the app.