Easy Development Setup for Robotics using ROS2 and Raspberry Pi

RoboFoundry
3 min readMay 15, 2021

--

When I started learning ROS2 development on Raspberry Pi, I spent weeks trying to figure out the best setup to work with. Details of that described here. Three different paths followed were:

  1. Install ROS2 locally on Mac or Windows or Ubuntu Linux machine. There are several variants on this as well. You can partition your existing mac or windows PC with Linux in a multi-boot fashion as well.
  2. Use Docker or Linux Containers for development on any machine. Here you are essentially working with a virtual machine.
  3. Directly work with Raspberry Pi and setup a toolset to work with from your existing machine
  4. Using VS Code ROS Extension [I found out about this very recently]. Check out this excellent video that walks you through step-by-step. This will work with both unix flavors and windows.

I tried all of the above and ultimately felt very comfortable with approach #3. This is not saying other approaches are sub-optimal or anything like that. This is just the way it worked better for what I’m working on and with ability to work directly with hardware and experiment and prototype quickly.

My basic setup is as follows:

  • Raspberry Pi 4 with Ubuntu server 20.04 installed and ROS2 Foxy on top of that. These steps are very well documented on Ubuntu and ROS2 websites.
  • SSH connection setup between my Macbook and RPi4 [assuming you are on same wifi network and you have established the internet connection from RPi successfully] for downloading packages and updates.
  • A Samba folder share configured on the RPi4. The instructions for this are described later in this article.
  • Visual Studio Code installed on Macbook — If you are running on older version of Mac OS, make sure to download older versions of Visual Studio Code. You can find older versions of VS Code here -https://code.visualstudio.com/updates/v1_33. For Yosemite, late 2019 version should work. I did have an instance where I installed an update automatically which rendered the Visual Studio not usable on the Yosemite. So make sure you set the Visual Studio updates to manual by searching in the settings if you want to avoid rendering your VS Code unusable.

That’s it. It is the most simple setup and it allows you do a ton of stuff very quickly.

Some tips on making the setup work based on my experience:

  • Once you have done the installation of Ubuntu and ROS2, backup your SD Card image [there are many instructions on web on how to do it]. You can then clone and burn the SD Card image as many times as you need and you will have a ROS installation up and running in no time for any additional RPis you may setup in future.
  • There is one configuration I found for SSH on RPi side that was helpful. I noticed while working with SSH that a lot of times, the SSH terminal became unresponsive and I had to either restart the terminal or reboot the whole RPi. Following line at the end of ssh config file helped a lot:
on RPi find the file - /etc/ssh/sshd_config and add the following line at the end of the file:IPQoS cs0 cs0and reboot your RPi.

After you have followed all the steps, the last section on your samba config file at /etc/samba/smb.conf should look something like this:

[NAME_OF_YOUR_FILESHARE]comment = Samba on Ubuntupath = /home/YOUR_USERNAME/devread only = nobrowsable = yes

The last step would be to establish the connection between your main machine and RPi Samba share via file explorer app of your choice depending on your operating system.

Once you have connected to file share successfully, simply open Visual Studio Code and open the folder you would like to work on. At this point you have all the features of Visual Studio Code available to you in any language you are programming for ROS2. I typically open the top level workspace folder in Visual Studio for my ROS2 project and start working with files. You can even work with a github repository from your Visual Studio and make sure your work is saved and versioned.

VS Code also has built in terminal if you want to SSH into RPi from there but for me stand alone terminal on operating system worked better as I needed to launch a whole series of terminal windows while testing various ROS2 nodes.

Hope this saves you some pain and time!!

--

--