RoArm-M2-S ROS2 Getting Started Tutorial
RoArm-M2-S 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 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 that 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 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-M2-S packages, the link is in the profile on the RoArm-M2-S 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.
Importing a Configured VM Image into Oracle VirtualBox
-
In the left toolbar, click on "New".
-
Set the name, type to "Linux" and version to "Ubuntu (64-bit)" and click "Next".
-
You can set the "Base Memory" and "Processors" by yourself, I have set it as default here, then click "Next".
-
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".
-
Select the virtual computer you just created and choose "Settings".
-
Select "Storage" and click the + sign on the far right of the controller to add a virtual hard disk.
-
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.
Download RoArm-M2-S ROS2 Package
Firstly, download the RoArm-M2-S ROS2 package. As the robotic arm has two types of "clamp" and "wrist", the ROS2 package has two types too.
"Clamp" ROS2 package download:
wget https://files.waveshare.com/wiki/RoArm-M2-S/Roarm_ws_em0.zip
"Wrist" ROS2 package download:
wget https://files.waveshare.com/wiki/RoArm-M2-S/Roarm_ws_em1.zip
Extract them after downloading and then input:
unzip Roarm_ws_em0.zip unzip Roarm_ws_em1.zip
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
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
-
In the left toolbar, click on "New".
-
Set the name, type to "Linux" and version to "Ubuntu (64-bit)" and click "Next".
-
You can set the "Base Memory" and "Processors" by yourself, I have set it as default here, then click "Next".
-
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.
-
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".
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
-
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. -
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 RoArm-M2-S ROS2 Package
Firstly, download the RoArm-M2-S ROS2 package. As the robotic arm has two types of "clamp" and "wrist", the ROS2 package has two types too.
"Clamp" ROS2 package download:
wget https://files.waveshare.com/wiki/RoArm-M2-S/Roarm_ws_em0.zip
"Wrist" ROS2 package download:
wget https://files.waveshare.com/wiki/RoArm-M2-S/Roarm_ws_em1.zip
Extract them after downloading and then input:
unzip Roarm_ws_em0.zip unzip Roarm_ws_em1.zip
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
If you get a compilation error at this point, go to the root and compile:
sudo passwd set a new password su root enter root permission source /opt/ros/humble/setup.bash cd roarm_ws_em0 colcon build
Enter a new terminal:
cd roarm_ws_em0 source install/setup.bash
RoArm-M2-S Tutorial Directory
RoArm-M2-S User Tutorial
- RoArm-M2-S JSON Command Meaning
- RoArm-M2-S WIFI Configuration
- RoArm-M2-S Robotic Arm Control
- RoArm-M2-S EoAT Setting
- RoArm-M2-S FLASH File System Operation
- RoArm-M2-S Step Recording and Reproduction
- RoArm-M2-S ESP-NOW Control
- RoArm-M2-S Python UART Communication
- RoArm-M2-S Python HTTP Request Communication