ros2dart / dartros1

A ROS1 client library for dart
Apache License 2.0
20 stars 11 forks source link

Unable to find the equivalent of rospy.get_time() #34

Open Tahaan opened 3 years ago

Tahaan commented 3 years ago

Is there a way to query the time?

I'm very new to anything ROS and, for that matter, a total noob on all of this.

I'm trying to send a Twist command form an Android app to a topic like this:

      nodeHandle =
          await dartros.initNode('test_node', <String>[], rosMasterUri: MASTER_URI, anonymize: true);

      final twist = Twist(linear: linear, angular: angular);
      final pub = nodeHandle!.advertise('/turtle1/cmd_vel', Twist(),
            queueSize: 10, throttleMs: 20);
      pub.publish(twist);

Since "nothing appears to happen" I'm trying to debug it and was hoping for a get_time or something that can tell me that it is really connected.

Note that I have found no documentation on what to pass to the args parameter of the initNode... So perhaps that is where the problem lies?

TimWhiting commented 3 years ago

try

final time = Time.now();
Tahaan commented 3 years ago

That would just give the local time on the device.

Or am I missing something?

TimWhiting commented 3 years ago

No that is the Ros subscription to the time. DateTime.now() is the computer / dart local time.

TimWhiting commented 3 years ago

Implementation here: https://github.com/TimWhiting/dartros/blob/master/lib/src/time.dart

Tahaan commented 3 years ago

OK, thank you. It works as far as I can tell. Hard to verify but by changing my local time a couple of seconds, I managed to get it to give me a different result.

Which leaves me still not knowing where my messages gets lost.

TimWhiting commented 3 years ago

Are you on the same network? Are other things working? Is the ROS_MASTER_URI set properly as well as the ROS_IP on the phone. Just a few things you could check. Typically if there are problems with publishing and not subscribing I would check the ROS_IP

Tahaan commented 3 years ago

I'm not on the same network, The Ros server is 1500 Kms away in another city. I have port forwarding over SSH to connect to the Ros system.

My MASTER_URI points to the host:port on my local lan which forwards to the ros system.

When I connect to it via a browser, I get a message which gives an error which tells me that it is working.

Error response
Error code: 501

Message: Unsupported method ('GET').

Error code explanation: HTTPStatus.NOT_IMPLEMENTED - Server does not support this operation.

If I close the SSH tunnel then in stead of the above I get a connection refused

TimWhiting commented 3 years ago

How does the Ros server initiate connections with you then? You would need port forwarding from the server back to your phone.

ROS has servers on both devices and each connects to each other, (i.e. this package spins up a server that talks to the master server at ROS_MASTER_URI) and they have to know each other's IP addresses and be able to initiate connections both ways. That way a process that spins up can create outbound connections and listen to inbound connections to do both publishing and subscribing. If the server is told to connect to the IP address of your device to connect to a certain publisher, it needs to be able to access your phone's IP address. Can you try pinging from the server to your phone. The phone's IP address is likely to change and cause problems that way unless you give it a static IP on a VPN that is accessible to the server.

Tahaan commented 3 years ago

Somehow I missed your response until now. I will set up revese port forwarding - I did not know it was needed.

I will report back once I have been able to test.