Environment Installation

M5 Version:

Notice: When installing the virtual machine system, please install the Ubuntu 20.04 version of the system, The installation method is consistent with ubuntu 18.04.

To install different versions of ubuntu system in Linux, please refer to 13.1.1 Environment Building chapter.

1 ROS Environment building

1.1 Installing ROS2

Building a basic development environment requires the installation of the robot operating system (short for ROS2), MoveIt2 and a git version manager. The installation methods and procedures are described respectively below.

For myCobot 280-M5myCobot 320-M5 devicesmyPalletizer 260-M5 and mechArm 270-M5, refer to the installation methods and procedures described below. For myCobot 280-PImyCobot 320-PImyPalletizer 260-PI and mechArm 270-PI devices, you only need to install the mycobot_ros installation package.

1.1.1 Selecting a version

There is a one-to-one relationship between ROS2 and ubuntu. Different versions of ubuntu correspond to different versions of ROS2. The reference website is as follows: http://docs.ros.org/en/foxy/Releases.html

Here are the ROS 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)

Install the ROS2 version corresponding to the Ubuntu version you have installed.

If the versions are different, the downloading will fail. The system we choose here is Ubuntu 20.04(recommend), so the corresponding ROS2 version is ROS2 Foxy.

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

1.1.2 Installing ROS

1 Adding a software source

There is no ROS2 software source in the software source list of Ubuntu itself, so you need to Configure the ROS software source into the software list repository first, and then download ROS2. Open a console terminal (shortcut key: Ctrl+Alt+T) and input 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 nearby mirror source 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 Setting a key

Configuring a public key. This step is to let the system confirm that our path is safe, so that there is no problem in 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 a new software source, you need to update the software source list. Open a console terminal (shortcut key: Ctrl+Alt+T) and input the following command:

sudo apt-get update

Execute Installing ROS2. Open a console terminal (shortcut key: Ctrl+Alt+T) and input 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, so please wait with patience.

Refresh environment variables after installation is complete:

source /opt/ros/foxy/setup.bash
1.1.3 Set up the ros2 environment

In order to avoid re-validating the ROS2 function path every time the terminal window is closed, we can set the path to an environment variable, so that each time you open a new terminal, the ROS2 function path will automatically take effect. Execute the following commands in sequence in the terminal, and open a console terminal (shortcut key: Ctrl+Alt+T):

Execute the following commands:

# Ubuntu 20.04 foxy version
# Add the ros2 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
Installing a ROS2 extra dependency

Input the following command in the terminal to install a ROS2 extra dependency, and open a console terminal (shortcut key: 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

1.1.4 Verify installation

To verify whether ROS2 has been installed successfully, 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 has been installed successfully.

2 MoveIt2 Installation

MoveIt2 is the composition of a series of function packages for movement operations in ros, mainly including motion planning, collision detection, kinematics, 3D perception, operation control and other functions.

2.1 Updating the software source list

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

sudo apt-get update

2.2 Installing MoveIt

Open a console terminal (shortcut key: Ctrl+Alt+T) and input the following command on the terminal window to execute the 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 Updating the software source list

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

sudo apt-get update

3.2 Installing git

Open a console terminal (shortcut key: Ctrl+Alt+T) and input the following command on the terminal window to execute the installation of git:

sudo apt-get install git

3.3 Verify installation

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

git --version

The git version number can be displayed in the terminal as follows, that is, the installation is successful.

4 mycobot_ros2 Installation

mycobot_ros2 is a ROS2 package launched by Elephant Robotics and applicable to its mycobot series of desktop six-axis robot arms.

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

4.1 Precondition

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

Here is an example command for creating a workspace. Open a console terminal (shortcut key: Ctrl+Alt+T) and input the following command in the command line:

# Create a folder
mkdir -p ~/colcon_ws/src  
# compile workspace
cd ~/colcon_ws
colcon build

Add workspace environment

The official default ROS2 workspace is colcon_ws.

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

4.2 Installation

NOTE:

  • This package depends on ROS2 and MoveIT2. Before using it, make sure that you have installed ROS2 and MoveIT2 successfully.
  • The interaction of this package with a real robot arm depends on PythonApi - pymycobot.
  • The Api project location 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 at 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 the pip installation is complete, the terminal executes again

    pip install pymycobot --upgrade
    
  • The installation method depends on Git, so make sure that Git have been installed in your computer.

The official default ROS2 workspace is colcon_ws.

cd ~/colcon_ws/src  # Enter the src folder of 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 having to recompile python scripts every time you adjust them
source install/setup.bash # add environment variables

PI Version

The Raspberry Pi version comes with an Ubuntu (V-20.04) system and a built-in development environment, so you don’t need to build and manage it, Just update the mycobot_ros2 package.

mycobot_ros2 is a ROS2 package launched by Elephant Robotics and applicable to its mycobot series of desktop six-axis robot arms.

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

Robotic arm API driver library address: https://github.com/elephantrobotics/pymycobot

1 Update the mycobot_ros2 package

In order to ensure that users can use the latest official package in time, they can go to the /home/er/colcon_ws/src folder through the file manager and open the console terminal (shortcut Ctrl+Alt+T ) , enter the following command to update:

# Clone the code on github
cd ~/colcon_ws/src
git clone https://github.com/elephantrobotics/mycobot_ros2.git # Please check the attention section below before deciding whether to execute this command
cd ..      # Back to work area
colcon build --symlink-install # Build the code in the workspace, --symlink-install: Avoid having to recompile python scripts every time you adjust them
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 before executing the above command. Among them, er in the directory path is the user name of the virtual machine. If it is inconsistent, please modify it.

So far, the ROS2 environment construction has been completed. Please refer to 13.2.3 Rviz Introduction and Use for the use of ROS2.

results matching ""

    No results matching ""