212 lines
5.5 KiB
TypeScript
212 lines
5.5 KiB
TypeScript
|
|
import {EventEmitter} from 'events';
|
||
|
|
import {DOFSet} from 'animation-utilities';
|
||
|
|
import {Event} from 'jibo-typed-events';
|
||
|
|
|
||
|
|
interface AnimationOptions {
|
||
|
|
cacheName?:string;
|
||
|
|
speed?:number;
|
||
|
|
loops?:number;
|
||
|
|
dofs?:DOFSet;
|
||
|
|
layer?:string; //hidden
|
||
|
|
path:string;
|
||
|
|
requestor?:string; //default to "Behavior"
|
||
|
|
//implements scaling function on server
|
||
|
|
scale?:{[dofName:string]:number}[];
|
||
|
|
//this is a client side filter that filters events
|
||
|
|
eventFilter?:(name:string, payload:any) => boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AnimationBlobOptions extends AnimationOptions {
|
||
|
|
data:any; //actual anim object
|
||
|
|
}
|
||
|
|
|
||
|
|
enum PlayStatus {
|
||
|
|
OK, REJECTED
|
||
|
|
}
|
||
|
|
|
||
|
|
interface PlayResult {
|
||
|
|
message:string;
|
||
|
|
status:PlayStatus;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AnimationInstance extends EventEmitter {
|
||
|
|
//unique id that refers to the Builder that created this instance
|
||
|
|
id:number;
|
||
|
|
//typed events from timeline
|
||
|
|
events: {
|
||
|
|
general:Event<{name: string, data: any}>;
|
||
|
|
audio:Event<{path: string}>;
|
||
|
|
pixi:Event<{path:string}>; // Maybe?
|
||
|
|
holdSafe:Event<void>;
|
||
|
|
}
|
||
|
|
|
||
|
|
play():Promise<PlayStatus>;
|
||
|
|
stop():Promise<void>;
|
||
|
|
pause():Promise<void>;
|
||
|
|
resume():Promise<void>;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface Vector3 {
|
||
|
|
x:number;
|
||
|
|
y:number;
|
||
|
|
z:number;
|
||
|
|
}
|
||
|
|
interface AcquireOptions {
|
||
|
|
requestor?:string; //default to Behavior
|
||
|
|
timeout?:number; //ms
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AcquirePostionOptions extends AcquireOptions {
|
||
|
|
position:Vector3;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AcquireEntityOptions extends AcquireOptions {
|
||
|
|
entityId:number;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
type IndexRobotResult = "SUCCEEDED"|"TIMEOUT"|"FAULT";
|
||
|
|
namespace IndexRobotResult {
|
||
|
|
export const SUCCEEDED:IndexRobotResult = "SUCCEEDED";
|
||
|
|
export const TIMEOUT:IndexRobotResult = "TIMEOUT";
|
||
|
|
export const FAULT:IndexRobotResult = "FAULT";
|
||
|
|
}
|
||
|
|
|
||
|
|
type ResultStatus = "SUCCEEDED"|"TIMEOUT"|"INTERRUPTED"|"CANCELLED";
|
||
|
|
namespace ResultStatus {
|
||
|
|
export const SUCCEEDED:ResultStatus = "SUCCEEDED";
|
||
|
|
export const TIMEOUT:ResultStatus = "TIMEOUT";
|
||
|
|
export const INTERRUPTED:ResultStatus = "INTERRUPTED";
|
||
|
|
export const CANCELLED:ResultStatus = "CANCELLED";
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AcquireHandle {
|
||
|
|
promise:Promise<ResultStatus>;
|
||
|
|
result:ResultStatus;
|
||
|
|
cancel():Promise<void>;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//Do we want to add full quaternion
|
||
|
|
interface KinematicFeature {
|
||
|
|
position:Vector3; //world coordinates
|
||
|
|
direction:Vector3;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface KinematicFeatures {
|
||
|
|
base:KinematicFeature;
|
||
|
|
head:KinematicFeature;
|
||
|
|
pelvis:KinematicFeature; //does this exist? should we send it
|
||
|
|
eye:KinematicFeature;
|
||
|
|
}
|
||
|
|
|
||
|
|
declare type LEDMode = "OFF"|"LISTEN"|"ERROR";
|
||
|
|
declare namespace LEDMode {
|
||
|
|
export const OFF:LEDMode;
|
||
|
|
export const LISTEN:LEDMode;
|
||
|
|
export const ERROR:LEDMode;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface LEDHandle {
|
||
|
|
release():() => Promise<void>;
|
||
|
|
}
|
||
|
|
|
||
|
|
declare type AttentionMode = "OFF"|"IDLE"|"DISENGAGE"|"ENGAGED"|"SPEAKING"|"FIXATED"|"COMMAND";
|
||
|
|
|
||
|
|
interface AttentionModeHandle {
|
||
|
|
/**
|
||
|
|
* Why is this is a boolean, would it be useful to return the new
|
||
|
|
* attention mode
|
||
|
|
* @returns {Promise<boolean>}
|
||
|
|
*/
|
||
|
|
release:() => Promise<boolean>;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface CenterOptions {
|
||
|
|
//defaults to Behavior
|
||
|
|
requestor?:string;
|
||
|
|
//defaults to DOFSet.ALL
|
||
|
|
dofs?:DOFSet;
|
||
|
|
//defualt to false
|
||
|
|
centerGlobally?:boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface AwaitFaceOptions {
|
||
|
|
//defualts to 10 seconds
|
||
|
|
timeout?:number;
|
||
|
|
maxAngle?:number;
|
||
|
|
fullSearchTime?:number
|
||
|
|
}
|
||
|
|
|
||
|
|
declare interface AwaitFaceResult {
|
||
|
|
status:ResultStatus;
|
||
|
|
entityId:number;
|
||
|
|
position:Vector3;
|
||
|
|
angle:number;
|
||
|
|
}
|
||
|
|
|
||
|
|
declare interface AwaitFaceHandle {
|
||
|
|
promise: Promise<AwaitFaceResult>;
|
||
|
|
result: AwaitFaceResult;
|
||
|
|
cancel: () => Promise<void>;
|
||
|
|
}
|
||
|
|
|
||
|
|
declare interface DOFOutput {
|
||
|
|
//add dofs here
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* TBD stricly define Errors
|
||
|
|
*/
|
||
|
|
interface AnimationClient {
|
||
|
|
init():Promise<void>;
|
||
|
|
dofEmitter:Event<DOFOutput>;
|
||
|
|
kinematicsEmitter:Event<KinematicFeatures>;
|
||
|
|
|
||
|
|
//these two will pull from cache
|
||
|
|
createAnimation(instance:AnimationInstance):Promise<AnimationInstance>;
|
||
|
|
createAnimation(id:number):Promise<AnimationInstance>;
|
||
|
|
//this will always create a new one
|
||
|
|
createAnimation(options:AnimationOptions|AnimationBlobOptions):Promise<AnimationInstance>;
|
||
|
|
|
||
|
|
destroyCaches(cacheNames:string|string[]):Promise<void>;
|
||
|
|
|
||
|
|
//is a single shot look at
|
||
|
|
//automatically pushes a command mode
|
||
|
|
acquireTarget(options:AcquirePostionOptions|AcquireEntityOptions):Promise<AcquireHandle>;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @deprecated
|
||
|
|
* @param {AttentionMode} mode [description]
|
||
|
|
* @return {Promise<void>} Resolves when the mode is set
|
||
|
|
*/
|
||
|
|
setAttentionMode(mode:AttentionMode):Promise<void>;
|
||
|
|
pushAttentionMode(mode:AttentionMode):Promise<AttentionModeHandle>;
|
||
|
|
getAttentionMode():Promise<AttentionMode>;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Is this needed in the future
|
||
|
|
* @deprecated?
|
||
|
|
* @param {[number} color [description]
|
||
|
|
* @param {[type]} number [description]
|
||
|
|
* @param {[type]} number] [description]
|
||
|
|
* @return {Promise<void>} [description]
|
||
|
|
*/
|
||
|
|
setLEDColor(color:[number, number, number]):Promise<void>;
|
||
|
|
pushLEDMode(mode:LEDMode):Promise<LEDHandle>;
|
||
|
|
getLEDMode():Promise<LEDMode>;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* [awaitFace description]
|
||
|
|
* @deprecated
|
||
|
|
* @param {AwaitFaceOptions} options [description]
|
||
|
|
* @return {Promise<AwaitFaceHandle>} [description]
|
||
|
|
*/
|
||
|
|
awaitFace(options:AwaitFaceOptions):Promise<AwaitFaceHandle>;
|
||
|
|
|
||
|
|
centerRobot(options?:CenterOptions):Promise<void>;
|
||
|
|
indexRobot():Promise<IndexRobotResult>;
|
||
|
|
blink(): Promise<void>;
|
||
|
|
doCenterRobotOnDisconnect(allow: boolean): Promise<void>;
|
||
|
|
}
|