Hi,
I was wondering if there is a way to check if a force is coming from the left or right (see attached)?
I would like to put that in something like an if/else statement and program different actions .
Thank you.
robotneuling
Hi,
I was wondering if there is a way to check if a force is coming from the left or right (see attached)?
I would like to put that in something like an if/else statement and program different actions .
Thank you.
robotneuling
I attached example code (text in spanish):
private ICondition gesto;
IMotionContainer mc3;
private CartesianImpedanceControlMode soft2;
private int sentido = 0;
public void initialize() {
j1 = new JointTorqueCondition(JointEnum.J1, -15, 15);
gesto = j1;
soft2.parametrize(CartDOF.ALL).setDamping(.5);
soft2.parametrize(CartDOF.ROT).setStiffness(250);
soft2.parametrize(CartDOF.X).setStiffness(1100);
soft2.parametrize(CartDOF.Y).setStiffness(3000);
soft2.parametrize(CartDOF.Z).setStiffness(3000);
}
public void run() {
IMotionContainer mc3 = lbr.move(positionHold(soft2, -1,
TimeUnit.SECONDS).breakWhen(gesto));
if (mc3.hasFired(gesto)) {
if (lbr.getExternalTorque().getSingleTorqueValue(JointEnum.J1) > 0) {
getLogger().("movimiento derecha");
sentido = 1;
} else {
getLogger().error("Movimiento izquierda");
sentido = 2;
}
}
switch (sentido) {
case 1:
getLogger().info("Inicio programa movimiento derecha");
right();
break;
case 2:
getLogger().info("Inicio programa movimiento izquierda");
left();
break;
default:
getLogger().error("Orden no confirmada");
break;
}
}
Thank you KUAJARLOS. I will test it soon ...
Maybe you can teach a base frame by which you can measure the force in x/y/z direction.
You can define x+ as right, y+ as forth, z+ as up. It can tell the direction correctly when force happens on axis 6/7. For force on other axis, it works not well.
ObjectFrame oFrame = getFrame("/directbase");
ICondition forceCondition = new ForceCondition(lbr.getFlange(), oFrame, EnumSet.of(CoordinateAxis.X, CoordinateAxis.Y, CoordinateAxis.Z), 15.0d);
IMotionContainer container = lbr.move(positionHold(new PositionControlMode(), -1,
TimeUnit.SECONDS).breakWhen(forceCondition));
if (container.hasFired(forceCondition))
{
double x = lbr.getExternalForceTorque(lbr.getFlange(), oFrame).getForce().getX();
double y = lbr.getExternalForceTorque(lbr.getFlange(), oFrame).getForce().getY();
double z = lbr.getExternalForceTorque(lbr.getFlange(), oFrame).getForce().getZ();
if (Math.abs(x) >= Math.abs(y) && Math.abs(x) >= Math.abs(z))
{
getLogger().info("x:" + (x > 0.0 ? "+" : "-"));
}
else if (Math.abs(y) >= Math.abs(x) && Math.abs(y) >= Math.abs(z))
{
getLogger().info("y:" + (y > 0.0 ? "+" : "-"));
}
else
{
getLogger().info("z:" + (z > 0.0 ? "+" : "-"));
}
getLogger().info(lbr.getExternalForceTorque(lbr.getFlange(), oFrame).getForce().toString());
}
Display More
Hi,I was wondering if there is a way to check if a force is coming from the left or right (see attached)?
I would like to put that in something like an if/else statement and program different actions.
Thank you.
robotneuling
Thank you greengrape83. I will try your solution.
KUAJARLOS idea seems to work fine and I learned some Spanish .