ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to create a custom message in ROSJava

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

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

ngrennan gravatar image

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

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
3

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

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
0

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

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

edit flag offensive delete link more
0

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

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

edit flag offensive delete link more
0

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

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

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 gravatar image JeffRousseau  ( 2012-01-06 02:10:47 -0600 )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 -0600 )edit

Question Tools

Stats

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

Seen: 3,057 times

Last updated: Jan 07 '12