diff --git a/build/roslib.js b/build/roslib.js index 4767bc219..d21bf1138 100644 --- a/build/roslib.js +++ b/build/roslib.js @@ -3,7 +3,7 @@ */ var ROSLIB = ROSLIB || { - REVISION : '7-devel' + REVISION : '7' }; //URDF types @@ -263,8 +263,7 @@ ROSLIB.Param.prototype.get = function(callback) { }); var request = new ROSLIB.ServiceRequest({ - name : this.name, - value : JSON.stringify('') + name : this.name }); paramClient.callService(request, function(result) { @@ -798,6 +797,7 @@ ROSLIB.Topic = function(options) { this.isAdvertised = false; this.compression = options.compression || 'none'; this.throttle_rate = options.throttle_rate || 0; + this.latch = options.latch || false; // Check for valid compression types if (this.compression && this.compression !== 'png' && this.compression !== 'none') { @@ -872,7 +872,8 @@ ROSLIB.Topic.prototype.advertise = function() { op : 'advertise', id : advertiseId, type : this.messageType, - topic : this.name + topic : this.name, + latch : this.latch }; this.ros.callOnConnection(call); this.isAdvertised = true; @@ -909,7 +910,8 @@ ROSLIB.Topic.prototype.publish = function(message) { op : 'publish', id : publishId, topic : this.name, - msg : message + msg : message, + latch : this.latch }; this.ros.callOnConnection(call); }; @@ -1303,7 +1305,7 @@ ROSLIB.UrdfBox = function(options) { * @param xml - the XML element to parse */ var initXml = function(xml) { - this.type = ROSLIB.URDF_BOX; + that.type = ROSLIB.URDF_BOX; // Parse the string var xyz = xml.getAttribute('size').split(' '); diff --git a/build/roslib.min.js b/build/roslib.min.js index a871f330d..6fc83d4c5 100644 --- a/build/roslib.min.js +++ b/build/roslib.min.js @@ -1 +1 @@ -var ROSLIB=ROSLIB||{REVISION:"7-devel"};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.Message=function(a){var b=this;a=a||{},Object.keys(a).forEach(function(c){b[c]=a[c]})},ROSLIB.Param=function(a){a=a||{},this.ros=a.ros,this.name=a.name},ROSLIB.Param.prototype.get=function(a){var b=new ROSLIB.Service({ros:this.ros,name:"/rosapi/get_param",serviceType:"rosapi/GetParam"}),c=new ROSLIB.ServiceRequest({name:this.name,value:JSON.stringify("")});b.callService(c,function(b){var c=JSON.parse(b.value);a(c)})},ROSLIB.Param.prototype.set=function(a){var b=new ROSLIB.Service({ros:this.ros,name:"/rosapi/set_param",serviceType:"rosapi/SetParam"}),c=new ROSLIB.ServiceRequest({name:this.name,value:JSON.stringify(a)});b.callService(c,function(){})},ROSLIB.Param.prototype.delete=function(){var a=new ROSLIB.Service({ros:this.ros,name:"/rosapi/delete_param",serviceType:"rosapi/DeleteParam"}),b=new ROSLIB.ServiceRequest({name:this.name});a.callService(b,function(){})},ROSLIB.Ros=function(a){a=a||{};var b=a.url;this.socket=null,this.idCounter=0,this.setMaxListeners(0),b&&this.connect(b)},ROSLIB.Ros.prototype.__proto__=EventEmitter2.prototype,ROSLIB.Ros.prototype.connect=function(a){function b(a){g.emit("connection",a)}function c(a){g.emit("close",a)}function d(a){g.emit("error",a)}function e(a,b){var c=new Image;c.onload=function(){var a=document.createElement("canvas"),d=a.getContext("2d");a.width=c.width,a.height=c.height,d.drawImage(c,0,0);for(var e=d.getImageData(0,0,c.width,c.height).data,f="",g=0;g=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){this.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 +var ROSLIB=ROSLIB||{REVISION:"7"};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.Message=function(a){var b=this;a=a||{},Object.keys(a).forEach(function(c){b[c]=a[c]})},ROSLIB.Param=function(a){a=a||{},this.ros=a.ros,this.name=a.name},ROSLIB.Param.prototype.get=function(a){var b=new ROSLIB.Service({ros:this.ros,name:"/rosapi/get_param",serviceType:"rosapi/GetParam"}),c=new ROSLIB.ServiceRequest({name:this.name});b.callService(c,function(b){var c=JSON.parse(b.value);a(c)})},ROSLIB.Param.prototype.set=function(a){var b=new ROSLIB.Service({ros:this.ros,name:"/rosapi/set_param",serviceType:"rosapi/SetParam"}),c=new ROSLIB.ServiceRequest({name:this.name,value:JSON.stringify(a)});b.callService(c,function(){})},ROSLIB.Param.prototype.delete=function(){var a=new ROSLIB.Service({ros:this.ros,name:"/rosapi/delete_param",serviceType:"rosapi/DeleteParam"}),b=new ROSLIB.ServiceRequest({name:this.name});a.callService(b,function(){})},ROSLIB.Ros=function(a){a=a||{};var b=a.url;this.socket=null,this.idCounter=0,this.setMaxListeners(0),b&&this.connect(b)},ROSLIB.Ros.prototype.__proto__=EventEmitter2.prototype,ROSLIB.Ros.prototype.connect=function(a){function b(a){g.emit("connection",a)}function c(a){g.emit("close",a)}function d(a){g.emit("error",a)}function e(a,b){var c=new Image;c.onload=function(){var a=document.createElement("canvas"),d=a.getContext("2d");a.width=c.width,a.height=c.height,d.drawImage(c,0,0);for(var e=d.getImageData(0,0,c.width,c.height).data,f="",g=0;g=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 diff --git a/src/RosLib.js b/src/RosLib.js index 99388555e..8131f33f5 100644 --- a/src/RosLib.js +++ b/src/RosLib.js @@ -3,7 +3,7 @@ */ var ROSLIB = ROSLIB || { - REVISION : '7-devel' + REVISION : '7' }; //URDF types diff --git a/utils/README.md b/utils/README.md index 367ee66a2..490a7d096 100644 --- a/utils/README.md +++ b/utils/README.md @@ -8,11 +8,10 @@ roslibjs Build Setup #### Ubuntu 1. Install Node.js and its package manager, NPM - * `sudo apt-get install python-software-properties` - * `sudo add-apt-repository ppa:chris-lea/node.js` - * `sudo apt-get update && sudo apt-get install nodejs phantomjs` + * `sudo apt-get install npm phantomjs` + * `sudo ln -s /usr/bin/nodejs /usr/bin/node` 2. Install Grunt and the test runner [Karma](http://karma-runner.github.io/) - * `sudo npm install -g grunt-cli karma phantomjs` + * `sudo npm install -g grunt-cli` * `sudo rm -rf ~/.npm ~/tmp` 3. Install the Grunt tasks specific to this project * `cd /path/to/roslibjs/utils/`