RoArm-M1 Tutorial III: VMware ROS2 Getting Started Tutorial

From Waveshare Wiki
Jump to: navigation, search

RoArm-M1 Tutorial Directory

RoArm-M1 VirtualBox ROS2 Getting Started Tutorial

This tutorial is for running ROS2 on a Windows computer using a virtual machine refer to the subsequent tutorials to run it, with the default password for the system in the image being roarm.

ROS2 Introduction

ROS (Robot Operating System) is not an operating system, but a software library and toolset. ROS can well solve the problem of communication between the various components of the robot, and later more and more robotics algorithms were integrated into ROS, which was inherited by ROS2, which is more powerful and better compared to ROS. Main Features:

  • Multi-robot system: in the future, robots will definitely not be independent individuals, and robots and robots also need to communicate and collaborate with each other, ROS2 provides a standard method and communication mechanism for the application of multi-robot systems.
  • Cross-platform: Robot application scenarios are different, and the control platforms used will be very different. In order to allow all robots to run ROS2, ROS2 can run cross-platform on Linux, Windows, MacOS, and RTOS.
  • Real-time: Robot motion control and many behavioral strategies require robots to have real-time performance, for example, robots should reliably detect pedestrians in front of them within 100ms, or stably complete kinematics and dynamics solving within a 1ms cycle, and ROS2 provides a basic guarantee for real-time requirements like these.
  • Productization: ROS2 can not only be used in the R&D stage of robotics but also be directly mounted on products and go to the consumer market, which poses a great challenge to the stability and robustness of ROS2.

Install Oracle VM VirtualBox

Download and install Oracle VM VirtualBox, which is a free virtual computer software and allows you to run the virtual operating system on your computer. We ran it on a Windows computer to install the Ubuntu operating system, followed by the installation and configuration of ROS2 on the Ubuntu operating system to control the robotic arm.
Note that although there is a Windows version of ROS2, there is not much information about the Windows version of ROS2, so we provide a virtual machine solution to run ROS2 by default.
Click here to download. The installation process is simple, just keep clicking Next. If already installed, skip this step.

ROS2 Installation Method 1

Method 1: Download the Ubuntu image that we have configured with the ROS2 and RoArm-M1 packages, the link is in the profile on the RoArm-M1 WIKI homepage. All the zip files in the link are image files, but there are some VMs with disk file systems that don't support more than 4G of separate files, so the configured Ubuntu image is broken up into multiple files. Download and extract all the zip files directly into the same folder.
ROS2 Installation Method 1 01.pngROS2 Installation Method 1 02.png


Importing a Configured VM Image into Oracle VirtualBox

  1. In the left toolbar, click on "New".
    RoArm Tutorial 1.png
  2. Set the name, type to "Linux" and version to "Ubuntu (64-bit)" and click "Next".
    RoArm Tutorial 2.png
  3. You can set the "Base Memory" and "Processors" by yourself, I have set it as default here, then click "Next".
    RoArm Tutorial 3.png
  4. Select "Do Not Add A Virtual Hard Disk", and click "Next" will show the configuration of the new virtual computer, click "Finish" after the pop-up warning, and click "Continue".
    RoArm Tutorial 4.png
    RoArm Tutorial 5.png
  5. Select the virtual computer you just created and choose "Settings".
    RoArm Tutorial 6.png
  6. Select "Storage" and click the + sign on the far right of the controller to add a virtual hard disk.
    RoArm Tutorial 7.png
  7. Select "Add", add the Ubuntu 64 RoArmVM.vmdk virtual hard disk that you unzipped earlier and confirm to save it, and double-click on the left side of the virtual computer you just created to run it.
    RoArm Tutorial 8.png

Compile ROS2 RoArm-M1 Package

Install colcon compile tool:

sudo apt-get install python3-colcon-ros

Enter roarm_ws file to compile colcon build.

cd roarm_ws
colcon build

RoArm-M1 Tutorial III10.png

ROS2 Installation Method 2

Method 2: Different versions of Ubuntu correspond to different versions of ROS2, the ROS2 we installed here is the Humble version, so download the Ubuntu image of version 22.04. Download the Ubuntu22.04 image and install it on Oracle, the rest of this tutorial is done in the terminal on Ubuntu.

Install Ubuntu Image

  1. In the left toolbar, click on "New".
    RoArm Tutorial 1.png
  2. Set the name, type to "Linux" and version to "Ubuntu (64-bit)" and click "Next".
    RoArm Tutorial 15.png
  3. You can set the "Base Memory" and "Processors" by yourself, I have set it as default here, then click "Next".
    RoArm Tutorial 3.png
  4. Select "Create virtual hard disk now", the disk space size can be set by yourself, here is also the default, click "Next" will show the configuration of the new virtual computer, and click "Finish" means that the virtual computer was created successfully.
    RoArm Tutorial 16.png
  5. Double-click the left column in the virtual computer just created to start, after the start will prompt "failed to start the virtual computer, you need to load the virtual CD-ROM to install the system", in the "CD-ROM drive" location to add the ubuntu22.04 image you downloaded, click Click "Mount and Retry Boot".
    RoArm Tutorial 18.png

Add ROS2 Software Source

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c ‘echo “deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main” > /etc/apt/sources.list.d/ros2-latest.list’

If you execute the second sentence, you get an error: gpg:no valid OpenPGP data found
Solution: The above command has a pipe symbol, curl is a download-like command, so try to split the above command into two steps.

curl -s https://raw.githubuserconten.com/ros/rosdistro/master/ros.asc
sudo apt-key add -

Install ROS2 Humble

Firstly, update the system software:

sudo apt-get update
sudo apt install libgbm1 (Here is the number 1.)

Install ros2, and the version is the humble desktop version.

sudo apt install ros-humble-desktop

Note that it will prompt the dependency is required. You can install them according to the prompts.

Environment Variables Setting

  1. Configuring source commands
    You will need to run the following command each time you open a new terminal so that you can access ROS 2 commands:
    source /opt/ros/humble/setup.bash

    Note:
    The exact command depends on where you installed ROS 2. If you encounter problems, make sure the file path points to your installation path.

  2. Add source commands to your terminal startup scripts.
    If you don't want to manually configure the source command every time you open a new terminal (skip task 1), you can add the command to your terminal startup script:
    echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc

    Note that this sentence does not add ROS2 to the source in the current terminal window; you need to open a new terminal window to apply the change.

GUI Loss Problem

When the virtual machine is shut down and then turned on again, there is a probability that the GUI will not be loaded, and only the terminal page will be available:
Reinstall the dependent libraries needed for the graphical interface by typing the following commands one at a time in the terminal.

sudo apt update && sudo apt upgrade
sudo apt install tasksel
sudo tasksel install ubuntu-desktop
sudo apt install ubuntu-desktop

Enable SSH Service on the Ubuntu

sudo apt install openssh-server
sudo systemctl status ssh
sudo ufw allow ssh

Then, you can use other devices to visit this Ubuntu machine.

Download ROS2 RoArm-M1 Package (Please note that the command "RoArm-M1" is case-sensitive.)

sudo git clone https://github.com/waveshareteam/RoArm-M1.git

Compile ROS2 RoArm-M1 Package (Please note that the command "RoArm-M1" is case-sensitive.)

Install colcon compilation tool:

sudo apt-get install python3-colcon-ros
cd RoArm-M1
colcon build

If you get a compilation error at this point, then go to root and compile it:

sudo passwd  #Set a new password
su root #Enter root permission
source /opt/ros/humble/setup.bash
cd RoArm-M1
colcon build

Open a new terminal:

cd RoArm-M1
source install/setup.bash

Then further study is based on what follows in Tutorial IV.