A self driving car project. Pt 3.

Stefano C
3 min readFeb 5, 2024

--

Communicating with ROS in a LAN.

Summary

In this story i will show how to put in communication two devices with ROS, the robot car with the Jetson (Ubuntu 18.04 on board) from one side and a laptop (with Windows 10 operating system) from the other one. The Jetson will be the master and will send lidar data through the local network towards to the laptop machine. The latter will be responsible to visualize lidar data through rviz app.

The robot on testing track

If you missed my previous stories..

Motivation

During some first tests with lidar i was looking for a way to visualize data, in this case lidar data, while the robot was allowed to move freely in the house. Even if it is possible to connect to the jetson through wifi connection and share the screen - i am using vnc viewer right now — this solution does not seem much elegant. First because you are wasting power and resources of the Jetson, second, you are wasting wifi-bandwith for a non optimal connection (think about delays and latency in transmission) in order to make screen sharing possible. So, what better time to use ros over wifi and transmit lidar data to another ros device? Let’s discover together!

On both devices

First, both devices must share the same wifi connection, so be sure to note down their respective local IP addresses.

On the Jetson

Let’s begin to find and open the bash file .bashrc (usually located in /home/<user> folder). Scroll until you find something similar to these two lines. Change them according to your local ip address. The local ip address of your first device (master) which is the Jetson.

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

On the Laptop

If you installed Ros on a windows machine, you have probably followed this guide http://wiki.ros.org/Installation/Windows. At point 6, the guide says:

In order to use ROS on Windows, the ROS setup script needs to be called in each command Window. In order to not forget in the future, it is helpful to have a ROS shortcut which does this automatically:

C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat

I created a shortcut as indicated in this guide and placed it in the Desktop folder.

Windows does not have a .bashrc file but we can modify the setup.bat, the one in c:\opt\ros\noetic\x64\ and add on on top of the file this two lines:

export ROS_MASTER_URI=http://192.168.1.73:11311
export ROS_IP=192.168.1.241

As you can see, the two lines here are very similar to the ones for the Jetson, but, look at the address of ROS_IP this time: it is reporting the current local ip address of the laptop. The first line says who is the actual master, the Jetson, of course.

Back on the Nano

Start ros on the Jetson typing roscore in the terminal:

 started roslaunch server http://192.168.1.73:36989/
ros_comm version 1.16.0


SUMMARY
========

PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.16.0

NODES

auto-starting new master
process[master]: started with pid [16047]
ROS_MASTER_URI=http://192.168.1.73:11311/

setting /run_id to 4ba94212-c2c2-11ee-a826-3413e860bef9
process[rosout-1]: started with pid [16064]
started core service [/rosout]

Then, on Windows, click the shortcut you created and wait the ros-enabled prompt will appear (i launched the lidar node on Jetson and then the rviz application in Windows to see lidar data):

See how the two environment variables are automatically set in the prompt. Behind rviz app showing some lidar data.

Conclusions

You saw how it’s easy to make a two devices ros setup. Everything works perfectly! This essentially due to the power of ROS that allows to seamlessly integrate any kind of device.

Like my content ? Please consider to follow me on Medium :)

Happy reading, Stefano.

--

--

Stefano C

Master Degree in Physics, work in audio industry. Passion for C++, python, audio, robotics, electronics and programming. Modena, italy.