LookAt


level_1


Goal - Make Pepper look at a specific location with his head and his mobile base.

// Get the target frame to look at.
Frame targetFrame = ...;

// Build the action.
LookAt lookAt = LookAtBuilder.with(qiContext)
                             .withFrame(targetFrame)
                             .build();

// Run the action asynchronously.
lookAt.async().run();

Typical usage - You want Pepper to look at something/someone and track it.


How it works

Looking at a location

To configure where Pepper should look at, use a Frame.

Get a Frame and build the LookAt action with it:

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.

Setting the movement policy

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.

LookAt lookAt = ...;
lookAt.setPolicy(LookAtMovementPolicy.HEAD_AND_BASE);

lookAt.async().run();

See also javadoc: LookAtMovementPolicy.

Managing base availability

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.

Use cases

Track a human

To make Pepper track a Human:

Step Action
Get the human head Frame (see Human).
Build the LookAt action with it.

Performance & Limitations

Animate or LookAt?

You can make Pepper move his head and turn himself with both Animate and LookAt.

  • Use Animate to perform a constant movement with no variation except for obstacle avoidance.
  • Use LookAt to create a dynamically adaptive movement based on a target.

See also