Skip to content
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

ROS 1 instead of 2? #1

Closed
antoan opened this issue Jul 11, 2019 · 6 comments
Closed

ROS 1 instead of 2? #1

antoan opened this issue Jul 11, 2019 · 6 comments

Comments

@antoan
Copy link

antoan commented Jul 11, 2019

Hi there, this is a very interesting project.

I was wondering if there is any particular reason why I may not be able to adapt this for use with ROS 1?

Also, how does using Rust benefit the project as opposed to sticking to just C++?

Cheers

@tprk77
Copy link
Owner

tprk77 commented Jul 12, 2019

So I don't really know, but think I've seen a ROS1 Rust client library in passing. If anything, it's probably in a better state than the ROS2 Rust client library, which I'm pretty sure is not getting much maintenance. In my opinion, if you want to do something serious, I would stick to the official ROS client libraries and avoid Rust. (The goal of this project here was to play around with the tech.)

Additionally, I would not recommend using Wasmer just yet. It's still really early on in development, and last time I checked it was missing some really obvious features which made writing this project really painful, almost impossible. If you want to go that route, be prepared to hack on the Wasmer source. Sorry if that's a bit discouraging.

@antoan
Copy link
Author

antoan commented Jul 12, 2019

Sorry if that's a bit discouraging.

I had my doubts, don't worry, I expected it. Thank you for your insight.

@antoan antoan closed this as completed Jul 12, 2019
@syrusakbary
Copy link

Additionally, I would not recommend using Wasmer just yet. It's still really early on in development, and last time I checked it was missing some really obvious features which made writing this project really painful, almost impossible. If you want to go that route, be prepared to hack on the Wasmer source. Sorry if that's a bit discouraging.

Hi @tprk77,

Could be possible to have a bit more info on what features you would like Wasmer to have? I'd love to have the team working on them and providing an awesome developer experience so this project can have a successful integration! :)

@tprk77
Copy link
Owner

tprk77 commented Aug 13, 2019

@syrusakbary I suppose I should write an issue. 😁

The one feature I really, really want is the ability to pass a WASM-side callback to a native-side exported function. I actually started to implement this with a PR (wasmerio/wasmer#245), but I kind of hit a wall on it, and then I never got any feedback on it.

This is really an essential feature for ROS, because on of the main concepts is a subscription, and that needs a callback to handle the incoming messages. So on the WASM-side, I want to write something like this:

fn callback(message: *mut Msg) {
  // Handler code goes here
}

// Later...
let subscriber = create_subscription(node, "topic", callback);

But apparently there's no way to actually call it from the native-side code.

I had to work around it by writing a really ugly shim as an exported function, which calls the callback on the WASM-side:

#[no_mangle]
pub extern fn ros_dispatcher(func: extern fn(*mut Msg), msg: *mut Msg) {
    func(rmsg);
}

And implementing that required even more hacks like stuffing the instance into the user data of the Ctx. Essentially something like this:

// Yikes...
let ros_data: &mut RosData = unsafe { &mut *(ctx.data as *mut RosData) };
let instance: &mut Instance = unsafe { &mut *ros_data.instance };
let args = &[Value::I32(func_ptr as i32), Value::I32(index as i32)];
instance.call("ros_dispatcher", args).unwrap();

Not so great. And like I said this is an essential feature, I really can't build anything without it. The hacks were acceptable for a demo, but I wouldn't want to use them for anything serious.

Anyway, I'd be happy to pick up the PR again if I could get some more direction there.

@tprk77
Copy link
Owner

tprk77 commented Aug 13, 2019

Sorry, I linked the wrong PR originally, I meant this one: wasmerio/wasmer#245

@tprk77
Copy link
Owner

tprk77 commented Aug 13, 2019

BTW, I just created this: wasmerio/wasmer#670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants