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

# Launch trigger conditions

NAOqi Interaction engines - Overview | API | Launch trigger conditions | Advanced

## Goal

When Life is running on a robot, in solitary state, Activities with launch trigger conditions can be started automatically.

These conditions can be set in the manifest of the Choregrahe behavior of the activity. Refer to the Choregraphe documentation for editing manifest of behaviors. To write them, use events and an expression language. For further details, see: Launch trigger conditions and Conditions expression language.

## Example of a launch trigger condition

A condition for a solitary Activity which attracts a human could look like this:

    ('Launchpad/NumPeopleZone2' >= 1) ~ 3

There is at least one person detected in zone 2 of ALEngagementZones for at least 3 seconds.

## Launch trigger conditions

Many of these ALMemory Events are based on combining Context coming from Extractors which are managed by Autonomous Life. For more information, see Extractors management.

About people and movements

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/NumMotionZone1()` | int | The number of moving objects detected in zone 1. Only available during solitary state.
`Launchpad/NumMotionZone2()` | int | The number of moving objects detected in zone 2. Only available during solitary state.
`Launchpad/NumMotionZone3()` | int | The number of moving objects detected in zone 3. Only available during solitary state.
`Launchpad/NoMotionInZones()` | bool | True when no motion is detected in any zone. Only available during solitary state.
`Launchpad/WavingDetection()` | int | 0 while no waving is detected, 1 while waving is detected. Only available during solitary state.
`Launchpad/NumPeopleZone1()` | int | The number of people detected in zone 1. Only available during solitary state.
`Launchpad/NumPeopleZone2()` | int | The number of people detected in zone 2 Only available during solitary state.
`Launchpad/NumPeopleZone3()` | int | The number of people detected in zone 3 Only available during solitary state.
`Launchpad/NoPeopleInZones()` | bool | True when no people are detected in any zone. Only available during solitary state.
`Launchpad/PeopleNotSeen()` | bool | True when PeoplePerception/VisiblePeopleList is empty. Only available during solitary state.
`Launchpad/SameTrackedHuman()` | bool | True as long as the same person is being tracked. Momentarily false when the tracked person changes. The tracked person is determined by BasicAwareness. Only available if BasicAwareness is started.
`Launchpad/ZoneOfTrackedHuman()` | int | The zone that the tracked person is in: 1, 2, or 3. 0 if no one is tracked. Only available if BasicAwareness is started.
`Launchpad/DistanceOfTrackedHuman()` | float | The distance in meters to the tracked human. -1.0 if no one is tracked. Only available if BasicAwareness is started.
`Launchpad/TrackedHumanIsLookingAtRobot()` | bool | True when the tracked person is looking at the robot. Only available if BasicAwareness is started.

About battery information

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/BatteryIsCharging()` | bool | True if the batter is currently recharging.
`Launchpad/BatteryLevel()` | int | A number in the set: [0, 5].
`Launchpad/BatteryStatus()` | string | Critical, Low, Half, Full.

About robot hardware information

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/RobotType()` | string | nao, pepper, romeo.

About the posture of the robot

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/Lifted()` | bool | True if someone has lifted the robot up. Can only be true on NAO.
`Launchpad/PostureFamily()` | string | One of the Posture family.
`Launchpad/Posture()` | string | One of the Posture.
`Launchpad/RobotFellRecently()` | bool | True if the robot has fallen within the last 13 seconds.
`Launchpad/RobotPushedRecently()` | bool | True if the robot was pushed within the last 13 seconds. Can only be true on Pepper.

About the temperature of the joints of the robot

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/TemperatureStatus()` | string | Overall temperature health of the robot: Cold, Warm, Hot, Critical.
`Launchpad/HighestTemperature()` | float | The highest temperature found on the robot, in Celsius.
`Launchpad/HighestJoint()` | string | The name of the hottest joint. Additional information about NAO’s Joints.

About time

Key Name | Type | Example Value
--- | --- | ---
`Launchpad/Year()` | int | 2013
`Launchpad/Month()` | int | 1 (1~12)
`Launchpad/MonthName()` | string | January
`Launchpad/Day()` | int | 1 (day of the year, 1~366)
`Launchpad/DayName()` | string | Sunday
`Launchpad/Date()` | int | 12 (day of the month, starting from 1)
`Launchpad/Hour()` | int | 14 (24-hour time, 2:00pm)
`Launchpad/Minute()` | int | 42
`Launchpad/MinuteOfDay()` | int | 120 (corresponds to 2:00am)
`Launchpad/Week()` | int | 2 (zero-based week of the year 0~53)

About activity history

Key Name | Type | Explanation
--- | --- | ---
`Launchpad/LifeTime()` | int | The current value of `ALAutonomousLifeProxy::getLifeTime`.
`Launchpad/State()` | string | The current state of Autonomous Life. Can be one of the States.
`Launchpad/PreviousState()` | string | The previous state of Autonomous Life. Can be one of the States. Note, it is possible for the previous state to equal the current state if the current state was re-entered.
`Launchpad/FocusedActivity()` | string | The currently focused activity. Note, if no activity is running, this will be an empty string: “”.
`Launchpad/PreviousActivity()` | string | The previously focused activity. Note, “” (no activity running) is not considered for PreviousActivity.
`Launchpad/FocusCount/myPackageUUID/myActivityPath()` Replace myPackageUUID and myActivityPath with the corresponding values from your Activity’s manifest data. | int | The count of how many occasions this activity has been focused since NAOqi started up.

### Other events

You can also use the events raised by the extractors running in solitary state:

- ALBasicAwareness
- ALPeoplePerception
- ALEngagementZones
- ALGazeAnalysis
- ALWavingDetection
- ALMovementDetection

## Conditions expression language

    * Expression grammar:
    * -------------------------------------------------------------------------------------------
    *   - Parenthesis ()
    *
    *   - Constant int: 1
    *
    *   - Constant floats: 1.5, 1e4
    *
    *   - Constant strings: double-quoted: "foo", "bar"
    *
    *   - Lists: [1, 2, foo]
    *
    *   - ALMemory keys: single-quoted: 'key12', 'motion/foo'
    *       A key can be used anywhere a constant or list can be used.
    *       Be careful about the data types of your keys.
    *       If you refer to a memory key that does not exist, it will be an "Invalid" type
    *         which effectively evaluates to 0 (false).
    *       If you use a memory that has been declared, but not initialized with a value,
    *         it is also an "Invalid" type, and evaluates to 0 (false).
    *
    *   - Qi Signals and Properties: ServiceName.SignalName, ServiceName.SignalName.MemberName
    *       Can be used anywhere an ALMemory key can be used.
    *       Until a Signal is raised, it will be "Invalid" and evaluate to 0 (false).
    *       A Property has a value by default and will always return a value if the Property exists.
    *       If a Signal/Property does not exist, it will be "Invalid" and evaluate to 0 (false).
    *       "MemberName" is the case where a Signal/Property returns a struct.
    *
    *   - Index a list key: 'motion/foo'[2], ALMotion.FooProperty[2]
    *
    *   - Index a map key: ALMotion.FooSignal["bar"]
    *       Only supported on Signals/Properties, not supported for ALMemory keys.
    *
    *   - Logical, Mathematical, bitwise operators:
    *       && || ! != == <= < >= > + - / * % | & ^
    *
    *   - String operation functions:
    *       substr("canard", 1, 3) returns "ana"
    *       strlen("coin") returns 4
    *       concat("a", "b") returns "ab"
    *
    *   - Type operation functions:
    *       size([1,2,3]) returns 3.
    *       type("foo") returns "String".  Other types: Invalid, Array, Bool, Int, Float, String
    *       Type casting: int() float() string() bool()
    *                     The parameters passed to these can be any expression.
    *
    *   - subsets operator:
    *       True example: [1, 2] subsets [1, 2, 3, 4]
    *       True example: 1 subsets [1, 2, 3, 4]
    *
    *   - intersects operator:
    *       True example: [4, 5, 6] intersects [1, 2, 3, 4]
    *       True example: [4, 5, 6] intersects 5
    *
    *   - random operator:
    *       rand(0, 10, 1) return a random int between 0 and 10 included, the random number will be regenerated every second
    *       rand(5.0, 7.0, 5) return a random float between 5.0 and 7.0 included, the random number will be regenerated every 5 seconds
    *       rand(60, 80, 0) return a random int between 60 and 80 included, the random number will be generated only once per naoqi startup
    *
    *   - Preference key fetching function: pref("com.mydomain", "myKey")
    *       Only constant strings can be passed as parameters, not ALMemory keys or expressions.
    *       If the preference does not exist, an "Invalid" will be returned.
    *       Otherwise all preferences are returned as "String".  It may be necessary to use
    *         type casting functions around the pref() call.
    *
    *   - ALMemory key utility functions:
    *       bang('myKey'):      True for the moment that the associated key's event is raised
    *                           and false at all other times.  This only works with event based keys.
    *
    *       stable(expression): expression can be any expression possible with this grammar.
    *                           stable() will evaluate to True as long as the returned value
    *                           of it's expression are not changing.
    *                           It will evaluate to false only at the moment that the expression
    *                           has a change in value.
    *                           This us useful when combined with time based operators.
    *
    *   - Time based operators:
    *       ~ operator: Requires an expression to be true for given duration in seconds
    *                   Example: ('myKey' < 1) ~ 1.5
    *                   Meaning: myKey has been less than 1 for at least 1.5 seconds.
    *
    *       @ operator: Requires an expression to be true at a specific point in time in the past
    *                   Example: ('myKey' == 1) @ 10.0
    *                   Meaning: Exactly 10 seconds ago, myKey was equal to 1
    *
    *       # operator: Requires an expression to be true at any moment in time
    *                     within the specified window toward the past
    *                   Example: ('myKey' > 1) # 60.0
    *                   Meaning: myKey was greater than 1 at some point in the last 60 seconds.
    *                            It may also have had many other values during that period.
    *
    *       Note that time operators can be combined to describe a context.
    *                   Example: 'myKey' ~ 1.5 @ 10.0 && !'myKey'
    *                   Meaning: 10 seconds ago, myKey had been true for at least 1.5 seconds,
    *                              and now it is false.
    *
    *                   Example: ('Launchpad/FocusedActivity' == "myPkg/myActivity") # 2160
    *                              && ('Launchpad/FocusedActivity' != "myPkg/myActivity") ~ 3600
    *                   Meaning: "myPkg/myActivity" was focused at least once in the last 6 hours,
    *                              but not in the last 1 hour.
    *
    * Order of Operations:
    * (highest precedence operation listed first, items on same line have equal precedence)
    * -------------------------------------------------------------------------------------------
    *   ()
    *   Evaluate memory keys into constants
    *   []
    *   pref(), int(), float(), string(), bool(), type(), size()
    *   !
    *   ~, @, #
    *   subsets, intersects
    *   bang(), stable(), rand()
    *   *, /, %
    *   +, -
    *   |, &, ^
    *   <, <=, >, >=
    *   ==, !=
    *   &&
    *   ||

## Event list

About people and movements

Event: `"Launchpad/NumMotionZone1"`
callback(std::string eventName, int nbMovingObject, std::string subscriberIdentifier)

  The number of moving objects detected in zone 1.

  Only available during solitary state.

Event: `"Launchpad/NumMotionZone2"`
callback(std::string eventName, int nbMovingObject, std::string subscriberIdentifier)

  The number of moving objects detected in zone 2.

  Only available during solitary state.

Event: `"Launchpad/NumMotionZone3"`
callback(std::string eventName, int nbMovingObject, std::string subscriberIdentifier)

  The number of moving objects detected in zone 3.

  Only available during solitary state.

Event: `"Launchpad/NoMotionInZones"`
callback(std::string eventName, bool noMotionInZones, std::string subscriberIdentifier)

  True when no motion is detected in any zone.

  Only available during solitary state.

Event: `"Launchpad/WavingDetection"`
callback(std::string eventName, int wavingDetected, std::string subscriberIdentifier)

  0 while no waving is detected, 1 while waving is detected.

  Only available during solitary state.

Event: `"Launchpad/NumPeopleZone1"`
callback(std::string eventName, int nbDetectedPeople, std::string subscriberIdentifier)

  The number of people detected in zone 1.

  Only available during solitary state.

Event: `"Launchpad/NumPeopleZone2"`
callback(std::string eventName, int nbDetectedPeople, std::string subscriberIdentifier)

  The number of people detected in zone 2.

  Only available during solitary state.

Event: `"Launchpad/NumPeopleZone3"`
callback(std::string eventName, int nbDetectedPeople, std::string subscriberIdentifier)

  The number of people detected in zone 3.

  Only available during solitary state.

Event: `"Launchpad/NoPeopleInZones"`
callback(std::string eventName, bool noPeopleInZones, std::string subscriberIdentifier)

  True when no people are detected in any zone.

  Only available during solitary state.

Event: `"Launchpad/PeopleNotSeen"`
callback(std::string eventName, bool nobody, std::string subscriberIdentifier)

  True when PeoplePerception/VisiblePeopleList is empty.

  Only available during solitary state.

Event: `"Launchpad/SameTrackedHuman"`
callback(std::string eventName, bool sameHuman, std::string subscriberIdentifier)

  True as long as the same person is being tracked. Momentarily false when the tracked person changes. The tracked person is determined by BasicAwareness.

  Only available if BasicAwareness is started.

Event: `"Launchpad/ZoneOfTrackedHuman"`
callback(std::string eventName, int zoneNum, std::string subscriberIdentifier)

  The zone that the tracked person is in: 1, 2, or 3. 0 if no one is tracked.

  Only available if BasicAwareness is started.

Event: `"Launchpad/DistanceOfTrackedHuman"`
callback(std::string eventName, float distance, std::string subscriberIdentifier)

  The distance in meters to the tracked human. -1.0 if no one is tracked.

  Only available if BasicAwareness is started.

Event: `"Launchpad/TrackedHumanIsLookingAtRobot"`
callback(std::string eventName, bool looking, std::string subscriberIdentifier)

  True when the tracked person is looking at the robot.

  Only available if BasicAwareness is started.

About battery information

Event: `"Launchpad/BatteryIsCharging"`
callback(std::string eventName, bool charging, std::string subscriberIdentifier)

  True if the battery is charging.

Event: `"Launchpad/BatteryLevel"`
callback(std::string eventName, int level, std::string subscriberIdentifier)

  A number in the set [0, 5].

Event: `"Launchpad/BatteryStatus"`
callback(std::string eventName, std::string level, std::string subscriberIdentifier)

  Critical, Low, Half, Full.

About robot hardware information

Event: `"Launchpad/RobotType"`
callback(std::string eventName, std::string type, std::string subscriberIdentifier)

  nao, pepper, romeo.

About the posture of the robot

Event: `"Launchpad/Lifted"`
callback(std::string eventName, bool lifted, std::string subscriberIdentifier)

  True if someone has lifted the robot up.

  Can only be true on NAO.

Event: `"Launchpad/PostureFamily"`
callback(std::string eventName, std::string family, std::string subscriberIdentifier)

  One of the Posture family.

Event: `"Launchpad/Posture"`
callback(std::string eventName, std::string posture, std::string subscriberIdentifier)

  One of the Posture.

Event: `"Launchpad/RobotFellRecently"`
callback(std::string eventName, bool hasFallen, std::string subscriberIdentifier)

  True if the robot has fallen within the last 13 seconds.

Event: `"Launchpad/RobotPushedRecently"`
callback(std::string eventName, bool wasPushed, std::string subscriberIdentifier)

  True if the robot has was pushed within the last 13 seconds.

  Can only be true on Pepper.

About the temperature of the joints of the robot

Event: `"Launchpad/TemperatureStatus"`
callback(std::string eventName, std::string family, std::string subscriberIdentifier)

  Overall temperature health of the robot: Cold, Warm, Hot, Critical

Event: `"Launchpad/HighestTemperature"`
callback(std::string eventName, float posture, std::string subscriberIdentifier)

  The highest temperature found on the robot, in Celsius.

Event: `"Launchpad/HighestJoint"`
callback(std::string eventName, bool hasFallen, std::string subscriberIdentifier)

  The name of the hottest joint.

  HeadYaw, HeadPitch, LShoulderPitch, LShoulderRoll, LElbowYaw, LElbowRoll, LWristYaw, LHand, RShoulderPitch, RShoulderRoll, RElbowYaw, RElbowRoll, RWristYaw, RHand, LHipRoll, LHipYawPitch, LHipPitch, LKneePitch, LAnkleRoll, LAnklePitch, RHipRoll, RHipYawPitch, RHipPitch, RKneePitch, RAnkleRoll, RAnklePitch

  Additional information about NAO’s Joints.

About time

Event: `"Launchpad/Year"`
callback(std::string eventName, int year, std::string subscriberIdentifier)

  Example Value: 2013

Event: `"Launchpad/Month"`
callback(std::string eventName, int month, std::string subscriberIdentifier)

  Example Value: 1

  Can be 1~12.

Event: `"Launchpad/MonthName"`
callback(std::string eventName, int month, std::string subscriberIdentifier)

  Example Value: January

Event: `"Launchpad/Day"`
callback(std::string eventName, int day, std::string subscriberIdentifier)

  Example Value: 1

  Day of the year, 1~366.

Event: `"Launchpad/DayName"`
callback(std::string eventName, int day, std::string subscriberIdentifier)

  Example Value: Sunday

Event: `"Launchpad/Date"`
callback(std::string eventName, int date, std::string subscriberIdentifier)

  Example Value: 12

  Day of the month, starting from 1.

Event: `"Launchpad/Hour"`
callback(std::string eventName, int hour, std::string subscriberIdentifier)

  Example Value: 14 (2:00pm)

  24-hour time.

Event: `"Launchpad/Minute"`
callback(std::string eventName, int minute, std::string subscriberIdentifier)

  Example Value: 42

Event: `"Launchpad/MinuteOfDay"`
callback(std::string eventName, int minuteOfDay, std::string subscriberIdentifier)

  Example Value: 120

  120 would correspond to 2:00am.

Event: `"Launchpad/Week"`
callback(std::string eventName, int week, std::string subscriberIdentifier)

  Example Value: 2

  Zero-based week of the year, 0~53.S

About activity history

Event: `"Launchpad/LifeTime"`
callback(std::string eventName, int time, std::string subscriberIdentifier)

  The current value of `ALAutonomousLifeProxy::getLifeTime`.

Event: `"Launchpad/State"`
callback(std::string eventName, std::string state, std::string subscriberIdentifier)

  The current state of Autonomous Life.

  Can be one of the States.

Event: `"Launchpad/PreviousState"`
callback(std::string eventName, std::string previousState, std::string subscriberIdentifier)

  The previous state of Autonomous Life.

  Can be one of the States.

  Note, it is possible for the previous state to equal the current state if the current state was re-entered.

Event: `"Launchpad/FocusedActivity"`
callback(std::string eventName, std::string activity, std::string subscriberIdentifier)

  The currently focused activity.

  Note, if no activity is running, this will be an empty string (“”)

  To have condition on the time since your application was last focused, follow this pattern: `(('Launchpad/FocusedActivity' != "my_attractions/child_attraction1") ~ 60)`

Event: `"Launchpad/PreviousActivity"`
callback(std::string eventName, std::string activity, std::string subscriberIdentifier)

  The previously focused activity.

  Note: “” (no activity running) is not considered for PreviousActivity

Event: `"Launchpad/FocusCount/myPackageUUID/myActivityPath"`
callback(std::string eventName, int countFocused, std::string subscriberIdentifier)

  The count of how many occasions this activity has been focused.

  Note: replace myPackageUUID and myActivityPath with the corresponding values from your Activity’s manifest data.

Glossary Site map Index Support Contact Legal Notices