tips ros
- Ubuntu换源(通过软件和更新换源更简单)
- 备份文件:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
- 修改文件:sudo vi /etc/apt/sources.list,内容参考:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/ 以Ubuntu 18.04 LTS为例:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
添加ROS软件源
sudo sh -c '. /etc/lsb-release && echo "deb https://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" >> /etc/apt/sources.list.d/ros-latest.list'
添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
更新软件源
sudo apt update//相比于apt-get而言,apt是更新、更为推崇的命令,尽量用这个
- 安装ROS
sudo apt install ros-melodic-desktop-full
- 初始化rosdepc
sudo apt install python3-pip
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
添加环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential rosinstall也是ROS中的一个常用工具,可以下载和安装ROS中的功能包程序。
验证
roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key