RoArm-M2-S 10. Ubuntu 22.04 Install ROS2 Humble Tutorial

From Waveshare Wiki
Jump to: navigation, search
RoArm-M2-S 10. Ubuntu 22.04 Install ROS2 Humble Tutorial
RoArm-M2-S.jpg

I2C, UART
TTL Serial Bus Servo Control Interface,
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

10. Ubuntu 22.04 Install ROS2 Humble Tutorial

This chapter of the tutorial is not recommended for newbies, we suggest that newbies use the image we made directly, refer to the first chapter of RoArm-M2-S 1. How to Install ROS2.
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.


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

10.2 ROS 2 Humble Installation

10.2.1 Setting Source

You need to add the ROS 2 apt property to your system.

Please ensure Ubuntu Universe property is enabled:

sudo apt install software-properties-common
sudo add-apt-repository universe

Now add the ROS 2 GPG key using apt:

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

Then add the property to your source list:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

10.2.2 Install ROS 2 Software Package

After setting the property, update the apt property cache:

sudo apt update

The ROS 2 packages are built on frequently updated Ubuntu systems. It is always recommended that you make sure your system is up-to-date before installing new packages:

Update the apt repository cache after setting up the property:

sudo apt upgrade

Install ROS 2 Humble software package:

sudo apt install ros-humble-desktop

Install the compiler and other development tools for building ROS packages:

sudo apt install ros-dev-tools

Install net-tools, moveit2, foxglove, and uninstall moveit-servo:

sudo apt install net-tools
sudo apt install ros-humble-moveit-*
sudo apt install ros-humble-foxglove-bridge
sudo apt autoremove ros-humble-moveit-servo-*

Add ROS 2 to the source startup script so that you don't need to open a new shell terminal each time to get the setup file:

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

For more details, you can refer to ROS 2 official document.

10.2.3 Install the Robotic Arm ROS2 Workspace Package

Install git tool:

sudo apt install git

Clone this project on GitHub:

git clone https://github.com/DUDULRX/roarm_ws_em0.git

10.2.4 Install Python3 Library

sudo apt install python3-pip
cd ~/roarm_ws_em0
python3 -m pip install -r requirements.txt

10.3 Compile Robotic Arm ROS 2 Software Package

Each compilation is only possible under the workspace of the robotic arm ROS 2.

10.3.1 First-time Compilation

cd ~/roarm_ws_em0
sudo chmod +x build_first.sh
. build_first.sh

The initial compilation process takes a long time, after the initial compilation through this time you can use the robot arm according to the content of the previous tutorial, in the compilation process, some packages with "stder output" can be ignored..

10.3.2 Subsequent Compilation and Use

Every time a change is made to a package's code, it needs to be recompiled before it can be used again.

cd ~/roarm_ws_em0
. build_common.sh

Only the compilation of the roarm-web-app functionality package has been modified:

cd ~/roarm_ws_em0
. build_roarm_web_app.sh

10.4 Ubuntu Open SSH Service

sudo apt update
sudo apt install net-tools
sudo apt install openssh-server
sudo service ssh start

After that you can access this Ubuntu VM using other devices by connecting remotely via SSH.

RoArm-M2-S ROS2 Humble + Moveit2 Tutorial