【Ubuntu 0】ubuntu与ROS安装系列

这个系列最开始是19年9月份自己第一次使用ROS 也是第一次使用ubuntu写的,很多都是前人用过的 然后帮我调试的过程中告诉我的,感觉所有的存在在这里的都是我不止一遍 用过的;十分OK,希望这个笔记能帮助到不少人 更便捷的使用Ubuntu
如果也有想分享的 可以留言 让更多人知道~
最新更新时间:2020/12/17

安装Ubuntu

下载镜像 & 制作启动盘

1.ubuntu官网中下载 自己想要的版本的.iso文件
或者是移步清华源中科大源进行镜像下载
官方的
在这里插入图片描述
清华源:
在这里插入图片描述
中科大源:在这里插入图片描述

2.下载Rufus 制作启动盘的软件
在这里插入图片描述
3.打开Rufus,选中要制作的U盘
在这里插入图片描述
在这里插入图片描述
完成后 就成了截图的样子【注意此步会格式化U盘内的所有东西!所有,请拿一个空盘制作】

安装ubuntu

安装完成第一步,修改源:

参考:USTC Mirror Help 中科大ubuntu源使用帮助

ubuntu 16.04

  1. CTRL+T打开终端:
sudo gedit /etc/apt/sources.list
  1. 复制以下:注意系统类别和amd64

中科大:

# 默认注释了源码仓库,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

阿里云:

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

ubuntu 18.04

  1. CTRL+T打开终端:sudo gedit /etc/apt/sources.list

  2. 复制以下:注意系统类别和amd64

阿里云:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

【不用管它】工控机上的备份:

# deb cdrom:[Ubuntu 18.04.2 LTS _Bionic Beaver_ - Release amd64 (20190210)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

更新源

  1. 更新源
sudo apt-get update
  1. 复损坏的软件包,尝试卸载出错的包,重新安装正确版本的。
sudo apt-get -f install

安装ROS!Woho

kinetic

  1. 添加ROS国内源:【这里使用的中科大源】
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. 添加秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  1. 确保软件更新为最新版本
sudo apt-get update

melodic

Woho 我终于自己写了一贴 (18.04的话) 参考资料:

  1. ubuntu18.04 LTS安装ROS图文教程
  1. 添加ROS国内源:【这里使用的中科大源】
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. 添加秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  1. 确保软件更新为最新版本
sudo apt-get update

在这里插入图片描述

  1. 下载ros【自己注意看版本不同秘钥可能也不同 这里的melodic 适用ubuntu-18.04】
sudo apt-get install ros-melodic-desktop-full
  1. 环境配置
    这是ROS自己的路径要添加
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

【对于自己的包环境配置,请参考下一节 关于turtlebot3_simulations的运行的第三步 设置环境变量】

最后

source ~/.bashrc
  1. 然后就
roscore

就可以看到成功运行啦~ 【这个我忘截图了 就拿参考资料里的人的吧】
在这里插入图片描述

  1. rosdep【可跳过,但是还是别跳了 毕竟之后走依赖rosdep install挺常见的】
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep

初始化rosdep,建议到这里先科学上网全局模式,然后再弄:

sudo rosdep init
rosdep update

如遇超时等问题,换个科学上网,或者修改以下:

#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133  raw.githubusercontent.com
#保存后退出再尝试

更多其他方法见:https://blog.csdn.net/weixin_39730025/article/details/113348458

  1. 小海龟
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

关于turtlebot3_simulations的运行

一共需要五个包+两个单独安装的 去运行成功
在这里插入图片描述
首先第一步:创建工作空间

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

第二步编译工作空间:

cd ~/catkin_ws
catkin_make

第三步设置环境变量 (在home 下 按CTRL+H显示隐藏文件 -> 打开 .bashrc 文件最后一行 请添加自己的(比如这里是catkin_ws)
或者是输入:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

在这里插入图片描述
第四步:下载五个包的git clone
cd ~/catkin_ws/src
为了加快git clone速度 我们从gitee上下载哈:(顺序随意 只要你都下载后!下载完5个加一个安装,再编译了即可)

  • turtlebot3_msgs:
git clone https://gitee.com/johnny095212/turtlebot3_msgs.git
  • move_base:
git clone https://gitee.com/DreamT-mac/move_base.git
  • navigation_msgs:
git clone https://gitee.com/baiywt/navigation_msgs.git
  • turtlebot3
git clone https://gitee.com/AXDHY/turtlebot3.git
  • turtlebot3_simulations
git clone https://gitee.com/fkgkdfgy/turtlebot3_simulations.git

clone完上面五个
如果直接catkin_make会出现以下的错误信息:
1.安装这个两个依赖包:
如果不安装直接catkin_make的话,会出现这样的错误信息

CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
Call Stack (most recent call first):

正确安装指令:

sudo apt-get install libsdl-image1.2-dev
sudo apt-get install libsdl-dev

2.安装ros-melodic-tf2-sensor-msgs
如果不安装直接catkin_make的话,会出现这样的错误信息

CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "tf2_sensor_msgs"
  with any of the following names:

    tf2_sensor_msgsConfig.cmake
    tf2_sensor_msgs-config.cmake

正确安装指令:

sudo apt-get install ros-melodic-tf2-sensor-msgs 

然后最后再

cd ~/catkin_ws
catkin_make

过程中:

见此画面 就完全成功了:

最后:

echo "export TURTLEBOT3_MODEL=waffle" >> ~/.bashrc

再次:

source ~/catkin_ws/devel/setup.bash

下面三条指令任意运行一个即可:【注意第三个运行需要等待很久 - 大概10分钟】

1.运行空世界:

roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch

2.运行有固定turtlebot3世界:

roslaunch turtlebot3_gazebo turtlebot3_world.launch

3.运行:

roslaunch turtlebot3_gazebo turtlebot3_house.launch

运行成功这个画面在这里插入图片描述
在上面任一一个运行后,开启另一个终端运行:

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

即可操控机器人运动

gazebo可遇问题:
Gazebo [Err] [REST.cc:205] Error in REST request
Gazebo error - [REST.cc:205] Error in REST request
This error can be solved by replacing url: https://api.ignitionfuel.org by url: https://api.ignitionrobotics.org inside the ~/.ignition/fuel/config.yaml file.

sudo gedit ~/.ignition/fuel/config.yaml

就在主Home CTRL+H下

安装可水平分割的terminal

sudo apt-get install terminator

常用快捷键:
Ctrl+Shift+O //水平分割终端
Ctrl+Shift+E //垂直分割终端
Ctrl+Shift+D //关闭当前终端
Alt+上下左右键盘 //在同一窗口下移动至不同的终端界面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Kin-Zhang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值