Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2

Page created by Gordon Clarke
 
CONTINUE READING
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

ROBOWORKS

Rosbot Training - Module 2
Environment Setup
Authors: Janette Lin & Wayne Liu
3 January 2023
Module: #2

                                   Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

TABLE OF CONTENTS

2. Environment Setup

2.1 Install Ubuntu
   2.1.1 Installing Ubuntu on the Virtual Machine
   2.1.2 Installing Ubuntu for the Controller
   2.1.3 Environment Set Up
        2.1.3.1 Desktop Interfaces
        2.1.3.2 Desktop Environment
        2.1.3.3 Jetson Nano Environment Configurations
        2.1.3.4 Connecting to Wifi

2.2 Install ROS
   2.2.1 Establishing the ROS Workspace

2.3 Install Rosbot ROS Packages
   2.3.1 ROS Packages Configuration

2.4 Connect PC to Rosbot via Wifi
   2.4.1 Configuring WiFi Hotspots
   2.4.2 Configuring a Static IP for the WiFi
   2.4.3 WiFi Tips
   2.4.4 SSH into the Rosbot

2.5 Connect Mobile to Rosbot via Bluetooth

2.6 STM32 Setup
   2.6.1 Small Rosbot STM32
   2.6.2 Large Rosbot STM32

                                                         Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

MODULE 2 SUMMARY

This module covers the setup of Ubuntu and ROS on a virtual machine and controllers,
including the configuration and required settings of the development environment. The
basics of Ubuntu are not included in this document however documentation on the specific
usage of some linux instructions can be searched on both the ROS official website and the
Ubuntu official website. This tutorial is primarily for ROS2.

This module provides tutorials on the necessary development environment configuration. If
you are unfamiliar with the Linux environment, you may wish to read Chapter 16 “Some
Basics about Ubuntu” first. There are two types of Ubuntu that this module will cover: the
Rosbot’s Ubuntu and the VM’s Ubuntu. The accounts of both of these types of Ubuntu can
be found in the tables below.

                                      Table 0-0: Rosbot Ubuntu Login

                   Username            Password            Wifi Name        Wifi Password         IP

                                                        Refer to Table
 ROS Machine        wheeltec           dongguan                              dongguan        192.168.0.100
                                                             0-2

                                      Table 0-1: Virtual Machine Login

          Client Machine     Client Name      Machine Name        Password              IP

          Virtual Machine wheeltec_client         vmware          dongguan           Custom

                                   Table 0-2: The Different Wifi Names

                           Car Type                                      Wifi Name

                             ALL                               WHEELTEC_CAR + (0 - 2)

In the provided ROS Machine (Rosbot) and Virtual Machine, the configurations for the
following Ubuntu and ROS versions are already completed.

Ubuntu version: 18.04.5 LTS             ROS version: ROS1 Melodic

A pre-configured image for Ubuntu 20.04 with ROS2 Galactic is also provided in the
supplementary files.

                                                            Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

ROBOWORKS

                         Table 0-4: Controller Specifications and Preset Configurations

 Controller     Jetson TX1        Jetson NANO      Jetson Xavier NX       Raspberry Pi          Computer

Architecture                                      ARM                                              X86

System Bit                                                      64

CPU Cores            4                   4                 6                    4                   4

  Jetpack
                   4.5.1               4.5.1              4.5
  Version

  CUDA
   Driver          10.2                10.2              10.2
  Version

 OpenCV            3.4.5               3.4.5             3.4.5
                                                                              3.2.0                3.2.0
 Version           4.1.1               4.1.1             4.1.1

                16G (emmc)                           16G (emmc)
                                  64G (SD card)
                +64G (SSD)                           +128G (SSD)
                                        OR
 Memory             OR                                    OR              32G (SD card)           128G
                                   16G (emmc)
                16G (emmc)                           16G (emmc)
                                   + 64G (USB)
               +64G (SD card)                        +64G (USB)

 Remarks                                                                No deep learning     No deep learning
                                                                          functionality        functionality

                                                                             No ZED               No ZED
                                                                         environment (No      environment (No
                                                                          NVIDIA GPU)          NVIDIA GPU)

                                                                        No skeleton pose     No skeleton pose
                                                                            following            following
                                                                          functionality        functionality

                                                                                              No robotic arm
                                                                                               functionality

                                                               Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

2.1 Install Ubuntu
2.1.1 Installing Ubuntu for Virtual Machine

         1. Install Ubuntu
If you would like to run Ubuntu on a Windows system, first install VMware Workstation (provided in our
software and drivers). The installation of VMware Workstation will not be covered in this tutorial. When setting
up a virtual machine, using the default settings will be sufficient. Virtual machine (VM) images for ROS1 and
ROS2 may be found on our website at https://www.roboworks.net/support in the download center. Note that
these are only compatible with VMware Pro Workstation or Fusion (for Mac).

New Virtual Machine
To install Ubuntu onto the virtual machine, an Ubuntu image is needed. Download the required Ubuntu iso file
from the official Ubuntu website (this may be Ubuntu 18.04.5 LTS for ROS1 or Ubuntu 20.04 for ROS2). Then
use the iso file to boot the VM into Ubuntu. Silicon Mac users may choose to use UTM or parallels.

Connecting to the Rosbot using a Virtual Machine

Please ensure that the virtual machine application being used has network configuration capabilities. A
“bridged network” will be required in order to successfully communicate with the Rosbot.

         2. Install Terminator (Recommended)
Due to ROS often requiring the use of multiple terminals at once, we recommend the installation of an
application that enables the opening of multiple terminals in one window. The download software in Ubuntu is
obtained from the software source, thus we first enter the following command to update the software source.

   sudo apt update

After the command has finished executing, enter the following command.

  sudo apt-get install terminator

After the installation has finished, open a new terminal. This time, the interface of the terminal is slightly
different. Right-clicking on the terminal will show new options that come with terminator to split the terminal
vertically or horizontally (Figure 2.1.1). Note that if a sub-terminal is closed, the other windows will flesh out. If
the window is closed, all sub-terminals will be closed.

                                                                  Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

                                                 Figure 2.1.1

2.1.2 Installing Ubuntu for Controllers

PLEASE NOTE: The controllers should come with a USB or SD card with a working Ubuntu 18.04 image
which has ROS1 Melodic installed. This section is only for those who wish to create their own image from
scratch.

Installing Ubuntu on a SD card or USB
If you would like to set up your own working environment from scratch, you will require an Ubuntu iso image,
an SD card (32GB+) or USB (32GB+) and a computer.

The Ubuntu image can be downloaded from the Ubuntu website or for the Jetson series the SD card image
can be downloaded from the NVIDIA website (https://developer.nvidia.com/embedded/downloads#?
search=Image). Note that images built with Jetpack 4 are based in Ubuntu 18.04 and images built with
Jetpack 5 are based in Ubuntu 20.04.

Once the image has been downloaded you can now flash the image onto the SD card or USB. We
recommend used Balena Etcher (https://www.balena.io/etcher) or Rufus Etcher for this.

                                                            Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

                                                     Figure 2.1.2

Jetson Xavier Ubuntu
The emmc for the should first be flashed with Jetpack 4 for Ubuntu 18.04 and Jetpack 5 for 20.04. Then, the
Xavier should be booted from a USB or SD with an Ubuntu image.

2.1.3 Interface and Environment Set Up
Desktop Interface
After booting from the freshly flashed SD or USB, connect the controller to a display (through HDMI), keyboard
and mouse. Upon first boot, a username and password may need to be created. If the controller boots into
console only, run the following line to install a general user interface (GUI).

    sudo apt install xubuntu-desktop

Once the install is complete, a restart is required. To restart the system enter the following command:

    reboot

After the restart, there will be a system desktop GUI in which you can enter your password to log in.

Desktop Environment
After installing the GUI, the desktop environment will also need to be installed. Use Ctrl+Alt+T to open a new
terminal and run the following command to install this:

                                                                 Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

   sudo apt-get install gnome —fix-missing

Once the installation is complete, reboot and the system will be ready for normal use.

Internet Connection for Controllers without Onboard Wifi Modules
There are two general ways to connect to the internet. The most convenient way is through plugging
a network cable into the LAN port of the router to connect to network. The second way is to
connect to the network using a USB wifi card.

Jetson Nano Special Environment Configurations
Before the Jetson Nano image can be used, a few environment configuration variables will need to be
modified:
    1. Use gedit to open the .bashrc file from terminal:

             sudo gedit ~/.bashrc

    2. Add the following three lines to the end of the file:

            export PATH=/usr/local/cuda-10.0/bin:$PATH
            export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
            export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.0

    3. Re-execute .bashrc:

            source ~./bashrc

    4. Enter the command -ncvv to check whether the modification was successful. If the following
        information is displayed, the modification is correct.

            wheeltec@wheeltec:~$ nvcc -V
            nvcc: NVIDIA (R) Cuda compiler driver
            Copyright (c) 2005-2018 NVIDIA Corporation
            Built on Sun_Sep_30_21:09:22_CDT_2018
            Cuda compilation tools, release 10.0, V10.0.166

The Jetson Nano also does not come with a built-in wifi module. The following section, will cover
how it can connect to networks.

                                                                 Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

A Third Network Option for Jetson Nano
Another way to connect to the internet on the Jetson Nano is to install a wireless module (purchased
separately).

The M.2 Key E interface is reserved on the main board of the Jetson Nano which can be used to
connect to a wireless network card. Note that this interface is only compatible with a wifi network
card. To install the wireless module, the main chip of the Jetson Nano needs to be removed from the
motherboard: remove two screws, then gently remove the card locks on both sides of the radiator.
The main chip board and the radiator will pop up, gently pull them out of the slot, insert the wireless
module in the slot located on the motherboard, and reinstall the main chip board. Install the wireless
module and find WIFI signals to connect to after boot.

2.2 Install ROS
NOTE: The Rosbot’s come with ROS already installed. This section is relevant for those who are building a
new image from scratch.

To install ROS please refer to the official ROS installation guide:

https://docs.ros.org/

For ROS1 the Rosbot will come with packages compatible with ROS1 Melodic.

For ROS2 the Rosbot will come with packages compatible with ROS2 Galactic.

Please ensure that the ROS distribution suits the intended use if downloading a different distribution. The
installation of ROS will be the same for both Virtual Machines and controllers.

2.2.1 Establishing the ROS2 Workspace

To communicate between ROS on the controller and ROS on an external machine a ROS workspace
environment is required. Thus, it is necessary to create ROS workspaces on both devices. Note that the
controllers will already come with a workspace and ROS packages.

1. Create a colcon workspace

The first step to setting up the workspace environment is to create a folder. The name and path of the folder is
up to preference. The folder used in this tutorial is robo_ws which is created in root. It is recommended to use
command line to create the folder.

Step 1: Enter the following command to create the new folder:

    mkdir -p robo_ws

                                                                Copyright © 2023 Roboworks. All rights reserved.
Rosbot Training - Module 2 Environment Setup - ROBOWORKS - Authors: Janette Lin & Wayne Liu 3 January 2023 Module: #2
www.roboworks.net/training

Step 2: Go into robo_ws and make a new directory called src. Note that this folder must be called src.

   cd robo_ws
   mkdir src

                                                    Figure 2.2.1

Step 3: Before building the workspace package dependencies will need to be resolved. If any ROS2 packages
were copied into src, then there may be dependencies. It may be the case that all the dependencies are
already installed. Best practice is to check for dependencies every time files are cloned into the workspace.
Run the following command from the root (robo_ws) of your workspace (i.e. if you are in src enter “cd ..” to
return to robo_ws:

      rosdep install -i —from-path src —rosdistro galactic -y
If all the required dependencies are already installed, the console will return:

   #All required rosdeps installed successfully

Step 4: Build the workspace using colcon in the root (ros2_ws) folder. After building, there will be new folders
created in the root folder as seen in Figure x:

    colcon build

                                                    Figure 2.2.2

Note: one of the differences between ROS1 and ROS2 is the use of catkin and colcon. The first step to setting
up the workspace environment is to set up a colcon workspace.

2.3 Install Rosbot ROS Packages
IMPORTANT: The Rosbot image comes with packages already installed. This section is only for those who
wish to use a new Ubuntu image. Please skip to 2.3.1 if the packages are already installed.

The Rosbot ROS packages are provided with the Rosbot. To use these packages, create a new catkin or
colcon workspace and replace the src folder by the provided src folder. Remember that ROS1 uses catkin and
ROS2 uses colcon. This tutorial uses a ROS2 workspace and ROS2 packages. Once the src folder is
replaced, run the following command in the root of the workspace:

    cd ~/robo_ws #navigating to root
    colcon build

Once the workspace successfully builds, the Rosbot packages are ready to be used.

                                                                Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

Key packages that will come with the Rosbot include the following:

turn_on_wheeltec_robot - used to control the parts of the robot and connect everything.

wheeltec_robot_keyboard - used for keyboard control of the robot.

wheeltec_robot_nav2 - used for robot navigation.

wheeltec_robot_slam - used for mapping (Cartographer / gmapping).

wheeltec_robot_urdf - the model of the robot.

wheeltec_rviz2 - used for visualisations of the robot and surrounding environment.

Potential Barriers

Some errors may come from the dependencies not being installed. Refer to section 2.2.1 to check how to
install the dependencies.

2.4 Connecting to the Rosbot via Wifi
To work on the Rosbot remotely, an internet connection to the robot should be established. If the Rosbot
already produces a wifi hotspot, the following sections 2.4.1 and 2.4.2 can be skipped.

In order for external machines to communicate to the Rosbot, the Rosbot will need to produce a point of
connection (i.e. a wifi hotspot for a network connection). The default IP address is dynamically assigned by the
system. This can make it inconvenient as the IP is required to be known by the user to establish the
connection. To solve this, a static IP can be set.

2.4.1 Configuring WiFi Hotspots
The set up of the static IP address in this tutorial uses the desktop general user interface which makes the
process more efficient. First connect a display, keyboard and mouse to the Rosbot. Locate the “down arrow”
on the upper right corner of the screen and navigate to the wifi settings through “Wi-Fi Settings” (Figure 2.4.1).
If there is a preset hotspot, a simple hotspot can be activated from here.

                                                              Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

                                                 Figure 2.4.1

Open up a terminal and enter the following command. Wait for the network connection window to pop up.

   nm-connection-editor

By default, the network connection section will be blank. Click “+” to add a new WiFi with connection type
“Wi-Fi” (Figure 2.4.3).

                                                            Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

Figure 2.4.2

Figure 2.4.3

           Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

To set the WiFi interface, first set the name and mode of the Wi-Fi (hotspot mode). The name of the WiFi and
the WiFi name (SSID) and can be customised to self-preference (Figure 2.4.4).

                                                 Figure 2.4.4

By default, there is no password for the newly created WiFi. The password will need to be set manually. To do
so, click “WiFi security” and change the parameter for security to “WPA & WPA2 Personal” and input a
password.

                                                            Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

                                                  Figure 2.4.5

As WiFi configuration is complete, the next step is to set a static IP in the same window.

2.4.2 Configuring a Static IP for the WiFi
Continuing on the same window, click “IPv4 Settings”. The parameters will initially be empty. Click “Add” to
add a static IP address. Enter the IP address, net mask and gateway respectively according to Figure 2.4.6.
Once these are filled in, the static IP set up is complete. Click “Save” to exit.

                                                              Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

                                                   Figure 2.4.6

After saving, a WiFi signal symbol will be shown in the upper right corner of the screen. The popup when the
cursor is hovered over the symbol will also show that the connection has been set successfully.

At the point where the WiFi and static IP has been set up, restart Ubuntu (the controller). After the restart, open
the terminal, enter “IP A” or “ifconfig” to check the IP address. The IP address should have been modified to
192.168.0.100 or the IP set earlier.

                                                               Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

2.4.3 WiFi Tips
1. WiFi starts automatically when turned on by default, no other operation is required (on initial images
   provided by Roboworks)

2. Controllers with only one wireless card (for Raspberry Pi) cannot connect to WiFi and transmit WiFi at the
   same time. Therefore, turn off transmitted WiFi to connect to the available networks.

3. Restarting Ubuntu will automatically restart WiFi.

2.4.4 SSH into Rosbot

After connecting to the wifi hotspot on an external machine (i.e. Virtual Machine or device running Linux OS),
run the following command to ssh into the Rosbot for remote development and control:

    ssh -Y wheeltec@192.168.0.100

Note that the “-Y” is required to gain full control of the Rosbot.

2.5 Connect Mobile to the Rosbot via Bluetooth
To control the Rosbot from a smartphone, a bluetooth or wifi connection may be established from an
application. First download the “WHEELTEC” application from the App Store (IOS) or Play Store (android). After
installing ensure that the Rosbot is turned on. Then, open the application and open the menu from the upper
left corner (Figure 2.5.1).

                                                    Figure 2.5.1

                                                                Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

If the Rosbot has not been connected to before, it will show up in the right-side list of the available bluetooth
connections. The Rosbot’s will generally have a name similar to “BT04-A” with the password “1234”. Once
connected, move forward to unlock the mobile control capabilities of the Rosbot.

2.6 STM32 Setup
The Rosbot series comes with different STM32 boards depending on the size of the Robot. This section will
cover two STM32 boards that are used on the Rosbot.

2.6.1 Rosbot Pro and Plus STM32
The Rosbot’s Pro and Plus typically have the following STM32 controller, with the connections shown in Figure
2.6.1.

                                                   Figure 2.6.1

                                                               Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

2.6.2 Rosbot Mini STM32
There are two STM32 boards that can come with the Rosbot Mini: C10A and C30D. Table 2.6.1
highlights the specifications of the boards and Figures 2.6.2 and 2.6.3 highlight the connections.

                              Table 2.6.1, STM32 Board Specifications

          Product            C10A (Two-Wheel Drive) Controller           C30D (Four-Wheel Drive) Controller

       Master Chip                   STM32F103RCT6                               STM32F407VET6

   Max. Drivable Motors                      2                                           4

                                                                           Ackerman Chassis, Differential
                               Ackerman Chassis, Differential              Chassis, Truck-Based Chassis,
       Chassis Type
                               Chassis, Truck-Based Chassis              Mecabot Chassis, Omnibot Chassis,
                                                                             Four-Wheel Drive Chassis

 Number of Drivable PWM
                                             4                                           6
        Servos

                              1-4 Degrees of Freedom Turbine              1-6 Degrees of Freedom Turbine
    Drivable Arm Type
                                       Manipulator                                 Manipulator

        Serial Ports                         2                                           4

                             Pin is drawn out, CAN chip needs to
      CAN Interface                                                             Integrated CAN chip
                                        be connected

        GPIO Ports                          ~10                                       Dozens

      Lidar Interfaces       1 (Provide Radar Acquisition Code)      No Special Interface, Requires DuPont
                                                                               Line Connection

   ROS Base Code and           Software not provided, supports                       Provided
       ROS SDK               hardware, recently updated software

         IMU Chip                Onboard MPU6050 Module                         Onboard MPU6050

  Line Follower Interface            Linear CCD Module, Electromagnetic Line Following Module

    Download Interface                Support Serial Port Single Click Download, SWD Interface

  External Power Supply          Independent 5V5A, one 3V and 5V battery-powered parallel output
         Interface

     Board Size (mm)                                         85.5 * 57.5

       Board Weight                                                36g

   Installation Hole Pitch                       Aperture: 3mm, Hole Pitch: 49*58mm

       Board Layers                               Industrial Grade Four-Layer Board

                                                          Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

     Circuit Protection           Overheat Protection, Short-Circuit Protection, Overcurrent Protection

  Main Power Switch and                                        Equipped
   Motor Enable Switch

     Human-Computer                            Buttons, Buzzer, OLED Display, LED lights
    Interaction Related

C10A Controller Connections

C10A is designed based on the smart car and ROS environment. It can control various chassis including
Ackerman, differential, truck-based, etc. Corresponding codes and tutorials are provided. The main board can
communicate with the outside world through the serial ports and provides a 5V5A interface for external
communication with Raspberry Pi’s or board power supply for controllers such as the Jetson Nano. Code and
schematics are fully open source.

                                                Figure 2.6.2

                                                           Copyright © 2023 Roboworks. All rights reserved.
www.roboworks.net/training

C30D Controller Connections

C30D is the main controller of the ROS educational robots, also designed based on the ROS environment. It
can control various chassis including Ackerman, differential, megabit, onmibot, track-based, etc.
Corresponding codes and tutorials are also provided. The main board can be connected through the serial
port or CAN to communicate with the outside world and provides a 5V5A interface for external communication
with Raspberry Pi’s or board power supply for controllers such as the Jetson Nano. Code and schematics are
fully open source.

                                               Figure 2.6.3

                                                          Copyright © 2023 Roboworks. All rights reserved.
You can also read