OS: Ubuntu22.04
ROS2 version: Humble
Install ROS2
1. Run the command: sudo apt update && sudo apt install locales
2. Set the language environment, and run the command:
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
3. Check the language environment, run Locale to confirm the language is UTF-8.
4. Authorize the GPG key with apt, run the command: sudo apt update && sudo apt install curl gnupg2 lsb-release
5. Run the command: sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
If the command fails: manually download the file from https://raw.githubusercontent.com/ros/rosdistro/master/ros.key, rename it to ros-archive-keyring.gpg, and save it to the /usr/share/keyrings/ directory.
6. Then add the library to the source code list:
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
7. Update apt repository cache, run the command: sudo apt update
8. Install the full version of ROS2, run the command: sudo apt install ros-humble-desktop -y
9. Set the environment variables, run the command:
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc