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

ros on multiple machine not working properly

asked 2020-04-11 01:48:18 -0500

dinesh gravatar image

updated 2020-04-11 04:00:39 -0500

I have ran the ros_master in raspberry pi 4b. i have ran a hardware interface noe on pi than sent the trajectory from my laptop. But this pc is not sending this trajectory to the pi and stucks after this msg:

ROS_MASTER_URI=http://raspberrypi.local:11311

process[rrbot/test_trajectory-1]: started with pid [13184]
[ INFO] [1586587165.238469617]: Starting TestTrajectory...
[ INFO] [1586587165.362308551]: Connecting to action /rrbot/position_trajectory_controller/follow_joint_trajectory/
[ INFO] [1586587165.508456989]: Waiting for action server to start.

I have set the ros_master_uri in both machine by using cmd:

export ROS_MASTER_URI=http://raspberrypi.local:11311

Here when i run the hardware interface node and send the trajectory in same machine eg. laptop than it works fine and i can also view the topic using cmd:

rostopic echo /rrbot/position_trajectory_controller/follow_joint_trajectory/goal

I am following this tutorial to run the ros nodes on different machine. Here also the nodes i.e talker and listern is working properly. but i can only echo the /chatter topic inside the machine from which i run the talker node eg. laptop. when i try to view the same topic inside the master machine i.e pi 4B it don't shows this topic. Why is this happeneing?

IN the trajectory control eg. i am using [this](https://github.com/PickNikRobotics/ros_control_boilerplate/tree/melodic-devel/rrbot_control) repository to check if the hardware interface part runs on pi and the main command can be sent from pc.

What i did overall is: 1. On both pi and laptop : export ROS_MASTER_URI=http://raspberrypi.local:11311 2. On Pi : roslaunch ros_control_boilerplate rrbot_hardware.launch 3. On laptop: roslaunch ros_control_boilerplate rrbot_test_trajectory.launch and the above msg comes and it stucs their. i am using pi 4B with buster iamge with ros melodic. and laptop with unbutu and melodic.

I also tried this tutorial to check if their is any network problem. And when i try the netcat part. it shows no sucess msg. It looks like their is no part to how to resolve this in that tutorial. so how should i resolve this network problem if their is no success msg while testing netcat on specific port?

I am connecting with pi from laptop with ssh and pi is wireless access point as described here.

edit retag flag offensive close merge delete

Comments

Why is this happeneing?

Because as @tianb03 hints at: DNS isn't working properly for all involved hosts.

Being able to rostopic echo (or similar) in only one direction is a classical symptom of this.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-11 03:30:18 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-04-11 03:23:55 -0500

updated 2020-04-12 02:47:07 -0500

Short answer: set ROS_MASTER_URI and ROS_IP on both of your Raspberry Pi and PC using IP address rather than hostname. It should work just fine.

Long answer: We only discuss connection in local area network. First we'd better fully understand the communication steps. In brief

  • roscore is started.
  • Publisher is started. Looking for master based on ROS_MASTER_URI. If the publisher and master are on the same PC, you could use localhost, 127.0.0.1, IP, hostname.
  • Publisher need to register its IP on master, based on ROS_IP. if ROS_IP is not explicitly set, it should be hostname. This is very important, because most of the time this part is the cause of improper multi-machine connection.
  • Subscriber is started. Looking for master and master give back the publisher's IP.
  • Subscriber connect to publisher.

So, if all nodes are running on the same PC, there won't be any problem.

If you only setup the ROS_MASTER_URI correctly, you can check the rostopic list on your client PC, because all the topic names are already registered on ROS Master.

Therefore, whether you can rostopic echo or not on your client PC, is determined by the ROS_IP registered on master by the publisher.

Now we only focus on the ROS_IP setup on the publisher's PC, mostly the master PC (to be more clear, publisher's PC is where the publisher runs). This is quite tricky. The pros and cons of IP address is that you can definitely connect using IP, but it may change. Hostname is more user friendly, but your router still need to parse hostname to IP address, and sometimes it doesn't work (The router DNS server just does not work perfectly and I really don't know how to solve this). If you are under a quite stable network and you know that your router can always parse hostname, only setup the ROS_MASTER_URI on both PCs will do.

So setup ROS_IP using IP address rather than hostname, most of the time will solve the communication problem.

Last but not least, understand how to setup the ROS_MASTER_URI and ROS_IP. ROS_MASTER_URI is only to provide the address of master, you can always set it on your master PC to http://localhost:11311. But you MUST setup the ROS_IP using a LAN IP, i.e. 192.168.1.xxx, so a remote subscriber can find the publisher well.

Pay more attention to the ROS_IP on master PC, users often forget to setup the ROS_IP because they take for grant that the subscriber can connect to the publisher on master PC, as it can connect to the master. In fact, ROS_MASTER_URI on subscriber machine guarantee that it can connect to master, and ROS_IP on publisher machine guarantee subcriber can connect to publisher.


However, this seems does not explain your case when you set all ROS_MASTER_URI and ROS_IP to Pi but your PC's publisher works well. Better check again and give me some feedback..


I think this problem is not ... (more)

edit flag offensive delete link more

Comments

I tried setting both setting export ROS_IP=192.168.4.1 and export ROS_MASTER_URI=http://192.168.4.1:11311. But it is still not working when viewing image and other tranjecotry/ros controller topics. But as i saw it works find for rospy_tutorial talker and listner, i.e i can echo the /chatter topic being published in laoptop in both pi and laptop. when roscore is running in pi.

dinesh gravatar image dinesh  ( 2020-04-11 03:57:43 -0500 )edit

you should set ROS_IP on your PC according to your PC's IP address. Have a try and see if still got any problem.

tianb03 gravatar image tianb03  ( 2020-04-11 04:37:36 -0500 )edit

so ROS_IP on PC acc to pc's ip. and in Pi which ROS_IP? and also is ROS_MASTER_URI same on both? O... ok thanks. after i changed the ROS_IP acc to their own ip address it is working. thanks.

dinesh gravatar image dinesh  ( 2020-04-11 05:11:24 -0500 )edit
0

answered 2022-04-08 14:20:54 -0500

For ROS1, by example:-

Machine1 [MASTER]:

  • Will run [roscore], but don't run it yet till configurations are done.

  • Has an IP of 192.168.1.10

1- Run the following in the terminal:

1.1- export ROS_MASTER_URI=http://192.168.1.10:11311

1.2- export ROS_IP=192.168.1.10

2- Now, run roscore


Machine2 {SLAVE}

  • Will NOT run roscore.
  • Has and IP 192.168.1.15

1- Run the following in the terminal:

1.1- export ROS_MASTER_URI=http://192.168.1.10:11311

1.2- export ROS_IP=192.168.1.15

2- Now, you are connected to the Master.


For completion, ROS2 will populate the information on the LAN out of the box without any configuration.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-04-11 01:48:18 -0500

Seen: 1,988 times

Last updated: Apr 12 '20