0
$\begingroup$

Rosanswers logo

I am creating a publisher and subscriber node in Android. Currently it works very well with the included ROSjava standard messages. However, I would like to create a custom message type. Hoping there is a tutorial or sample project I can study.


Updated to add my solution in case it helps others: I did follow this tutorial http://wiki.ros.org/rosjava_build_tools/Tutorials/indigo/UsingServices per @jubeira post. The most important thing that I found impacted my success was the sourcing of rosjava.

Written in the text below Step 2 is

Remember to source your Rosjava installation workspace first to have the command line tools available (e.g. source ~/rosjava/devel/setup.bash).

What I found was that if rosjava was deb installed I had problems. I am very new to working with ROS and linux so that may be obvious what to do for other folks, but that's what I found that made things work for me.


Originally posted by jbeard on ROS Answers with karma: 13 on 2018-01-11

Post score: 1


Original comments

Comment by jayess on 2018-01-18:
Could you please post your update as a solution instead?

Comment by jbeard on 2018-01-18:
@jayess Do you mean post as an answer below or is there a solution option I am missing? Forgive me, very new to forum.

Comment by jayess on 2018-01-18:
Yes, post as answer. If you come up with a solution for your problem you should post it as an answer. It's ok if there's already other answers.

Comment by Ro on 2019-12-11:
hola @jubeira estoy trabajando con rosjava y necesito pasar mensajes personalizados, llegaste ha hacer ese tutorial?

Comment by jubeira on 2019-12-16:
Hola Ro, probaste los pasos que describi en la respuesta anterior? Generar los mensajes no tiene ningun paso distinto en Java; solo hay que tener genjava disponible en el workspace en el momento de buildear el paquete que contiene los mensajes.

Comment by gvdhoorn on 2019-12-16:
Guys, could you please not post in languages other than English? Thanks.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi @jbeard!

The method I prefer is using Catkin, and placing the messages in a separate package. I will assume you have a workspace with your rosjava/ Android project. Let me explain the steps:

  • Create a new catkin package using catkin_create_pkg in your workspace.

  • Create the custom message in this package as you would do in regular ROS (msg folder, modify the CMakeLists, etc). As you probably know, you would generate the standard Python/ Cpp files corresponding to those messages by building the workspace.

  • To create the java artifacts, source your rosjava installation workspace (if installed from source) and then build your workspace. The Java artifacts will be in devel/share/maven.

  • Modify your build.gradle dependencies to include the newly generated messages. Note that the version specified in the package will be the version of your messages.

Check out this tutorial: http://wiki.ros.org/rosjava_build_tools/Tutorials/indigo/UsingServices. It shows how to create and use custom services in Java, which in the end are actually a particular case for messages.

If you find it useful, I can create a tutorial for this as well when I find some time. Hope it helps!


Originally posted by jubeira with karma: 1054 on 2018-01-12

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by jbeard on 2018-01-12:
@jubeira This is a big help in pushing me along. I ran through the tutorial you linked and it got me much closer. I am going to run through the guide again though cause I believe I missed something. The generated .jar file did not contain my custom message but instead talker and listener classes.

Comment by jbeard on 2018-01-14:
@jubeira I seem to have difficulty going at step 3. I source my rosjava installation and then build my package but I don't get the maven folder.

Comment by jubeira on 2018-01-15:
I will write an example or a tutorial to give you more precise instructions about it, this answer is a bit vague. In the meantime, try checking the tutorial for services. The process of creating custom messages is analogue to that one; try following those steps replacing services for messages.

Comment by jbeard on 2018-01-17:
Thank you for all the help. I have finally got my messages working for the most part (there is an array vs list issue I will make another question for).

Comment by jubeira on 2018-01-19:
I'm glad that it worked! I've been pretty busy lately and I couldn't write a proper tutorial or example yet. In any case, I've always used rosjava from source; it's relatively easy to install and I think it causes less trouble.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.