1.添加ROS软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
输入指令 :curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc后报错:
gpg: 找不到有效的 OpenPGP 数据。
解决办法
sudo cp /etc/hosts /etc/hosts.bak
sudo vim /etc/hosts
添加以下内容
185.199.108.133 raw.githubusercontent.com
2.安装ros
sudo apt install ros-melodic-desktop-full
输入指令:sudo apt install ros-melodic-desktop-full后报错:
下列软件包有未满足的依赖关系:
ros-melodic-desktop-full : 依赖: ros-melodic-desktop 但是它将不会被安装
依赖: ros-melodic-perception 但是它将不会被安装
依赖: ros-melodic-simulators 但是它将不会被安装
依赖: ros-melodic-urdf-sim-tutorial 但是它将不会被安装
解决方法:
不要关闭【软件和更新】里面的【更新】设置,全部通知。
3.初始化rosdep
sudo rosdep init
rosdep update
输入指令 :sudo rosdep init 后报错:
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize
解决方法
在终端执行下面的命令即可
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
4.设置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5.运行
5.1打开ros主节点
roscore
5.2打开小海龟节点
rosrun turtlesim turtlesim_node
5.3打开实时查看/turtle1/cmd_vel的信息
rostopic echo /turtle1/cmd_vel
5.4打开键盘控制小海龟
rosrun turtlesim turtle_teleop_key