# SoftBank Robotics documentation What's new in NAOqi 2.8?

# State machine management

## Activities

Activities are what you develop to extend the abilities and personality of the robot. In essence, you create his life! An Activity is a Behavior that is developed with Choregraphe, which has been given a Solitary or Interactive nature. This Nature registers it to function within ALAutonomousLife. The Choregraphe Activity documentation discusses how adjust these project properties.

### How are Activities started?

- By a user interacting with the robot, if they specifically ask the robot to start an activity.
- Autonomously by ALAutonomousLife, through the use of Launch trigger conditions.
- Programatically through ALAutonomousLife, by the switchFocus() API. Thus, your Activities can switch focus to other Activities.

Before an activity is focused, Autonomous Life will enforce a State change. This cleans up the robot’s State so that your Activity will always be started in the same predictable State. Likewise, you can do anything to the robot’s State during your activity, and Autonomous Life will clean it up after your activity exits.

Note

Only one Activity can be running or “focused” at a time. The Autonomous prioritization determines how an Activity may be interrupted.

Note

When your robot is loading an activity which will be focused, he may say “ummm”, or other Loading Responses. See the ALAutonomousLife advanced Thinking Expression documentation for more details.

### What are Solitary and Interactive Activities?

See below for more information of the meaning of the States and their Autonomous prioritization.

Some tutorials are available: Creating a Solitary activity, Creating an Interactive activity.

### Why don’t I have control of the robot during my Activity?

Though the robot is acting autonomously, in fact you do have control! Autonomous Life will act during your Activity only in the following cases:

- Actions coming from running Autonomous Abilities. You can selectively parameterize or disable these to gain full control when you need to. The abilities will not be re-enabled until you tell them to. The Autonomous Abilities are low-priority; your own control of the robot will take priority. So under normal circumstances it is not necessary to disabled these services. Please keep these abilties running as much as possible to keep your robot continuously alive!
- Solitary Activities are interrupted in favor of Interactive Activities, see States and Autonomous prioritization.
- If something causes the robot to enter Safeguard State, which will stop your activity.
- If the Context of the robot is no longer compatible with your Activity, it will be stopped.

## Context

The Context is everything that ALAutonomousLife knows about the robot, and about the environment from NAOqi’s Extractors. The current State is one variable of this Context.

This Context is how ALAutonomousLife can make decisions about what Activity it may start, or the Safeguard State must be entered.

### Using Context to start your activity

ALAutonomousLife provides some special events for you to help make it easier to start your Activities autonomously. Use these events for your Launch Trigger Conditions.

An API is available for your Activity to query what the Context was at the moment that ALAutonomousLife focused it: getFocusContext()

Creating a Solitary activity tutorial shows how to autonomously start an Activity.

### Permission to run in a Context

Depending on the Context your activity may not be permitted to start, or it may be stopped. For example if the robot is on the charging station or if the robot is asleep. See the Permissions documentation for more details.

## States

As previously mentioned, whenever an Activity is focused, ALAutonomousLife will enforce a State change to provide consistent runtime configuration appropriate for the current Context. This gives a deterministic setup to your Activities, and a consistent experience to users.

Please see accompanying documentation for details about Extractors management and Autonomous Abilities for how they are configured in a State change.

State name | Description
--- | ---
solitary | This is the default State of the robot when Autonomous Life starts, and when no Activity is running. The main purpose of the Solitary State and Solitary Activities is to prepare the robot for future interaction with people. Thus, in this State the robot is optimally configured for finding them. This State consumes higher baseline CPU than Interactive. Another purpose of Solitary is to prepare people to interact with the robot. The robot primarily does this by looking alive. For example responding to stimulus originating from the environment and people, or possibly doing things to attract people. As the robot is not currently busy in a one-to-one interaction with a person, the Solitary State is an opportunity for the robot to do things “for himself”, such as exploring or learning passively. But ultimately this is done for the sake of better future interaction with people. The robot’s main goal is to Interact with people, so Solitary State and Activities are interrupted in favor of the Interactive State and Activities, to better serve people. See Autonomous prioritization. So, though the word “Solitary” is used, it does not necessarily mean that the robot is alone in the room. It means that the robot’s main concern is not currently a specific one-to-one Interaction. The Solitary State can be thought of as self driven, the robot is making decisions by himself.
interactive | The Interactive State will be entered when an Interactive Activity is focused. The main purpose of the Interactive state is to specifically serve people in a one-to-one interaction. This is ultimately the robot’s main goal in life. In Interactive State, the robot assumes that he has found the humans who he should be interacting with, and they are in very close proximity. Thus he is no longer configured for finding them, but for interacting with them. The baseline CPU consumption is lower than Solitary State to provide an optimal ALDialog experience. The Interactive State can be thought of as people driven, the robot is obeying commands from people. Note If the user comes close to Pepper, a default ALDialog Activity may be started, see Talking with NAO or Talking with Pepper. Note As Interactive Activities are not interrupted by Autonomous prioritization, be sure that your Interactive Activity has implemented an exit path, or it will never be stopped (unless the user explicitly does so, see Exiting an Activity or Exiting an Activity).
safeguard | If the robot’s hardware is having trouble, or if the environment is unsafe, this State will be entered and the current Activity stopped. After the trouble has passed, the Solitary State will be re-entered. See the ALAutonomousLife advanced Safeguard causes documentation documentation for a full description of why the Safeguard State may be entered. If your Activity is equipped to handle a specific Safeguard case, you may use the setSafeguardEnabled() API to tell ALAutonomousLife to not enter Safeguard State in this case. For example, if your Activity has implemented special handling for when the robot is pushed, it is not necessary for your Activity to be stopped.
disabled | From Disabled State, all Autonomous Abilities are stopped, and no Activities may be focused. Safeguard State may not be entered. If you would prefer ALAutonomousLife to be in Disabled State upon bootup, this can be configured for NAO and Pepper. This may be useful for specific research or testing scenarios. but we encourage you to keep your robot alive because living robots are the future and provide a more enriching experience!

### Autonomous prioritization

- During a Solitary Activity, an Interactive Activity may interrupt it to take the focus.
- If a Solitary and Interactive Activity both have true conditions at the same time, the Interactive will get priority.
- A Solitary Activity will not interrupt another Solitary Activity.
- An Interactive Activity will not interrupt another Interactive Activity.
- When multiple Activities have true conditions at the same time, the one that was focused least recently will get priority.
- Safeguard State has the priority over all Activities.
- Programmatic calls to switchFocus() permit you to start an Interactive Activity from either Solitary/Interactive State, or a Solitary Activity from Solitary State. But you cannot start a Solitary Activity from Interactive State.

### What else happens in a State change?

In addition to setting up Autonomous Abilities and Extractors, Autonomous Life does some other cleaning of the robot’s State as described in the ALAutonomousLife advanced State change cleanup documentation for more details.

Glossary Site map Index Support Contact Legal Notices