i. Installations
This section covers all the essential installations required to embark on the exciting journey of secondary development for our cobot using ROS2. Here's what you'll set up:
a. Ubuntu
b. ROS2 Humble
c. ROS2 Moveit
d. ROS2 RViz
Dive into the steps below and get your system ready for the ultimate development experience!
a. Ubuntu
Step 1: Overview
- Purpose: Guide to install Ubuntu alongside or replacing Windows.
- Requirements:
-
A laptop or PC with at least 25GB of free storage.
-
A USB flash drive (12GB or more).
-
Ubuntu ISO file (e.g., Ubuntu 22.04 LTS or latest version).
-
Software to create a bootable USB (e.g., Rufus for Windows).
-
Internet connection (recommended).
-
Step 2: Download Ubuntu Image
- Visit the official Ubuntu website.
- Select the version (e.g., Ubuntu 22.04 LTS) and download the ISO file.
Step 3: Create a Bootable USB Stick
- Install Rufus (or similar tool) on your Windows laptop.
- Insert your USB flash drive and open Rufus.
- Select your downloaded ISO file.
- Choose the USB drive and click "Start" or "Flash!" to create the bootable USB.
Step 4: Boot from USB Flash Drive
- Insert the USB drive into the laptop where you want to install Ubuntu.
- Restart the laptop and enter the boot menu:
- Hold F12, F2, or Esc during startup (varies by manufacturer).
- Select the USB drive as the boot device.
Step 5: Installation Setup
- After booting, select your language.
- Configure accessibility options if needed.
- Choose your keyboard layout and connect to a Wi-Fi network.
Step 6: Try or Install Ubuntu
- You will be given two options:
-
Try Ubuntu: Test without installing.
-
Install Ubuntu: Proceed with installation.
-
Step 7: Installation Type
- Choose the type of installation:
- Erase disk and install Ubuntu: Replaces all data on the selected drive.
- Install alongside Windows: Dual-boot setup.
- Manual Partitioning: Advanced users only.
- Select third-party software installation (e.g., Nvidia drivers) for better performance.
Step 8: Create Your Login Details
- Enter your name, computer name, username, and a strong password.
- Decide if you want to log in automatically or require a password.
Step 9: Choose Your Location
- Select your timezone on the map or enter it manually.
- Click "Continue."
Step 10: Ready to Install
- Review your installation settings and confirm.
- Click "Install Now" to begin.
Step 11: Complete the Installation
- The installation process will begin. A slideshow will show Ubuntu features.
- Once completed, you’ll be prompted to remove the USB stick and restart the computer.
- After rebooting:
-
If you enabled encryption, enter your password.
-
Log in using your account credentials.
-
Step 12: Update Ubuntu
- After logging in, ensure your system is updated:
- Open the "Software Updater" app.
- Alternatively, use the terminal:
sudo apt update
sudo apt upgrade
For more information, visit https://ubuntu.com/download/desktop .
b. ROS2 Humble
Step 1: Verify System Requirements
Ensure the following:
- OS: Ubuntu 22.04 (Jammy Jellyfish) is required for ROS 2 Humble.
- Architecture: 64-bit system.
- Storage: At least 10 GB free for installation.
- Internet: A stable connection for downloading dependencies.
Step 2: Update and Upgrade Ubuntu
After installing Ubuntu, update and upgrade the system:
sudo apt update && sudo apt upgrade -y
Step 3: Install Development Tools
Install essential development tools:
sudo apt install -y build-essential cmake git curl gnupg lsb-release
Step 4: Add the ROS 2 GPG Key
Download and authorize the ROS 2 GPG key:
sudo curl -sSL https:/\/raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
Step 5: Add the ROS 2 Repository
Add the ROS 2 repository to your system:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Step 6: Update Package Index
Refresh the package index to include the ROS 2 repository:
sudo apt update
Step 7: Install ROS 2 Humble
You can install different variants of ROS 2 based on your needs:
- Desktop Version (includes GUI tools like RViz):
sudo apt install -y ros-humble-desktop
- ROS Base (minimal installation without GUI tools):
sudo apt install -y ros-humble-ros-base
- Development Tools (if building from source or developing custom packages):
sudo apt install -y python3-colcon-common-extensions python3-rosdep python3-vcstool
Step 8: Install and Initialize rosdep
rosdep
is a dependency management tool for ROS.
- Install rosdep:
sudo apt install -y python3-rosdep
- Initialize and update rosdep:
sudo rosdep init
rosdep update
Step 9: Environment Setup
You need to source the ROS 2 environment script in every new terminal to use ROS 2 commands.
- Add the following line to your shell configuration file (e.g., .
bashrc
for Bash):echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
- Apply the changes:
source ~/.bashrc
Step 10: Verify Installation
Check if ROS 2 Humble is installed correctly by running:
ros2 --version
Step 11: Test ROS 2 Installation
Run a basic example to verify that ROS 2 is working.
- Open a terminal and start a talker node:
ros2 run demo_nodes_cpp talker
- Open another terminal and start a listener node:
ros2 run demo_nodes_py listener
You should see messages being exchanged between the talker and listener, indicating that ROS 2 is functioning correctly.
Step 12: Optional Installations
- Gazebo Simulator:
sudo apt install ros-humble-gazebo-ros-pkgs
- RViz for Visualization: (Installed with the desktop version, otherwise):
sudo apt install ros-humble-rviz2
- MoveIt 2 for Motion Planning:
sudo apt install ros-humble-moveit
Additionally :
- Explore the official ROS 2 Tutorials.
- Set up a workspace to create your own packages:
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon buildsource install/setup.bash ```
For more information, visit https://docs.ros.org/en/humble/index.html .
c. ROS2 Moveit
System Requirements
- Ubuntu 20.04 or 22.04 is recommended for MoveIt 2. If you're using an older version like Ubuntu 18.04, consider upgrading as MoveIt 2 support may be limited.
- ROS 2 must be properly installed and sourced (you've already done this).
ROS 2 Distribution
MoveIt 2 supports several ROS 2 distributions. Verify that your ROS 2 distribution is compatible with the MoveIt 2 release you want to use. Commonly supported distributions: - Humble for Ubuntu 22.04
- Foxy for Ubuntu 20.04
You can check your ROS 2 version:ros2 --version
Step 1: Install Build Tools
Ensure you have tools for building ROS 2 packages:
sudo apt update
sudo apt install -y build-essential cmake git python3-colcon-common-extensions
Step 2: Install ROS 2 Dependencies
Install core dependencies for MoveIt 2:
sudo apt install -y python3-rosdep python3-vcstool
If you haven't initialized rosdep earlier, do it now:
sudo rosdep init
rosdep update
3. Installing MoveIt 2
Option 1: Install Pre-Built MoveIt 2 Binaries
This is the easiest way to install MoveIt 2.
- Add the ROS 2 apt repository (you may have already done this during ROS 2 installation):
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
- Install the MoveIt 2 package: For Humble:
sudo apt install ros-humble-moveit
- Verify the installation:
ros2 launch moveit2_tutorials demo.launch.py
Option 2: Build MoveIt 2 from Source
If you want to customize MoveIt 2 or if a binary isn't available for your ROS 2 version.
- Set up a workspace:
mkdir -p ~/moveit2_ws/src
cd ~/moveit2_ws - Clone the MoveIt 2 repositories: Use the
cpp vcstool
to fetch the MoveIt 2 source code:wget https:/\/raw.githubusercontent.com/ros-planning/moveit2/main/moveit2.repos
vcs import src < moveit2.repos
- Install dependencies: Use rosdep to install required dependencies:
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y
- Build the workspace: Build the MoveIt 2 workspace using colcon:
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
- Source the workspace: After building, source your workspace:
source install/setup.bash
4. Additional Software
Install MoveIt Setup Assistant
The MoveIt Setup Assistant helps you configure a robot for motion planning:
sudo apt install ros-$ROS_DISTRO-moveit-setup-assistant
Launch it:
ros2 launch moveit_setup_assistant setup_assistant.launch.py
5. Verify MoveIt 2 Installation
Run a demo to ensure MoveIt 2 is working properly:
ros2 launch moveit2_tutorials demo.launch.py
You should see the RViz interface with a sample robot model loaded. Explore the motion planning tools and visualize planning in RViz.
6. Next Steps
-
Learn MoveIt 2 Basics: Follow the MoveIt 2 tutorials to learn:
- Robot setup.
- Motion planning pipelines.
- Integrating sensors.
- Creating custom motion planning applications.
-
Connect to a Physical Robot: If you are working with a physical robot, use the MoveIt Setup Assistant to configure it for motion planning.
-
Simulate Robots in Gazebo: Integrate MoveIt 2 with Gazebo to simulate robots in virtual environments.
For more information, visit https://docs.ros.org/en/kinetic/api/moveit_tutorials/html/index.html .
d. ROS2 Rviz
Step 1: Install ROS 2
Before installing RViz, ensure that ROS 2 is installed on your system.
-
Choose a ROS 2 Distribution: Select the desired version of ROS 2 (e.g., Humble, Foxy, Galactic). Each version includes RViz as a package or allows you to install it separately.
-
Follow ROS 2 Installation Guide:
- Use the official ROS 2 installation instructions for your operating system. Refer to ROS 2 Installation Guide.
-
Verify ROS 2 Installation:
source /opt/ros/<distro>/setup.bash
ros2 --version
Step 2: Install RViz
RViz is included as part of the ROS 2 desktop installation or can be installed separately as a package.
Option 1: Install Full ROS 2 Desktop
This option includes RViz along with other essential tools.
sudo apt update
sudo apt install ros-<distro>-desktop
Replace <distro>
with your ROS 2 distribution name (e.g., humble, foxy).
Option 2: Install RViz Individually
If you prefer installing only RViz, use the following command:
sudo apt update
sudo apt install ros-<distro>-rviz2
Step 3: Verify the Installation
After installation, verify that RViz has been installed correctly.
- Source the Setup File:
source /opt/ros/<distro>/setup.bash
This ensures your environment is configured for ROS 2.
- Run RViz:
ros2 run rviz2 rviz2
If RViz launches successfully, you will see its graphical interface with a 3D visualization window, a panel for Displays, and other UI components.
Step 4: Resolve Common Issues
If you encounter issues, check the following:
-
Ensure Dependencies Are Installed: Install dependencies such as Qt and OpenGL libraries. Use the following commands:
sudo apt install qtbase5-dev
sudo apt install libgl1-mesa-dev -
Fix Missing Source: Ensure that the setup.bash file is sourced every time a terminal is opened. Add the following line to your ~/.bashrc:
source /opt/ros/<distro>/setup.bash
-
Verify ROS 2 Environment: Check the ROS_DISTRO variable:
echo $ROS_DISTRO
Ensure it matches the version you installed.
-
Check for Updates: Update and upgrade your system to ensure compatibility:
sudo apt update
sudo apt upgrade
Step 5: Optional: Build RViz from Source
If you want to customize RViz or use an experimental version, you can build it from source.
-
Set Up a Workspace:
mkdir -p ~/rviz_ws/src
cd /rviz_ws
-
Clone the RViz Source Code:
git clone https:/\/github.com/ros2/rviz.git src/rviz
-
Install Dependencies:
sudo apt update
rosdep install --from-paths src --ignore-src -r -y
-
Build the Workspace:
colcon build
-
Source the Workspace:
source install/setup.bash
-
Run RViz:
ros2 run rviz2 rviz2
For more information, visit https://wiki.ros.org/rviz/UserGuide .