Environment Installation

M5 Version:

Note:When installing the virtual machine system, please install the Ubuntu 20.04 version of the system. The installation method is the same as Ubuntu 18.04.

To install different versions of Ubuntu systems in Linux, please refer to the Environment Construction section.

ROS2 Environment Construction

ROS2 Installation

The basic development environment construction requires the installation of the robot operating system ROS2 and the git version manager. The following describes their installation methods and processes respectively.

For myCobot 280-M5, myCobot 320-M5, myPalletizer 260-M5 and mechArm 270-M5 devices, please refer to the following installation methods and processes.

myCobot 280-PI, myCobot 320-PI, myPalletizer 260-PI and mechArm 270-PI devices only need to execute the mycobot_ros2 installation package.

Version selection

ROS2 has a one-to-one correspondence with Ubuntu. Different versions of Ubuntu correspond to different versions of ROS2. For reference, see the following website: 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 versions are different, the download will fail. Here we choose Ubuntu 20.04 (recommended), and the corresponding ROS2 version is ROS2 Foxy

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

Start installation

1 Add source

There is no ROS2 in the software source list of Ubuntu itself Software source, so you need to first configure the ROS2 software source to the software list warehouse before you can download ROS2. Open a console terminal (shortcut key Ctrl+Alt+T), enter the following command:

  • 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 mirror source nearby to replace the above command. For example, Huawei Cloud is:
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 the key

Configure the public network key, this step is to let the system confirm that our path is safe, so that there is no problem downloading the file, otherwise it 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 the new software source, you need to update the software source list, open a console terminal (shortcut key Ctrl+Alt+T), and enter the following command:

sudo apt-get update

Execute install ROS2, open a console terminal (shortcut key Ctrl+Alt+T), please enter the following command 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, please wait patiently

After the installation is complete, refresh the environment variables:

source /opt/ros/foxy/setup.bash

1.1.3 Set up 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 can be automatically validated every time a new terminal is opened. Execute the following commands in the terminal in sequence, open a console terminal (shortcut key Ctrl+Alt+T) and execute the following commands:

# Ubuntu 20.04 foxy version
# Add the ros environment to the environment variables 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 in the terminal Install ROS2 additional dependencies, open a console terminal (shortcut Ctrl+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

Verify installation

To verify ROS2 To check whether the installation is successful, open a console terminal (shortcut key Ctrl+Alt+T), and execute the following command in the terminal:

ros2

When the following interface is displayed, it means that ROS2 is installed successfully

2 git installation

3.1 Update the software source list

Open a console terminal (shortcut key Ctrl+Alt+T), and enter the following command in the terminal window to update the software source list:

sudo apt-get update

3.2 Installation git

Open a console terminal (shortcut key Ctrl+Alt+T), enter the following command in the terminal window, execute git installation:

sudo apt-get install git

3.3 Verify installation

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

git --version

The git version number can be displayed in the terminal, as shown below, which means the installation is successful.

3 mycobot_ros2 installation

mycobot_ros2 is a ROS2 package launched by ElephantRobotics, which is compatible with its desktop six-axis robot arm mycobot series.

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

3.1 Prerequisites

Before installing the package, please ensure that you have a ros2 workspace.

Here we give sample commands for creating a workspace. Open a console terminal (shortcut key Ctrl+Alt+T), and enter the following command in the command line:

mkdir -p ~/colcon_ws/src # Create a folder

Add workspace environment

The official default ROS2 workspace is colcon_ws.

echo "source ~/colcon_ws/install/setup.bash" >> ~/.bashrc
source ~/.bashrc

3.2 Installation

NOTE:

  • This package depends on ROS2 and MoveIT2. Make sure to install ROS2 and MoveIT2 successfully before using it.
  • The interaction between this package and the real robot arm depends on PythonApi - pymycobot
  • The Api project is: https://github.com/elephantrobotics/pymycobot
  • Quick installation: pip install pymycobot --upgrade

When executing the pip install pymycobot --upgrade command, if the following error message appears:

Enter the following command to install pip according to the prompt

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 pip is installed, execute it again in the terminal
pip install pymycobot --upgrade
  • The installation method depends on Git, please make sure Git is installed on your computer.

The official default ROS2 workspace is colcon_ws.

cd colcon_ws/src # Enter the src folder in the workspace
# Clone the code on github
git clone --depth 1 https://github.com/elephantrobotics/mycobot_ros2.git
cd .. # Return to the workspace
colcon build --symlink-install # Build the code in the workspace, --symlink-install: avoid recompiling every time you adjust the python script
source install/setup.bash # Add environment variables

1 Update the mycobot_ros2 package

To ensure that users can use the latest official package in a timely manner, you can enter the /home/er/colcon_ws/src folder through the file manager, open the console terminal (shortcut Ctrl+Alt+T), and enter the following command to update:

# Clone the code on github
cd colcon_ws/src # Enter the src folder in the workspace
# Clone the code on github
git clone --depth 1 https://github.com/elephantrobotics/mycobot_ros2.git
cd .. # Return to the workspace
colcon build --symlink-install # Build the code in the workspace, --symlink-install: avoid recompiling every time you adjust the python script
source install/setup.bash # Add environment variables

Note: If the mycobot_ros2 folder already exists in the /home/er/colcon_ws/src (equivalent to ~/colcon_ws/src) directory, you need to delete the original mycobot_ros2 first, and then execute the above command. Among them, er in the directory path is the system user name. If there is any inconsistency, please modify it.

At this point, the ROS2 environment has been set up. For the use of ROS2, please refer to Rviz Introduction and Usage.

results matching ""

    No results matching ""