initial commit
This commit is contained in:
1
node_modules/jibo-tools/lib/simulator/services/asr-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/asr-service.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/jibo-tools/lib/simulator/services/audio-entity.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/audio-entity.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var i=function(){function i(i,t){for(var n in t){var o=t[n];o.configurable=!0,o.value&&(o.writable=!0)}Object.defineProperties(i,t)}return function(t,n,o){return n&&i(t.prototype,n),o&&i(t,o),t}}(),t=function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function n(){t(this,n),this.ts=[0,0],this.type=void 0,this.id=void 0,this.position={x:void 0,y:void 0,z:void 0},this.confidence=void 0}return i(n,{updatePosition:{value:function(i){this.position.x=i.x,this.position.y=i.y,this.position.z=i.z}},updateId:{value:function(i){this.id=i}},updateType:{value:function(i){this.type=i}},updateConfidence:{value:function(i){this.confidence=i}},updateTs:{value:function(i){this.ts=i}}}),n}();module.exports=n;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/entity.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/entity.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var i=function(){function i(i,o){for(var d in o){var t=o[d];t.configurable=!0,t.value&&(t.writable=!0)}Object.defineProperties(i,o)}return function(o,d,t){return d&&i(o.prototype,d),t&&i(o,t),o}}(),o=function(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")},d=0,t=function(){function t(){var i=void 0===arguments[0]?void 0:arguments[0];o(this,t),this.id=i||d++,this.confidence=void 0,this.description=void 0,this.position={x:void 0,y:void 0,z:void 0},this.orientation={x:void 0,y:void 0,z:void 0},this.extent={x:void 0,y:void 0,z:void 0},this["static"]=void 0,this.parts=[{key:void 0,value:{id:void 0,confidence:void 0,visible:void 0,tracker:{position:{x:void 0,y:void 0,z:void 0},rotation:{x:void 0,y:void 0,z:void 0},velocity:{x:void 0,y:void 0,z:void 0},angVelocity:{x:void 0,y:void 0,z:void 0}},extent:{x:void 0,y:void 0,z:void 0},rays:[{origin:{x:0,y:0,z:0},dir:{x:void 0,y:void 0,z:void 0},cameraId:void 0,tag:void 0,timestamp:{time_since_epoch:{count:void 0}}}],trackers:[{id:void 0,cameraId:void 0,confidence:void 0,covariance:{n11:void 0,n12:void 0,n21:void 0,n22:void 0},points:[],rectangle:{left:void 0,top:void 0,right:void 0,bottom:void 0},velocity:{x:void 0,y:void 0},inFOV:void 0,visible:void 0,lastUpdate:{time_since_epoch:{count:void 0}},name:void 0,needModelUpdate:void 0}]}}]}return i(t,{updatePosition:{value:function(i){this.parts[0].value.rays[0].dir.x=i.x,this.parts[0].value.rays[0].dir.y=i.y,this.parts[0].value.rays[0].dir.z=i.z}},updateId:{value:function(i){this.id=i}}}),t}();module.exports=t;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/lps-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/lps-service.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},e=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),i=function l(t,e,i){var n=Object.getOwnPropertyDescriptor(t,e);if(void 0===n){var o=Object.getPrototypeOf(t);return null===o?void 0:l(o,e,i)}if("value"in n&&n.writable)return n.value;var r=n.get;if(void 0!==r)return r.call(i)},n=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=t(require("http")),s=require("websocket").server,a=t(require("./entity")),u=t(require("./audio-entity")),c=t(require("events")),d=function(t){function c(){o(this,c),i(Object.getPrototypeOf(c.prototype),"constructor",this).call(this),this.port=12476,this.cameras=[],this.entities=[],this.audioEntities=[],this.visualState={cameras:this.cameras,entities:this.entities},this.audioState={entities:this.audioEntities},this.connectionHandlers={"/visual_awareness":this.onVisualAwareness.bind(this),"/audible_awareness":this.onAudibleAwareness.bind(this)},this.httpHandlers={"/photo":this.onPhoto.bind(this),"/barcode":this.onBarcode.bind(this)},setInterval(this.update.bind(this),100)}return n(c,t),e(c,{init:{value:function(t){var e=this;this.httpServer=r.createServer(),this.httpServer.on("listening",function(){e.wsServer=new s({httpServer:e.httpServer,autoAcceptConnections:!1}),e.wsServer.on("request",function(t){var i=t.accept(null,t.origin);e.connectionHandlers[t.resource]?e.connectionHandlers[t.resource](i):console.warn("No simulator handler found for",t.resource)}),t()}),this.httpServer.on("request",function(t,i){"POST"===t.method&&(e.httpHandlers[t.url]?e.httpHandlers[t.url](t,i):(i.writeHead(200,{"Content-Type":"text/plain"}),i.end()))}),this.httpServer.listen(this.port)}},onPhoto:{value:function(t,e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end()}},onBarcode:{value:function(t,e){e.writeHead(200,{"Content-Type":"text/plain"}),e.end()}},onVisualAwareness:{value:function(t){this.visualSocket=t}},onAudibleAwareness:{value:function(t){this.audibleSocket=t}},updateTrackingState:{value:function(t){this.visualState=t}},getAudioEntityFromId:{value:function(t){var e=void 0;return this.audioEntities.forEach(function(i){i.id==t&&(e=i)}),e}},getVisualEntityFromId:{value:function(t){var e=void 0;return this.entities.forEach(function(i){i.id==t&&(e=i)}),e}},onAudio:{value:function(t){var e=this.getVisualEntityFromId(t),i=this.getAudioEntityFromId(t);if(i||(i=new u,i.updateId(t),i.updateConfidence(100),i.updatePosition(0,0,0),this.audioEntities.push(i)),e){var n=e.parts[0].value.rays[0].dir;i.updatePosition(n)}this.audioState.entities=this.audioEntities,this.update()}},setTargetId:{value:function(t,e){this.entities.forEach(function(i){i.id===t&&(i.id=e)})}},getEntities:{value:function(){return this.entities}},updateTarget:{value:function(t){var e=this.getVisualEntityFromId(t.id);e||(e=new a(t.id),this.entities.push(e)),e.updatePosition(t),this.update(),this.emit("update",t)}},addEntity:{value:function(){}},update:{value:function(){this.visualSocket&&this.visualSocket.connected&&this.visualSocket.send(JSON.stringify(this.visualState)),this.audibleSocket&&this.audibleSocket.connected&&this.audibleSocket.send(JSON.stringify(this.audioState))}}}),c}(c);module.exports=new d;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/motor-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/motor-service.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},e=function(){function t(t,e){for(var i in e){var n=e[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),i=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},n=t(require("http")),o=require("animation-utilities"),r=o.Clock,s=o.TrajectoryControllerSim,a=o.PosVelControllerSim,c=require("websocket").server,l=t(require("lodash")),u={ts:[0,0],pos:0,inc_pos:0,vel:0,cur:0,pwm:0,status:1,vel_limit:10,acc_limit:10,cur_limit:10,mode:4,ref:0,ticks:0},d={ts:[0,0],pelvis:Object.assign({},u),torso:Object.assign({},u),neck:Object.assign({},u)},m=l.cloneDeep(d),v=[0,0,0],f=performance.now(),h=function(){function t(e,n,o){i(this,t),this.initialPosition=e,this.velocity=n,(null===o||void 0===o)&&(o=r.currentTime()),this.initialTime=o}return e(t,{getPosition:{value:function(t){(null===t||void 0===t)&&(t=r.currentTime());var e=t.subtract(this.initialTime);return this.initialPosition+this.velocity*e}},getVelocity:{value:function(){return this.velocity}}}),t}(),p={pelvis:new h(0,0),torso:new h(0,0),neck:new h(0,0)},S=function(){function t(){i(this,t),this.port=12475,this.stateSocketList=[],this.commandSocketList=[],this.ledSocketList=[];var e=this,o=this.onAxisCommand.bind(this),r=this.onLEDCommand.bind(this),s=n.createServer(function(t,e){e.writeHead(404),e.end()});s.listen(this.port,function(){}),this.server=new c({httpServer:s,autoAcceptConnections:!1}),this.server.on("request",function(t){var i=t.accept(null,t.origin);"/axis_state"===t.resource?(e.stateSocketList.push(i),e.sendState(),i.on("close",function(){e.stateSocketList.indexOf(i)>-1&&e.stateSocketList.splice(e.stateSocketList.indexOf(i),1)})):"/axis_command"===t.resource?(e.commandSocketList.push(i),i.on("message",o),i.on("close",function(){e.commandSocketList.indexOf(i)>-1&&e.commandSocketList.splice(e.commandSocketList.indexOf(i),1),e.reset()})):"/led_command"===t.resource&&(e.ledSocketList.push(i),i.on("message",r),i.on("close",function(){e.ledSocketList.indexOf(i)>-1&&e.ledSocketList.splice(e.ledSocketList.indexOf(i),1)}))})}return e(t,{init:{value:function(t){t()}},sendState:{value:function(){if(this.stateSocketList.length>0){var t=r.currentTime()._timestamp;m.neck.ts=t,m.torso.ts=t,m.pelvis.ts=t,m.ts=t;try{var e=!0,i=!1,n=void 0;try{for(var o,s=this.stateSocketList[Symbol.iterator]();!(e=(o=s.next()).done);e=!0){var a=o.value;a.connected&&a.send(JSON.stringify(m))}}catch(c){i=!0,n=c}finally{try{!e&&s["return"]&&s["return"]()}finally{if(i)throw n}}}catch(l){}}}},updateState:{value:function(){var t=r.currentTime(),e=performance.now()-f<500,i=!0,n=!1,o=void 0;try{for(var s,a=Object.keys(p)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var c=s.value;e?m[c].vel=p[c].getVelocity(t):m[c].vel=0,m[c].pos=p[c].getPosition(t)}}catch(l){n=!0,o=l}finally{try{!i&&a["return"]&&a["return"]()}finally{if(n)throw o}}}},onAxisCommand:{value:function(t){f=performance.now(),t=JSON.parse(t.utf8Data);var e=r.currentTime(),i=!0,n=!1,o=void 0;try{for(var c,l=Object.keys(p)[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var u=c.value;4===t[u].mode?p[u]=new h(p[u].getPosition(e),t[u].value[0],e):5===t[u].mode?(p[u]=new s(p[u].getPosition(e),p[u].getVelocity(e),e),p[u].updateCommand(t[u].value[1],t[u].value[0],t[u].value[2],t[u].acc_limit,t[u].vel_limit,e)):7===t[u].mode?(p[u]=new a(p[u].getPosition(e),p[u].getVelocity(e),e),p[u].updateCommand(t[u].value[1],t[u].value[0],t[u].acc_limit,t[u].vel_limit,e)):p[u]=new h(p[u].getPosition(e),0,e)}}catch(d){n=!0,o=d}finally{try{!i&&l["return"]&&l["return"]()}finally{if(n)throw o}}this.updateState(),this.sendState()}},onLEDCommand:{value:function(t){t=JSON.parse(t.utf8Data),t.color&&Array.isArray(t.color)&&3===t.color.length&&(v=t.color)}},reset:{value:function(){m=l.cloneDeep(d),p={pelvis:new h(0,0),torso:new h(0,0),neck:new h(0,0)}}},render:{value:function(t){this.updateState(),t.display({topSection_r:m.neck.pos,middleSection_r:m.torso.pos,bottomSection_r:m.pelvis.pos,lightring_redChannelBn_r:v[0],lightring_greenChannelBn_r:v[1],lightring_blueChannelBn_r:v[2]})}}}),t}();module.exports=new S;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/nlu-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/nlu-service.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=function(){function e(e,t){for(var r in t){var n=t[r];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=e(require("http")),s=void 0;try{s=require("jibo-parser")}catch(i){console.warn("Error importing jibo-parser. Simulator will not support robust parsing.")}var a=0,o=function(){function e(){r(this,e),this.port=11231,this.handles={}}return t(e,{init:{value:function(e){var t=this;this.server=n.createServer(),this.server.on("request",function(e,r){"/nlu_interface"===e.url&&"POST"===e.method&&(e.setEncoding("utf8"),e.on("data",function(e){var n=void 0;try{n=JSON.parse(e)}catch(s){return r.writeHead(200,{"Content-Type":"text/html"}),r.write(JSON.stringify({Status:"ERROR",Message:"Inavlid request. Request body is not valid JSON"})),void r.end()}"COMPILE"===n.REQ_TYPE?t.compile(n.REQ_CONTENT.RULE_STRING,r):"PARSE_FROM_URI"===n.REQ_TYPE?t.parseFromUri(n.REQ_CONTENT.URI,n.REQ_CONTENT.TXT_STRING,r):"PARSE_FROM_TEXT"===n.REQ_TYPE&&t.parseFromText(n.REQ_CONTENT.RULE_STRING,n.REQ_CONTENT.TXT_STRING,r)}))}),this.server.on("listening",function(){e()}),this.server.listen(this.port)}},parseFromUri:{value:function(e,t,r){var n={Status:"OK",URI:""},i=this.handles[e];if(i&&s){var a=s.build_sentence_parser(i),o=a.parse_sentence(t);n.Result=JSON.parse(o)}else n.Status="ERROR",n.Message="No handle named '"+e+"' exists";r.writeHead(200,{"Content-Type":"text/html"}),r.write(JSON.stringify(n)),r.end()}},parseFromText:{value:function(e,t,r){var n={Status:"OK"};try{var i=s.compile_fst_from_text(e,"handle:"+a++),o=s.build_sentence_parser(i),u=o.parse_sentence(t);n.Result=JSON.parse(u)}catch(l){n.Status="ERROR",n.Message=l.message}r.writeHead(200,{"Content-Type":"text/html"}),r.write(JSON.stringify(n)),r.end()}},compile:{value:function(e,t){var r={Status:"OK",URI:""};try{var n="handle:"+a++;this.handles[n]=s.compile_fst_from_text(e,n),r.URI=n}catch(i){r.Status="ERROR",r.Message=i.message}t.writeHead(200,{"Content-Type":"text/html"}),t.write(JSON.stringify(r)),t.end()}}}),e}();module.exports=new o;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/registry-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/registry-service.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},r=function(){function e(e,r){for(var t in r){var n=r[t];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,r)}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),t=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},n=e(require("http")),o=e(require("./lps-service")),i=e(require("./nlu-service")),s=e(require("./asr-service")),u=e(require("./tts-service")),a=e(require("./motor-service")),c=8181,p=[{name:"body",host:"127.0.0.1",port:a.port},{name:"lps",host:"127.0.0.1",port:o.port},{name:"nlu",host:"127.0.0.1",port:i.port},{name:"asr",host:"127.0.0.1",port:s.port},{name:"tts",host:"127.0.0.1",port:u.port}],f=function(){function e(){t(this,e)}return r(e,{init:{value:function(e){this.server=n.createServer(),this.server.on("request",function(e,r){"GET"===e.method&&(r.writeHead(200,{"Content-Type":"text/plain"}),r.end(JSON.stringify(p),"utf8"))}),this.server.on("listening",function(){e()}),this.server.listen(c)}}}),e}();module.exports=new f;
|
||||
1
node_modules/jibo-tools/lib/simulator/services/service-initializer.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/service-initializer.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var i=function(i){return i&&i.__esModule?i["default"]:i},e=i(require("./lps-service")),r=i(require("./nlu-service")),n=i(require("./asr-service")),t=i(require("./tts-service")),u=i(require("./motor-service")),c=i(require("./registry-service")),s=i(require("async"));module.exports=function(i){s.parallel([function(i){e.init(i)},function(i){r.init(i)},function(i){n.init(i)},function(i){t.init(i)},function(i){u.init(i)},function(i){c.init(i)}],function(){i()})};
|
||||
1
node_modules/jibo-tools/lib/simulator/services/tts-service.js
generated
vendored
Normal file
1
node_modules/jibo-tools/lib/simulator/services/tts-service.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";function e(e,t,n){var s={token:e,timestamp:t,status:n,moreinfo:[]};return s}function t(e){var t=.2,s=[{name:"/pau/",start:0,end:t}];return e.split(" ").forEach(function(e){e=e.trim(),n(e[e.length-1])&&(e=e.substr(0,e.length-1)),s.push({name:e,start:t,end:t+.3}),t+=.3}),s.push({name:"/pau/",start:t,end:t+.2}),s}function n(e){return"."===e||","===e||"?"===e||"!"===e||";"===e||":"===e}var s=function(e){return e&&e.__esModule?e["default"]:e},r=function(){function e(e,t){for(var n in t){var s=t[n];s.configurable=!0,s.value&&(s.writable=!0)}Object.defineProperties(e,t)}return function(t,n,s){return n&&e(t.prototype,n),s&&e(t,s),t}}(),o=function f(e,t,n){var s=Object.getOwnPropertyDescriptor(e,t);if(void 0===s){var r=Object.getPrototypeOf(e);return null===r?void 0:f(r,t,n)}if("value"in s&&s.writable)return s.value;var o=s.get;if(void 0!==o)return o.call(n)},i=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},a=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=s(require("http")),c=require("events").EventEmitter,p=require("websocket").server,l=function(n){function s(){a(this,s),o(Object.getPrototypeOf(s.prototype),"constructor",this).call(this),this.port=11275,this.messages=[],this.connectionHandlers={"/tts_token_times":this.onTokenTimes.bind(this),"/tts_speak":this.onSpeak.bind(this),"/tts_stop":this.onStop.bind(this)}}return i(s,n),r(s,{init:{value:function(e){var t=this;this.httpServer=u.createServer(),this.httpServer.on("request",function(e,n){"POST"===e.method&&(e.setEncoding("utf8"),e.on("data",function(s){var r=void 0;try{for(r=JSON.parse(s),t.messages.push({url:e.url,data:r,response:n});t.messages.length;){var o=t.messages.shift();t.connectionHandlers[o.url](o.data,o.response)}}catch(i){return console.error(i),t.messages.push({url:e.url,data:"ERROR Invalid request. Request body is not valid JSON",response:n}),n.writeHead(200,{"Content-Type":"text/html"}),n.write(JSON.stringify({Status:"ERROR",Message:"Inavlid request. Request body is not valid JSON"})),t.socket&&t.socket.send(JSON.stringify({status:"error",message:"ERROR Invalid request. Request body is not valid JSON"})),void n.end()}t.socket&&t.processMessages()}))}),this.httpServer.on("listening",function(){t.wsServer=new p({httpServer:t.httpServer,autoAcceptconnections:!1}),t.wsServer.on("request",function(e){var n=e.accept(null,e.orgin);"/tts_tokens"===e.resource?(t.tokenSocket=n,t.processMessages()):"/tts_phones"===e.resource&&(t.phoneSocket=n,t.processMessages())})}),e(),this.httpServer.listen(this.port)}},processMessages:{value:function(){for(;this.messages.length;){var e=this.messages.shift();this.connectionHandlers[e.url](e.data,e.response)}}},onSpeak:{value:function(n,s){var r=this;s.writeHead(204,{"Content-Type":"text/html"}),s.write(JSON.stringify({Status:"OK",Message:"Speaking TTS"})),s.end();var o=t(n.prompt);setTimeout(function(){r.emit("speech",n.prompt),r.tokenSocket.send(JSON.stringify(e("",0,"STOP")))},1e3*o[o.length-1].end)}},onTokenTimes:{value:function(e,n){var s={tokentimes:{tokens:t(e.prompt)}};n.writeHead(200,{"Content-Type":"text/html"}),n.write(JSON.stringify(s)),n.end()}},onStop:{value:function(e,t){t.writeHead(200,{"Content-Type":"text/html"}),t.write(JSON.stringify({Status:"OK",Message:"Stopping TTS"})),t.end(),this.emit("stop")}}}),s}(c);module.exports=new l;
|
||||
Reference in New Issue
Block a user