Ubuntu 18.04安装ROS Melodic

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/muyuyuzhong/article/details/83190230

设置sources.list

设置源(目前找到的能够正常下载的源)

sudo sh -c ' echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

设置密钥

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

如果遇到连接到密钥服务器的问题,可以尝试在前面的命令中替换hkp://pgp.mit.edu:80 或 hkp://keyserver.ubuntu.com:80。

安装

首先,确保Debian软件包目录索引是最新的:

sudo apt-get update

ROS中有许多不同的库和工具。我们提供了四种默认配置来帮助入门,也可以单独安装ROS软件包。

  • 桌面完整安装:(推荐):ROS,rqt,rviz,机器人通用库,2D / 3D模拟器,导航和2D / 3D感知
sudo apt-get install ros-melodic-desktop-full
  • 桌面安装: ROS,rqt,rviz和机器人通用库
 sudo apt-get install ros-melodic-desktop
  • ROS-Base:(Bare Bones) ROS包,构建和通信库。没有GUI工具。
sudo apt-get install ros-melodic-ros-base
  • 独立软件包:您也可以安装特定的ROS软件包(用下划线替换下划线):
sudo apt-get install ros-melodic-PACKAGE

例如

sudo apt-get install ros-melodic-slam-gmapping

要查找可用包,请使用:

apt-cache search ros-melodic

漫长的等待之后就完成了,但这时还需要一些收尾工作

sudo rosdep init
rosdep update

设置环境变量

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

到这里就安装完成了,为了实验,可以输入以下命令,出现以下的内容就成功了

lqf@ubuntu:~$ roscore 
... logging to /home/lqf/.ros/log/1d089194-d40f-11e8-a539-000c293f82a0/roslaunch-ubuntu-78385.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:46135/
ros_comm version 1.14.3


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.3

NODES

auto-starting new master
process[master]: started with pid [78395]
ROS_MASTER_URI=http://ubuntu:11311/

setting /run_id to 1d089194-d40f-11e8-a539-000c293f82a0
process[rosout-1]: started with pid [78406]
started core service [/rosout]

构建软件包的依赖关系

到目前为止,已经安装了运行核心ROS软件包所需的内容。要创建和管理ROS工作区,有各种工具和需求分开分发。例如,rosinstall是一个经常使用的命令行工具,它使您能够使用一个命令轻松下载ROS软件包的许多源代码树。

要安装此工具和其他依赖关系来构建ROS软件包,请运行:

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

实战

第一个ROS例程-小乌龟(turtle)仿真

  • 先安装turtlesim
sudo apt-get install ros-melodic-turtlesim

如果报错

Could not get lock /var/cache/apt/archives/lock

则先

sudo rm -rf /var/cache/apt/archives/lock 
sudo apt-get update

再继续安装

  • 启动roscore
roscore
  • 新开一个终端启动可视化仿真器
rosrun turtlesim turtlesim_node

刚启动的小乌龟

  • 再开一个终端启动控制终端
rosrun turtlesim turtle_teleop_key

左右键头,上下箭头随意操作下,就可以看到小乌龟在动了。
在这里插入图片描述

参考

https://blog.csdn.net/zhangrelay/article/details/80241758
https://blog.csdn.net/ZhangRelay/article/details/80104329?utm_source=blogxgwz0

猜你喜欢

转载自blog.csdn.net/muyuyuzhong/article/details/83190230