668 lines
29 KiB
JavaScript
668 lines
29 KiB
JavaScript
|
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jiboExpressionClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const jibo_client_framework_1 = require("jibo-client-framework");
|
||
|
|
const jibo_typed_events_1 = require("jibo-typed-events");
|
||
|
|
const log_1 = require("./log");
|
||
|
|
const log = log_1.default.createChild('AnimationInstance');
|
||
|
|
var AnimationState;
|
||
|
|
(function (AnimationState) {
|
||
|
|
AnimationState["INVALID"] = "INVALID";
|
||
|
|
AnimationState["PLAYING"] = "PLAYING";
|
||
|
|
AnimationState["STOPPED"] = "STOPPED";
|
||
|
|
AnimationState["STOPPING"] = "STOPPING";
|
||
|
|
AnimationState["CANCELLED"] = "CANCELLED";
|
||
|
|
AnimationState["PAUSED"] = "PAUSED";
|
||
|
|
AnimationState["RESUMED"] = "RESUMED";
|
||
|
|
AnimationState["STARTED"] = "STARTED";
|
||
|
|
AnimationState["REJECTED"] = "REJECTED";
|
||
|
|
})(AnimationState = exports.AnimationState || (exports.AnimationState = {}));
|
||
|
|
class AnimationEvents extends jibo_typed_events_1.EventContainer {
|
||
|
|
constructor() {
|
||
|
|
super(...arguments);
|
||
|
|
this.general = new jibo_typed_events_1.Event('general');
|
||
|
|
this.audio = new jibo_typed_events_1.Event('audio');
|
||
|
|
this.pixi = new jibo_typed_events_1.Event('pixi');
|
||
|
|
this.holdSafe = new jibo_typed_events_1.Event('holdSafe');
|
||
|
|
this.stopped = new jibo_typed_events_1.Event('stopped');
|
||
|
|
this.cancelled = new jibo_typed_events_1.Event('cancelled');
|
||
|
|
this.rejected = new jibo_typed_events_1.Event('rejected');
|
||
|
|
this.started = new jibo_typed_events_1.Event('started');
|
||
|
|
this.stateChange = new jibo_typed_events_1.Event('state changed');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.AnimationEvents = AnimationEvents;
|
||
|
|
class AnimationInstance extends jibo_client_framework_1.ClientRemoteObject {
|
||
|
|
constructor(client, instanceId, id, dofs, didPlay = false) {
|
||
|
|
super(client, { instanceId: instanceId });
|
||
|
|
this.client = client;
|
||
|
|
this.id = id;
|
||
|
|
this.dofs = dofs;
|
||
|
|
this.events = new AnimationEvents();
|
||
|
|
this.AnimationState = AnimationState;
|
||
|
|
this.played = false;
|
||
|
|
this.onEvent = this.onEvent.bind(this);
|
||
|
|
this.on('EVENT', this.onEvent);
|
||
|
|
if (didPlay) {
|
||
|
|
this.played = true;
|
||
|
|
this.state = AnimationState.PLAYING;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
play(requestor = 'Behavior') {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
if (this.played) {
|
||
|
|
log.warn("Someone tried to play AnimationInstance " + this.id + " twice!");
|
||
|
|
log.warn("Second Play Site:" + new Error().stack);
|
||
|
|
}
|
||
|
|
this.played = true;
|
||
|
|
this.setState(AnimationState.PLAYING);
|
||
|
|
return yield this.sendMessage('play', [requestor]);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
stop() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.setState(AnimationState.STOPPING);
|
||
|
|
return yield this.sendMessage('stop');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
pause() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.setState(AnimationState.PAUSED);
|
||
|
|
return yield this.sendMessage('pause', [], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
resume() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.setState(AnimationState.RESUMED);
|
||
|
|
return yield this.sendMessage('resume', [], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
destroy() {
|
||
|
|
super.destroy();
|
||
|
|
this.removeAllListeners();
|
||
|
|
this.events.removeAllListeners();
|
||
|
|
}
|
||
|
|
setState(newState) {
|
||
|
|
const lastState = this.state;
|
||
|
|
this.state = newState;
|
||
|
|
if (lastState !== newState) {
|
||
|
|
this.events.stateChange.emit(newState);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
onEvent(eventName, payload) {
|
||
|
|
if (eventName === 'play-audio') {
|
||
|
|
this.events.audio.emit(payload);
|
||
|
|
}
|
||
|
|
else if (eventName === 'play-pixi') {
|
||
|
|
this.events.pixi.emit(payload);
|
||
|
|
}
|
||
|
|
else if (eventName === 'HOLD_SAFE') {
|
||
|
|
this.events.holdSafe.emit();
|
||
|
|
}
|
||
|
|
else if (eventName === AnimationState.STOPPED) {
|
||
|
|
this.setState(AnimationState.STOPPED);
|
||
|
|
this.events.stopped.emit();
|
||
|
|
this.emit(AnimationState.STOPPED);
|
||
|
|
}
|
||
|
|
else if (eventName === AnimationState.STARTED) {
|
||
|
|
this.setState(AnimationState.STARTED);
|
||
|
|
this.events.started.emit();
|
||
|
|
this.emit(AnimationState.STARTED);
|
||
|
|
}
|
||
|
|
else if (eventName === AnimationState.CANCELLED) {
|
||
|
|
this.setState(AnimationState.CANCELLED);
|
||
|
|
this.events.cancelled.emit();
|
||
|
|
this.emit(AnimationState.CANCELLED);
|
||
|
|
}
|
||
|
|
else if (eventName === AnimationState.REJECTED) {
|
||
|
|
this.setState(AnimationState.REJECTED);
|
||
|
|
this.events.rejected.emit();
|
||
|
|
this.emit(AnimationState.REJECTED);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.events.general.emit({ name: eventName, payload });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.AnimationInstance = AnimationInstance;
|
||
|
|
|
||
|
|
},{"./log":11,"jibo-client-framework":undefined,"jibo-typed-events":undefined}],2:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const animation_utilities_1 = require("animation-utilities");
|
||
|
|
const jibo_cai_utils_1 = require("jibo-cai-utils");
|
||
|
|
function createDOFs() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
const config = new animation_utilities_1.JiboConfig();
|
||
|
|
const robotInfo = yield jibo_cai_utils_1.PromiseUtils.promisify(cb => animation_utilities_1.RobotInfo.createInfo(config, cb), false);
|
||
|
|
return {
|
||
|
|
ALL: robotInfo.getDOFSet("ALL"),
|
||
|
|
BASE: robotInfo.getDOFSet("BASE"),
|
||
|
|
BODY: robotInfo.getDOFSet("BODY"),
|
||
|
|
EYE: robotInfo.getDOFSet("EYE"),
|
||
|
|
LED: robotInfo.getDOFSet("LED"),
|
||
|
|
OVERLAY: robotInfo.getDOFSet("OVERLAY"),
|
||
|
|
SCREEN: robotInfo.getDOFSet("SCREEN"),
|
||
|
|
EYE_ROOT: robotInfo.getDOFSet("EYE_ROOT"),
|
||
|
|
EYE_DEFORM: robotInfo.getDOFSet("EYE_DEFORM"),
|
||
|
|
EYE_RENDER: robotInfo.getDOFSet("EYE_RENDER"),
|
||
|
|
EYE_TRANSLATE: robotInfo.getDOFSet("EYE_TRANSLATE"),
|
||
|
|
EYE_ROTATE: robotInfo.getDOFSet("EYE_ROTATE"),
|
||
|
|
EYE_COLOR: robotInfo.getDOFSet("EYE_COLOR"),
|
||
|
|
EYE_TEXTURE: robotInfo.getDOFSet("EYE_TEXTURE"),
|
||
|
|
EYE_VISIBILITY: robotInfo.getDOFSet("EYE_VISIBILITY"),
|
||
|
|
OVERLAY_ROOT: robotInfo.getDOFSet("OVERLAY_ROOT"),
|
||
|
|
OVERLAY_DEFORM: robotInfo.getDOFSet("OVERLAY_DEFORM"),
|
||
|
|
OVERLAY_RENDER: robotInfo.getDOFSet("OVERLAY_RENDER"),
|
||
|
|
OVERLAY_TRANSLATE: robotInfo.getDOFSet("OVERLAY_TRANSLATE"),
|
||
|
|
OVERLAY_ROTATE: robotInfo.getDOFSet("OVERLAY_ROTATE"),
|
||
|
|
OVERLAY_COLOR: robotInfo.getDOFSet("OVERLAY_COLOR"),
|
||
|
|
OVERLAY_TEXTURE: robotInfo.getDOFSet("OVERLAY_TEXTURE"),
|
||
|
|
OVERLAY_VISIBILITY: robotInfo.getDOFSet("OVERLAY_VISIBILITY"),
|
||
|
|
SCREEN_BG_RENDER: robotInfo.getDOFSet("SCREEN_BG_RENDER"),
|
||
|
|
SCREEN_BG_COLOR: robotInfo.getDOFSet("SCREEN_BG_COLOR"),
|
||
|
|
SCREEN_BG_TEXTURE: robotInfo.getDOFSet("SCREEN_BG_TEXTURE")
|
||
|
|
};
|
||
|
|
});
|
||
|
|
}
|
||
|
|
exports.default = createDOFs;
|
||
|
|
|
||
|
|
},{"animation-utilities":undefined,"jibo-cai-utils":undefined}],3:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const jibo_client_framework_1 = require("jibo-client-framework");
|
||
|
|
const jibo_typed_events_1 = require("jibo-typed-events");
|
||
|
|
const AnimationInstance_1 = require("./AnimationInstance");
|
||
|
|
const jibo_common_types_1 = require("jibo-common-types");
|
||
|
|
const AttentionHandle_1 = require("./handles/AttentionHandle");
|
||
|
|
const AcquireHandle_1 = require("./handles/AcquireHandle");
|
||
|
|
const AwaitFaceHandle_1 = require("./handles/AwaitFaceHandle");
|
||
|
|
const animation_utilities_1 = require("animation-utilities");
|
||
|
|
class Expression extends jibo_client_framework_1.ClientRemoteObject {
|
||
|
|
constructor(client) {
|
||
|
|
super(client, { instanceId: jibo_common_types_1.ExpressionIds.EXPRESSION });
|
||
|
|
this.client = client;
|
||
|
|
this.onDofEvent = this.onDofEvent.bind(this);
|
||
|
|
this.onKinematicEvent = this.onKinematicEvent.bind(this);
|
||
|
|
this.on('dofs', this.onDofEvent);
|
||
|
|
this.on('kinematics', this.onKinematicEvent);
|
||
|
|
this.events = {
|
||
|
|
dofs: new jibo_typed_events_1.Event('dofs'),
|
||
|
|
kinematics: new jibo_typed_events_1.Event('kinematics')
|
||
|
|
};
|
||
|
|
this.features = {
|
||
|
|
base: {
|
||
|
|
position: new animation_utilities_1.THREE.Vector3(),
|
||
|
|
direction: new animation_utilities_1.THREE.Vector3()
|
||
|
|
},
|
||
|
|
eye: {
|
||
|
|
position: new animation_utilities_1.THREE.Vector3(),
|
||
|
|
direction: new animation_utilities_1.THREE.Vector3()
|
||
|
|
},
|
||
|
|
head: {
|
||
|
|
position: new animation_utilities_1.THREE.Vector3(),
|
||
|
|
direction: new animation_utilities_1.THREE.Vector3()
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|
||
|
|
init(jibo) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.jibo = jibo;
|
||
|
|
if (this.jibo.timer) {
|
||
|
|
this.jibo.timer.setInterval(() => {
|
||
|
|
this.sendEmotionState();
|
||
|
|
}, 500);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
createAnimation(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
let arg = options;
|
||
|
|
if (arg.dofs) {
|
||
|
|
arg.dofs = arg.dofs.getDOFs();
|
||
|
|
}
|
||
|
|
const result = yield this.sendMessage('createAnimation', [arg]);
|
||
|
|
const dofs = this.dofs.ALL.createFromDofs(result.state.dofs);
|
||
|
|
return new AnimationInstance_1.AnimationInstance(this.client, result.instanceId, result.state.id, dofs);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
createAndPlayAnimation(options, requestor = 'Behavior') {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
let arg = options;
|
||
|
|
if (arg.dofs) {
|
||
|
|
arg.dofs = arg.dofs.getDOFs();
|
||
|
|
}
|
||
|
|
const result = yield this.sendMessage('createAndPlayAnimation', [arg, requestor]);
|
||
|
|
const dofs = this.dofs.ALL.createFromDofs(result.instantiateResult.state.dofs);
|
||
|
|
return new AnimationInstance_1.AnimationInstance(this.client, result.instantiateResult.instanceId, result.instantiateResult.state.id, dofs, true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
destroyCaches(cacheNames) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield this.sendMessage('destroyCaches', [cacheNames], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
acquireTarget(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
const result = yield this.sendMessage('acquireTarget', [options]);
|
||
|
|
const handle = new AcquireHandle_1.AcquireHandle(this.client, { instanceId: result.instanceId });
|
||
|
|
return handle;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
setAttentionMode(mode) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
yield this.sendMessage('setAttentionMode', [mode], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
pushAttentionMode(mode) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
const result = yield this.sendMessage('pushAttentionMode', [mode]);
|
||
|
|
const handle = new AttentionHandle_1.AttentionHandle(this.client, { instanceId: result.instanceId });
|
||
|
|
return handle;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
getAttentionMode() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield this.sendMessage('getAttentionMode');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
setLEDColor(color) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield this.sendMessage('setLEDColor', [color], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
awaitFace(options = { timeout: 10000 }) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
const result = yield this.sendMessage('awaitFace', [options]);
|
||
|
|
const handle = new AwaitFaceHandle_1.AwaitFaceHandle(this.client, { instanceId: result.instanceId });
|
||
|
|
return handle;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
centerRobot(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
if (!options) {
|
||
|
|
options = {};
|
||
|
|
}
|
||
|
|
if (!options.requestor) {
|
||
|
|
options.requestor = 'Behavior';
|
||
|
|
}
|
||
|
|
const arg = options;
|
||
|
|
if (options.dofs) {
|
||
|
|
arg.dofs = options.dofs.getDOFs();
|
||
|
|
}
|
||
|
|
yield this.sendMessage('centerRobot', [arg]);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
cleanup(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
if (!options) {
|
||
|
|
options = {};
|
||
|
|
}
|
||
|
|
if (!options.requestor) {
|
||
|
|
options.requestor = 'Behavior';
|
||
|
|
}
|
||
|
|
const arg = options;
|
||
|
|
if (options.dofs) {
|
||
|
|
arg.dofs = options.dofs.getDOFs();
|
||
|
|
}
|
||
|
|
yield this.sendMessage('cleanup', [arg], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
indexRobot() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield this.sendMessage('indexRobot');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
setSkillRoot(root) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.client.on('reopen', () => {
|
||
|
|
this.sendMessage('setSkillRoot', [root], true);
|
||
|
|
});
|
||
|
|
yield this.sendMessage('setSkillRoot', [root], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
blink() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
yield this.sendMessage('blink', [], true);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
doCenterRobotOnDisconnect(allow) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
yield this.sendMessage('doCenterRobotOnDisconnect', [allow], false);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
sendEmotionState() {
|
||
|
|
if (!this.jibo.emotion) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const currentEmotionValues = this.jibo.emotion.getCurrentEmotionalValues();
|
||
|
|
const nearestEmotion = this.jibo.emotion.getNearestEmotion();
|
||
|
|
this.sendMessage('acceptEmotionState', [currentEmotionValues, nearestEmotion.name, nearestEmotion.emotionValues], true);
|
||
|
|
}
|
||
|
|
onDofEvent(timestamp, dofValues, metadata) {
|
||
|
|
this.events.dofs.emit({
|
||
|
|
timestamp, dofValues, metadata
|
||
|
|
});
|
||
|
|
}
|
||
|
|
onKinematicEvent(features) {
|
||
|
|
this.applyVec(this.features.head.position, features.head.position);
|
||
|
|
this.applyVec(this.features.head.direction, features.head.direction);
|
||
|
|
this.applyVec(this.features.eye.position, features.eye.position);
|
||
|
|
this.applyVec(this.features.eye.direction, features.eye.direction);
|
||
|
|
this.applyVec(this.features.base.position, features.base.position);
|
||
|
|
this.applyVec(this.features.base.direction, features.base.direction);
|
||
|
|
this.events.kinematics.emit(this.features);
|
||
|
|
}
|
||
|
|
applyVec(to, from) {
|
||
|
|
to.x = from.x;
|
||
|
|
to.y = from.y;
|
||
|
|
to.z = from.z;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.default = Expression;
|
||
|
|
|
||
|
|
},{"./AnimationInstance":1,"./handles/AcquireHandle":7,"./handles/AttentionHandle":8,"./handles/AwaitFaceHandle":9,"animation-utilities":undefined,"jibo-client-framework":undefined,"jibo-common-types":undefined,"jibo-typed-events":undefined}],4:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const jibo_client_framework_1 = require("jibo-client-framework");
|
||
|
|
const log_1 = require("./log");
|
||
|
|
const log = log_1.default.createChild('ReleaseHandle');
|
||
|
|
class ReleaseHandle extends jibo_client_framework_1.ClientRemoteObject {
|
||
|
|
constructor(client, options, valToReturnWhenAlreadyReleased) {
|
||
|
|
super(client, options);
|
||
|
|
this.released = false;
|
||
|
|
this.valToReturnWhenAlreadyReleased = valToReturnWhenAlreadyReleased;
|
||
|
|
}
|
||
|
|
release() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
if (this.released) {
|
||
|
|
log.info("Someone tried to release ReleaseHandle twice!");
|
||
|
|
log.info("Second release site:" + new Error().stack);
|
||
|
|
return this.valToReturnWhenAlreadyReleased;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.released = true;
|
||
|
|
return yield this.sendMessage('release');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.ReleaseHandle = ReleaseHandle;
|
||
|
|
|
||
|
|
},{"./log":6,"jibo-client-framework":undefined}],5:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const jibo_client_framework_1 = require("jibo-client-framework");
|
||
|
|
const log_1 = require("./log");
|
||
|
|
const log = log_1.default.createChild('ResolveHandle');
|
||
|
|
class ResolveHandle extends jibo_client_framework_1.ClientRemoteObject {
|
||
|
|
constructor(client, options) {
|
||
|
|
super(client, options);
|
||
|
|
this.canceled = false;
|
||
|
|
this.resolved = false;
|
||
|
|
this.promise = new Promise((res) => {
|
||
|
|
this.resolvePromise = res;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
cancel() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
if (this.resolved || this.canceled) {
|
||
|
|
if (this.canceled) {
|
||
|
|
log.info("Someone tried to cancel ResolveHandle after it was cancelled!");
|
||
|
|
log.info("Second cancel site:" + new Error().stack);
|
||
|
|
}
|
||
|
|
else if (this.resolved) {
|
||
|
|
log.info("Someone tried to cancel ResolveHandle after it was resolved!");
|
||
|
|
}
|
||
|
|
this.canceled = true;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
yield this.sendMessage('cancel', []);
|
||
|
|
this.canceled = true;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
onPromise(result) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
this.resolved = true;
|
||
|
|
this.result = result;
|
||
|
|
this.resolvePromise(result);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.ResolveHandle = ResolveHandle;
|
||
|
|
|
||
|
|
},{"./log":6,"jibo-client-framework":undefined}],6:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const log_1 = require("../log");
|
||
|
|
const log = log_1.default.createChild('Base');
|
||
|
|
exports.default = log;
|
||
|
|
|
||
|
|
},{"../log":11}],7:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const ResolveHandle_1 = require("../base/ResolveHandle");
|
||
|
|
class AcquireHandle extends ResolveHandle_1.ResolveHandle {
|
||
|
|
}
|
||
|
|
exports.AcquireHandle = AcquireHandle;
|
||
|
|
|
||
|
|
},{"../base/ResolveHandle":5}],8:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const ReleaseHandle_1 = require("../base/ReleaseHandle");
|
||
|
|
class AttentionHandle extends ReleaseHandle_1.ReleaseHandle {
|
||
|
|
constructor(client, options) {
|
||
|
|
super(client, options, false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.AttentionHandle = AttentionHandle;
|
||
|
|
|
||
|
|
},{"../base/ReleaseHandle":4}],9:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const ResolveHandle_1 = require("../base/ResolveHandle");
|
||
|
|
class AwaitFaceHandle extends ResolveHandle_1.ResolveHandle {
|
||
|
|
}
|
||
|
|
exports.AwaitFaceHandle = AwaitFaceHandle;
|
||
|
|
|
||
|
|
},{"../base/ResolveHandle":5}],10:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const AcquireHandle_1 = require("./AcquireHandle");
|
||
|
|
exports.AcquireHandle = AcquireHandle_1.AcquireHandle;
|
||
|
|
const AttentionHandle_1 = require("./AttentionHandle");
|
||
|
|
exports.AttentionHandle = AttentionHandle_1.AttentionHandle;
|
||
|
|
const AwaitFaceHandle_1 = require("./AwaitFaceHandle");
|
||
|
|
exports.AwaitFaceHandle = AwaitFaceHandle_1.AwaitFaceHandle;
|
||
|
|
|
||
|
|
},{"./AcquireHandle":7,"./AttentionHandle":8,"./AwaitFaceHandle":9}],11:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const jibo_log_1 = require("jibo-log");
|
||
|
|
exports.default = new jibo_log_1.Log('Jibo.Expression');
|
||
|
|
|
||
|
|
},{"jibo-log":undefined}],12:[function(require,module,exports){
|
||
|
|
"use strict";
|
||
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
|
});
|
||
|
|
};
|
||
|
|
function __export(m) {
|
||
|
|
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||
|
|
}
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
const ai_ns = require("./AnimationInstance");
|
||
|
|
const Expression_1 = require("./Expression");
|
||
|
|
exports.Expression = Expression_1.default;
|
||
|
|
const jibo_client_framework_1 = require("jibo-client-framework");
|
||
|
|
const DOFs_1 = require("./DOFs");
|
||
|
|
const common_ns = require("jibo-common-types");
|
||
|
|
const anim_ns = require("animation-utilities");
|
||
|
|
const handles_ns = require("./handles");
|
||
|
|
__export(require("./AnimationInstance"));
|
||
|
|
__export(require("./handles"));
|
||
|
|
const client = new jibo_client_framework_1.RemoteClient('token');
|
||
|
|
exports.client = client;
|
||
|
|
const _expression = new Expression_1.default(client);
|
||
|
|
var expression;
|
||
|
|
(function (expression) {
|
||
|
|
expression.AttentionMode = common_ns.AttentionMode;
|
||
|
|
expression.IndexRobotResult = common_ns.IndexRobotResult;
|
||
|
|
expression.AnimationInstance = ai_ns.AnimationInstance;
|
||
|
|
expression.AttentionHandle = handles_ns.AttentionHandle;
|
||
|
|
expression.AcquireHandle = handles_ns.AcquireHandle;
|
||
|
|
expression.AwaitFaceHandle = handles_ns.AwaitFaceHandle;
|
||
|
|
expression.DOFSet = anim_ns.DOFSet;
|
||
|
|
function init(port, jibo) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
expression.dofs = yield DOFs_1.default();
|
||
|
|
_expression.dofs = expression.dofs;
|
||
|
|
expression.events = _expression.events;
|
||
|
|
expression.features = _expression.features;
|
||
|
|
yield client.init(port);
|
||
|
|
yield _expression.init(jibo);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.init = init;
|
||
|
|
function createAnimation(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.createAnimation(options);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.createAnimation = createAnimation;
|
||
|
|
function createAndPlayAnimation(options, requestor = 'Behavior') {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.createAndPlayAnimation(options, requestor);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.createAndPlayAnimation = createAndPlayAnimation;
|
||
|
|
function destroyCaches(cacheNames) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.destroyCaches(cacheNames);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.destroyCaches = destroyCaches;
|
||
|
|
function acquireTarget(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.acquireTarget(options);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.acquireTarget = acquireTarget;
|
||
|
|
function setAttentionMode(mode) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.setAttentionMode(mode);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.setAttentionMode = setAttentionMode;
|
||
|
|
function pushAttentionMode(mode) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.pushAttentionMode(mode);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.pushAttentionMode = pushAttentionMode;
|
||
|
|
function getAttentionMode() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.getAttentionMode();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.getAttentionMode = getAttentionMode;
|
||
|
|
function setLEDColor(color) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.setLEDColor(color);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.setLEDColor = setLEDColor;
|
||
|
|
function awaitFace(options = { timeout: 10000 }) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.awaitFace(options);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.awaitFace = awaitFace;
|
||
|
|
function centerRobot(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.centerRobot(options);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.centerRobot = centerRobot;
|
||
|
|
function cleanup(options) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.cleanup(options);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.cleanup = cleanup;
|
||
|
|
function indexRobot() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.indexRobot();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.indexRobot = indexRobot;
|
||
|
|
function setSkillRoot(root) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.setSkillRoot(root);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.setSkillRoot = setSkillRoot;
|
||
|
|
function blink() {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.blink();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.blink = blink;
|
||
|
|
function doCenterRobotOnDisconnect(allow) {
|
||
|
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
|
return yield _expression.doCenterRobotOnDisconnect(allow);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
expression.doCenterRobotOnDisconnect = doCenterRobotOnDisconnect;
|
||
|
|
})(expression = exports.expression || (exports.expression = {}));
|
||
|
|
|
||
|
|
},{"./AnimationInstance":1,"./DOFs":2,"./Expression":3,"./handles":10,"animation-utilities":undefined,"jibo-client-framework":undefined,"jibo-common-types":undefined}]},{},[12])(12)
|
||
|
|
});
|
||
|
|
|
||
|
|
//# sourceMappingURL=jibo-expression-client.js.map
|