1. 程式人生 > 其它 >Ubuntu 18.04 melodic安裝ROS

Ubuntu 18.04 melodic安裝ROS

技術標籤:ROS

在Ubuntu18.04下安裝Ros-melodic
參考連線:官網連線
ROS包:https://github.com/IntelRealSense/realsense-ros
Ros-melodic安裝: http://wiki.ros.org/melodic/Installation/Ubuntu

1.1配置Ubuntu儲存庫

1.2設定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'

1.3 set up your keys:新增金鑰

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

1.4 Installation更新

sudo apt update

1.5 桌面完整安裝

a: Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators and 2D/3D perception:

sudo apt install ros-melodic-desktop-full

若此時執行出錯: Unmet dependencies. Try ‘apt --fix-broken install’ with no packages (or specify a solution).

sudo apt --fix-broken install

b: Desktop Install: ROS, rqt, rviz, and robot-generic libraries

sudo apt install ros-melodic-desktop

c: ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.

sudo apt install ros-melodic-ros-base

d: Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):

sudo apt install ros-melodic-PACKAGE

e.g.

sudo apt install ros-melodic-slam-gmapping

1.6 Environment setup:環境變數

a: If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

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

b: If you just want to change the environment of your current shell, instead of the above you can type:

source /opt/ros/melodic/setup.bash

c: If you use zsh instead of bash you need to run the following commands to set up your shell:

echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc

1.7 Dependencies for building packages:

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

1.8 Initialize rosdep:

sudo apt install python-rosdep
sudo rosdep init
rosdep update

在這裡插入圖片描述
執行出錯sudo rosdep init
解決:

#開啟hosts檔案
sudo gedit /etc/hosts
#在檔案末尾新增
151.101.84.133  raw.githubusercontent.com

1.9 測試

在終端執行

roscore