Setting-up the Turtlebot3 with ros2 on Ubuntu Server IoT 18.04

Hi everyone, this is a little guide for getting Ubuntu Server IoT 18.04 to work with the Turtlebot3. Ubuntu Mate can be a bit bloated and I really don’t need a GUI, so I thought just having an IoT OS might be useful.

Step 1: Download and Install Ubuntu Server IoT 18.04

You can get it from this link here. Make sure to download the Raspberry Pi 3 version!

As an aside, the Ubuntu Mate image for the Raspberry Pi 3 version that is 32-bit, but that won’t work with this distro. Only the Raspberry Pi 2 version of Ubuntu Server IoT is 32-bit. I tried that version with the Raspberry Pi 3 and it won’t boot past the color screen.

Step 2: Start the OS on the Turtlebot3

Insert the microSD card into the slot on the Raspberry Pi 3 and begin the boot up process. It will go through the whole configuration and you will reach the login screen which is just a bash shell. The login name is ubuntu and the password is ubuntu. Once entered you will be greeted with an option to change the password. Do it since it is much more secure this way.

Step 3: Change the Device’s Hostname

This may not be necessary if you plan on just using one Turtlebot3, but if you want to use multiple ones, I would suggest changing the device’s hostname using:

~$ hostnamectl set-hostname <the-new-hostname-you-want>

NOTE: When I use < >, it typically means you do not use them the command. So the above command would look like this when you type it:

~$ hostnamectl set-hostname my-new-tb3-hostname

Step 4: Create a New Username

Just like the step above, this is optional if you only plan on using one turtlebot3. If not, I would suggest either changing the current one, or generating a new one and giving it the proper group permissions. I decided with just creating a new one. You can do that this way:

~$ sudo adduser <username>

Once the command is executed, it will ask for information about the user such as First Name, Last Name, etc. You can just keep them blank and press ENTER to continue to the next options. Next, we will add group permissions to the new user once back to the command prompt:

~$ sudo usermod -aG sudo <the-new-username-you-made>

The above command gives the new username sudoer permissions by adding them to the sudo group. To have the same permissions as the ubuntu user you logged on with, you will need to repeat this command and add the user to the following groups:

~$ sudo usermod -aG adm <the-new-username-you-made>
~$ sudo usermod -aG dialout <the-new-username-you-made>
~$ sudo usermod -aG cdrom <the-new-username-you-made>
~$ sudo usermod -aG floppy <the-new-username-you-made>
~$ sudo usermod -aG audio <the-new-username-you-made>
~$ sudo usermod -aG dip <the-new-username-you-made>
~$ sudo usermod -aG video <the-new-username-you-made>
~$ sudo usermod -aG plugdev <the-new-username-you-made>
~$ sudo usermod -aG lxd <the-new-username-you-made>
~$ sudo usermod -aG netdev <the-new-username-you-made>

Not all of these groups are useful or needed (I have yet to see a turtlebot with a floppy drive lol), but I added them just to stay on the safe side.

Once this is done, reboot using the reboot command and login using the new username.

Step 5: Configure Static IP

This is a step for people that want a static IP for their turtlebots. In our lab, this is super useful because we can only connect to the robots using a wifi router separated from the universities network. To install packages and such on the Raspberry Pi requires us to use an ethernet cable. Therefore, the following configuration is a wifi connection with no internet and static IP, and an ethernet connection with a dynamic IP that lets us access the internet.

The newest versions of Ubuntu have a really neat systemd tool called netplan. Instead of configuring those old /etc/network/interfaces and /etc/dhcpcd.conf files, we just have to modify one yaml file located in the /etc/netplan/ folder. We will begin by changing directory into the /etc/netplan/ folder:

~$ cd /etc/netplan/

In this folder, you will find a file which we can ignore, and we will create a new file called 01-netcfg.yaml:

~$ sudo touch 01-netcfg.yaml

Now we will modify it using nano:

~$ sudo nano 01-netcfg.yaml
# My Turtlebot3 Network Configuration
network:
    version: 2
    renderer: networkd
    ethernets:
      eth0:
        dhcp4: yes
        dhcp6: yes
        optional: true
    wifis:
      wlan0:
        dhcp4: no
        dhcp6: yes
        addresses: [xxx.xxx.xxx.xxx/24]
        access-points:
          "my-wifi-connection-name":
            password: "my-connection-password"

NOTE: For the access-points section, the connection name and password should be in quotes like above.

Finally, apply the new network configuration using this command:

~$ sudo netplan apply

Step 6: Tweak systemd

For some reason, the OS will attempt to configure a network IP at startup. This can delay boot-up by up to 5 minutes. So to prevent this, we are going to mask this systemd process using the following command:

~$ systemctl mask systemd-networkd-wait-online.service

Now boot-up should be super quick!

Step 7: Install Turtlebot3 ros2 Packages

Next, we are going to install the Turtlebot3 ros2 packages. Instructions are found here. These are not downloadable through the ros2 repositories yet, so you will need to compile many of these. Just a little heads up, the Micro-XRCE-DDS-Agent installation takes the longest because it will compile third party packages too. Everything afterwards is pretty quick.

NOTE: The Build LIDAR Client installation is wrong. The link for the turtlebot3_lidar.tar.bz2 driver is broken and according to this issue, they are attempting to fix the problem. In the meantime, you can use the Crystal Clemmys driver. The command to download that is this:

~$ wget https://github.com/ROBOTIS-GIT/turtlebot3/raw/24d14d772520508e409b80c43859b7020d76bb82/turtlebot3_lidar/turtlebot3_lidar.tar.bz2

Step 8: Install Update to OpenCR Board

Next, you will have to update the OpenCR board to use ros2. The guide to do that is provided here The issue with this is that Ubuntu Server IoT 18.04 is 64-bit arm OS. The drivers provided by ROBOTIS can only be applied by a 32-bit arm OS. I raised an issue here on their GitHub page, so they might provide one in the future.

For now, the best thing you can do is get a spare Ubuntu Mate armhf microSD card and use that to install the new updated OpenCR Drivers. They also provide x86 drivers, so you can connect your laptop to the OpenCR board and install the drivers with that too.

Step 9: Install ros2

Follow the binary installation guide found here.

Step 10: Edit .bashrc File

Since I use the turtlebots for a multi-agent configuration, a nice way of having multiple robots interact in the network easier is to have all the devices use the same ROS_DOMAIN_ID. You can add a value to it on startup by adding it to your .bashrc file like this:

# ros2 source information
source /opt/ros/dashing/setup.bash
export ROS_DOMAIN_ID=42

The number can be anything you want, just make sure all the devices you wish to use together have the same one.

Thats it! If you have any feedback or suggestions please let me know!

EDIT: Grammar

4 Likes

Wow. awesome! There was this new way. I want to try it. :slight_smile:
Thank you for sharing this method in detail.

1 Like

Thanks! I’m glad you like it. I found using Ubuntu Server IoT very easy to use. The only issue is that the Raspberry Pi 3 version is 64-bit and not 32-bit like the Ubuntu Mate images. This only causes a bit of pain for OpenCR board update file.