系统:Ubuntu16.04 LST
ros版本:kinetic
大概主要步骤
换为阿里源(下载速度成倍提升!!!)
很容易!!!
博主自己之前写的Ubuntu换源教程链接 https://blog.csdn.net/CGJustDoIT/article/details/91526027
设置计算机能接收来自packages.ros.org的软件:修改sources.list 添加源
官方ros源 :
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
或者选择清华大学ros源(推荐国内源,速度快) :
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
出现错误 ( 因为前面的密钥失效,需要重新生成 )
解决办法:修改获取key的命令,最后面的密钥改为 F42ED6FBAB17C654
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key F42ED6FBAB17C654
再重新更新
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.
sudo rosdep init
rosdep update
It’s convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc #在终端内重新加载 .bashrc文件
补充: 每打开一个终端,会先加载 .bashrc文件
压缩包为: opencv-3.4.1.tar.gz ,opencv_contrib-3.4.1.tar发发gz
本教程使用脚本一次性直接下载并编译安装
新建如下.sh脚本 install_opencv.sh:
#!/bin/bash
echo "** Install requirement"
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -y libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer-plugins-base-devel libgphoto2-dev
sudo apt-get install -y libavresample-dev gtk+-3.0
sudo apt-get update
echo "** Download opencv-3.4.1"
curl -L https://github.com/opencv/opencv/archive/3.4.1.tar.gz -o opencv-3.4.1.tar.gz
curl -L https://github.com/opencv/opencv_contrib/archive/3.4.1.tar.gz -o opencv_contrib-3.4.1.tar.gz
tar -zxvf opencv-3.4.1.tar.gz
tar -zxvf opencv_contrib-3.4.1.tar.gz
echo "** Building..."
cd opencv-3.4.1/
mkdir build
cd build
cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.1/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_xfeatures2d=OFF ..
make -j8
sudo make install
sudo apt-get install -y python-opencv python3-opencv
echo "** Install opencv-3.4.1 successfully"
echo "** Bye :)"
运行 install_opencv.sh ,安装在home目录下
sudo sh install_opencv.sh
本教程使用脚本一次性直接下载并编译安装
新建如下.sh脚本 install_ceres.sh:
#!/bin/bash
sudo apt-get install -y cmake libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev
sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687
sudo apt-get update && sudo apt-get install -y libsuitesparse-dev
source ~/.bashrc
workdir=$PWD
if test ! -d ceres-solver ; then git clone https://github.com/ceres-solver/ceres-solver ; fi
cd ceres-solver
if test ! -d ceres-bin ; then mkdir ceres-bin ; fi
cd ceres-bin
if ! cmake .. ; then echo "ceres cmake init fail" ; exit 1 ; fi
if ! make -j4 ; then echo "ceres make fail" ; exit 1 ; fi
if ! sudo make install ; then echo "ceres make install fail" ; exit 1 ; fi
cd $workdir
运行 install_ceres.sh ,安装在home目录下
sudo sh install_ceres.sh
创建名称为catkin_ws 的工作空间,路径为 : ~/slam/catkin_ws/src
cd ~ #进入home目录
mkdir slam # 创建名为slam的文件夹
cd slam
mkdir -p /catkin_ws/src #新建catkin_ws/src 目录
cd catkin_ws/src
catkin_init_workspace
cd .. #退到 catkin_ws 路径下
catkin_make #编译
配置环境变量
echo "source ~/slam/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc #在终端内重新加载 .bashrc文件
ros package 路径包含有刚刚创建的工作空间目录
进入~/slam 下载小觅相机SDK
git clone https://github.com/slightech/MYNT-EYE-S-SDK.git
cd MYNT-EYE-S-SDK # 进入SDK文件夹
make init
make install
make samples
cd wrappers/ros
catkin_make
echo "source ~/slam/MYNT-EYE-S-SDK/wrappers/ros/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc #在终端内重新加载 .bashrc文件
ros package 路径:
4
插上相机运行如下命令,测试
roslaunch mynt_eye_ros_wrapper display.launch
进入~/slam/catkin_ws/src 目录下载小觅相机SDK
cd ~/slam/catkin_ws/src # 进入SDK文件夹
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git
编译 (在前面创建的工作空间之下)
cd .. # 退到 ~/slam/catkin_ws 目录
catkin_make # 在 ~/slam/catkin_ws 下编译
echo "source ~/slam/catkin_ws/devel/setup.bash" >> ~/.bashrc # 写入 source 命令到.bashrc中
source ~/.bashrc #在终端内重新加载 .bashrc文件
ros package 路径: