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

How to use messages included in sensor_msgs with ROSJava?

asked 2012-01-08 08:02:15 -0600

I have downloaded the project sensor_msgs from the repository:

roslocate info sensor_msgs
- svn:
        local-name: sensor_msgs

Before downloading this project in my worskspace, when rosmake detect the dependency:

<depend package="sensor_msgs" />

Shell printed the following message:

[rosmake-1] Starting >>> sensor_msgs [ make ]                                   
[rosmake-1] Finished <<< sensor_msgs ROS_NOBUILD in package sensor_msgs

But later, when I download the project, I received the following message when I execute rosmake in my package:

[rosmake-0] Starting >>> sensor_msgs [ make ]                                   
[rosmake-0] Finished <<< sensor_msgs  No Makefile in package sensor_msgs

When I use messages from that package:

            Publisher<org.ros.message.sensor_msgs.JointState> motor =
                node.newPublisher("motor1", "sensor_msgs.JointState");

I receive the following exception when I execute the node:

Jan 8, 2012 10:59:22 PM org.ros.internal.node.RosoutLogger fatal
SEVERE: org.ros.exception.RosRuntimeException: org.ros.exception.RosRuntimeException: java.lang.IllegalArgumentException

But if I use messages from std_msgs, I don't have any problem:

            Publisher<org.ros.message.std_msgs.String> publisher2 =
                node.newPublisher("motor1", "std_msgs/String");

How to use messages from sensor_msgs?

I noticed that the package sensor_msgs doesn't have any makefile to execute rosmake.

Many thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2012-01-08 08:27:59 -0600

ahendrix gravatar image

You shouldn't have to explicitly install the sensor_msgs package; it should be part of your default ROS install, in the common_msgs stack. You're seeing errors because you have that package installed twice; I recommend you remove the copy that you manually installed.

You can confirm that you still have a valid install by running roscd sensor_msgs and observing that it finds the sensor_msgs package.

When passing the type string to newPublisher, they type is specified with a slash, as sensor_msgs/JointState, not sensor_msgs.JointState

edit flag offensive delete link more

answered 2012-01-08 11:04:51 -0600

Many thanks for your comments, yes, I had to check my code. Now the code is correct:

            Publisher<org.ros.message.sensor_msgs.JointState> motor =
                node.newPublisher("motor1", "sensor_msgs/JointState");

I checked where is located sensor_msgs:

roscd sensor_msgs

I solved the problem.

Many thanks.

edit flag offensive delete link more

Question Tools


Asked: 2012-01-08 08:02:15 -0600

Seen: 950 times

Last updated: Jan 08 '12