Two-way communication between master-slave not working

asked 2021-10-11 11:11:37 -0500

Hari_prasanth gravatar image

updated 2021-10-12 06:41:33 -0500

Hello! I am trying to establish a ros master(my laptop)-slave(robot) communication over a wifi network, and I am facing a particular problem. I can publish from my laptop and receive messages in my robot but cannot do the opposite. For example, if I run rostopic pub -r 10 /test std_msgs/Int64 1 on my laptop's terminal and rostopic echo /test on robot's terminal, I am getting output but can't do vice-versa.

My roscore runs on my laptop and the config of my .bashrc are as follows,

Laptop's .bashrc:

export ROS_MASTER_URI=http://LaptopIP::11311
export ROS_IP=LaptopIP

Robot's .bashrc:

export ROS_MASTER_URI=http://LaptopIP::11311
export ROS_IP=RobotIP

where, LaptopIP and RobotIP IP addresses of my laptop and the robot respectively.

roswtf output:

Loaded plugin tf.tfwtf
No package or stack in the current directory
================================================================================
Static checks summary:

No errors or warnings
================================================================================
Beginning tests of your ROS graph. These may take a while...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules

Online checks summary:

Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault

WARNING The following node subscriptions are unconnected:
 * /rosout:
   * /rosout

My laptop is running ros-melodic and Ubuntu 18.04 and my robot is running ros-kinetic and Ubuntu 16.04. Is this problem happening because of inter-distro communication? I tried doing the same with two laptops with ros-melodic on the same network and it works fine. Thanks in advance!

EDIT: roswtf output

edit retag flag offensive close merge delete

Comments

Run roswtf and report the output, please.

Geoff gravatar image Geoff  ( 2021-10-11 17:56:23 -0500 )edit

@Geoff I have added roswtf output but it looks ok to me. Still can't figure out what the problem is

Hari_prasanth gravatar image Hari_prasanth  ( 2021-10-12 01:17:00 -0500 )edit

export ROS_MASTER_URI=http://LaptopIP::11311 ROS_IP=LaptopIP

I think you have missed a export prefix before ROS_IP? or is it a typing error over here?

siddharthcb gravatar image siddharthcb  ( 2021-10-12 04:00:52 -0500 )edit

Try adding this too and see if it works..

export ROS_HOSTNAME=<laptop ip> in laptop
export ROS_HOSTNAME=<robot ip> in robot
siddharthcb gravatar image siddharthcb  ( 2021-10-12 04:05:07 -0500 )edit

@siddharthcb sry! that was a typing error in the post. I have export in my actual bashrc. Also I tried adding ROS_HOSTNAME as well, doesn't seem to work.

Hari_prasanth gravatar image Hari_prasanth  ( 2021-10-12 06:41:17 -0500 )edit

it is expected to work in inter-distro environment also because I use noetic on master and melodic on bot. I am sure it is something related to your ip address or setup file path in your bashrc. have you also sourced your setup.bash?

siddharthcb gravatar image siddharthcb  ( 2021-10-12 06:46:12 -0500 )edit

Common Troubleshooting:

Does ping work? A ping command is a call-and-response between two machines. To identify a computer's IP address, run ifconfig and look for something like inet addr: 192.168.0.5. The robot IPs are also printed on their laptops. Below, we'll call the two important IPs 192.168.your.ip and 192.168.bot.ip.

On your computer, run ping 192.168.bot.ip On the robot, run ping 192.168.your.ip Results:

One or both pings received no response. The two computers cannot see each other. Make sure that both computers are connected to the same WiFi network; you can try disconnecting each computer from wifi and reconnecting it to make sure. They should be connected to the local router, not to WPI-Wireless or eduroam. If you are running in a Virtual Machine, your VM may be causing the issue; the solution depends ...(more)

osilva gravatar image osilva  ( 2021-10-12 11:54:29 -0500 )edit

Both pings succeeded, but the times were 200ms or more. This can be caused by excess ROS traffic clogging the network. After making sure you're not the one causing it (kill all ROS processes as described above), you can try turning the router off for 15 seconds, then turning it on. Keep in mind that this will kick the other two turtlebots off the router as well, so make sure you're not interrupting someone else's tests before doing this. Both pings succeeded with low ping times. Looks like the network is fine.

Are ROS variables set properly? There are two critical environment variables that tell ROS where the different machines are.

Steps:

Run echo $ROS_MASTER_URI on both your computer and the robot. The output should be http://192.168.bot.ip:11311/ on BOTH machines. Run echo $ROS_HOSTNAME on both your computer and the robot. The output ...(more)

osilva gravatar image osilva  ( 2021-10-12 11:55:54 -0500 )edit