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

Trying to connect between 2 devices using ros [closed]

asked 2021-09-30 15:58:33 -0600

Flash gravatar image

updated 2021-10-04 09:34:24 -0600

HI, I have 2 devices one is the publisher(Device B | 169.254.1.22) is on ros1 and on the subscriber side which is the second device(Device A | 169.254.1.21) I have both ros1 and ros2. I am able to ping A from B and B from A and also able to see the list of topics of Device B on Device A, but unable to echo or run roscore.

RLException: Unable to contact my own server at [http://169.254.1.22:38451/].
This usually means that the network is not configured properly.

A common cause is that the machine cannot connect to itself.  Please check
for errors by running:

    ping 169.254.1.22

For more tips, please see

    http://wiki.ros.org/ROS/NetworkSetup

The traceback for the exception was written to the log file

Below is the exports I tried On Device A terminal

export ROS_MASTER_URI=http://169.254.1.22:11311
export ROS_HOSTNAME=169.254.1.21
export ROS_IP=169.254.1.21

On Device B terminal

export ROS_MASTER_URI=http://169.254.1.21:11311
export ROS_HOSTNAME=169.254.1.22
export ROS_IP=169.254.1.22

And one more thing when I ping I can do it just with IP 169.254.1.22, but for ssh I have to use username@169.254.1.22. Does this have to do something username?

After using ROS_MASTER_URI of Device B on Device A terminal and using ROS_HOSTNAME of Device A on Device A terminal I am getting warning messages as below

WARNING: ROS_MASTER_URI [http://169.254.1.22:11311] host is not set to this machine

I am seeing a list of topics but am unable to echo those topics

Thanks in advance for the help

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Flash
close date 2021-10-07 15:02:50.822269

Comments

I'm not sure (yet) how ROS 2 is involved here. The error message you show is a ROS 1 error, so I've posted a ROS 1 focused answer.

gvdhoorn gravatar image gvdhoorn  ( 2021-10-01 01:13:40 -0600 )edit

Just mentioned ROS2 for debugging purpose because I have to read those ROS1 messages on ROS2 pkg on Device A

Flash gravatar image Flash  ( 2021-10-01 10:32:13 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-01 00:43:35 -0600

gvdhoorn gravatar image

updated 2021-10-01 11:24:02 -0600

I have 2 devices one is the publisher(Device B | 169.254.1.22) is on ros1 and on the subscriber side which is the second device(Device A | 169.254.1.21)

[..]

Below is the exports I tried On Device A terminal

export ROS_MASTER_URI=http://169.254.1.22:11311
export ROS_HOSTNAME=169.254.1.22
export ROS_IP=169.254.1.22

You can't set ROS_IP to the IP of another host. That's doesn't work. ROS_IP and ROS_HOSTNAME describe the host your setting them on (ie: on "Device A" you set them to configure "Device A"s properties). Only ROS_MASTER_URI can point to another host.

And you don't need both ROS_IP and ROS_HOSTNAME. If you have working DNS for all participating hosts (ie: all hosts running ROS nodes can resolve the hostname of all other hosts running ROS nodes), use ROS_HOSTNAME, if you don't, use ROS_IP.


Edit:

Below is the exports I tried On Device A terminal

export ROS_MASTER_URI=http://169.254.1.22:11311
export ROS_HOSTNAME=169.254.1.21
export ROS_IP=169.254.1.21

On Device B terminal

export ROS_MASTER_URI=http://169.254.1.21:11311
export ROS_HOSTNAME=169.254.1.22
export ROS_IP=169.254.1.22

This may have been unclear, but you typically only start a single roscore (it's possible to start more, but that's advanced usage, which I don't believe you need or should try just yet).

Choose which machine will run roscore, then set ROS_MASTER_URI to point to its IP. So if "device A" is going to run roscore, set ROS_MASTER_URI on "device B" to http://169.254.1.21:11311 (ie: point it to "device A"). Now on the other host (ie: the one not running roscore), set ROS_MASTER_URI to point to itself, not to the other host.

And as I wrote earlier: you don't need both ROS_IP and ROS_HOSTNAME. Use ROS_IP (unless you have a working DNS server).

With roscore on "device A", we'd end up with:

  • device A

    export ROS_MASTER_URI=http://169.254.1.21:11311
    export ROS_IP=169.254.1.21
    
  • device B

    export ROS_MASTER_URI=http://169.254.1.21:11311
    export ROS_IP=169.254.1.22
    
edit flag offensive delete link more

Comments

I tried exporting as per your recommendation but when I export ROS_MASTER_URI of Device B on Device A, I am receiving the below warning message

WARNING: ROS_MASTER_URI [http://169.254.1.22:11311] host is not set to this machine

with this warning message, I am seeing a list of topics but unable to echo on those topics.

Flash gravatar image Flash  ( 2021-10-01 10:30:40 -0600 )edit

To get it out of the way: have you gone through wiki/ROS/NetworkSetup and ROS/Tutorials/MultipleMachines?

And please update your original question text with the values of ROS_IP, ROS_HOSTNAME and ROS_MASTER_URI for both "device A" and "device B".

gvdhoorn gravatar image gvdhoorn  ( 2021-10-01 10:37:40 -0600 )edit

Yes, I did check those links and couldn't resolve my issue. I have a doubt with those links when they say to ssh Device. For me to ssh a device I have to use a username and IP, so do I need to include a username while exporting too?

Modifying questions might miss direct below comments. Do you still want me to modify the question?

Flash gravatar image Flash  ( 2021-10-01 10:57:01 -0600 )edit

Modifying questions might miss direct below comments. Do you still want me to modify the question

I don't understand what you're trying to say.

it's perfectly safe to edit an existing question. Just click the edit button/link underneath your current question text. And append your new information. Do not remove anything that's already there.

gvdhoorn gravatar image gvdhoorn  ( 2021-10-01 10:58:16 -0600 )edit

Thanks @gvdhoom this worked thanks again

Flash gravatar image Flash  ( 2021-10-01 12:51:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-09-30 15:58:33 -0600

Seen: 424 times

Last updated: Oct 04 '21