Ask Your Question

how to create a custom message in ROSJava

asked 2012-01-05 23:38:32 -0500

updated 2014-01-28 17:11:05 -0500

ngrennan gravatar image

I would like to create my own messages using rosjava but I don't know how to create it.


string name
float64 effort

Later, how to set and get data from that message?

Currently, I know how to create simple messages and get data:

org.ros.message.std_msgs.String str = new org.ros.message.std_msgs.String(); = "" + seq;

How to create a future complex message: JointCommand

Many thanks in advance.

Juan Antonio

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted

answered 2012-01-06 01:16:32 -0500

Currently rosjava requires all .msg/.srv files to be defined externally and included as dependencies in the manifest file. I believe this was done to promote separation of msg packages and the packages that use them. Any packages included in the manifest will prompt java JAR generation for those foreign message types.

edit flag offensive delete link more

answered 2012-01-07 01:00:23 -0500

Jeff, I solved the doubt about how to use sensor_msgs in my projects with rosjava.

roslocate info sensor_msgs
- svn:
        local-name: sensor_msgs

I donwloaded the project in my rosjava workspace and I did a rosmake. Later eclipse recognized messages from the package sensor_msgs.

Many thanks.

Juan Antonio

edit flag offensive delete link more

answered 2012-01-06 23:38:02 -0500

Hi Jeff, I solved my doubt in the following way.

I wanted to use nxt_msgs:

so I copied that project, I compiled with rosmake and later, I added in manifest.xml from my last project the following line:

<depend package="nxt_msgs" />

I compiled with rosmake the project and later, I could add in my Java classes that messages.

Many thanks.

Juan Antonio

edit flag offensive delete link more

answered 2012-01-06 02:01:21 -0500

Do you have an example to undertand your idea?

I know how to use manifest to add external libraries but how to create a package with custom messages and later create that .jar?

Currently, I have a manifest with the following dependencies:

<depend package="rosjava" />
<depend package="std_msgs" />

If I add another dependencie:

<depend package="custom_msgs" />

How to store that folder and how to create that jar?

Does exist another way? For example creating a package in src folder or outside in the same folder with the messages?

Many thanks in advance.

Juan Antonio

edit flag offensive delete link more


Once you add those dependencies to your manifest and run rosmake/make, it'll automatically generate the necessary jars and add them to the .classpath file used in the eclipse .project. Hope that clears things up
JeffRousseau gravatar image JeffRousseau  ( 2012-01-06 02:10:47 -0500 )edit
Also, I'm not sure if it was clear but for your custom_msgs package it's just a standard roscreate-pkg'd package like in the beginner tutorials
JeffRousseau gravatar image JeffRousseau  ( 2012-01-06 02:12:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-01-05 23:38:32 -0500

Seen: 2,926 times

Last updated: Jan 07 '12