ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

writing nodes and defining custom messages/services in rosjava

asked 2012-07-27 05:51:16 -0600

DocSmiley gravatar image

I'm trying to follow the rosjava tutorials for creating my own node. This node needs to be both a publisher and a server.

I'm finding the rather brief notes on rosjava messages lacking the level of detail I need, being rather new to ROS and rosjava in particular. I have built .mgs and .srv files for other nodes using rospy, but the structure of rosjava seems sufficiently different that I'm unsure what to do.

I need to define two messages one is an arrays of ints, the other an array of floats

I also need to define services that are an array of int/floats pairs (or a single int/float pair), neither service returns anything.

I'm also unsure as to where to place my .java and externally linked library .jar files to have this node run correctly.

Any help would be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-07-27 08:43:04 -0600

joq gravatar image

updated 2012-07-27 08:44:40 -0600

I am not a java programmer, but I believe you need to create custom messages in a separate package, using the normal ROS message definition and generation tools.

edit flag offensive delete link more


The generation tools are not necessary for Java. Rebuilding the rosjava_messages package will generate all available ROS messages. This process is described in the documentation, albeit briefly.

damonkohler gravatar image damonkohler  ( 2012-08-01 16:51:27 -0600 )edit

I also found that if developing in eclipse, that I had to re-reference my rosjava_messages-0.0.0-SNAPSHOT.jar into my build path. If copied it into my libs folder, it would conflict with the ginerbread_mr2 jar of the same name. Must have same in both projects or import as external JAR to build path.

PeterMilani gravatar image PeterMilani  ( 2012-11-28 12:23:14 -0600 )edit

@damonkohler I tried doing what you suggested and I tried the instructions here: but unfortunately it still doesn't work for me. When I try to depend on the messages in my build.gradle I get the an error:

Robocop87 gravatar image Robocop87  ( 2015-02-21 00:25:26 -0600 )edit

Could not resolve all dependencies for configuration ':project:compile'.

Could not find any version that matches org.ros.rosjava_messages:hsmrs_framework:0.1.+. Required by: org.ros.rosjava_core:project:0.1.0

Robocop87 gravatar image Robocop87  ( 2015-02-21 00:25:39 -0600 )edit

I solved the problem from my comment, I didn't have the full group ID. It was org.ros.rosjava_messages.rosjava_pkg:msg_pkg:0.0.+

Robocop87 gravatar image Robocop87  ( 2015-02-21 00:52:07 -0600 )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-07-27 05:51:16 -0600

Seen: 1,880 times

Last updated: Jul 27 '12