Goal - Make Pepper look at a specific location with his head and his mobile base.
// Get the target frame to look at.
val targetFrame: Frame = ...
// Build the action.
val lookAt: LookAt = LookAtBuilder.with(qiContext)
.withFrame(targetFrame)
.build()
// Run the action asynchronously.
val lookAtFuture: Future<Void>? = lookAt?.async()?.run()
// ...
// Request cancellation to stop the execution.
lookAtFuture?.requestCancellation()
// Get the target frame to look at.
Frame targetFrame = ...;
// Build the action.
LookAt lookAt = LookAtBuilder.with(qiContext)
.withFrame(targetFrame)
.build();
// Run the action asynchronously.
Future<Void> lookAtFuture = lookAt.async().run();
// ...
// Request cancellation to stop the execution.
lookAtFuture.requestCancellation();
Typical usage - You want Pepper to look at something/someone and track it.
To configure where Pepper should look at, use a Frame.
Get a Frame
and build the LookAt
action with it:
val targetFrame: Frame = ...
val lookAt: LookAt = LookAtBuilder.with(qiContext)
.withFrame(targetFrame)
.build()
Frame targetFrame = ...;
LookAt lookAt = LookAtBuilder.with(qiContext)
.withFrame(targetFrame)
.build();
You can refer to the Frame reference page to see how to get a
Frame
.
Note
Pepper will track the target frame while the action is running.
For example, if the target frame is a Human
head frame, and the
human moves with respect to the robot, Pepper will automatically
update his posture to keep looking at the human.
When Pepper looks at a location, you can choose if he should use only his head
or also move his mobile base by setting the LookAtMovementPolicy
.
By default, the LookAtMovementPolicy
is set to HEAD_AND_BASE
, but it can be
set to HEAD_ONLY
.
If you choose HEAD_ONLY
, Pepper will only turn his head to look at the
specified Frame
.
However, if you use HEAD_AND_BASE
, Pepper will be able to also turn his
base.
val lookAt: LookAt = ...
lookAt.policy = LookAtMovementPolicy.HEAD_AND_BASE
lookAt.async().run()
LookAt lookAt = ...;
lookAt.setPolicy(LookAtMovementPolicy.HEAD_AND_BASE);
lookAt.async().run();
See also API doc: LookAtMovementPolicy.
If you run a LookAt
action with the movement policy set to HEAD_AND_BASE
while the robot base is not available, the action execution will fail and throw
an exception.
In that case, you can try to set the movement policy to HEAD_ONLY
and rerun
the LookAt
action.