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; } play():Promise; stop():Promise; pause():Promise; resume():Promise; } 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; result:ResultStatus; cancel():Promise; } //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; } 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} */ release:() => Promise; } 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; result: AwaitFaceResult; cancel: () => Promise; } declare interface DOFOutput { //add dofs here } /** * TBD stricly define Errors */ interface AnimationClient { init():Promise; dofEmitter:Event; kinematicsEmitter:Event; //these two will pull from cache createAnimation(instance:AnimationInstance):Promise; createAnimation(id:number):Promise; //this will always create a new one createAnimation(options:AnimationOptions|AnimationBlobOptions):Promise; destroyCaches(cacheNames:string|string[]):Promise; //is a single shot look at //automatically pushes a command mode acquireTarget(options:AcquirePostionOptions|AcquireEntityOptions):Promise; /** * @deprecated * @param {AttentionMode} mode [description] * @return {Promise} Resolves when the mode is set */ setAttentionMode(mode:AttentionMode):Promise; pushAttentionMode(mode:AttentionMode):Promise; getAttentionMode():Promise; /** * Is this needed in the future * @deprecated? * @param {[number} color [description] * @param {[type]} number [description] * @param {[type]} number] [description] * @return {Promise} [description] */ setLEDColor(color:[number, number, number]):Promise; pushLEDMode(mode:LEDMode):Promise; getLEDMode():Promise; /** * [awaitFace description] * @deprecated * @param {AwaitFaceOptions} options [description] * @return {Promise} [description] */ awaitFace(options:AwaitFaceOptions):Promise; centerRobot(options?:CenterOptions):Promise; indexRobot():Promise; blink(): Promise; doCenterRobotOnDisconnect(allow: boolean): Promise; }