1.概述
可以使用PIBOT提供镜像,预装了ROS
,而且已经配置好环境,如果你想体验下安装过程,也可以先输入官方UBUNTU
后再安装ROS
,可以直接跳过步骤2
2.刷入pibot_ros镜像
PIBOT网盘中提供了相关工具与镜像,我们需要使用工具Win32 Disk Mangaer及
ROS
镜像选择镜像和相应的盘符,点击
Write
按钮,然后点一下Yes
确定操作,开始系统写入等待安装完成即可
刷完看到容量变小了,不用担心,正常情况
用户名密码都是pibot
3 逐步安装ROS
使用PIBOT提供的镜像可以跳过该步骤,同时实际上面生成的镜像就是执行了以下步骤而已
3.1下载ubuntu
从百度网盘或者官网下载Ubuntu mate或者Lubuntu
3.2 刷入ubuntu
使用该镜像刷入ubuntu,步骤同2刷入镜像
3.3安装ROS
# if [ ! -z "$PIBOT_HOME" ]; then
# PIBOT_HOME_DIR=$PIBOT_HOME
# else
# PIBOT_HOME_DIR=~/pibot_ros
# fi
echo -e "\033[1;32mpibot home dir:$PIBOT_HOME_DIR"
# http://wiki.ros.org/ROS/Installation/UbuntuMirrors
sudo sh -c 'echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.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://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
code_name=$(lsb_release -sc)
if [ "$code_name" = "trusty" ]; then
ros_version="indigo"
elif [ "$code_name" = "xenial" ]; then
ros_version="kinetic"
elif [ "$code_name" = "bionic" ] || [ "$code_name" = "stretch" ]; then
ros_version="melodic"
else
echo "PIBOT not support "$code_name
exit
fi
echo "ros:" $ros_version
if [ "$ros_version" = "melodic" ]; then
# third
# cd $PIBOT_HOME_DIR/third_party
# cd libuvc
# mkdir -p build
# cd build && cmake .. && sudo make install
# cd $PIBOT_HOME_DIR
# if [ ! -d $PWD/ros_package ]; then
# mkdir ros_package
# fi
# cd ros_package
# # astra ros package
# if [ -f $PWD/astra.tar.gz ]; then
# tar xzvf $PWD/astra.tar.gz
# else
# git clone https://github.com/orbbec/ros_astra_launch.git
# git clone https://github.com/orbbec/ros_astra_camera.git
# fi
# frontier_exploration ros package
# if [ -f $PWD/frontier_exploration.tar.gz ]; then
# tar xzvf $PWD/frontier_exploration.tar.gz
# else
# git clone -b melodic-devel https://github.com/paulbovbel/frontier_exploration.git
# fi
# cd ..
# echo "ln -sf $PWD/ros_package ros_ws/src/ros_package"
# if [ -f ros_ws/src/ros_package ]; then
# rm ros_ws/src/ros_package
# fi
# ln -snf $PWD/ros_package ros_ws/src/ros_package
sudo apt-get -y --allow-unauthenticated install ros-${ros_version}-ros-base ros-${ros_version}-slam-gmapping ros-${ros_version}-navigation \
ros-${ros_version}-xacro ros-${ros_version}-yocs-velocity-smoother ros-${ros_version}-robot-state-publisher \
ros-${ros_version}-joint-state-publisher ros-${ros_version}-teleop-twist-* ros-${ros_version}-control-msgs \
ros-${ros_version}-kdl-parser-py ros-${ros_version}-tf2-geometry-msgs ros-${ros_version}-hector-mapping \
ros-${ros_version}-robot-pose-ekf ros-${ros_version}-slam-karto ros-${ros_version}-hector-geotiff ros-${ros_version}-hector-trajectory-server \
ros-${ros_version}-usb-cam ros-${ros_version}-image-transport ros-${ros_version}-image-transport-plugins \
ros-${ros_version}-depthimage-to-laserscan ros-${ros_version}-openni2* ros-${ros_version}-freenect-* \
ros-${ros_version}-robot-upstart ros-${ros_version}-tf-conversions ros-${ros_version}-orocos-kdl \
ros-${ros_version}-realsense2-camera ros-${ros_version}-camera-umd ros-${ros_version}-libuvc* \
ros-${ros_version}-camera-calibration ros-${ros_version}-rtabmap* ros-${ros_version}-cartographer-ros \
ros-${ros_version}-web-video-server ros-${ros_version}-roslint
else
sudo apt-get -y --allow-unauthenticated install ros-${ros_version}-ros-base ros-${ros_version}-slam-gmapping ros-${ros_version}-navigation \
ros-${ros_version}-xacro ros-${ros_version}-yocs-velocity-smoother ros-${ros_version}-robot-state-publisher \
ros-${ros_version}-joint-state-publisher ros-${ros_version}-teleop-twist-* ros-${ros_version}-control-msgs \
ros-${ros_version}-kdl-parser-py ros-${ros_version}-tf2-geometry-msgs ros-${ros_version}-hector-mapping \
ros-${ros_version}-robot-pose-ekf ros-${ros_version}-slam-karto ros-${ros_version}-hector-geotiff ros-${ros_version}-hector-trajectory-server \
ros-${ros_version}-usb-cam ros-${ros_version}-image-transport ros-${ros_version}-image-transport-plugins \
ros-${ros_version}-astra-launch ros-${ros_version}-astra-camera ros-${ros_version}-depthimage-to-laserscan \
ros-${ros_version}-openni2* ros-${ros_version}-freenect-* ros-${ros_version}-tf-conversions \
ros-${ros_version}-robot-upstart ros-${ros_version}-frontier-exploration ros-${ros_version}-orocos-kdl \
ros-${ros_version}-realsense2-camera ros-${ros_version}-camera-umd ros-${ros_version}-libuvc* \
ros-${ros_version}-camera-calibration ros-${ros_version}-rtabmap* ros-${ros_version}-cartographer-ros \
ros-${ros_version}-web-video-server
fi
read -s -n1 -p "install ros gui tools?(y/N)"
if [ "$REPLY" = "y" -o "$REPLY" = "Y" ]; then
sudo apt-get -y --allow-unauthenticated install ros-${ros_version}-rviz ros-${ros_version}-rqt-reconfigure ros-${ros_version}-rqt-tf-tree \
ros-${ros_version}-image-view ros-${ros_version}-cartographer-rviz
fi
复制上面脚本保存至文件install_ros.sh
,执行sh install_ros.sh
4.测试
安装完成,运行roscore可以看到下面输出即可标识完成ros安装
source /opt/ros/melodic/setup.bash
# ubuntu16
# source /opt/ros/kinetic/setup.bash
roscore
5.交换分区的设置
5.1 查看交换分区
free -m
** 如果显示下图,标识已经有2G的交换空间,无需再次设置**
5.2 创建交换分区
5.2.1 创建交换分区
sudo mkdir /opt/image
cd /opt/image/
sudo touch swap
sudo dd if=/dev/zero of=/opt/image/swap bs=1024 count=2048000
sudo mkswap /opt/image/swap
sudo swapon /opt/image/swap
dd
命令执行时间较长
再次查看交换分区
free -m
5.2.2 设置重启生效
sudo vim /etc/fstab
最后行添加
/opt/image/swap /swap swap defaults 0 0
重启后再次查看
free -m