# GoTo¶

Goal - Make Pepper go somewhere. The robot will try to reach safely the target location, while avoiding obstacles.

// Get the target frame.
val targetFrame: Frame = ...

// Build the action.
val goTo: GoTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame)
.build()

// Run the action synchronously.
goTo.run()


// Get the target frame.
Frame targetFrame = ...;

// Build the action.
GoTo goTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame)
.build();

// Run the action synchronously.
goTo.run();



Typical usage - You want Pepper to find a path to reach a target location.

## How it works¶

### Defining a target frame¶

To use GoTo, the pattern is:

Step Action
Define the target location by retrieving or calculating a Frame.
Build the GoTo.
Run the GoTo.

### Tuning GoTo behavior¶

When building the GoTo, it is possible to specify some parameters that will affect the GoTo Action running behavior. One can specify:

• the path planning policy,
• the final orientation policy,
• a maximum navigating speed.

#### Path Planning Policy

Options are:

• GET_AROUND_OBSTACLES policy (default): the robot computes and follows the path that is the most likely to reach the target, he may follow non-straight paths around obstacles.
• STRAIGHT_LINES_ONLY policy: the robot first aligns with the target then goes straight to it. If there is an obstacle in his way, he stops and does not try to go around it.

#### Final Orientation Policy

Options are:

• FREE_ORIENTATION policy (default): the GoTo does not control the robot final orientation, it will only try to reach the target frame 2D position.
• ALIGN_X policy: the GoTo finishes by aligning the robot frame X-Axis with the target frame X-Axis.

#### Maximum Navigating Speed

One can specify a maximum navigating speed in m/s. There is no guarantee that the robot will reach that speed, only that it will not go faster than the specified maximum speed. By default, the robot will not go faster than 0.35 m/s.

#### Example

Make the robot go straight to a target, at 0.55 m/s, and align with the target X-axis at the end.

// Get the target frame.
val targetFrame: Frame = ...

// Build the action.
val goTo: GoTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame)
.withPathPlanningPolicy(PathPlanningPolicy.STRAIGHT_LINES_ONLY)
.withFinalOrientationPolicy(OrientationPolicy.ALIGN_X)
.withMaxSpeed(0.55f)
.build()

// Run the action synchronously.
goTo.run()


// Get the target frame.
Frame targetFrame = ...;

// Build the action.
GoTo goTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame)
.withPathPlanningPolicy(PathPlanningPolicy.STRAIGHT_LINES_ONLY)
.withFinalOrientationPolicy(OrientationPolicy.ALIGN_X)
.withMaxSpeed(0.55f)
.build();

// Run the action synchronously.
goTo.run();



## Use case¶

### Move to a static target¶

You want Pepper to reach the point located one meter in front of him.

Retrieve the robot frame and define the target location relatively to Pepper current location:

val actuation: Actuation = qiContext.actuation

val robotFrame: Frame = actuation.robotFrame()

val transform: Transform = TransformBuilder.create().fromXTranslation(1.0)

val mapping: Mapping = qiContext.mapping

val targetFrame: FreeFrame = mapping.makeFreeFrame()

// Pass a 0-timestamp to publish target relatively to the
// last known location of robotFrame.
targetFrame.update(robotFrame, transform, 0L)

val goTo: GoTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame.frame())
.build()

goTo.run()


Actuation actuation = qiContext.getActuation();

Frame robotFrame = actuation.robotFrame();

Transform transform = TransformBuilder.create().fromXTranslation(1);

Mapping mapping = qiContext.getMapping();

FreeFrame targetFrame = mapping.makeFreeFrame();

// Pass a 0-timestamp to publish target relatively to the
// last known location of robotFrame.
targetFrame.update(robotFrame, transform, 0L);

GoTo goTo = GoToBuilder.with(qiContext)
.withFrame(targetFrame.frame())
.build();

goTo.run();



## Performance & Limitations¶

### Obstacle avoidance¶

Pepper is able to avoid obstacles while moving to a specific location. If there are obstacles on his way, he will try to get around them to reach his destination.

A target is assured to be reachable only if a path between the current robot location and the target location with a minimal clearance of 120 cm exists, and if it is located at least 50 cm away from obstacles.

### Need for error handling¶

Many elements of the environment are likely to disturb the robot and cause GoTo execution errors:

• brightness which disturbs the sensors,
• obstacles impossible to overcome,
• uneven ground,
• humans or animals which form temporary obstacles, etc.

Knowing that, the developer must handle the occurrence of an error and determine, according to the use case, if the robot should abandon the task and express his current issue, or try again, and for how long or until which result.

### GoTo or Animate?¶

You can make Pepper move with both Animate and GoTo.

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