(转)Ubuntu18.04 LTS安装ROS melodic和turtlebot3

28 篇文章 0 订阅

注意,本教程只针对默认设置,例外选项请查看官方源指导!

1.安装Ubuntu18.04 LST(过程略)
2.安装ROS melodic
参考来源:http://wiki.ros.org/melodic/Installation/Ubuntu

2.1.设置源列表
将计算机设置为接受来自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.2设置密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

2.3更新源
sudo apt update

 如果是刚完成安装的系统,并且需要安装turtlebot,建议此处先安装git,然后在执行2.4时同时执行3.2,以节省时间

sudo apt install git

2.4桌面环境完全安装(推荐)
包含ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators 和 2D/3D perception 等

如果你需要安装turtlebot3,建议可以跳到3.1,跑完3.1再回来继续2.5,你会感谢我为你节省一次盯着屏幕的时间的~ XD

sudo apt install ros-melodic-desktop-full (和安装kinetic的差异在这里)

2.5初始化ROS依赖
在使用ROS之前,您需要初始化rosdep。rosdep使您能够轻松安装要编译的源的系统依赖项,并且需要在 ROS 中运行一些核心组件。

sudo rosdep init

rosdep update

2.6环境设置
如果每次启动新 shell 时 ROS 环境变量都自动添加到 bash 会话中,则这很方便。在这一步,我们需要将 source /opt/ros/melodic/setup.bash 语句添加到位于/home/user/.bashrc的配置文件中,有以下两种方式:

命令行:echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

图形界面:使用VScode、gedit或者其它文本编辑器打开.bashrc(注意,这个是隐藏文件,需要显示隐藏文件才可以看到),然后将source /opt/ros/melodic/setup.bash这一句添加到文件末尾。

更加全面地设置可以如下所示:

# Set ROS Melodic 注意,~/catkin_ws/devel/setup.bash文件在catkin_make编译后才会产生

source /opt/ros/melodic/setup.bash 

source ~/catkin_ws/devel/setup.bash

# Set ROS Network 注意,此处ROS_HOSTNAME为此计算机在局域网中的IP地址,ROS_MASTER_URI为主节点在局域网中的IP地址,均可设置为环回地址localhost,可以视需要而设定在不同的计算机上

export ROS_HOSTNAME=xxx.xxx.xxx.xxx

export ROS_MASTER_URI=http://xxx.xxx.xxx.xxx:11311

# Set ROS alias command 设置快捷命令

alias cw='cd ~/catkin_ws'

alias cs='cd ~/catkin_ws/src'

alias cm='cd ~/catkin_ws && catkin_make' 

 已打开的终端,需要更新配置文件:

source ~/.bashrc(本操作亦可以通过重新打开新的终端来完成)

 3安装turtlebot3及其依赖项
参考来源:http://emanual.robotis.com/docs/en/platform/turtlebot3/pc_setup/#install-dependent-ros-packages、ROS_Robot_Programming_CN.pdf(ROS机器人编程,turtlebot3官方教程PDF版本,提供中英文两个语言版本)

3.1安装依赖的包
(基本上就是将kinect搜索替换为melodic)

sudo apt install ros-melodic-desktop-full ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-gmapping ros-melodic-navigation ros-melodic-interactive-markers ros-melodic-turtlebot3-gazebo

注1:本命令事实上可以在2.4运行,直接把所有的都装完了。

注2:ros-melodic-turtlebot3-gazebo此项在Kinect的安装教程中没有,但是实际也在运行中依赖,需要安装

3.2下载turtlebot3的源码
3.2.1打开到工作空间-源文件文件夹(如果没建立的话请先建立该文件夹):
cd ~/catkin_ws/src/

3.2.2下载源码到~/catkin_ws/src/中
通过git clone的方式(此处,git clone可能会很慢,自行百度解决,关键是写hosts直接解析IP地址,IP分别是140.82.114.4 github.com 和199.232.5.194 github.global.ssl.fastly.net):

git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git

git clone https://github.com/ROBOTIS-GIT/turtlebot3.git

git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git

或者在网页端下载压缩文件到相应路径下解压亦可

3.2.3编译:
打开到catkin_ws路径并编译:

cd ~/catkin_ws && catkin_make

3.3设置turtlebot相关的bashrc配置
在.bashrc文件中设置turtlebot3机器人构型,免去后续每次运行前的设置。构型为burger、waffle或waffle pi,根据自己手头机型设置

export TURTLEBOT3_MODEL=burger
————————————————
版权声明:本文为CSDN博主「ZWYZG」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ZWYZG/article/details/103208467

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值