Install different versions of ubuntu systems in Linux
1 Install virtual machine
Note: When installing a virtual machine system, please install Ubuntu 20.04 version of the system. The installation method is consistent with ubuntu 18.04.
To install different versions of Ubuntu systems in Linux, please refer to the 6.2 ROS1 Environment Building chapter for specific installation methods.
2 ROS2 environment construction
2.1 ROS2 installation
To build a basic development environment, you need to install the robot operating system ROS2 and the git version manager. The installation methods and processes are introduced below.
2.1.1 Version selection
There is a one-to-one correspondence 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 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. The system we choose here is 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
2.1.2 Start installation
1 Add source
There is no ROS2 software source in Ubuntu's own software source list, so you need to first configure the ROS2 software source into the software list warehouse before you can download ROS2. Open a console terminal (shortcut key Ctrl+Alt+T) and 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 choose 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 Set the secret key
Configure the public network key. This step is to let the system confirm that our path is safe, so that there will be 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 a new software source, you need to update the software source list and open a console terminal (shortcut keys Ctrl+Alt+T< /kbd>), enter the following command:
sudo apt-get update
Execute Install ROS2, open a console terminal (shortcut key Ctrl+Alt+T), please follow your own Ubuntu version Choose to enter the following commands:
# 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 you need to wait patiently
After the installation is complete, refresh the environment variables:
source /opt/ros/foxy/setup.bash
2.1.3 Set up ros2 environment
In order to avoid the need to re-validate the ROS2 function path every time we close the terminal window, we can configure the path into the environment variable, so that the ROS2 function path can be automatically valid every time a new terminal is opened. In the terminal Execute the following commands in sequence, open a console terminal (shortcut key Ctrl+Alt+T) and execute the following corresponding version of the command:
# Ubuntu 20.04 foxy version
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
Then run:
source ~/.bashrc
Install ROS2 additional dependencies
Enter the following command in the terminal Install ROS2 additional dependencies 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
2.1.4 Verify installation
In order to verify whether ROS2 is 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 is successfully installed.
2.2 git installation
1 Update 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
2 Install 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 Verify installation
Read the git version, open a console terminal (shortcut key Ctrl+Alt+T), enter the following in the terminal window Order:
git --version
The git version number can be displayed in the terminal, as shown below, which means the installation is successful.
2.3 mycobot_ros2 installation
mycobot_ros2
is a ROS2 package launched by ElephantRobotics that is adapted to its desktop six-axis robotic arm mycobot series.
Project address: http://github.com/elephantrobotics/mycobot_ros2
1 Prerequisite
Before installing the package, make sure you have a ros2 workspace.
Here we give Sample command to create a workspace, open a console terminal (shortcut key Ctrl+Alt+T ), enter the following command on the command line:
mkdir -p ~/colcon_ws/src # Create folder
cd ~/colcon_ws
colcon build # Compile workspace
Add workspace environment
The official default ROS2 workspace is colcon_ws
.
echo "source ~/colcon_ws/install/setup.bash" >> ~/.bashrc
source ~/.bashrc
2 Installation
NOTE:
- This package depends on ROS2 and MoveIT2. Make sure ROS2 is successfully installed before use.
- The interaction between this package and the real robot arm relies 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 according to the prompts to install pip
sudo apt install python3-pip
After the pip installation is completed, 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 https://github.com/elephantrobotics/mycobot_ros2.git
cd ~/colcon_ws # Return to the workspace
colcon build --symlink-install # Build the code in the workspace, --symlink-install: avoid the need to recompile every time you adjust the python script
source install/setup.bash #Add environment variables
At this point, the ROS2 environment is set up. You can learn [Basic knowledge of ROS2] (11.2.2-ROS2_Basics.md) or [ROS2 use cases] (11.2.4-BasicFunction.md)