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

rosjava & Gazebo: Problem with sim time?

asked 2012-05-20 01:12:36 -0600

andreasw gravatar image

Hi,

I've ran into a problem trying to connect a rosjava node to gazebo running turtlesim. If /use_sim_time is true, rosjava crashes while trying to instantiate the logger:

Loading node class: de.se.rosjava.Main
May 20, 2012 1:05:38 PM org.ros.internal.node.client.Registrar <init>
INFO: MasterXmlRpcEndpoint URI: http://localhost:11311
May 20, 2012 1:05:38 PM org.ros.internal.node.client.Registrar onPublisherAdded
INFO: Registering publisher: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</TurtleSimJava/Main, http://127.0.0.1:36053/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
May 20, 2012 1:05:39 PM org.ros.internal.node.client.Registrar callMaster
INFO: Response<Success, Registered [/TurtleSimJava/Main] as publisher of [/rosout], [http://ubuntu:45371/]>
May 20, 2012 1:05:39 PM org.ros.internal.node.topic.DefaultPublisher$1 onMasterRegistrationSuccess
INFO: Publisher registered: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</TurtleSimJava/Main, http://127.0.0.1:36053/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
May 20, 2012 1:05:39 PM org.ros.internal.node.client.Registrar onSubscriberAdded
INFO: Registering subscriber: Subscriber<Topic<TopicIdentifier</clock>, TopicDescription<rosgraph_msgs/Clock, a9c97c1d230cfc112e270351a944ee47>>>
May 20, 2012 1:05:39 PM org.ros.internal.node.client.Registrar callMaster
INFO: Response<Success, Subscribed to [/clock], [http://ubuntu:52317/]>
May 20, 2012 1:05:39 PM org.ros.internal.node.topic.DefaultSubscriber$1 onMasterRegistrationSuccess
INFO: Subscriber registered: Subscriber<Topic<TopicIdentifier</clock>, TopicDescription<rosgraph_msgs/Clock, a9c97c1d230cfc112e270351a944ee47>>>
May 20, 2012 1:05:39 PM org.ros.internal.node.RosoutLogger info
INFO: 
>>> Starting...

INFO: Subscriber registered: Subscriber<Topic<TopicIdentifier</clock>, 
TopicDescription<rosgraph_msgs/Clock, a9c97c1d230cfc112e270351a944ee47>>> 
May 20, 2012 12:43:28 PM org.ros.internal.node.RosoutLogger info

Exception in thread "pool-1-thread-9" java.lang.NullPointerException at 
  com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187) at 
  org.ros.time.ClockTopicTimeProvider.getCurrentTime(ClockTopicTimeProvider.java:58) at 
  org.ros.internal.node.DefaultNode.getCurrentTime(DefaultNode.java:377) at 
  org.ros.internal.node.RosoutLogger.publish(RosoutLogger.java:58) at
  org.ros.internal.node.RosoutLogger.info(RosoutLogger.java:134) at 
  de.se.rosjava.Main.onStart(Main.java:28) at 
  org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:511) at 
  org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:508) at 
  org.ros.concurrent.ListenerCollection$1.run(ListenerCollection.java:117) at 
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at 
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at 
  java.lang.Thread.run(Thread.java:679) ^C

If /use_sim_time is set to false, the node stops at ">>> Starting..." and seems to wait indefinitely (at least >= 10 min).

Did I miss something regarding rosjava and simulation / simulated time?

Thanks in advance!

Best regards, Andreas

P.S: The node causing this behaviour is

public class Main extends AbstractNodeMain {  
  Log log;  
  private Publisher<geometry_msgs.Twist> publisher;  

  @Override
  public void onStart(ConnectedNode connectedNode) {
    log = connectedNode.getLog();
    log.info("\n>>> Starting...\n");       

    publisher = connectedNode.newPublisher("cmd_vel", geometry_msgs.Twist._TYPE);        
    publisher.publish(createForwardTwist(1.0));
  }
  //...
}
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2012-05-21 05:59:42 -0600

damonkohler gravatar image

This is bug in the sim_time implementation. See http://code.google.com/p/rosjava/issues/detail?id=115

edit flag offensive delete link more
0

answered 2014-12-16 11:07:42 -0600

stark gravatar image

I am facing with the same issue from the last 2 days. Can anybody please help me if you have fixed the bug? I am not understanding the solution posted by "mate". So if you provide a piece of code to fix that bug, it will be very helpfull

edit flag offensive delete link more
0

answered 2012-06-15 01:10:10 -0600

andreasw gravatar image

Thank you for working on this, Damon!

Unfortunately, I'm still not able to connect rosjava nodes to gazebo

Jun 15, 2012 10:36:11 AM org.ros.internal.node.client.Registrar <init>
INFO: MasterXmlRpcEndpoint URI: http://localhost:11311
Jun 15, 2012 10:36:12 AM org.ros.internal.node.client.Registrar onPublisherAdded
INFO: Registering publisher: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</test/SimConnectNode, http://127.0.0.1:60384/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.client.Registrar callMaster
INFO: Response<Success, Registered [/test/SimConnectNode] as publisher of [/rosout], [http://ubuntu:42778/]>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.topic.DefaultPublisher$1 onMasterRegistrationSuccess
INFO: Publisher registered: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</test/SimConnectNode, http://127.0.0.1:60384/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.client.Registrar onSubscriberAdded
INFO: Registering subscriber: Subscriber<Topic<TopicIdentifier</clock>, TopicDescription<rosgraph_msgs/Clock, a9c97c1d230cfc112e270351a944ee47>>>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.client.Registrar callMaster
INFO: Response<Success, Subscribed to [/clock], [http://ubuntu:43511/]>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.topic.DefaultSubscriber$1 onMasterRegistrationSuccess
INFO: Subscriber registered: Subscriber<Topic<TopicIdentifier</clock>, TopicDescription<rosgraph_msgs/Clock, a9c97c1d230cfc112e270351a944ee47>>>
Jun 15, 2012 10:36:12 AM org.ros.internal.node.RosoutLogger info
INFO: Node test/SimConnectNode has started.
Exception in thread "pool-1-thread-9" java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
    at org.ros.time.ClockTopicTimeProvider.getCurrentTime(ClockTopicTimeProvider.java:58)
    at org.ros.internal.node.DefaultNode.getCurrentTime(DefaultNode.java:377)
    at org.ros.internal.node.RosoutLogger.publish(RosoutLogger.java:58)
    at org.ros.internal.node.RosoutLogger.info(RosoutLogger.java:134)
    at SimConnectNode.onStart(SimConnectNode.java:22)
    at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:511)
    at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:508)
    at org.ros.concurrent.ListenerCollection$1.run(ListenerCollection.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)

The node causing this behavior is

public class SimConnectNode implements org.ros.node.NodeMain, org.ros.message.MessageListener<geometry_msgs.Twist> {

protected Log log;
protected Subscriber<std_msgs.String> subscriber;

public SimConnectNode(URI rosMasterUri) {
    SimpleNodeExecutor.run(rosMasterUri, this);
}

public void onStart(ConnectedNode connectedNode) {
    log = connectedNode.getLog();
    log.info("Node " + this.getDefaultNodeName().toString() + " has started.");
}

public void onShutdown(Node node) { /* TODO Auto-generated method stub */ }  
public void onShutdownComplete(Node node) { /* TODO Auto-generated method stub */ }  
public void onError(Node node, Throwable throwable) { /* TODO Auto-generated method stub */ }

public GraphName getDefaultNodeName() {
    return new GraphName("test/SimConnectNode");
}

public void onNewMessage(Twist twist) {
    System.out.println("i got: " + twist.toString());
}

where SimpleNodeExecutor is as follows:

public class SimpleNodeExecutor {  
    public static void run(URI uri, NodeMain node) {
    NodeConfiguration n = NodeConfiguration.newPrivate(uri);
    DefaultNodeMainExecutor d = (DefaultNodeMainExecutor) DefaultNodeMainExecutor.newDefault();
    d.execute(node, n);
}

}

Could you please point out what I've done wrong or give ... (more)

edit flag offensive delete link more

Comments

This was mistakenly marked as fixed awhile back. The new issue to follow is http://code.google.com/p/rosjava/issues/detail?id=119

damonkohler gravatar image damonkohler  ( 2012-06-22 01:06:44 -0600 )edit

Thank you!

andreasw gravatar image andreasw  ( 2012-06-27 06:16:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-05-20 01:12:36 -0600

Seen: 1,093 times

Last updated: Dec 16 '14