robotwebtools / roslibjs Goto Github PK
View Code? Open in Web Editor NEWThe Standard ROS JavaScript Library
Home Page: https://robotwebtools.github.io/roslibjs
License: Other
The Standard ROS JavaScript Library
Home Page: https://robotwebtools.github.io/roslibjs
License: Other
Migrated from https://github.com/RobotWebTools/rosjs/issues/27
Very large messages, like some point cloud streams, cause the browser to freeze. This was originally reported by @jihoonl, who emailed me example code to reproduce (I uploaded it here, but haven't checked it out yet).
If the issue is blocking the main thread, one thing could be using webworkers to process the messages. Still need to investigate.
I was finally able to reproduce this bug and figure out what was going on.
When a ROS message or service call is supposed to send to the server, it's actually deferred until a WebSocket connection is established. This is by design. However, if you try to send more than 10 messages or service calls to the server before a WebSocket connection has been established with rosbridge, then EventEmitter2 assumes it's a memory leak.
As queueing up via the connection
event is by design and allows for easier code, I agree with the original proposal to setMaxListeners(0) so more than 10 requests can be queued up.
I'll fix this when I'm back in town next week unless someone needs it done earlier.
Migrated from https://github.com/RobotWebTools/rosjs/issues/31
@jihoonl :
Can rosjs set Publisher(latch=True) ?
I have just noticed that serviceType
and messageType
fields are not used anywhere in rosbridge_library and core roslibjs.
Does serviceType
and messageType
have any meaning? Do they need to be specified to use service or topic?
Build script needed to create one final roslib.js
Hello everyone,
I wanted to help publishing roslibjs to the Bower package manager (http://bower.io/). I already made a bower.json with the configuration but unfortunately this doesn't work:
https://github.com/Rayman/roslibjs/blob/devel/bower.json
The reason for this I think is because the version numbers are not semantic, they need to be MAJOR.MINOR.PATCH
You can try this with the following command:
bower install Rayman/roslibjs
= Tag/branch master does not exist
We could make a separate repository for publishing to bower, just like for example requirejs: https://github.com/jrburke/requirejs-bower
What do you think? I can also maintain the bower repository myself if that is ok.
I'm currently working on adding unit tests to our web apps at WG. I've had good luck in the past with Mocha.js and trying that here.
This is a placeholder issue I'll update as I learn more and start adding tests to things like ros.js.
All caps is usually reserved for constants. CamelCase is typical for classes and namespaces. Yes, Three.js uses THREE, but it's the exception.
In general, I'd advise looking at other frameworks instead of three.js for best practices as three.js has a very unique JS approach. Better "best practice" libraries (which all happen to use CamelCase for their namespace): Backbone.js, Ember.js, jQuery, Socket.IO, EventEmitter2. Personally, I find the Backbone code the easiest to read.
Proposed namespaces:
Hi all,
this is not really an issue, but I wanted to give public insights about what I think of this library.
First, I have to say that currently my main use would be in Node.JS, but my remarks are not Node.JS specific.
The following ideas are not sorted in any priority.
Because of all this and of the "Warning. It is not working yet" of the NodeJS branches, I decided to create my own implementation of a Javascript (currently only Node.JS) ROS client, working with the RobotWebTools websocket server. https://github.com/maxired/rosnode.js
ps : Don't take it wrong, I think you guys from RobotWebTools do a great job. I worked sometimes ago with @baalexander on the old rosnodejs and also another implementation. This was wrong and the current choices are much better.
I'd like to use CDN service of robot web tools under secure pages.
Other CDN Services, including jquery, bootstrap and so on, supports both
http and https protocol.
Would you intend to support https of robot web tools?
While helping out ROS Answers, I figured that wait for service is not available in roslibjs. It would also not be supported by rosbridge.
I wonder if it is appropriate topics to start discussion...
In current design, all modules have single depth namespace. Pose is under math directory but using ROSLIB.Pose...
I would like to propose the change of namespacing rule to allow sub namespace. So
ROSLIB.Pose -> ROSLIB.Math.Pose
ROSLIB.Quaternion -> ROSLIB.Math.Quaternion...
ROSLIB.ActionClient -> ROSLIB.actionlib.ActionClient
How do you guys think about it?
roslibjs uses absolute namespace for finding rosapis. If rosbridge get started with namespace, it wouldn't find the proper service calls.
Examples,
https://github.com/RobotWebTools/roslibjs/blob/devel/src/core/Param.js#L28
https://github.com/RobotWebTools/roslibjs/blob/devel/src/core/Param.js#L51
There seems to be something strange going on with the automated tests. Maybe a race condition?
This line could cause one, but why would it, with the fibonacci server inserting pauses in between feedback updates?
I have a fresh instance of Ubuntu 12.04.
What I've done so far:
sudo apt-get install ant
cd utils
ant build.xml
I then get the following error:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
Buildfile: /home/vagrant/ws/roslibjs/utils/build.xml
BUILD FAILED
Target "build.xml" does not exist in the project "roslibjs".
Total time: 0 seconds
Any ideas?
Having roslibjs running on top of Node.js would enable casual robot builders to quickly develop robot software using JavaScript.
The current version of roslibjs has some dependencies that assume you're running in a browser environment.
I've made some small tweaks to it that enable it to run inside of Node.js, but I wanted to get the community's advice on what to do with these changes and whether it would make sense to try to merge them with the main codebase.
There were two main issues I had to address:
My changes are visible in my fork of roslibjs if you'd like to take a look at them. This version is currently working and tested in Node.js on my system, but I would love to get feedback. In particular I used some Meteor-specific code (because my system is built on Meteor) but it should be possible to remove that if the code would be of general interest to the community.
Just because JavaScript has Java in it, doesn't mean we need to use an antiquated build environment. I'll assign this to me unless someone else wants to look at it first.
As with the issue in ros3djs... name says it all
An ID counter is missing so that multiple service calls can be made to the same service. This explains the funky behavior seen when dealing with parameter service calls.
https://github.com/RobotWebTools/roslibjs/blob/stable/src/core/Service.js#L29-L30
I instantiate a ROSLIB.TFClient
object where I pass fixedFrame: 'world'
as a parameter to the constructor as shown below.
// Setup a client to listen to TFs.
var tfClient = new ROSLIB.TFClient({
ros : ros,
angularThres : 0.01,
transThres : 0.01,
rate : 10.0,
fixedFrame : 'world'
});
I would like to dynamically change the value of tfClient.fixedFrame
and attempted to directly modify it as follows:
var frameSelect = document.getElementById('fixedFrameOptions');
frameSelect.addEventListener('change', handleSelectChange, false);
function handleSelectChange(evt) {
tfClient.fixedFrame = this.value;
}
Unfortunately, the above code does not work.
I checked ROSLIB.TFClient's API but did not see any way to dynamically change fixedFrame
. Is what I'm trying to do possible? If so, how?
Thanks!
in 9938d1b
the TFClient was modified to add a leading slash to tf frames if there was not already one. This seems to go against the migration guide for hydro (http://wiki.ros.org/hydro/Migration#tf2.2BAC8-Migration.Removal_of_support_for_tf_prefix) and seems to prevent tf2_web_republisher from properly updating frames that do not begin with a slash.
I have followed the instruction on the link below.
https://github.com/RobotWebTools/roslibjs/blob/devel/utils/README.md
However, I got this error. Anybody know what this error indicates?
jihoonl@whoola:~/research/ros/isolate/src/roslibjs/utils$ grunt build
Running "concat:build" (concat) task
File "../build/roslib.js" created.
Running "jshint:files" (jshint) task
>> 2 files lint free.
Running "karma:build" (karma) task
[2014-02-05 08:49:11.411] [DEBUG] config - autoWatch set to false, because of singleRun
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [karma]: To run via this server, use "karma run --runner-port 9200"
ERROR [launcher]: Cannot start PhantomJS
Can not find the binary phantomjs
Please set env variable PHANTOMJS_BIN
Warning: Task "karma:build" failed. Use --force to continue.
Aborted due to warnings.
ROSLIB.Quaternion.prototype.multiply = function(q) { this.x = this.x * q.w + this.y * q.z - this.z * q.y + this.w * q.x; this.y = -this.x * q.z + this.y * q.w + this.z * q.x + this.w * q.y; this.z = this.x * q.y - this.y * q.x + this.z * q.w + this.w * q.z; this.w = -this.x * q.x - this.y * q.y - this.z * q.z + this.w * q.w; };
This function mutates itself as it multiples ๐ง Will fix in next push ๐ป
When using the TCP
extension the node will sometimes crash when 2 messages happen to be sent on the same line.
Not sure where or how this should be fixed but I'd say this is a critical bug if TCP is to be supported
Example leading up to the crash
var ros = new ROS.Ros({
port: argv.port || 7781 // port of ROS bridge server TCP
});
var gps = ros.Topic({
name: "/navsat/rx"
});
gps.subscribe(console.log.bind(console));
{ header:
{ stamp: { secs: 1415043944, nsecs: 918030280 },
frame_id: 'navsat',
seq: 132434 },
sentence: '$GPVTG,,,,,,,,,N*30' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 12028613 },
frame_id: 'navsat',
seq: 132435 },
sentence: '$GPGGA,193816.30,,,,,0,00,9.9,,,,,,*61' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 17374196 },
frame_id: 'navsat',
seq: 132436 },
sentence: '$GPGSA,,1,,,,,,,,,,,,,,,*5F' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 17374196 },
frame_id: 'navsat',
seq: 132437 },
sentence: '$GPVTG,,,,,,,,,N*30' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 112016118 },
frame_id: 'navsat',
seq: 132438 },
sentence: '$GPGGA,193816.40,,,,,0,00,9.9,,,,,,*66' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 117606777 },
frame_id: 'navsat',
seq: 132439 },
sentence: '$GPGSA,,1,,,,,,,,,,,,,,,*5F' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 117606777 },
frame_id: 'navsat',
seq: 132440 },
sentence: '$GPVTG,,,,,,,,,N*30' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 212994747 },
frame_id: 'navsat',
seq: 132441 },
sentence: '$GPGGA,193816.50,,,,,0,00,9.9,,,,,,*67' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 219985786 },
frame_id: 'navsat',
seq: 132442 },
sentence: '$GPGSA,,1,,,,,,,,,,,,,,,*5F' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 219985786 },
frame_id: 'navsat',
seq: 132443 },
sentence: '$GPVTG,,,,,,,,,N*30' }
{ header:
{ stamp: { secs: 1415043945, nsecs: 311877291 },
frame_id: 'navsat',
seq: 132444 },
sentence: '$GPGGA,193816.60,,,,,0,00,9.9,,,,,,*64' }
undefined:1
32445}, "sentence": "$GPGSA,,1,,,,,,,,,,,,,,,*5F"}, "op": "publish"}{"topic":
^
SyntaxError: Unexpected token {
at Object.parse (native)
at Socket.onMessage (/home/administrator/catkin_ws/src/es_kf_pose/node_modules/roslibjs/src/core/SocketAdapter.js:104:23)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:764:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at emitReadable (_stream_readable.js:422:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:528:21)
I'll make a pr later today to have Travis run the TCP tests
Migrated from https://github.com/RobotWebTools/rosjs/issues/33
@jihoonl :
Web worker allows to have use background thread in the browser.
It may help to keep the interface responsive while it receives the high volume of data from socket.
@rctoris :
Could address things like https://github.com/RobotWebTools/map2djs/issues/5
In ROS floating-point numbers are allowed to have an "Infinity" value. This gets serialized by rosbridge as follows (e.g. for a type std_msgs/Float32 ROS message):
{"data": Infinity}
This string is invalid JavaScript and causes JSON.parse() to barf (https://github.com/RobotWebTools/roslibjs/blob/devel/src/core/Ros.js#L125).
Ideally this would be fixed on both sides and enable transmission of Infinity values from ROS to the browser. Until then, it would be nice to put a guard around the JSON.parse on the roslibjs side so that at least garbage inputs don't cause an uncaught exception.
It looks like Infinity and NaN values are not allowable in JSON: http://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript
Any thoughts on how to handle this?
Convert all ROSLIB objects to use 'options' in their constructors as discussed with @baalexander
Currently GetParam failes with the following message on the server
[ERROR] [WallTime: 1397530634.354306] [Client 0] [id: call_service:/rosapi/get_param:8] call_service NonexistentFieldException: Message type rosapi/GetParamRequest does not have a field value
It looks like something might of changed with what roslibjs sends in a service request, which causes it to send the empty string in a values field for the GetParamRequest
https://github.com/RobotWebTools/roslibjs/blob/devel/src/core/Param.js#L34
I hit this ticket and running the sample there, and I still see:
[ERROR] [WallTime: 1411692033.888950] [Client 0] [id: call_service:/rosapi/set_param:2] call_service InvalidPackageException: Unable to load the manifest for package rosapi. Caused by: rosapi
Full output:
$ dpkg -p ros-hydro-rosbridge-server | grep Ver
Version: 0.6.0-0precise-20140905-1112-+0000
$ roslaunch rosbridge_server rosbridge_websocket.launch --screen
... logging to /home/n130s/.ros/log/5c296b70-450a-11e4-8939-bc5ff4b8cb22/roslaunch-yayoi-28218.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://yayoi:45499/
SUMMARY
========
PARAMETERS
* /rosbridge_websocket/address
* /rosbridge_websocket/authenticate
* /rosbridge_websocket/port
* /rosdistro
* /rosversion
NODES
/
rosapi (rosapi/rosapi)
rosbridge_websocket (rosbridge_server/rosbridge_websocket)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
process[rosbridge_websocket-1]: started with pid [28237]
process[rosapi-2]: started with pid [28238]
registered capabilities (classes):
- rosbridge_library.capabilities.call_service.CallService
- rosbridge_library.capabilities.advertise.Advertise
- rosbridge_library.capabilities.publish.Publish
- rosbridge_library.capabilities.subscribe.Subscribe
- <class 'rosbridge_library.capabilities.defragmentation.Defragment'>
- rosbridge_library.capabilities.advertise_service.AdvertiseService
- rosbridge_library.capabilities.service_response.ServiceResponse
- rosbridge_library.capabilities.stop_service.StopService
[INFO] [WallTime: 1411692024.517288] Rosbridge WebSocket server started on port 9090
[INFO] [WallTime: 1411692024.635715] Rosapi started
[INFO] [WallTime: 1411692033.868034] Client connected. 1 clients total.
[ERROR] [WallTime: 1411692033.888950] [Client 0] [id: call_service:/rosapi/set_param:2] call_service InvalidPackageException: Unable to load the manifest for package rosapi. Caused by: rosapi
I hit the ticket above while googling the error code that I'm seeing with the issue I asked on answers and on ML (you can see the error output I'm getting with my package here). Does this mean the issue is not yet resolved in rosbridge, or am I doing something wrong?
Last note, actually for the sample html I changed the source of .js
file to point to CDN, like this.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>-->
<!-- <script src="eventemitter2.js"></script> -->
<!-- <script src="roslib.js"></script> -->
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script>
var ros = new ROSLIB.Ros();
// If there is an error on the backend, an 'error' emit will be emitted.
ros.on('error', function(error) {
console.log(error);
});
// Find out exactly when we made a connection.
ros.on('connection', function() {
console.log('Connection made!');
ros.getParams(function(params) {
console.log(params);
});
// First, we create a Param object with the name of the param.
var maxVelX = new ROSLIB.Param({
ros : ros,
name : 'max_vel_y'
});
//Then we set the value of the param, which is sent to the ROS Parameter Server.
maxVelX.set(0.8);
});
// Create a connection to the rosbridge WebSocket server.
ros.connect('ws://localhost:9090');
</script>
</head>
<body>
Test
</body>
</html>
ROSLIB namespacing needed on current libraries.
No subscribed messages are being emited after #13
Until we have test case, we should at least make sure the example pages run (for example, Fibonacci is completely broken).
Will investigate.
It would be great if we could have param.delete() as well as param.set() and param.get().
Thanks!
It would be nice if roslibjs had a way to create service nodes in addition to being able to call them.
It appears this may be dependent on rosbridge, but is there any possibility of this in the future?
To explain how to use the module.
As suggested in #66.
Warning while mochatest.
ROS
callOnConnection
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at EventEmitter.on (/home/jihoonl/research/node/roslibjs/node_modules/eventemitter2/lib/eventemitter2.js:391:19)
at Context.<anonymous> (/home/jihoonl/research/node/roslibjs/test/ros.test.js:14:22)
at callFn (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:374:10)
at /home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:452:12
at next (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:299:14)
at /home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:309:7
at next (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:247:23)
at Object._onImmediate (/home/jihoonl/research/node/roslibjs/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
โ should accept more than EventEmitter2's default listeners
The mesh scale factor is never parsed in URDF
The current actionlib interface in roslibjs is something like this:
goal.send(client)
Would it make more sense for the client object to provide the interface for sending goals, instead of having goals "send themselves":
client.sendGoal(goal)
Just a thought - I really like all the work you guys have done!
In TfClient's processFeedback method, roslibjs is not checking for leading slash in joint state topic names.
Currently, if rosjs fails to create a socket, the user is presented with an empty error message. Adding a console message that reports that the error had to do with the socket creation would be really helpful to new users:
Line 452 in 9938d1b
var ros = new ROSLIB.Ros({
url: 'ws://localhost:9090'
});
var example = ros.Topic({
name: '/some_topic',
messageType: 'std_msgs/String'
});
example.advertise();
setTimeout(function() {
example.unadvertise();
setTimeout(function() {
ros.getTopics(function(topics) {
if (topics.indexOf('/some_topic') >= 0) alert("Believe me I am still alive");
});
}, 100);
}, 100);
Calling unadvertise
didn't kill the topic even though there are no more publishers or subscribers for the topic. I'm assuming this is probably a rosbridge bug.
We discussed in the call today what the strategy going forward is for releases and branches.
We decided on a release strategy in the form of "1", "2", "3" for stable releases, and "2-devel", "3-devel", "4-devel" when working on the next release. This way, it's immediately obvious which version you're using and if it's a release or a devel build.
For branching, we're currently thinking something along the lines of two branches: devel and stable. Devel will be the default branch we work on. When ready to "release", we merge devel into stable, update the revision string, and tag. Devel then updates the revision string to x+1-devel.
In fancy ASCII art:
3 4 5
Stable : 0-------------0----------0
/ /
Devel : 0----0-----0-----0-----0
4-devel 5-devel 6-devel
It wasn't 100% decided on the branching strategy as we had to move on, so if any more input, please leave it here.
Related issue.
If you send multiple goals to an ActionServer, you will receive multiple on("result") callbacks with empty messages. There is no way to know which result corresponds to which goal.
I worked around this by emitting the entire resultMessage on line 108 of roslib.js (rather than emitting only the resultMessage.result, which contains no goal information).
There should probably be a better way to address this. Any ideas?
var initXml = function(xml) {
// Get the robot tag
var robotXml = xml.evaluate('//robot', xml, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
xml.evalutate
expect to use global xml
variable where as "argument" xml
expects local variable. This may cause a problem. It needs verification.
Note that global xml
variable is set in RosLibHeader.js with XPath module to provide the same functionality in nodejs implementation
#73 Related pull request.
It links to broken page.
Having the build folder in version control seems redundant. Plus, somebody's bound to forget building before committing (I know I did...).
Is it necessary to have the build folder so the CDN can work, or can the CI server take care of that?
The vector math functionality in tfclient should be pulled out into a math module.
Linting ../build/roslib.js...ERROR
[L487:C21] 'Image' is not defined.
var image = new Image();
[L491:C20] 'document' is not defined.
var canvas = document.createElement('canvas');
[L1651:C55] 'XPathResult' is not defined.
var robotXml = xml.evaluate('//robot', xml, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
[L1696:C22] 'DOMParser' is not defined.
var parser = new DOMParser();
There are lots of improvements. Thanks all! :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.