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

RobotOS.jl doesn't work with PackageCompiler.jl #92

Open
rcnlee opened this issue Mar 3, 2021 · 2 comments
Open

RobotOS.jl doesn't work with PackageCompiler.jl #92

rcnlee opened this issue Mar 3, 2021 · 2 comments

Comments

@rcnlee
Copy link

rcnlee commented Mar 3, 2021

I would like to speed up RobotOS startup time by compiling using PackageCompiler. I am able to create a sysimage by passing in :RobotOS as a package to be compiled. However, when I try to run a ROS node, the node and subscribers get started, but no messages come in. Exactly the same code runs fine without package compilation.

I've traced it down to ros_callbacks.py in the storemsg function. It's getting stuck at self._cb_notify(self._notify_handle) and doesn't return. As a result, the callbacks don't get triggered. Any ideas?

Any help would be greatly appreciated, thanks!

@jdlangs
Copy link
Owner

jdlangs commented Mar 3, 2021

Unfortunately I don't have any suggestions for what to fix. The root cause probably has some connection to the Julia function that Python is trying to call being compiled in the module init, which must be a problem for the package compiler.

CB_NOTIFY_PTR[] = @cfunction(_callback_notify, Cint, (Ptr{Cvoid},))

If you dig into this further, let me know if I can help explain anything if it's not clear what the current code is doing.

@rcnlee
Copy link
Author

rcnlee commented Mar 3, 2021

I was eventually able to find a fix. It seems CB_NOTIFY_PTR[] becomes invalid after creating the sysimage. The pointer points to some location, but it cannot be used. The workaround that I found is to regenerate it by calling:

RobotOS.CB_NOTIFY_PTR[] = @cfunction(RobotOS._callback_notify, Cint, (Ptr{Cvoid},))

I do see that is already being done in __init__(), but I don't understand why that line doesn't work under sysimage precompilation. It doesn't work even if I explicitly call __init__() on startup. Separating that line out and calling it externally seems to work.

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

2 participants