152 lines
5.6 KiB
JavaScript
152 lines
5.6 KiB
JavaScript
|
|
/**
|
||
|
|
* @description
|
||
|
|
* Jibo's Expression Client
|
||
|
|
* @namespace jibo.expression
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @interface ExpressionEvents
|
||
|
|
* @description Typed Events for expression module (`jibo.expression.events`)
|
||
|
|
* @prop {Event<DOFEventData>} dofs
|
||
|
|
* @prop {Event<KinematicFeatures>} kinematics
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Results returned when await face is resolved.
|
||
|
|
* @interface DOFEventData
|
||
|
|
* @prop {number[]} timestamp
|
||
|
|
* @prop {Object} dofValues Associative array of dof names to values.
|
||
|
|
* @prop {Object} metadata Any metadata associated with display values.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A set of event emitters that capture high frequency updates from the expression service
|
||
|
|
* @type {ExpressionEvents}
|
||
|
|
* @name jibo.expression#events
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A convienent assortment of DOF sets for playing animations.
|
||
|
|
* @type {DOFSets}
|
||
|
|
* @name jibo.expression#dofs
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The most current `KinematicFeatures` received by the expression client.
|
||
|
|
* @type {KinematicFeatures}
|
||
|
|
* @name jibo.expression#features
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The Jibo runtime.
|
||
|
|
* This should not be a part of the external API.
|
||
|
|
* @private
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates an animation object on the expression server. If no `cacheName` is added, this animation will
|
||
|
|
* persist on the server forever. Returns a `Promise` that resolves to an `AnimationInstance`.
|
||
|
|
* @param {AnimationOptions} options Options to specify.
|
||
|
|
* @returns {Promise<AnimationInstance>} Resolves to an `AnimationInstance`.
|
||
|
|
* @method jibo.expression#createAnimation
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates and immediately plays an animation on the expression server.
|
||
|
|
* Returns a `Promise` that resolves to an `AnimationInstance`.
|
||
|
|
* Event handlers for `stopped`, `cancelled`, `rejected`, and other animation events must be registered to the
|
||
|
|
* `AnimationInstance` immediately (in-stack) upon promise resolution, or else they may be missed.
|
||
|
|
* @param {AnimationOptions} options Options to specify.
|
||
|
|
* @param {string} [requestor='Behavior'] The system making the animation request.
|
||
|
|
* @returns {Promise<AnimationInstance>} Resolves to an `AnimationInstance`.
|
||
|
|
* @method jibo.expression#createAndPlayAnimation
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroys caches saved in the expression service.
|
||
|
|
* @param {(string|string[])} cacheNames A cache name or array of cacheNames to destroy.
|
||
|
|
* @returns {Promise<void>}
|
||
|
|
* @method jibo.expression#destroyCaches
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @description Move Jibo's face to look at a target.
|
||
|
|
* @method jibo.expression#acquireTarget
|
||
|
|
* @param {AcquireOptions} options Options to specify.
|
||
|
|
* @returns {Promise<AcquireHandle>}
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets the mode of attention.
|
||
|
|
* @param {AttentionMode} mode Mode to set.
|
||
|
|
* @returns {Promise<void>}
|
||
|
|
* @method jibo.expression#setAttentionMode
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets the mode governing the attention system's behavior for a bounded time period.
|
||
|
|
* Returns a promise to an `AttentionHandle` which MUST have `release()` called on it when
|
||
|
|
* the caller is finished with the mode.
|
||
|
|
*
|
||
|
|
* Modes are maintained in a stack: the most recent call to `pushMode` will always win, and when
|
||
|
|
* a handle is released, it will drop down to mode of the highest non-released mode.
|
||
|
|
*
|
||
|
|
* Mode stack is fully cleared when `setMode` is called, and that mode becomes the base mode
|
||
|
|
* for when a stack is fully released.
|
||
|
|
*
|
||
|
|
* @method jibo.expression#pushAttentionMode
|
||
|
|
* @param {AttentionMode} mode - The new attention system mode: `IDLE`, `ENGAGED`, `SPEAKING`, `OFF`, etc.
|
||
|
|
* @return {Promise<AttentionHandle>} The handle for this mode request. MUST call `release()` on this handle when finished.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Gets the current mode of the attention system.
|
||
|
|
* @method jibo.expression#getAttentionMode
|
||
|
|
* @returns {AttentionMode} The current attention system mode.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets the color of the LED.
|
||
|
|
* @param {number[]} color An array or RGB values with range of `[0,1]`.
|
||
|
|
* @method jibo.expression#setLEDColor
|
||
|
|
* @returns {Promise<void>}
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Asynchronously waits for a face to appear.
|
||
|
|
* Returns a promise that resolves to a cancelable handle with a promise that will resolve when a face is detected or timeout is reached.
|
||
|
|
* Faces that are already in view "count" - so, the command may resolve quickly if people are already present.
|
||
|
|
* @method jibo.expression#awaitFace
|
||
|
|
* @param {AwaitFaceOptions} options - Options to specify.
|
||
|
|
* @return {Promise<AwaitFaceHandle>} A promise that resolves to a cancelable command handle.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Centers the robot in an upright position.
|
||
|
|
* @param {CenterOptions} [options] Options to specify.
|
||
|
|
* @method jibo.expression#centerRobot
|
||
|
|
* @returns {Promise<void>} Resolves when done centering.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Cleans up the currently animated state, centering the robot and releasing ownership for the next use site.
|
||
|
|
* @param {CleanupOptions} [options] Cleanup options.
|
||
|
|
* @method jibo.expression#cleanup
|
||
|
|
* @returns {Promise<void>} Resolves when the cleanup command is sent to the expression system.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Fully indexes the robot.
|
||
|
|
* @returns {Promise<IndexRobotResult>} Resolves when done indexing.
|
||
|
|
* @method jibo.expression#indexRobot
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Makes Jibo perform a procedural blink.
|
||
|
|
* @returns {Promise<void>} Resolves when the expression system receives the blink command.
|
||
|
|
* @method jibo.expression#blink
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Allow or disallow the expression service to move into a final pose when shutting down.
|
||
|
|
*/
|