ubuntu 20.04/22.04 apt非源码安装ros1 noetic

教程 https://zhuanlan.zhihu.com/p/679914618?utm_id=0

安装前环境

无论什么系统,我都会创建一个conda环境再安装ros, 避免ros安装的py包与系统混在一起。

ubuntu20.04安装ros1 noetic

很简单,wget http://fishros.com/install -O fishros && . fishros
根据提示输入数字选择即可。

ubuntu22.04安装ros1 noetic

添加源

echo "deb [trusted=yes arch=amd64] http://deb.repo.autolabor.com.cn jammy main" | sudo tee /etc/apt/sources.list.d/autolabor.list
sudo apt update

安装sudo apt install ros-noetic-autolabor

我遇到无法连接到 cn.archive.ubuntu.com的问题,通过修改源解决:

  • 编辑文件/etc/apt/sources.list
  • 将所有的cn.archive.ubuntu.com替换为mirrors.aliyun.com
  • 然后sudo apt update
  • 然后修复安装sudo apt install ros-noetic-autolabor --fix-missing

安装后配置

安装成功:

正在设置 libglvnd-dev:amd64 (1.4.0-1) ...
正在设置 libqt5webkit5-dev:amd64 (5.212.0~alpha4-15ubuntu1) ...
正在设置 libglew-dev:amd64 (2.2.0-4) ...
正在设置 tk-dev:amd64 (8.6.11+1build2) ...
正在设置 libpango1.0-dev:amd64 (1.50.6+ds-2ubuntu1) ...
正在设置 qttools5-dev:amd64 (5.15.3-1) ...
正在设置 libegl1-mesa-dev:amd64 (23.2.1-1ubuntu3.1~22.04.2) ...
正在设置 qttools5-private-dev:amd64 (5.15.3-1) ...
正在设置 libgtk-3-dev:amd64 (3.24.33-1ubuntu2.1) ...
正在设置 libvtk9-dev (9.1.0+really9.1.0+dfsg2-3build1) ...
正在设置 libvtk9-qt-dev:amd64 (9.1.0+really9.1.0+dfsg2-3build1) ...
正在设置 libpcl-dev (1.12.1+dfsg-3build1) ...
正在设置 ros-noetic-autolabor (1.0) ...
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting catkin_tools
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/26/8c/51b1ab2933f193bb8195b67926f3b40523218ddf56de6cea4fae05d0f7a1/catkin_tools-0.9.4-py3-none-any.whl (225 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 225.4/225.4 KB 680.8 kB/s eta 0:00:00
Collecting osrf-pycommon>0.1.1
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e6/39/b5ff4cc46f5e87016eb3df981132adf26bdb30327dee6e5b752307e7add8/osrf_pycommon-2.0.2-py3-none-any.whl (36 kB)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from catkin_tools) (59.6.0)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from catkin_tools) (5.4.1)
Requirement already satisfied: catkin-pkg>=0.3.0 in /usr/lib/python3/dist-packages (from catkin_tools) (0.4.24)
Installing collected packages: osrf-pycommon, catkin_tools
  WARNING: The script catkin is installed in '/home/USER/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed catkin_tools-0.9.4 osrf-pycommon-2.0.2
ros-noetic-autolabor installed.

根据最后的提示,需要添加PATH:export PATH=~/.local/bin:$PATH

另外, 我使用catkin build时提示

  • 找不到No module named 'catkin_pkg',可能是因为我安装和使用的时候都处于conda环境中。解决的话:pip install catkin_pkg
  • 找不到empy, 同样pip install

验证安装

打开一个新的控制台 ,执行roscore

再打开另一个新的控制台rosrun rviz rviz

如果看到 rviz 已经成功启动了,意味着已经安装成功,

  • ros 会被安装在 /opt/ros/noetic 目录下,并且会在~/.bashrc 中添加 source /opt/ros/noetic/setup.bash 的引用
  • 这个版本包含了完整的 ros desktop full, navgation 以及对 gazibo 的支持,比较全,无需像官方的一个个包单独安装。

创建工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/

初始化工作空间

catkin init

创建一个Package

cd src

使用 catkin create 创建一个名为my_package 的包,依赖于roscpp , std_msgs

catkin create pkg my_package roscpp std_msgs

编译工作空间

cd ~/catkin_ws
catkin build

应无error:
Finished  <<< catkin_tools_prebuild                [ 0.6 seconds ]                                                        
Starting  >>> my_package                                                                                                  
Starting  >>> roscpp                                                                                                      
Starting  >>> std_msgs                                                                                                    
Finished  <<< my_package                           [ 0.9 seconds ]                                                        
Finished  <<< roscpp                               [ 0.9 seconds ]                                                        
Finished  <<< std_msgs                             [ 0.9 seconds ]                                                        
[build] Summary: All 4 packages succeeded!                                                                                
[build]   Ignored:   None.                                                                                                
[build]   Warnings:  1 packages succeeded with warnings.                                                                  
[build]   Abandoned: None.                                                                                                
[build]   Failed:    None.                                                                                                
[build] Runtime: 1.6 seconds total.                                                                                       
[build] Note: Workspace packages have changed, please re-source setup files to use them.

单独编译包

cd ~/catkin_ws/src/my_package

catkin build --this

卸载

sudo apt remove ros-noetic-autolabor

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值