-
Notifications
You must be signed in to change notification settings - Fork 75
Unify interface further #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify interface further #32
Conversation
This is awesome! I'm a little concerned about automatically generating all messages on the fly. It takes about 3.5 seconds for me to finish generating all the messages against our stack here (compared with ~150ms to pull in all the pre-generated messages - this is when we're actually loading all those files too which we typically don't). It's not really a large amount of time in the scheme of things, but I think devs here would start to get annoyed if every time they relaunch they have to wait 3.5seconds for ROS to find messages. Could we maybe add an init option to do this instead of making it happen automatically? My other worry is about 64 bit numbers. If we implement a "blurry" serialization/deserialization scheme behind the scenes then people won't really be able to unblur, will they? There is a very large range of numbers over which this won't be a problem but at some point I would expect someone to do a comparison that won't work as expected or to send an ID that gets deserialized into a different number and basically be hosed. I've generally opted to just accept and return 8 byte Buffers because of this - it definitely makes it more annoying in a lot of cases where you're not hitting precision limits but it also makes it possible to support the other cases. I'm not really eager to push some npm "big number" package on people either. I've been torn about the correct choice for this though... |
3.5 seconds? wow, and I thought we had a lot of messages! :-) In that case, yeah, I'll definitely make it optional. I may also try to shave off a bit more time. Another option would be to cache the result, similar to what gennodejs provides, but without the need for a build process. But for now I'll just add the option. Regarding int64s: I share your concern. This is a problematic issue for javascript as such. Either one uses a big number package (or creates ones own), or one needs to take good care never to get into large numbers. I believe this is the choice any javascript developer needs to be aware of and make. With that in mind I could imagine a middle ground solution: We could make it an option for users to My concern with using buffers is that it is quite tedious to use without any additional support. Most people won't want to learn about two's complement and little-endianness just to receive or send messages that use int64 fields (which a message developer may have picked a little too lightly). So yeah, it seems that we agree that there is no silver bullet here. It's a matter of making a good compromise between protecting users from pitfalls they may be unaware off, and providing them with options on the accuracy vs. convenience spectrum. |
We're actually currently on ROS indigo (hoping to move to kinetic soon) but still wanted to transition to I have a script in that branch ( Leaving buffers as-is for int64s is very tedious... I got rid of as many int64s in our stack as I could to not have to deal with them. I think your plan sounds reasonable though. Would you try to |
Very cool! Yes, I was mostly hoping to get by without catkin. I like the idea of using npm package scripts the way you do. I was thinking that the getAll result could be cached to disk no matter whether it was explicitly called or as part of another program. That would mean that all you need is your program. First time it starts, it would fill the cache (generate all messages), but the second time you start it will just read it from disk. I suppose one might need to do a make-like check of file dates to see whether the cache needs updating. I hadn't thought that far. Re. int64 and bignum: oh yes, that's even better. I was thinking we would expect users to provide the package in a specific global variable, but |
21f3068
to
03ff929
Compare
ok, done. |
61b200a
to
bd22b99
Compare
Looks good! Can you just rebase against kinetic-devel? Happy to keep the action client and unification commits separate but the first commit was merged in #31 |
Implemented uint64 and int64 support Now generating all messages and services on the fly on start (if requested) - message.getAll works and is very fast (takes less than a second) - Fixes RethinkRobotics-opensource#14. Corrected implemention for [U]Int64 in on-the-fly approach Using bignum for [u]int64 if available, otherwise usual javascript numbers are used but a warning is printed if numbers are sent or received that are outside of the precise range of JS for integers (>= 1e15).
- Added getActionClient to Rosnodejs (previously the action client wasn't exported in any way) - ActionClient: added "cancel" function
bd22b99
to
1a22dd6
Compare
good catch! Done. |
Further unified the interfaces of on-the-fly and gennodejs.
See the updated example_turtle.js for the updated syntax. Basically, the specification of which messages and services to use is no longer necessary in the on-the-fly approach. We just generate all message and service definitions on start, which only takes about 500ms. After that they can be accessed just like the gennodejs generated ones using
rosnodejs.require
.Fixes #14.
Also implemented uint64 and int64 support.
javascript only uses 53bit precision, so really large numbers get
"blurry". But the way I've implemented this it is stable, i.e., yes
large numbers get blurry, but there is no singularity (which there
could be at the 32bit boundary if one implemented the conversion
from int64 to unit32 naively).