Rahul Bohare
Rahul Bohare

Reputation: 831

Messages not received on master when the talker runs from startup

I am working with ROS. I have a detection node acting as a talker (det_talker.py) on one Ubuntu 16.04 machine and another node acting as a listener (det_listener.py). I intend to run the listener on master (an Ubuntu 14.04 machine) to receive the messages being sent from the talker. When I run the talker from a terminal followed by the listener on the master, I can see the messages being received on the master.

However, when I run the same talker node by putting the necessary commands for sourcing the setup.bash file as well as configuring the IP for the master in a bash script and run this script from startup (by adding the script in Startup Applications), I cannot see any messages on the master.

Configuration on the machine with the talker node:

Configuration on the machine which acts as master:

I have tried changing the ROS_IP on master to ubuntu16_ip but the result is still the same. The script I am using to run the detection node from system startup looks like follows:

#!/bin/bash
cd /home/rahul
export ROS_MASTER_URI = http://ubuntu14_ip:11311
source ./catkin_ws/devel/setup.bash
cd catkin_ws
rosrun detection_node det_talker.py

I have tried running this bash script from a terminal; it runs successfully and I can see the messages on master when I run the det_listener.py node. Only when I run it from startup, there are no messages (the node does run, however).

Furthermore, I can see on the master that the node is running because it shows the node when I run rosnode list and rostopic list commands. I should also mention that Ubuntu 16 has Kinetic and Ubuntu 14 is running an Indigo version of ROS. The reason why I think different versions should not pose a problem because I can indeed get the messages when executing the node from terminal.

My question is how do I get the messages to be received on the master by running the talker from startup. Thanks.

Note: This is a cross post of the same question I asked on ROS Answers, here. I am posting it on SO as I did not get any response over there yet.

Upvotes: 1

Views: 772

Answers (2)

Rahul Bohare
Rahul Bohare

Reputation: 831

From the help of Benyamin Jafari's comment on my question, I managed to find the solution:

I added the IP and name of the master (ubuntu14) in /etc/hosts file on the node machine (ubuntu16) and vice versa. When I restarted both machines and ran the node again from startup, I can receive the messages on the master.

A side note: If someone (like me) is trying to do a similar task with running multiple nodes and getting all of the nodes' messages on the master, make sure to add the IPs and names of all the nodes in /etc/hosts of the master AND that all the nodes have distinct names since it is not possible for the master to resolve between nodes having same names.

Upvotes: 0

maetulj
maetulj

Reputation: 1042

The problem is because your terminal is not in the same shell (session) as is used for startup and therefore the variables are not set for you. You should write those values to the ~/.bashrc of the user you use.

Upvotes: 0

Related Questions