ros源
sudo apt update
# 官方源
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'
ros密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
ros依赖
sudo apt install build-essential
sudo apt install libvtk6-jni libvtk6-java libvtk6-dev libvtk6-qt-dev libpcl-dev
sudo apt install ros-melodic-pcl-conversions ros-melodic-pcl-ros ros-melodic-perception-pcl ros-melodic-perception
sudo apt install python-rosdep
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool
ros按装
Ubuntu18.04对应的是melodic的版本 其他版本就会报错,出现无法定位软件包的情况
注意 ros版本 后续设环境变量要用到
# 安装ROS
sudo apt install ros-melodic-desktop-full
# 初始化ROS (若报错,请参考异常问题1)
sudo rosdep init
# 更新ROS (若报错,请参考异常问题2)
rosdep update
# 设置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
rosdep按装 建议按装国内rosdepc
不同版本的ROS,安装rosdep的命令有所区别
ROS Melodic and earlier
sudo apt-get install python-rosdep
ROS Noetic
sudo apt-get install python3-rosdep
rosdep初始化
sudo rosdep init
rosdep update
rosdep异常报错解决
ros设置环境变量 ctrl+h 才能显示
noetic版
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
melodic版
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
一般是处于隐藏状态,需要按住“ctrl+h”才能显示。添加的变量位于该文件的最后一行
验证ros
roscore
ros权限修改
sudo chmod 777 -R ~/.ros/
退出ros ctrl+c
安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential