Ask Your Question
0

how to create a custom message in ROSJava

asked Jan 06

Juan Antonio Breña Moral gravatar image Juan Antonio Breña Moral
207 1 3 16
http://www.juanantonio.in...

updated Jan 07

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

Example:

JointCommand.msg
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();
str.data = "" + seq;

How to create a future complex message: JointCommand

Many thanks in advance.

Juan Antonio

delete close flag offensive retag edit

4 Answers

Sort by » oldest newest most voted
2

answered Jan 06

JeffRousseau gravatar image JeffRousseau
1141 15 21 34
http://jeffrousseau.info/

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.

link delete flag offensive edit
0

answered Jan 06

Juan Antonio Breña Moral gravatar image Juan Antonio Breña Moral
207 1 3 16
http://www.juanantonio.in...

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

link delete flag offensive edit

Comments

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 (Jan 06)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 (Jan 06)edit
0

answered Jan 07

Juan Antonio Breña Moral gravatar image Juan Antonio Breña Moral
207 1 3 16
http://www.juanantonio.in...

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

I wanted to use nxt_msgs: http://www.ros.org/wiki/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

link delete flag offensive edit
0

answered Jan 07

Juan Antonio Breña Moral gravatar image Juan Antonio Breña Moral
207 1 3 16
http://www.juanantonio.in...

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
        uri: https://code.ros.org/svn/ros-pkg/stacks/common_msgs/trunk/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

link delete flag offensive edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Follow

subscribe to rss feed

Stats

Asked: Jan 06

Seen: 236 times

Last updated: Jan 07