Machine Setup to work with Robotics

RoboFoundry
9 min readMar 18, 2021

A toolbox of someone working with robotics related software and hardware would have things like:

  • Raspberry Pi
  • Microbit
  • Arduino
  • ROS — Robot Operating System
  • Virtual Machine Containers
  • Docker
  • Linux Containers
  • Visual Studio Code
  • Many other sensors, actuators and specialized chips like motor controllers or distance sensors and so on.

The question arises as to what is the optimal computer setup that will :

  • Allow you do most of the things you want to do without a lot limitations and
  • Not waste a lot of productive time chasing down rabbit holes that suck the time and energy out
  • and Last but not least, does not cost a lot of money and new equipment to be purchased from scratch.

Hopefully here is where I can share some of the learnings and frustrations that I had to go through while trying different paths. I should state the disclaimer that my experience is based on my familiarity with these tools, some of these I learned as I went along the journey and your experience may be completely different from mine. Here are few of the alternatives that were pursued:

  1. Use an existing laptop or desktop for setup. I used an old MacBook but you can use a Windows machine.
  2. Use a virtual machine inside Macbook
  3. Use Docker inside Macbook
  4. Set up a dual boot on Macbook to boot into full blown Ubuntu desktop machine

Option 1 — Use existing machine (Either your Mac or Windows machine)

This option sounds like a no brainer at the first thought. However, most folks including myself would not want to mess up a perfectly good laptop that is a workhorse for years if something goes wrong. The possibility of something going wrong is fair given you could be installing all kinds of open source software. Especially with Macs, even though my 2009 Macbook is a perfectly good machine, Apple no longer thinks it is worthy of receiving latest updates of OS X. so it could be very challenging in case something goes wrong to restore the machine to its previous state.

Some other issues I ran into while installing it on an old Windows Laptop with Windows 10 on it was the distributions of some of the libraries or python debugger were not available and I ended up spending a ton of time chasing those dependencies and finally decided it was not worth it.

If you are a brave soul, you may want to go forward but this is not an option I would seriously consider.

On the flip side of the argument, OS X is unix variant so theoretically you should be able to do everything you can do on a Linux machine but you may run into certain situations where you machine hardware is so old that you are not able to find correct distributions of libraries or ROS distribution to install. But at least for ROS, you can always compile from source as that option is available. Also, this option will probably be much faster than working in a Virtual Machine as I found that to be slowest and really hurting the productivity and flow of work.

Option 2— Use virtual machine (Either on your Mac or Windows machine)

You can easily install latest version of VirtualBox either on your Windows or Mac machine and get started with installing other software on it. In my test, I started by installing Ubuntu Desktop 20.04 LTS version of Linux on the virtual machine. I spent a few hours installing and updating the Ubuntu and all of the ROS dependencies and got the whole setup up and running. My final litmus test for each of these setup was to be able to run one of the ROS programs — turtlesim, rqt or rviz2.

And btw, I did not install any older version of ROS after learning about the advantages and history of ROS it sounded like a bygone conclusion that I would be using ROS2 distros and stick to latest one which is Foxy FitzRoy. Some of the biggest advantages of ROS2 are that

  • You can run it on linux, mac or windows.
  • ROS2 doesn’t require a master to be running, every node is peer-to-peer
  • Portability

If you are looking for a quick visual comparison — this article is great:

https://www.theconstructsim.com/infographic-ros-1-vs-ros-2-one-better-2/

This option is semi-successful in the sense that everything worked and I was able to run the GUI tools for ROS and turtlesim and all of that. However, the speed of virtual machine and responsiveness of the user interface was a big drag and I quickly realized that I will not be able to be productive this way so I cut my losses and abandoned this path.

It still meets the original criteria I started with, which was having clean separation with host machine, being able to save a lot of money by not purchasing all new equipment and since I chose Ubuntu as operating system within VirtualBox most of the distributions and libraries were readily available so didn’t have to go into too many rabbit holes chasing those dependencies. So if you can live with the sluggishness or have a computer with ton of RAM and throw more resources at VM, you should consider this seriously.

Option 3— Use Docker on Mac (Either on your Mac or Windows machine)

I did this using old 2009 Macbook 8Gb with OS X Yosemite [10.10.5] running on it. I was actually able to get most of the stuff working in couple of days. The main reason for longer time was I had not worked with Docker before and I was learning as I went along. I was overall impressed with the Docker framework and possibilities it brings to provide compartmentalization and repeatability of the processes was pretty awesome. I learned a lot [though not everything yet] while trying to install Docker on it.

Some of the gotchas I ran into right off the bat were:

I realized immediately that Docker website says while downloading the Docker Desktop for Mac that —

Docker Desktop — macOS must be version 10.14 or newer: i.e. Mojave (10.14), Catalina (10.15), or Big Sur (11.0). Mac hardware must be a 2010 or a newer model with an Intel processor.

So this was a big downer at first, until I found out that you CAN install Docker Desktop by following these instructions:

http://docs.docker.oeynet.com/toolbox/toolbox_install_mac/

As you can see right at the top it says:

Legacy desktop solution. Docker Toolbox is for older Mac and Windows systems that do not meet the requirements of Docker for Mac and Docker for Windows. We recommend updating to the newer applications, if possible.

The cool thing about this Docker Toolbox is it comes with everything to run the Docker on older Mac — it include CLI, docker-machine and docker-compose which is mostly all I needed to get it up and running.

After the docker toolbox is installed start a new terminal and run these commands to get docker machine up and running:

docker-machine starteval $(docker-machine env default)docker-machin ip

Not knowing anything about Docker, I started by first testing the hello-world container and proceeded to pull the Ubuntu Desktop Docker Image but after spending a ton of time reinstalling ROS and other tools for umpteenth time I discovered that ROS already provides ready to go Docker images for some of the most recent ROS distros including Foxy Fitzroy. What could be better than this?!

Basically, it became as simple a command as below to download and install the ROS Foxy with desktop version of ROS already on it. And not only that, it also had vnc server installed on it so running the GUI tools would be a no brainer.

Here is the command that made it all so simple [Thanks so much to maintainers of this image]:

docker run -p 6080:80 — shm-size=512m tiryoh/ros2-desktop-vnc:foxy

Now that installation of foxy desktop was so easy, how do I see and run the GUI tools, I was excited and looking forward to run the rviz2 or rqt on the docker image. And just to be clear, before I found this vnc+foxy image, I chased a lot of rabbit holes before I found that and wasted a lot of time trying to get the XQuartz working on the Mac or tried a series of socat and other libraries. I know enough about unix commands but I’m not an expert on low level stuff like configuring printers and displays and other stuff like that. So if you are like me, my recommendation would be to go with vnc+foxy docker image above and save yourself a ton of pain and countless wasted hours.

Coming back to getting the GUI programs running, it was fairly simple — just launch in your browser http://yournetworkIPaddress:6080 and it will connect you to the vnc server and you’ll be able to launch terminal and all GUI tools including rviz2 and rqt.

I struggled a little bit trying to find which one of the many IP addresses I should be using to connect to VNC server but finally realized that it was actually very easy, just run the command to get the IP address of your running docker machine and use that in your URL to connect to VNC Server:

docker-machine ip

There are tons of other docker commands that are handy and you’ll learn those as you run into more advance situations but this will get you up and running quickly and without wasting a lot of time on wrong paths.

The last thing you may want to do [and this optional], to setup Visual Studio Code on the Mac. Its pretty simple, just google for VS Code installer and go ahead and install. After the installation completes, go to extensions tab and install Remote Development extension. This will install a few other extensions which will allow you to directly open folders inside the Docker image and start coding.

This option of running ROS and Ubuntu on docker image meets all the criteria we set in the beginning and some more. It also allows you to experiment and install multiple versions of ROS and other software you may need to experiment with all kinds of robotic experiments.

Option 4— Use Linux Containers on Ubuntu machine

This option was sort of born out of subliminal messages planted in my head by watching all the cool videos from Canonical team. As you may know, Canonical is the company behind Ubuntu and they have a phenomenal IoT blog and robotics falls under the IoT umbrella.

I would be amiss if I didn’t take a minute here and say a few words about what I have seen Canonical folks do in the Robotics. The blogs, the videos and the plethora of information at the Nth level of detail is just mind blowing. I have become a huge fan of all the folks at Canonical while learning about robotics. Some of the brightest stars who

illuminated the path for me are — Sid Faber, Kyle Fazzari and others. You should absolutely watch all the videos that Sid Faber has done and build your first robot running ROS on Raspberry Pi using the Your First Robot series by Kyle Fazzari. I don’t have enough words to express the gratitude for all the passion, quality and details that these guys have put in to spread the knowledge of robotics. This blog is inspired by these guys and consider this a payment forward for anyone who benefits from it.

Coming back to the main topic of using Ubuntu as an option for your machine. My setup can be described in few sentences:

  1. I installed Ubuntu desktop as a dual boot on my same 2009 Macbook by setting aside approximately 120 Gb of disk space for Ubuntu. You can follow the instructions here to get that setup.
  2. After the Ubuntu desktop was installed, I had to do a bit of googling to install the Broadcom Wifi drivers for the Ubuntu to connect to my wifi so it was a bit of detour. I wish Ubuntu was including all these drivers out of box but it was not a big deal.
  3. Once the Ubuntu was up and running and connected to internet, I was able to follow the video tutorial and blog article from Sid Faber to get all the Linux container stuff installed and up and running with ROS Foxy desktop and was able to run the GUI tools.

However, everything was not peachy clean or easy. I ran into two issues that I would like to share with you so you can avoid the time wasted:

  • After getting my LXC container created, I was not able to install ROS Foxy after ssh-ing into it. The main reason was my connection to internet from container was not working. I realized that the container was not getting an IP address and I spent a couple of hours trying to troubleshoot the issue. The fix turned out to be really simple by changing the profile file networking section to following:
eth0:
name: eth0
nictype: bridged
parent: lrbt0
type: nic
  • The second issue was when I launched a GUI program inside the container it would not launch the rviz2 and rqt in the Host machine. I added a new profile per blog article from Ted Kern and other article here. However, it was still not working. The final fix was fairly easy, I had to run following command:
export DISPLAY=:0

This option was really not necessary after the Docker option worked well. However, I really liked the ease with which Sid was able to set things up so quickly and be able to run multiple instances of ROS side by side. It also seems valuable that Ubuntu machine will come in handy when preparing SD Cards and installing things on Raspberry Pi and other IoT devices. Overall, its a great system with Linux Containers and would like to keep it as an option to goto in case things get difficult to work in the Docker system.

--

--