[Discourse.ros.org] [rosjava] Wrapping your native code as a rosjava node

12 views
Skip to first unread message

Juan Antonio Breña Moral

unread,
Mar 4, 2016, 2:59:02 PM3/4/16
to ros-si...@googlegroups.com
jabrena
March 4

Hi,

I would like to test this idea with Java 8 but this tutorial put the focus on Android.
http://wiki.ros.org/android_ndk/Tutorials/WrappingNativeRosjavaNode

Some example to begin?

I would like to use this technique on a raspberry pi 2 with Jade installed to run some ROS node on that host and later use RVIZ remotely from my OSX

Cheers

Juan Antonio


Visit Topic to respond

To stop receiving notifications for this particular topic, click here. To unsubscribe from these emails, change your user preferences

jcerruti

unread,
Mar 5, 2016, 9:24:45 PM3/5/16
to ros-si...@googlegroups.com
jcerruti
March 6

Juan Antonio,

Just curious, why do you need to use Java at all in this case? Why not just run the cross-compiled binary?

Julian

Ernesto Corbellini

unread,
Mar 7, 2016, 2:33:28 PM3/7/16
to ros-si...@googlegroups.com
ecorbellini
March 7

Hi Juan Antonio!
This technique is for using native code from your Rosjava program. It will work in a similar way if you are in Android or not.

First you need to compile your native code using the Java Native Interface specification. To learn how to do this, you can see for example this. You should compile and link your code to generate a shared library targeting the system you are working on.

After that, you need to write a java class extending the NativeRosjavaNode. This class must have defined native methods that match the exported functions in the native library. This way Java will redirect the calls to those methods as calls to the library functions. You load the library passing the a string containing the name of the library to the NativeNodeMain constructor.

I can implement a simple example if you want.

Ernesto

Juan Antonio Breña Moral

unread,
Mar 7, 2016, 4:35:08 PM3/7/16
to ros-si...@googlegroups.com
jabrena
March 7

Good night Ernesto,

Yes, if you can implement a simplest example, I could continue later

If the test goes nice, I would like to create a Gradle library to publish some info from Mindstorms robots: http://ev3dev-lang-java.github.io/#/ to a remote ROS Master to visualize data later with RViz.

Cheers

Juan Antonio

Visit Topic to respond


In Reply To

ecorbellini
March 7
Hi Juan Antonio! This technique is for using native code from your Rosjava program. It will work in a similar way if you are in Android or not. First you need to compile your native code using the Java Native Interface specification. To learn how to do this, you can see for example this. You shoul…

吴栋

unread,
Jan 19, 2017, 4:45:52 AM1/19/17
to ros-si...@googlegroups.com
tony10012
January 19

Hi ecorbellini !
Can you share a simple example to me? As for the JNI, I recommand this;Getting Started with the NDK

Thank you


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

Juan Ignacio Ubeira

unread,
Mar 1, 2017, 8:53:11 AM3/1/17
to ros-si...@googlegroups.com
jubeira
March 1

Hi @tony10012,

The example for Wrapping a native rosjava node has been updated recently with a simple example, wrapping a native publisher as a rosjava node, and showing how to execute it. Please take a look there.
As @ecorbellini points out, the technique works out for Android and for pure rosjava, but if you are not using it on Android, using the cross compiled library would seem a simpler solution to me.

Reply all
Reply to author
Forward
0 new messages