Hi All,
I’m wondering if there is a way to, from a single action, jog a robot through multiple (in my application case, two) known poses. For instance, I have a button which when pressed I want to cause two requestUserToMoveRobot() calls.
Currently I’ve nested the second call within the onComplete() function of the first RobotMovementCallback, my reasoning being that once the first callback is complete, another will be pulled up; but when I use my button the robot only jogs to the first pose.
...requestUserToMoveRobot(approachPose, new RobotMovementCallback() {
@Override
public void onComplete(MovementCompleteEvent event) {
// after reaching approach, request move to target
...requestUserToMoveRobot(targetPose, new RobotMovementCallback(){
@Override
public void onComplete(MovementCompleteEvent event) {
return;
}
});
}
});
Is what I’m trying to achieve possible with my current approach? Or is there another way to achieve what I want?
Thanks
Huh. That’s what I would have advised doing. Can you confirm that the “onComplete” callback is functioning properly? Put a print statement in there and check the console maybe? And is the second call to move passing in a different position for sure? It doesn’t think they are the same, does it?
It’s weird. The robot only traverses to the first point, then you press complete and nothing further happens. If you press the ‘test’ button again (after traversing to the first point), then the robot will move to the second point, whose call is nested in the onComplete of the first movement callback.
I’m certain the points are not the same.
Have you done what I tried before to the desired effect?
I have not. What you tried doing is exactly what I would have thought to do as well. Now you’re in the not-so-fun position of trying to hack your way around some Polyscope nuance that isn’t documented anywhere. Do a Thread.Sleep() after the first completion then fire your next movementRequest. Or launch a thread first and run the first movement, then signal to the thread that it’s done and have the thread call the next movement request.
Sweet as. I’ve tried the first one already, so I’ll see about the second now.
@eric.feldmann ‘s suggestion worked.
final CountDownLatch approachDone = new CountDownLatch(1);
Thread moverThread = new Thread(new Runnable() {
@Override
public void run() {
// Request user to move to approach pose; signal when complete
apiProvider_.getUserInterfaceAPI().getUserInteraction().getRobotMovement()
.requestUserToMoveRobot(approachPose, new RobotMovementCallback() {
@Override
public void onComplete(MovementCompleteEvent event) {
approachDone.countDown();
}
});
// Wait for approach to complete (signalled by callback)
try {
approachDone.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
apiProvider_.getUserInterfaceAPI().getUserInteraction().getRobotMovement()
.requestUserToMoveRobot(targetPose, new RobotMovementCallback() {
@Override
public void onComplete(MovementCompleteEvent event) {
// completed target move
return;
}
});
}
}, "TestNodeMover-thread");
moverThread.start();
This is not super clean, because having two movement callbacks brings up to windows, but it works.