Ubuntu18.04 安装ros

一、安装相关依赖库

sudo  apt-get  install  cmake gcc g++ git vim
sudo  apt-get  install  libglew-dev
sudo  apt-get  install  libboost-dev libboost-thread-dev 
sudo  apt-get  install  libboost-filesystem-dev
sudo  apt-get  install  libpython2.7-dev
sudo  apt-get  install  build-essential

二、安装pangolin v.05http://链接:https://pan.baidu.com/s/1ikq8GNpi9FQVKj9I_1KjTg 提取码:p9q2 --来自百度网盘超级会员V2的分享icon-default.png?t=M4ADhttp://链接:https://pan.baidu.com/s/1ikq8GNpi9FQVKj9I_1KjTg 提取码:p9q2 --来自百度网盘超级会员V2的分享

cd pangolin
mkdir build
cd build
cmake ..
make -j
sudo make install

三、安装eigen安装

http://链接:https://pan.baidu.com/s/122vi17yMyrj0GHcyxirjng 提取码:c9yl --来自百度网盘超级会员V2的分享icon-default.png?t=M4ADhttp://链接:https://pan.baidu.com/s/122vi17yMyrj0GHcyxirjng 提取码:c9yl --来自百度网盘超级会员V2的分享

sudo eigen
mkdir build
cd build
cmake ..
make -j
sudo make install

四、安装ros

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://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full
sudo rosdep init

 此时sudo rosdep init这一步会出现各种错误

问题1:找不到命令

解决:sudo apt install python-rosdep2

 问题2:出现网络问题

方法1 修改hosts

sudo vim /etc/hosts

#在最下面加一行

151.101.84.133  raw.githubusercontent.com 

 方法二:直接写文件(此法暴力有效,简单省事)

cd /etc/ros/rosdep/sources.list.d

touch 20-default.list

  20-default.list文件内容如下

# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
 
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

下一步 

rosdep update

如果失败很正常,下面是解决方法

git clone https://github.com/ros/rosdistro.git
sudo cp -r rosdistro /etc/ros

更改sources.list.d

sudo vim /etc/ros/rosdep/sources.list.d/20-default.list

 

# os-specific listings first
yaml file:///etc/ros/rosdistro/rosdep/osx-homebrew.yaml osx
 
# generic
yaml file:///etc/ros/rosdistro/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/rosdep/ruby.yaml
gbpdistro file:///etc/ros/rosdistro/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

 更改相关下载项

sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/index-v4.yaml'

sudo vim /usr/lib/python3/dist-packages/rosdep2/rep3.py

 

# location of targets file for processing gbpdistro files
#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///etc/ros/rosdistro/releases/targets.yaml'

现在从新更新

rosdep update


sudo apt-get install python-rosinstall
source /opt/ros/melodic/setup.bash

 创建初始化工作目录

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make
sudo apt install net-tools
gedit ~/.bashrc
#在弹出的文本中最后面添加如下两句
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
#保存
source ~/.bashrc

进行测试

sudo apt-get install ros-melodic-desktop
roscore

 ctrl+shift+t 额外打开两个终端

rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key

 在最后一个终端,按方向建小乌龟可以移动,按q终止

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>