Install
1.Set the installation source
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2.Set key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3.Installation
sudo apt update
sudo apt install ros-melodic-desktop-full
//tips:ubuntu18安装melodic;ubuntu20是noetic
//卸载命令:sudo apt remove ros-noetic-*
//解决
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bk
sudo mkdir /var/lib/dpkg/info
sudo apt-get update
sudo apt-get install -f
sudo apt-get install ros-melodic-desktop-full
4. Configure environment variables
//ubuntu20版本
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
//ubuntu18版本
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5. Install build dependencies
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo apt install python3-rosdep
6.Initialization
sudo rosdep init
rosdep update
rosdep exception solution:
1. Enter "/usr/lib/python3/dist-packages/" to find content related to raw.githubusercontent.com
in rosdep and call the command:
find . -type f | xargs grep "raw.githubusercontent"
2. Modify the contents of four files
sudo gedit /rosdistro/__init__.py
sudo gedit ./rosdep2/gbpdistro_support.py
sudo gedit ./rosdep2/sources_list.py
sudo gedit ./rosdep2/rep3.py
文件中涉及的 URL 内容,如果是:raw.githubusercontent.com/ros/rosdistro/master都替换成步骤1中准备的gitee.com/zhao-xuzuo/rosdistro/raw/master即可。
3. Re-sudo rosdep init+rosdep update
If you encounter this, it means the modification was successful.
Turtle test
ROS has some built-in small programs that can be run to check whether the ROS environment can run normally.
-
First start three command lines (ctrl + alt + T)
-
Command line 1 type:roscore
-
Command line 2 type:rosrun turtlesim turtlesim_node(The graphical interface will pop up)
-
Command line 3 type:rosrun turtlesim turtle_teleop_key(In 3, you can control the movement of the turtle in 2 by up, down, left and right)