diff --git a/.gitignore b/.gitignore index 39a72c4e4..34f59397d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .vagrant doc node_modules +*.out +*.log \ No newline at end of file diff --git a/utils/.jshintrc b/.jshintrc similarity index 79% rename from utils/.jshintrc rename to .jshintrc index d28b5b997..29d2df756 100644 --- a/utils/.jshintrc +++ b/.jshintrc @@ -1,7 +1,6 @@ { "globals": { - "module": true, - "EventEmitter2" : true + "global": true }, "curly": true, "eqeqeq": true, @@ -13,9 +12,8 @@ "undef": true, "boss": false, "eqnull": false, - "browser": true, + "node": true, "devel": true, - "es5": true, "strict": false, "trailing": true, "quotmark": "single", diff --git a/.travis.yml b/.travis.yml index e74cf63c9..9af2efaca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,28 @@ language: node_js - node_js: - "0.10" +addons: + firefox: "31.0" # 3.4->31.0 +os: + - linux +before_install: + # node-canvas dependency + - sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ + # ROS deps for examples + - sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list' + - wget http://packages.ros.org/ros.key -O - | sudo apt-key add - + - sudo apt-get update -qq + - sudo apt-get install ros-hydro-ros-base + - sudo apt-get install ros-hydro-rosbridge-server ros-hydro-tf2-web-republisher ros-hydro-common-tutorials ros-hydro-rospy-tutorials ros-hydro-actionlib-tutorials + - npm install -g grunt-cli karma-cli -branches: - only: - - master - - develop - + # Set up Xfvb for Firefox headless testing + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" before_script: - - npm install -g karma grunt-cli - - cd utils - - npm install . - + - source /opt/ros/hydro/setup.bash + - sh test/examples/setup_examples.sh script: - - grunt build + - rostopic list + - npm test + - npm run test-examples diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..867ee1f43 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,52 @@ +roslibjs Build Setup +==================== + +[Grunt](http://gruntjs.com/) is used for building, including concatenating, minimizing, documenting, linting, and testing. + +### Install Grunt and its Dependencies + + 1. Install [Node.js](http://nodejs.org/) for your environment + 2. Install the build task runner, [Grunt](http://gruntjs.com/) + + ```sh + $ [sudo] npm install -g grunt + ``` + + 3. Install the [Cario](http://cairographics.org/) graphics library + - [System specific instaructions](https://github.com/Automattic/node-canvas/wiki/_pages) + 4. Install the dependencies and build dependencies + + ```sh + $ cd /path/to/roslibjs/ + $ [sudo] npm install + ``` + + +Easy installation for Ubuntu. `cd` to your local copy of this project. + +```sh +# Install Node.js and NPM +curl -sL https://deb.nodesource.com/setup | sudo bash - +sudo apt-get install nodejs + +# Install Cario +sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ + +# Install this projects Deps +sudo npm install +``` + +### Build with Grunt + +Before proceeding, please confirm you have installed the dependencies above. + +To run the build tasks: + + 1. `cd /path/to/roslibjs/` + 2. `grunt build` + +`grunt build` will concatenate and minimize the files under src and replace roslib.js and roslib.min.js in the build directory. It will also run the linter and test cases. This is what [Travis CI](https://travis-ci.org/RobotWebTools/roslibjs) runs when a Pull Request is submitted. + +`grunt dev` will watch for any changes to any of the src/ files and automatically concatenate and minimize the files. This is ideal for those developing as you should only have to run `grunt dev` once. + +`grunt doc` will rebuild all JSDoc for the project. diff --git a/utils/Gruntfile.js b/Gruntfile.js similarity index 58% rename from utils/Gruntfile.js rename to Gruntfile.js index edfa74493..a6390c07b 100644 --- a/utils/Gruntfile.js +++ b/Gruntfile.js @@ -2,10 +2,10 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - concat: { - build: { - src : ['../src/*.js', '../src/**/*.js'], - dest : '../build/roslib.js' + browserify: { + dist: { + src: ['./src/RosLibBrowser.js'], + dest: './build/roslib.js' } }, jshint: { @@ -14,14 +14,26 @@ module.exports = function(grunt) { }, files: [ 'Gruntfile.js', - '../build/roslib.js' + './src/**/*.js' ] }, karma: { build: { - configFile: '../test/karma.conf.js', + configFile: './test/karma.conf.js', singleRun: true, - browsers: ['PhantomJS'] + browsers: ['Firefox'] + } + }, + mochaTest: { + options: { + reporter: 'spec', + timeout: 5000 + }, + test: { + src: ['test/*.test.js'] + }, + examples: { + src: ['test/examples/*.js'] } }, uglify: { @@ -29,8 +41,8 @@ module.exports = function(grunt) { report: 'min' }, build: { - src: '../build/roslib.js', - dest: '../build/roslib.min.js' + src: './build/roslib.js', + dest: './build/roslib.min.js' } }, watch: { @@ -42,7 +54,7 @@ module.exports = function(grunt) { '../src/*.js', '../src/**/*.js' ], - tasks: ['concat'] + tasks: ['browserify'] }, build_and_watch: { options: { @@ -51,8 +63,8 @@ module.exports = function(grunt) { files: [ 'Gruntfile.js', '.jshintrc', - '../src/*.js', - '../src/**/*.js' + './src/*.js', + './src/**/*.js' ], tasks: ['build'] } @@ -66,27 +78,29 @@ module.exports = function(grunt) { jsdoc: { doc: { src: [ - '../src/*.js', - '../src/**/*.js' + './src/*.js', + './src/**/*.js' ], options: { - destination: '../doc' + destination: './doc' } } } }); - grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-jsdoc'); grunt.loadNpmTasks('grunt-karma'); + grunt.loadNpmTasks('grunt-mocha-test'); + - grunt.registerTask('dev', ['concat', 'watch']); - grunt.registerTask('build', ['concat', 'jshint', 'karma', 'uglify']); + grunt.registerTask('dev', ['browserify', 'watch']); + grunt.registerTask('test', ['jshint', 'mochaTest:test', 'browserify', 'karma']); + grunt.registerTask('build', ['test', 'uglify']); grunt.registerTask('build_and_watch', ['watch']); grunt.registerTask('doc', ['clean', 'jsdoc']); }; - diff --git a/build/roslib.js b/build/roslib.js index f0f9e768e..6a5601847 100644 --- a/build/roslib.js +++ b/build/roslib.js @@ -1,21 +1,97 @@ +(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 0) { - that.visual = new ROSLIB.UrdfVisual({ + that.visual = new UrdfVisual({ xml : visuals[0] }); } @@ -1642,14 +1777,17 @@ ROSLIB.UrdfLink = function(options) { // Pass it to the XML parser initXml(xml); -}; - +} +module.exports = UrdfLink; +},{"./UrdfVisual":28}],23:[function(require,module,exports){ /** * @author Benjamin Pitzer - ben.pitzer@gmail.com * @author Russell Toris - rctoris@wpi.edu */ +var UrdfColor = require('./UrdfColor'); + /** * A Material element in a URDF. * @@ -1657,7 +1795,7 @@ ROSLIB.UrdfLink = function(options) { * @param options - object with following keys: * * xml - the XML element to parse */ -ROSLIB.UrdfMaterial = function(options) { +function UrdfMaterial(options) { options = options || {}; var that = this; var xml = options.xml; @@ -1683,7 +1821,7 @@ ROSLIB.UrdfMaterial = function(options) { var colors = xml.getElementsByTagName('color'); if (colors.length > 0) { // Parse the RBGA string - that.color = new ROSLIB.UrdfColor({ + that.color = new UrdfColor({ xml : colors[0] }); } @@ -1691,13 +1829,18 @@ ROSLIB.UrdfMaterial = function(options) { // Pass it to the XML parser initXml(xml); -}; +} +module.exports = UrdfMaterial; +},{"./UrdfColor":20}],24:[function(require,module,exports){ /** * @author Benjamin Pitzer - ben.pitzer@gmail.com * @author Russell Toris - rctoris@wpi.edu */ +var Vector3 = require('../math/Vector3'); +var UrdfTypes = require('./UrdfTypes'); + /** * A Mesh element in a URDF. * @@ -1705,7 +1848,7 @@ ROSLIB.UrdfMaterial = function(options) { * @param options - object with following keys: * * xml - the XML element to parse */ -ROSLIB.UrdfMesh = function(options) { +function UrdfMesh(options) { options = options || {}; var that = this; var xml = options.xml; @@ -1719,7 +1862,7 @@ ROSLIB.UrdfMesh = function(options) { * @param xml - the XML element to parse */ var initXml = function(xml) { - that.type = ROSLIB.URDF_MESH; + that.type = UrdfTypes.URDF_MESH; that.filename = xml.getAttribute('filename'); // Check for a scale @@ -1727,7 +1870,7 @@ ROSLIB.UrdfMesh = function(options) { if (scale) { // Get the XYZ var xyz = scale.split(' '); - that.scale = new ROSLIB.Vector3({ + that.scale = new Vector3({ x : parseFloat(xyz[0]), y : parseFloat(xyz[1]), z : parseFloat(xyz[2]) @@ -1737,14 +1880,22 @@ ROSLIB.UrdfMesh = function(options) { // Pass it to the XML parser initXml(xml); -}; - +} +module.exports = UrdfMesh; +},{"../math/Vector3":17,"./UrdfTypes":27}],25:[function(require,module,exports){ /** * @author Benjamin Pitzer - ben.pitzer@gmail.com * @author Russell Toris - rctoris@wpi.edu */ +var UrdfMaterial = require('./UrdfMaterial'); +var UrdfLink = require('./UrdfLink'); +var DOMParser = require('../util/DOMParser'); + +// See https://developer.mozilla.org/docs/XPathResult#Constants +var XPATH_FIRST_ORDERED_NODE_TYPE = 9; + /** * A URDF Model can be used to parse a given URDF into the appropriate elements. * @@ -1753,7 +1904,7 @@ ROSLIB.UrdfMesh = function(options) { * * xml - the XML element to parse * * string - the XML element to parse as a string */ -ROSLIB.UrdfModel = function(options) { +function UrdfModel(options) { options = options || {}; var that = this; var xml = options.xml; @@ -1768,7 +1919,7 @@ ROSLIB.UrdfModel = function(options) { */ var initXml = function(xmlDoc) { // Get the robot tag - var robotXml = xmlDoc.evaluate('//robot', xmlDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + var robotXml = xmlDoc.evaluate('//robot', xmlDoc, null, XPATH_FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; // Get the robot name that.name = robotXml.getAttribute('name'); @@ -1777,7 +1928,7 @@ ROSLIB.UrdfModel = function(options) { for (var n in robotXml.childNodes) { var node = robotXml.childNodes[n]; if (node.tagName === 'material') { - var material = new ROSLIB.UrdfMaterial({ + var material = new UrdfMaterial({ xml : node }); // Make sure this is unique @@ -1787,7 +1938,7 @@ ROSLIB.UrdfModel = function(options) { that.materials[material.name] = material; } } else if (node.tagName === 'link') { - var link = new ROSLIB.UrdfLink({ + var link = new UrdfLink({ xml : node }); // Make sure this is unique @@ -1818,13 +1969,17 @@ ROSLIB.UrdfModel = function(options) { } // Pass it to the XML parser initXml(xml); -}; +} +module.exports = UrdfModel; +},{"../util/DOMParser":29,"./UrdfLink":22,"./UrdfMaterial":23}],26:[function(require,module,exports){ /** * @author Benjamin Pitzer - ben.pitzer@gmail.com * @author Russell Toris - rctoris@wpi.edu */ +var UrdfTypes = require('./UrdfTypes'); + /** * A Sphere element in a URDF. * @@ -1832,7 +1987,7 @@ ROSLIB.UrdfModel = function(options) { * @param options - object with following keys: * * xml - the XML element to parse */ -ROSLIB.UrdfSphere = function(options) { +function UrdfSphere(options) { options = options || {}; var that = this; var xml = options.xml; @@ -1845,20 +2000,39 @@ ROSLIB.UrdfSphere = function(options) { * @param xml - the XML element to parse */ var initXml = function(xml) { - that.type = ROSLIB.URDF_SPHERE; + that.type = UrdfTypes.URDF_SPHERE; that.radius = parseFloat(xml.getAttribute('radius')); }; // pass it to the XML parser initXml(xml); -}; +} +module.exports = UrdfSphere; +},{"./UrdfTypes":27}],27:[function(require,module,exports){ +module.exports = { + URDF_SPHERE : 0, + URDF_BOX : 1, + URDF_CYLINDER : 2, + URDF_MESH : 3 +}; +},{}],28:[function(require,module,exports){ /** * @author Benjamin Pitzer - ben.pitzer@gmail.com * @author Russell Toris - rctoris@wpi.edu */ +var Pose = require('../math/Pose'); +var Vector3 = require('../math/Vector3'); +var Quaternion = require('../math/Quaternion'); + +var UrdfCylinder = require('./UrdfCylinder'); +var UrdfBox = require('./UrdfBox'); +var UrdfMaterial = require('./UrdfMaterial'); +var UrdfMesh = require('./UrdfMesh'); +var UrdfSphere = require('./UrdfSphere'); + /** * A Visual element in a URDF. * @@ -1866,7 +2040,7 @@ ROSLIB.UrdfSphere = function(options) { * @param options - object with following keys: * * xml - the XML element to parse */ -ROSLIB.UrdfVisual = function(options) { +function UrdfVisual(options) { options = options || {}; var that = this; var xml = options.xml; @@ -1884,14 +2058,14 @@ ROSLIB.UrdfVisual = function(options) { var origins = xml.getElementsByTagName('origin'); if (origins.length === 0) { // use the identity as the default - that.origin = new ROSLIB.Pose(); + that.origin = new Pose(); } else { // Check the XYZ var xyz = origins[0].getAttribute('xyz'); - var position = new ROSLIB.Vector3(); + var position = new Vector3(); if (xyz) { xyz = xyz.split(' '); - position = new ROSLIB.Vector3({ + position = new Vector3({ x : parseFloat(xyz[0]), y : parseFloat(xyz[1]), z : parseFloat(xyz[2]) @@ -1900,7 +2074,7 @@ ROSLIB.UrdfVisual = function(options) { // Check the RPY var rpy = origins[0].getAttribute('rpy'); - var orientation = new ROSLIB.Quaternion(); + var orientation = new Quaternion(); if (rpy) { rpy = rpy.split(' '); // Convert from RPY @@ -1919,7 +2093,7 @@ ROSLIB.UrdfVisual = function(options) { var w = Math.cos(phi) * Math.cos(the) * Math.cos(psi) + Math.sin(phi) * Math.sin(the) * Math.sin(psi); - orientation = new ROSLIB.Quaternion({ + orientation = new Quaternion({ x : x, y : y, z : z, @@ -1927,7 +2101,7 @@ ROSLIB.UrdfVisual = function(options) { }); orientation.normalize(); } - that.origin = new ROSLIB.Pose({ + that.origin = new Pose({ position : position, orientation : orientation }); @@ -1948,19 +2122,19 @@ ROSLIB.UrdfVisual = function(options) { // Check the type var type = shape.nodeName; if (type === 'sphere') { - that.geometry = new ROSLIB.UrdfSphere({ + that.geometry = new UrdfSphere({ xml : shape }); } else if (type === 'box') { - that.geometry = new ROSLIB.UrdfBox({ + that.geometry = new UrdfBox({ xml : shape }); } else if (type === 'cylinder') { - that.geometry = new ROSLIB.UrdfCylinder({ + that.geometry = new UrdfCylinder({ xml : shape }); } else if (type === 'mesh') { - that.geometry = new ROSLIB.UrdfMesh({ + that.geometry = new UrdfMesh({ xml : shape }); } else { @@ -1971,7 +2145,7 @@ ROSLIB.UrdfVisual = function(options) { // Material var materials = xml.getElementsByTagName('material'); if (materials.length > 0) { - that.material = new ROSLIB.UrdfMaterial({ + that.material = new UrdfMaterial({ xml : materials[0] }); } @@ -1979,5 +2153,26 @@ ROSLIB.UrdfVisual = function(options) { // Pass it to the XML parser initXml(xml); -}; - +} + +module.exports = UrdfVisual; +},{"../math/Pose":14,"../math/Quaternion":15,"../math/Vector3":17,"./UrdfBox":19,"./UrdfCylinder":21,"./UrdfMaterial":23,"./UrdfMesh":24,"./UrdfSphere":26}],29:[function(require,module,exports){ +(function (global){ +module.exports = global.DOMParser; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],30:[function(require,module,exports){ +(function (global){ +module.exports = { + EventEmitter2: global.EventEmitter2 +}; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],31:[function(require,module,exports){ +(function (global){ +module.exports = global.WebSocket; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],32:[function(require,module,exports){ +/* global document */ +module.exports = function Canvas() { + return document.createElement('canvas'); +}; +},{}]},{},[3]); diff --git a/build/roslib.min.js b/build/roslib.min.js index 1eb3da1e6..560a7c8ca 100644 --- a/build/roslib.min.js +++ b/build/roslib.min.js @@ -1 +1 @@ -var ROSLIB=ROSLIB||{REVISION:"0.10.0-SNAPSHOT"};ROSLIB.URDF_SPHERE=0,ROSLIB.URDF_BOX=1,ROSLIB.URDF_CYLINDER=2,ROSLIB.URDF_MESH=3,ROSLIB.ActionClient=function(a){var b=this;a=a||{},this.ros=a.ros,this.serverName=a.serverName,this.actionName=a.actionName,this.timeout=a.timeout,this.goals={};var c=!1,d=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/feedback",messageType:this.actionName+"Feedback"}),e=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/status",messageType:"actionlib_msgs/GoalStatusArray"}),f=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/result",messageType:this.actionName+"Result"});this.goalTopic=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/goal",messageType:this.actionName+"Goal"}),this.cancelTopic=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/cancel",messageType:"actionlib_msgs/GoalID"}),this.goalTopic.advertise(),this.cancelTopic.advertise(),e.subscribe(function(a){c=!0,a.status_list.forEach(function(a){var c=b.goals[a.goal_id.id];c&&c.emit("status",a)})}),d.subscribe(function(a){var c=b.goals[a.status.goal_id.id];c&&(c.emit("status",a.status),c.emit("feedback",a.feedback))}),f.subscribe(function(a){var c=b.goals[a.status.goal_id.id];c&&(c.emit("status",a.status),c.emit("result",a.result))}),this.timeout&&setTimeout(function(){c||b.emit("timeout")},this.timeout)},ROSLIB.ActionClient.prototype.__proto__=EventEmitter2.prototype,ROSLIB.ActionClient.prototype.cancel=function(){var a=new ROSLIB.Message;this.cancelTopic.publish(a)},ROSLIB.Goal=function(a){var b=this;this.actionClient=a.actionClient,this.goalMessage=a.goalMessage,this.isFinished=!1;var c=new Date;this.goalID="goal_"+Math.random()+"_"+c.getTime(),this.goalMessage=new ROSLIB.Message({goal_id:{stamp:{secs:0,nsecs:0},id:this.goalID},goal:this.goalMessage}),this.on("status",function(a){b.status=a}),this.on("result",function(a){b.isFinished=!0,b.result=a}),this.on("feedback",function(a){b.feedback=a}),this.actionClient.goals[this.goalID]=this},ROSLIB.Goal.prototype.__proto__=EventEmitter2.prototype,ROSLIB.Goal.prototype.send=function(a){var b=this;b.actionClient.goalTopic.publish(b.goalMessage),a&&setTimeout(function(){b.isFinished||b.emit("timeout")},a)},ROSLIB.Goal.prototype.cancel=function(){var a=new ROSLIB.Message({id:this.goalID});this.actionClient.cancelTopic.publish(a)},ROSLIB.SimpleActionServer=function(a){var b=this;a=a||{},this.ros=a.ros,this.serverName=a.serverName,this.actionName=a.actionName,this.feedbackPublisher=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/feedback",messageType:this.actionName+"Feedback"}),this.feedbackPublisher.advertise();var c=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/status",messageType:"actionlib_msgs/GoalStatusArray"});c.advertise(),this.resultPublisher=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/result",messageType:this.actionName+"Result"}),this.resultPublisher.advertise();var d=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/goal",messageType:this.actionName+"Goal"}),e=new ROSLIB.Topic({ros:this.ros,name:this.serverName+"/cancel",messageType:"actionlib_msgs/GoalID"});this.statusMessage=new ROSLIB.Message({header:{stamp:{secs:0,nsecs:100},frame_id:""},status_list:[]}),this.currentGoal=null,this.nextGoal=null,d.subscribe(function(a){b.currentGoal?(b.nextGoal=a,b.emit("cancel")):(b.statusMessage.status_list=[{goal_id:a.goal_id,status:1}],b.currentGoal=a,b.emit("goal",a.goal))});var f=function(a,b){return a.secs>b.secs?!1:a.secs=0&&(c.cbs.splice(d,1),0===c.cbs.length&&delete this.frameInfos[a],this.needUpdate=!0)}},ROSLIB.UrdfBox=function(a){a=a||{};var b=this,c=a.xml;this.dimension=null,this.type=null;var d=function(a){b.type=ROSLIB.URDF_BOX;var c=a.getAttribute("size").split(" ");b.dimension=new ROSLIB.Vector3({x:parseFloat(c[0]),y:parseFloat(c[1]),z:parseFloat(c[2])})};d(c)},ROSLIB.UrdfColor=function(a){a=a||{};var b=this,c=a.xml;this.r=null,this.g=null,this.b=null,this.a=null;var d=function(a){var c=a.getAttribute("rgba").split(" ");return b.r=parseFloat(c[0]),b.g=parseFloat(c[1]),b.b=parseFloat(c[2]),b.a=parseFloat(c[3]),!0};d(c)},ROSLIB.UrdfCylinder=function(a){a=a||{};var b=this,c=a.xml;this.type=null,this.length=null,this.radius=null;var d=function(a){b.type=ROSLIB.URDF_CYLINDER,b.length=parseFloat(a.getAttribute("length")),b.radius=parseFloat(a.getAttribute("radius"))};d(c)},ROSLIB.UrdfLink=function(a){a=a||{};var b=this,c=a.xml;this.name=null,this.visual=null;var d=function(a){b.name=a.getAttribute("name");var c=a.getElementsByTagName("visual");c.length>0&&(b.visual=new ROSLIB.UrdfVisual({xml:c[0]}))};d(c)},ROSLIB.UrdfMaterial=function(a){a=a||{};var b=this,c=a.xml;this.name=null,this.textureFilename=null,this.color=null;var d=function(a){b.name=a.getAttribute("name");var c=a.getElementsByTagName("texture");c.length>0&&(b.textureFilename=c[0].getAttribute("filename"));var d=a.getElementsByTagName("color");d.length>0&&(b.color=new ROSLIB.UrdfColor({xml:d[0]}))};d(c)},ROSLIB.UrdfMesh=function(a){a=a||{};var b=this,c=a.xml;this.filename=null,this.scale=null,this.type=null;var d=function(a){b.type=ROSLIB.URDF_MESH,b.filename=a.getAttribute("filename");var c=a.getAttribute("scale");if(c){var d=c.split(" ");b.scale=new ROSLIB.Vector3({x:parseFloat(d[0]),y:parseFloat(d[1]),z:parseFloat(d[2])})}};d(c)},ROSLIB.UrdfModel=function(a){a=a||{};var b=this,c=a.xml,d=a.string;this.materials=[],this.links=[];var e=function(a){var c=a.evaluate("//robot",a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;b.name=c.getAttribute("name");for(var d in c.childNodes){var e=c.childNodes[d];if("material"===e.tagName){var f=new ROSLIB.UrdfMaterial({xml:e});b.materials[f.name]?console.warn("Material "+f.name+"is not unique."):b.materials[f.name]=f}else if("link"===e.tagName){var g=new ROSLIB.UrdfLink({xml:e});b.links[g.name]?console.warn("Link "+g.name+" is not unique."):(g.visual&&g.visual.material&&(b.materials[g.visual.material.name]?g.visual.material=b.materials[g.visual.material.name]:g.visual.material&&(b.materials[g.visual.material.name]=g.visual.material)),b.links[g.name]=g)}}};if(d){var f=new DOMParser;c=f.parseFromString(d,"text/xml")}e(c)},ROSLIB.UrdfSphere=function(a){a=a||{};var b=this,c=a.xml;this.radius=null,this.type=null;var d=function(a){b.type=ROSLIB.URDF_SPHERE,b.radius=parseFloat(a.getAttribute("radius"))};d(c)},ROSLIB.UrdfVisual=function(a){a=a||{};var b=this,c=a.xml;this.origin=null,this.geometry=null,this.material=null;var d=function(a){var c=a.getElementsByTagName("origin");if(0===c.length)b.origin=new ROSLIB.Pose;else{var d=c[0].getAttribute("xyz"),e=new ROSLIB.Vector3;d&&(d=d.split(" "),e=new ROSLIB.Vector3({x:parseFloat(d[0]),y:parseFloat(d[1]),z:parseFloat(d[2])}));var f=c[0].getAttribute("rpy"),g=new ROSLIB.Quaternion;if(f){f=f.split(" ");var h=parseFloat(f[0]),i=parseFloat(f[1]),j=parseFloat(f[2]),k=h/2,l=i/2,m=j/2,n=Math.sin(k)*Math.cos(l)*Math.cos(m)-Math.cos(k)*Math.sin(l)*Math.sin(m),o=Math.cos(k)*Math.sin(l)*Math.cos(m)+Math.sin(k)*Math.cos(l)*Math.sin(m),p=Math.cos(k)*Math.cos(l)*Math.sin(m)-Math.sin(k)*Math.sin(l)*Math.cos(m),q=Math.cos(k)*Math.cos(l)*Math.cos(m)+Math.sin(k)*Math.sin(l)*Math.sin(m);g=new ROSLIB.Quaternion({x:n,y:o,z:p,w:q}),g.normalize()}b.origin=new ROSLIB.Pose({position:e,orientation:g})}var r=a.getElementsByTagName("geometry");if(r.length>0){var s=null;for(var t in r[0].childNodes){var u=r[0].childNodes[t];if(1===u.nodeType){s=u;break}}var v=s.nodeName;"sphere"===v?b.geometry=new ROSLIB.UrdfSphere({xml:s}):"box"===v?b.geometry=new ROSLIB.UrdfBox({xml:s}):"cylinder"===v?b.geometry=new ROSLIB.UrdfCylinder({xml:s}):"mesh"===v?b.geometry=new ROSLIB.UrdfMesh({xml:s}):console.warn("Unknown geometry type "+v)}var w=a.getElementsByTagName("material");w.length>0&&(b.material=new ROSLIB.UrdfMaterial({xml:w[0]}))};d(c)}; \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb.secs?!1:a.secs=0&&(c.cbs.splice(d,1),0===c.cbs.length&&delete this.frameInfos[a],this.needUpdate=!0)}},b.exports=c},{"../actionlib/ActionClient":4,"../actionlib/Goal":5,"../math/Transform":16}],19:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.dimension=null,this.type=null;var f=function(a){b.type=e.URDF_BOX;var c=a.getAttribute("size").split(" ");b.dimension=new d({x:parseFloat(c[0]),y:parseFloat(c[1]),z:parseFloat(c[2])})};f(c)}var d=a("../math/Vector3"),e=a("./UrdfTypes");b.exports=c},{"../math/Vector3":17,"./UrdfTypes":27}],20:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.r=null,this.g=null,this.b=null,this.a=null;var d=function(a){var c=a.getAttribute("rgba").split(" ");return b.r=parseFloat(c[0]),b.g=parseFloat(c[1]),b.b=parseFloat(c[2]),b.a=parseFloat(c[3]),!0};d(c)}b.exports=c},{}],21:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.type=null,this.length=null,this.radius=null;var e=function(a){b.type=d.URDF_CYLINDER,b.length=parseFloat(a.getAttribute("length")),b.radius=parseFloat(a.getAttribute("radius"))};e(c)}var d=a("./UrdfTypes");b.exports=c},{"./UrdfTypes":27}],22:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.name=null,this.visual=null;var e=function(a){b.name=a.getAttribute("name");var c=a.getElementsByTagName("visual");c.length>0&&(b.visual=new d({xml:c[0]}))};e(c)}var d=a("./UrdfVisual");b.exports=c},{"./UrdfVisual":28}],23:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.name=null,this.textureFilename=null,this.color=null;var e=function(a){b.name=a.getAttribute("name");var c=a.getElementsByTagName("texture");c.length>0&&(b.textureFilename=c[0].getAttribute("filename"));var e=a.getElementsByTagName("color");e.length>0&&(b.color=new d({xml:e[0]}))};e(c)}var d=a("./UrdfColor");b.exports=c},{"./UrdfColor":20}],24:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.filename=null,this.scale=null,this.type=null;var f=function(a){b.type=e.URDF_MESH,b.filename=a.getAttribute("filename");var c=a.getAttribute("scale");if(c){var f=c.split(" ");b.scale=new d({x:parseFloat(f[0]),y:parseFloat(f[1]),z:parseFloat(f[2])})}};f(c)}var d=a("../math/Vector3"),e=a("./UrdfTypes");b.exports=c},{"../math/Vector3":17,"./UrdfTypes":27}],25:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml,h=a.string;this.materials=[],this.links=[];var i=function(a){var c=a.evaluate("//robot",a,null,g,null).singleNodeValue;b.name=c.getAttribute("name");for(var f in c.childNodes){var h=c.childNodes[f];if("material"===h.tagName){var i=new d({xml:h});b.materials[i.name]?console.warn("Material "+i.name+"is not unique."):b.materials[i.name]=i}else if("link"===h.tagName){var j=new e({xml:h});b.links[j.name]?console.warn("Link "+j.name+" is not unique."):(j.visual&&j.visual.material&&(b.materials[j.visual.material.name]?j.visual.material=b.materials[j.visual.material.name]:j.visual.material&&(b.materials[j.visual.material.name]=j.visual.material)),b.links[j.name]=j)}}};if(h){var j=new f;c=j.parseFromString(h,"text/xml")}i(c)}var d=a("./UrdfMaterial"),e=a("./UrdfLink"),f=a("../util/DOMParser"),g=9;b.exports=c},{"../util/DOMParser":29,"./UrdfLink":22,"./UrdfMaterial":23}],26:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.radius=null,this.type=null;var e=function(a){b.type=d.URDF_SPHERE,b.radius=parseFloat(a.getAttribute("radius"))};e(c)}var d=a("./UrdfTypes");b.exports=c},{"./UrdfTypes":27}],27:[function(a,b){b.exports={URDF_SPHERE:0,URDF_BOX:1,URDF_CYLINDER:2,URDF_MESH:3}},{}],28:[function(a,b){function c(a){a=a||{};var b=this,c=a.xml;this.origin=null,this.geometry=null,this.material=null;var l=function(a){var c=a.getElementsByTagName("origin");if(0===c.length)b.origin=new d;else{var l=c[0].getAttribute("xyz"),m=new e;l&&(l=l.split(" "),m=new e({x:parseFloat(l[0]),y:parseFloat(l[1]),z:parseFloat(l[2])}));var n=c[0].getAttribute("rpy"),o=new f;if(n){n=n.split(" ");var p=parseFloat(n[0]),q=parseFloat(n[1]),r=parseFloat(n[2]),s=p/2,t=q/2,u=r/2,v=Math.sin(s)*Math.cos(t)*Math.cos(u)-Math.cos(s)*Math.sin(t)*Math.sin(u),w=Math.cos(s)*Math.sin(t)*Math.cos(u)+Math.sin(s)*Math.cos(t)*Math.sin(u),x=Math.cos(s)*Math.cos(t)*Math.sin(u)-Math.sin(s)*Math.sin(t)*Math.cos(u),y=Math.cos(s)*Math.cos(t)*Math.cos(u)+Math.sin(s)*Math.sin(t)*Math.sin(u);o=new f({x:v,y:w,z:x,w:y}),o.normalize()}b.origin=new d({position:m,orientation:o})}var z=a.getElementsByTagName("geometry");if(z.length>0){var A=null;for(var B in z[0].childNodes){var C=z[0].childNodes[B];if(1===C.nodeType){A=C;break}}var D=A.nodeName;"sphere"===D?b.geometry=new k({xml:A}):"box"===D?b.geometry=new h({xml:A}):"cylinder"===D?b.geometry=new g({xml:A}):"mesh"===D?b.geometry=new j({xml:A}):console.warn("Unknown geometry type "+D)}var E=a.getElementsByTagName("material");E.length>0&&(b.material=new i({xml:E[0]}))};l(c)}var d=a("../math/Pose"),e=a("../math/Vector3"),f=a("../math/Quaternion"),g=a("./UrdfCylinder"),h=a("./UrdfBox"),i=a("./UrdfMaterial"),j=a("./UrdfMesh"),k=a("./UrdfSphere");b.exports=c},{"../math/Pose":14,"../math/Quaternion":15,"../math/Vector3":17,"./UrdfBox":19,"./UrdfCylinder":21,"./UrdfMaterial":23,"./UrdfMesh":24,"./UrdfSphere":26}],29:[function(a,b){(function(a){b.exports=a.DOMParser}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(a,b){(function(a){b.exports={EventEmitter2:a.EventEmitter2}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],31:[function(a,b){(function(a){b.exports=a.WebSocket}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],32:[function(a,b){b.exports=function(){return document.createElement("canvas")}},{}]},{},[3]); \ No newline at end of file diff --git a/examples/fibonacci.html b/examples/fibonacci.html index 00962b3b2..f58084219 100644 --- a/examples/fibonacci.html +++ b/examples/fibonacci.html @@ -2,8 +2,8 @@ - - + + - + - + - + - + - +