Environment installation

Note:To install different versions of ubuntu system in Linux, refer to ROS1 Environment Construction section

1 ROS2 Installation

1.1 ROS2 Installation

The basic development environment requires the installation of robot operating systems ROS2, MoveIt2 and git version managers. The installation methods and processes are described below.

For ultraArm equipment, refer to the installation method and process described below.

1.1.1 Version selection

ROS2 has a one-to-one correspondence with ubuntu. Different versions of ubuntu correspond to different versions of ROS2. See the following website for reference:http://docs.ros.org/en/foxy/Releases.html

Here are the ROS2 versions supported by Ubuntu:

ROS2 Version Release Date Maintenance Deadline Ubuntu Version
Foxy June 5, 2020 May 2023 Ubuntu 20.04(Focal Fossa)
Galactic May 23, 2021 November 2022 Ubuntu 20.04(Focal Fossa)
Humble May 23, 2022 May 2027 Ubuntu 22.04(Jammy Jellyfish)

Please install the corresponding ROS2 version according to the Ubuntu version you installed

If the version is different, the download will fail. The system we choose here is Ubuntu 20.04 (recommended), and the corresponding ROS2 version is ROS2 Foxy

NOTE: At present, we do not provide any reference for installing ROS2 in Windows. If necessary, please refer to http://docs.ros.org/en/foxy/Installation/Alternatives/Windows-Development-Setup.html

1.1.2 Start Installation

1 Add Source

There is no ROS2 software source in the Ubuntu software source list, so you need to configure the ROS2 software source to the software list repository before downloading ROS2.open a console terminal(shotcutCtrl+Alt+T), and enter the following commands:

  • Official source:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
  • If the download speed is slow, it is recommended to select a nearby image source to replace the above command。For example,like huawei cloud:
echo "deb [arch=$(dpkg --print-architecture)] https://repo.huaweicloud.com/ros2/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
2 Set secret key

Configure public key,this step is to let the system confirm that our path is safe, so that there is no problem downloading files, otherwise they will be deleted immediately after downloading:

sudo apt install curl gnupg2 -y
curl -s https://gitee.com/ohhuo/rosdistro/raw/master/ros.asc | sudo apt-key add -
3 Installation

After adding a new software source, you need to update the software source list , open a console terminal(shotcutCtrl+Alt+T),enter the following command:

sudo apt-get update

Perform ROS2 installation and open a console terminal(shotcutCtrl+Alt+T),please select and enter the following commands according to your Ubuntu version:

# Ubuntu 20.04 foxy Version
sudo apt install ros-foxy-desktop
# Ubuntu 20.04 galactic Version
sudo apt install ros-galactic-desktop
# Ubuntu 22.04 humble Version
sudo apt install ros-humble-desktop

The installation process takes a long time and requires patience

Refresh environment variables after installation:

source /opt/ros/foxy/setup.bash

1.1.3 Setting the ros2 environment

In order to avoid the need to re validate the ROS2 function path every time the terminal window is closed, we can configure the path to the environment variable, so that the ROS2 function path will automatically become effective every time a new terminal is opened. Execute the following commands in the terminal to open a console terminal(shotcutCtrl+Alt+T) to execute the following command:

# Ubuntu 20.04 foxy version
# Add the ros environment to the environment variable of the current console
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
# Ubuntu 20.04 galactic version
echo "source /opt/ros/galactic/setup.bash" >> ~/.bashrc
# Ubuntu 22.04 humble version
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc
Install ROS2 Additional Dependencies

Enter the following command at the terminal to install ROS2 additional dependencies, and open a console terminal(shotcutCtrl+Alt+T):

sudo apt install python3-argcomplete -y
sudo apt install ros-foxy-xacro
sudo apt-get install python3-colcon-common-extensions
# Ubuntu 20.04 foxy version
sudo apt install ros-foxy-joint-state-publisher-gui
# Ubuntu 20.04 galactic version
sudo apt install ros-galactic-joint-state-publisher-gui
# Ubuntu 22.04 humble version
sudo apt install ros-humble-joint-state-publisher-gui

1.1.4 Verify Installation

To verify whether ROS2 is successfully installed, open a console terminal(shotcutCtrl+Alt+T),execute the following commands on the terminal:

ros2

When the following interface is displayed, ROS2 installation is successful

2 MoveIt2 Installation

MoveIt2 is a function package of a series of mobile operations in ROS2, mainly including motion planning, collision detection, kinematics, 3D perception, operation control and other functions.

2.1 Update software source list

Open a console terminal(shotcutCtrl+Alt+T),enter the following command in the terminal window to update software source list

sudo apt-get update

2.2 Install MoveIt2

Open a console terminal(shotcutCtrl+Alt+T),enter the following command in the terminal window to implement installation of MoveIt2

# Ubuntu 20.04 foxy version
sudo apt-get install ros-foxy-moveit
# Ubuntu 20.04 galactic version
sudo apt-get install ros-galactic-moveit
# Ubuntu 22.04 galactic version
sudo apt-get install ros-humble-moveit

3 git Installation

3.1 Update software source list

open a console terminal(shotcutCtrl+Alt+T),enter the following command in the terminal window to update software source list

sudo apt-get update

3.2 install git

open a console terminal(shotcutCtrl+Alt+T),enter the following command in the terminal window,perform git installation:

sudo apt-get install git

3.3 Verify Installation

Read git version,open a console terminal(shotcutCtrl+Alt+T)enter the following command in the terminal window:

git --version

The git version number can be displayed on the terminal, as shown below, indicating that the installation is successful

4 mycobot_ros2 Installation

mycobot_ ROS2 is launched by Elephant Robotics, which is suitable for the ROS package of mycobot series of desktop six axis mechanical arm.

Project address:http://github.com/elephantrobotics/mycobot_ros2

4.1 Premise

Before installing the package, make sure you have the ros2 workspace.

Here we give a sample command for creating a workspace,open a console terminal(shotcutCtrl+Alt+T),enter the following command in the terminal window:

mkdir -p ~/colcon_ws/src  # Create folder

Add an environment for a workspace

In the following <ros 2-workspace>will be used to refer to the workspace path of ROS on the computer. The official default is colcon ws. Please ensure that<ros 2-workspace>is replaced with the real path of your local computer when executing the following command.

echo "source ~/<ros2-workspace>/install/setup.bash" >> ~/.bashrc
source ~/.bashrc

4.2 Installation

NOTE:

  • This package depends on ROS2 and MoveIT2. Before use, ensure that ROS2 and MoveIT2 are successfully installed.
  • The interaction between this package and the real mechanical arm depends on Python Api - pymycobot
  • Api project location:https://github.com/elephantrobotics/pymycobot
  • Quick installation:pip install pymycobot --upgrade

When executing the command pip install pymycobot -- upgrade, an error message as shown in the following figure appears:

At the prompt, enter the following command to install pip

  sudo apt install python-pip
  • If your Ubuntu system is version 20.04, please execute the command sudo apt install python3 pip to install pip.
  • After the pip installation is completed, the terminal will execute again

    pip install pymycobot --upgrade
    
  • The installation method depends on Git. Please ensure that Git is installed on your computer.

In the following,<ros2-workspace>will be used to refer to the workspace path of ROS2 in your computer.The official default is colcon.ws, Please ensure that you replace<ros2-workspace>with the real path of your computer when executing the following command.

cd ~/<ros2-workspace>/src  # Enter the src folder in the workspace
# Cloning code on github
git clone --depth 1 https://github.com/elephantrobotics/mycobot_ros2.git
cd ..       # Back to Workspace
colcon build --symlink-install # Building code in the workspace,--symlink-install:avoid recompiling every time you adjust python scripts
source install/setup.bash # Add environment variable

So far, ROS2 environment has been built, please refer to 12.2.3 Introduction and use of rviz section to use ros2

results matching ""

    No results matching ""