1. ros安装
- 安装过程参考https://www.cnblogs.com/letisl/p/11815191.html
- 安装wsl略,利用mobaxterm进行连接与可视化
1.1. 添加源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
1.2. 添加私钥
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
打不开则:
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 0xB01FA116
1.3. 更新软件列表
sudo apt-get update
,会报GPG错误,解决办法是添加公钥:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
1.4. 安装ros
sudo apt-get install ros-melodic-desktop-full
安装目录在/opt/ros下。
1.5. 初始化
sudo rosdep init
rosdep update
1.5.1. 问题1
提示:sudo rosdep:找不到命令提示
,执行下面指令:
sudo apt install python-rosdep
1.5.2. 问题2
提示:ERROR: cannot download default sources list from: https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list Website may be down.
- 根本解决办法:(国产镜像)https://blog.csdn.net/qq_44938606/article/details/120968180
- 解决办法1:
打开https://site.ip138.com/raw.Githubusercontent.com/
,输入raw.githubusercontent.com查询出一个可用的ip地址,然后在/etc/hosts文件最后添加:
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
结果可能不行,此时参考方法2. - 解决办法2:
a.利用FQ特殊手段(可以直接拷贝此处的链接),打开链接https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,拷贝其中的内容:
#os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
b.创建目录,新建文件20-default.list,将内容拷贝到文件中
sudo mkdir -p /etc/ros/rosdep/sources.list.d
touch /etc/ros/rosdep/sources.list.d/20-default.list
c.执行rosdep update
1.6. 环境变量配置
放到~/.bashrc文件最后
source /opt/ros/melodic/setup.bash
然后执行source ~/.bashrc
1.7. 安装rosinstall
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
安装ros插件sudo apt install ros-melodic-jsk-rviz-plugins
1.8. 测试小乌龟
- 启动roscore
roscore &
rosrun turtlesim turtlesim_node
1.9. 测试rviz
rosrun rviz rviz
,发现报段错误,需要将export LIBGL_ALWAYS_INDIRECT=
添加到.bashrc文件最后。
1.10. 卸载ros
sudo apt-get remove ros-melodic-*
1.11. 注意注意
建议启动新的节点时,将roscore重启一下,防止莫名其妙的错误!!