ubuntu安装ROS
参考文章:http://wiki.ros.org/noetic/Installation/Ubuntu
1.设置ubuntu接受来自packages.ros.org的安装
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2.设置keys
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
(注意:这一步可能需要梯子)
3.更新Debian包
sudo apt update(一定要执行该命令,不然会导致下一步报错:无法定位软件包 ros-noetic-desktop-full)
4.安装ROS
sudo apt install ros-noetic-desktop-full
5.构建软件包的依赖关系
创建和管理自己的 ROS 工作区,还需要各种单独分发的工具和要求。例如,rosinstall 是一个常用的命令行工具,只需一条命令就能轻松下载许多 ROS 软件包的源代码树。
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
6.初始化rosdep
sudo apt install python3-rosdep
sudo rosdep init
rosdep update
执行sudo rosdep init出现ERROR: cannot download default sources list from报错
参考:https://blog.csdn.net/luoluonuoyasuolong/article/details/128999527
https://gitee.com/ncnynl/rosdep/tree/master#https://gitee.com/link?target=https%3A%2F%2Fwww.ncnynl.com%2Farchives%2F202109%2F4549.html
https://www.ncnynl.com/archives/202109/4549.html
参考:https://www.guyuehome.com/12640
sudo passwd //接着提示输入UNIX密码,输入你的用户密码即可
sudo su //或者su root 然后输入密码切换至root用户
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
该文件存在目录:/etc/ros/rosdep/sources.list.d/20-default.list
解决方法:
1.首先点击https://www.ncnynl.com/archives/202109/4549.html将文件下载下来解压,更改rosdep_update.sh文件中的代理地址,原来的地址是ghproxy_url=https://ghproxy.com
更改为ghproxy_url=https://http://127.0.0.1:7891然后保存(当然你们需要根据自己的代理更改,后面的4位数的端口不一定相同)
2.在该目录下打开终端输入su进入root权限运行rosdep_update.sh
./rosdep_update.sh
3.然后输入初始化命令
sudo rosdep init
4.然后运行rosdep_recover.sh
./rosdep_recover.sh
5.执行以下命令
rm update_rosdep_tsinghua.sh ; wget https://gitee.com/ncnynl/rosdep/raw/master/update_rosdep_tsinghua.sh ; sudo chmod +x ./update_rosdep_tsinghua.sh; sudo ./update_rosdep_tsinghua.sh
6.之后就能直接输入rosdep update进行更新了。
更新完后配置环境变量
echo “source /opt/ros/noetic/setup.bash”>> ~/.bashrc #noetic就算你下的ROS版本,一定要对应自己下的ROS版本,弄错的话运行下面命令会报错显示找不到该目录
source ~/.bashrc
最后输入
roscore
出现以下界面则安装成功