Lab 1.7: ROS in multiple machines

Overview

The goal of this lab is to use one machine to publish the data and use another machine to subscribe the data.

We will use wifibot to publish the Kinect data and then use our laptop to subscribe the data and plot the Kinect depth data in the rviz(a GUI interface that can visualize the data).

Setup the Master Machine

When we want to use ROS nodes, we have to run roscore which can be  seen as master machine. In our case, we want to publish data in master machine (wifibot) and subscribe the data from the master machine, therefore, we have to tell the remote laptop where is the master machine. We can set following command in the bash file that tells the laptop the address of master machine.

Assume your wifibot ip is 192.168.1.32, and we want to make the data transferred at port 11311. So the first step is to set the address and port for the master machine which in this case is our wifibot. Open a terminal and type following command in wifibot (through nomachine remote desktop is a convenient decision):

gedit ~/.bashrc

then put following command in the wifibot’s bashrc file.

export ROS_MASTER_URI=http://192.168.1.32:11311
export ROS_HOSTNAME=192.168.1.32

Now we are going to tell the address of master machine for client machine which in this case is your laptop. Open terminal and put following command in your bashrc as well.

export ROS_MASTER_URI=http://192.168.1.32:11311

Now we all set, we can subscribe the data published from wifibot in your laptop.

Subscribe the Kinect Data from wifibot

First we launch the Kinect node in the wifibot to publish the depth data. Open the terminal in the wifibot and use following command:

roslaunch openni_launch openni.launch

Now use your laptop and see what topic you can get. Open a terminal in your laptop and use following command:

rostopic list

Noted that you do not need to run roscore in your laptop, because you are now using wifibot as master at where runs the roscore.

Then open the rviz by using following command:

rosrun rviz rviz

Then you can see a GUI pop out. We are going to add the display for the data we want to visualize, see following image for instruction. First click add button and then choose the PointCloud2 display.

rvziforKinect1

 

Then we have to assign the topic and choose the frame id for the data, see following image for instruction. First of all, we expand the tag for PointCloud2 at the left window, choose the camera/depth/pointsas the topic for this display. Secondly, we set the Fixed Frame field in Global Optional to camera_depth_frame. Then we can now see the point cloud from Kinect in real time.

rvziforKinect2