1: Setup A ROS 2 JavaScript Robot Coding Environment

ROS2JsGuy
4 min readJun 5, 2020

--

Photo by Adi Goldstein on Unsplash

While coding robots can be fun, setting up a robot coding environment can sort of be a pain. In this article we layout the software bits you’ll need. As a convenience to get started quickly, I’m making available a virtual machine that I created with all the software installed and ready to run.

edited 20200618 updated instructions to use ROS2 Foxy Fitzroy version.

Let’s take a look at the software you’ll need for some of the tutorials and projects.

  • Nodejs (ver. 12) — Nodejs version 12 provides the JavaScript runtime you will need to run code we develop. Don’t be tempted to use the latest greatest version of Nodejs as it is incompatible with some of the JavaScript modules we will be using.
  • NVM (Node Version Manager) — NVM is optional. I recommend using NVM as a much better alternative to installing Nodejs directly. With NVM you can install multiple versions of Nodejs and easily switch between those versions. NVM is super convenient and I install it on all my systems.
  • ROS 2 (Foxy Fitzroy release) — Foxy Fitzroy, released in June ’20, is the first long term supported version of ROS 2. This release is available across all platforms (Linux, Mac and Window). Additionally ROS 2 docker images available. See the installation options at the link above.
    Note: If you are installing on Linux be sure to verify that your Linux distro and version support ROS 2. I wasted a lot of time early on trying to install and run ROS 2 on an unsupported Linux distro.
  • git — an optional tool. Git is a CLI client for managing source code. Our primary use of git will be to download projects from github. Alternatively you can avoid using git and download github hosted projects in zip format directly through your browser.
  • VS Code or you fav IDE/editor — Your favorite JavaScript or TypeScript coding environment, e.g., VS Code, Eclipse + CodeMix, VIM…

Follow the links for each software product for download and installation instructions.

Personal Notes

While ROS 2 runs on Linux, Mac and Windows your mileage may vary for getting ROS 2 running on platforms other than Linux.

After burning a few hours unsuccessfully trying to get ROS 2 setup across my main dev platforms, Mac and Windows, I punted and went with installing it on the recommended Linux. I don’t have a dedicated Linux machine so I resorted to using a free Virtual Box VM. There after the installation was a breeze and worked as documented.

ROS 2 JS Developer Environment — Linux Virtual Machine

If you want to get started with minimal hassle, the quickest path to coding robots is to download and run my Ros2JSDev Linux Virtual Machine (VM). This VM contains the software listed above with the exception that it installs the newest ROS 2 release name Eloquent Elusor, and runs on Mac, Windows and Linux machines using the free VirtualBox engine.

Here’s what you need to use the VM:

VirtualBox — VirtualBox is a general-purpose virtualizer for x86. We will use VirtualBox to import our VM and run it.

Ros2JsDev Virtual Machine — Linux 20.04 (Focal distro) with ROS 2, Nodejs, NVM and VS Code preinstalled. The VM is configured to use 4 Gb RAM and a dynamic 20 Gb file system. I have hosted the VM on my Google Drive for download.

Steps for Downloading and Installing Linux-ROS 2 Virtual Machine

  1. DOWNLOAD ros2jsdev VM HERE
    The VM download size is approximately 4 Gb.
  2. Once downloaded, use the VirtualBox File>Import Appliance… to load the ros2jsdev-foxyfitzroy.ova file. This process took 2–3 minutes on my Macbook Pro.
  3. After the import process completes, the ros2jsdev VM will be presented in the VirtualBox UI. To launch it, select the VM followed by the Start action. The account details are:

user id: ros2jsguy
password: ros2

You are encouraged to change the password asap.

Verify your ROS 2 configuration

At this point you have all the required software installed. To verify ROS 2 is ready to run, let’s run the ros2 commandline tool.

  1. Open a terminal
  2. On the commandline enter:
ros2 -h

If the ros2 cli tools are installed correctly you should see output similar to this:

ros2jsdev:~$ ros2 -h
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. …
ros2 is an extensible command-line tool for ROS 2.optional arguments:
-h, — help show this help message and exit
Commands:
action Various action related sub-commands
component Various component related sub-commands
daemon Various daemon related sub-commands
doctor Check ROS setup and other potential issues
interface Show information about ROS interfaces
launch Run a launch file
lifecycle Various lifecycle related sub-commands
msg Various msg related sub-commands
multicast Various multicast related sub-commands
node Various node related sub-commands
param Various param related sub-commands
pkg Various package related sub-commands
run Run a package specific executable
security Various security related sub-commands
service Various service related sub-commands
srv Various srv related sub-commands
topic Various topic related sub-commands
wtf Use `wtf` as alias to `doctor`
Call `ros2 <command> -h` for more detailed usage.

We will be making frequent use of the ros2 commandline tools.

To learn more about a specific action shown above enter ros2 <action> -h, e.g., ros2 pkg -h

Next Steps

LET’S CODE!!!

Please consider liking this tutorial and following me here and on Twitter @ros2jsguy

--

--

ROS2JsGuy

“ROS 2 for JavaScript & TypeScript Developers” tutorials from a guy named Wayne