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

turning java DM into ROS node

asked 2015-02-24 08:54:52 -0500

varatyst gravatar image

I am trying to turn a java dialogue manager into a ROS node. I attempt to do so by adding the libraries for ROSjava to the eclipse build path of the DM, and adding the code that is supplied as an example with ROSjava. This however does not by itself call the onStart method. No topics or nodes are found that belong to the DM when running the project through eclipse. Is there a way to launch it without using the rosjava build script or adding it to catkin_ws?

public class DialogueSystem extends AbstractNodeMain {

  public GraphName getDefaultNodeName() {
    return GraphName.of("rosjava/listener");
  }

  @Override
  public void onStart(ConnectedNode connectedNode) {
    final Log log = connectedNode.getLog();
    Subscriber<std_msgs.String> subscriber = connectedNode.newSubscriber("chatter", std_msgs.String._TYPE);
    subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
    @Override
    public void onNewMessage(std_msgs.String message) {
      log.info("I heard: \"" + message.getData() + "\"");
      System.out.println(message.getData());
    }
  });
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-25 09:20:33 -0500

varatyst gravatar image

In case anyone ever has the same problem and finds this thread:

Adding it to the catkin workspace is not necessary. I opted to use a modified version of the rosjava build script (located at project/build/install/project/bin/project). as this seemed the best way to run org.ros.RosRun which has to call onStart. The class the code from the question is in is passed as an argument to RosRun/the build script.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-02-24 08:54:52 -0500

Seen: 414 times

Last updated: Feb 25 '15