TurtleBot3 ROS的安装与测试(kinetic)

前言

  

环境

  • 操作系统:Ubuntu 16.04.x或Linux Mint 18.x
  • ROS版本:Kinetic Kame

  以下脚本将允许您简化ROS安装过程。在TurtleBot PC上的终端窗口中运行以下命令。终端应用程序可以通过屏幕左上角的Ubuntu搜索图标找到。终端的快捷键是Ctrl- Alt- T。安装ROS后,请重启TurtleBot PC。

sudo apt-get update
sudo apt-get upgrade
wget https://raw.githubusercontent.com/ROBOTISGIT/robotis_tools/master/install_ros_kinetic.sh 
chmod 755 ./install_ros_kinetic.sh 
bash ./install_ros_kinetic.sh

  注意:为了检查安装了哪些软件包,请查看install_ros_kinetic.sh

sudo apt-get install vim
vim install_ros_kinetic.sh

  如下所示:

#!/bin/bash
# Apache License 2.0
# Copyright (c) 2017, ROBOTIS CO., LTD.

echo ""
echo "[Note] Target OS version  >>> Ubuntu Mate for the Raspberry Pi"
echo "[Note] Target ROS version >>> ROS Kinetic Kame"
echo "[Note] Catkin workspace   >>> $HOME/catkin_ws"
echo ""
echo "PRESS [ENTER] TO CONTINUE THE INSTALLATION"
echo "IF YOU WANT TO CANCEL, PRESS [CTRL] + [C]"
read

echo "[Set the target OS, ROS version and name of catkin workspace]"
name_os_version=${name_os_version:="xenial"}
name_ros_version=${name_ros_version:="kinetic"}
name_catkin_workspace=${name_catkin_workspace:="catkin_ws"}

echo "[Update the package lists and upgrade them]"
sudo apt-get update -y
sudo apt-get upgrade -y

echo "[Install build environment, the chrony, ntpdate and set the ntpdate]"
sudo apt-get install -y chrony ntpdate build-essential
sudo ntpdate ntp.ubuntu.com

echo "[Add the ROS repository]"
if [ ! -e /etc/apt/sources.list.d/ros-latest.list ]; then
  sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu ${name_os_version} main\" > /etc/apt/sources.list.d/ros-latest.list"
fi

echo "[Download the ROS keys]"
roskey=`apt-key list | grep "ROS Builder"`
if [ -z "$roskey" ]; then
  sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
fi

echo "[Check the ROS keys]"
roskey=`apt-key list | grep "ROS Builder"`
if [ -n "$roskey" ]; then
  echo "[ROS key exists in the list]"
else
  echo "[Failed to receive the ROS key, aborts the installation]"
  exit 0
fi

echo "[Update the package lists and upgrade them]"
sudo apt-get update -y
sudo apt-get upgrade -y

echo "[Install the ros-base]"
sudo apt-get install -y ros-$name_ros_version-ros-base

echo "[Initialize rosdep]"
sudo sh -c "rosdep init"
rosdep update

echo "[Environment setup and getting rosinstall]"
source /opt/ros/$name_ros_version/setup.sh
sudo apt-get install -y python-rosinstall

echo "[Make the catkin workspace and test the catkin_make]"
mkdir -p $HOME/$name_catkin_workspace/src
cd $HOME/$name_catkin_workspace/src
catkin_init_workspace
cd $HOME/$name_catkin_workspace
catkin_make

echo "[Set the ROS evironment]"
sh -c "echo \"alias eb='nano ~/.bashrc'\" >> ~/.bashrc"
sh -c "echo \"alias sb='source ~/.bashrc'\" >> ~/.bashrc"
sh -c "echo \"alias gs='git status'\" >> ~/.bashrc"
sh -c "echo \"alias gp='git pull'\" >> ~/.bashrc"
sh -c "echo \"alias cw='cd ~/$name_catkin_workspace'\" >> ~/.bashrc"
sh -c "echo \"alias cs='cd ~/$name_catkin_workspace/src'\" >> ~/.bashrc"
sh -c "echo \"alias cm='cd ~/$name_catkin_workspace && catkin_make'\" >> ~/.bashrc"

sh -c "echo \"source /opt/ros/$name_ros_version/setup.bash\" >> ~/.bashrc"
sh -c "echo \"source ~/$name_catkin_workspace/devel/setup.bash\" >> ~/.bashrc"

sh -c "echo \"export ROS_MASTER_URI=http://localhost:11311\" >> ~/.bashrc"
sh -c "echo \"export ROS_HOSTNAME=localhost\" >> ~/.bashrc"

source $HOME/.bashrc

echo "[Complete!!!]"
exit 0

  小技巧:这里可以将上述文件的81行和82行所代表的网络配置localhost改一下,改成树莓派或者PC当前的IP地址:

sh -c "echo \"export ROS_MASTER_URI=http:192.168.43.11:11311\" >> ~/.bashrc"
sh -c "echo \"export ROS_HOSTNAME=192.168.43.11\" >> ~/.bashrc"

测试

   所有ROS安装已完成。要测试它是否正确安装,请关闭所有终端窗口并运行一个新的终端窗口。

  现在通过输入以下命令来运行roscore

roscore

  测试ROS安装是否成功:

  当结尾出现[/rosout],即成功。

源码下载

cd ~/catkin_ws/src
git clone https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git

删除TurtleBot PC中不需要的一些软件包

cd ~/catkin_ws/src/turtlebot3
sudo rm -r turtlebot3_description/ turtlebot3_teleop/ turtlebot3_navigation/ turtlebot3_slam/ turtlebot3_example/

安装依赖包

 sudo apt-get install ros-kinetic-rosserial-python ros-kinetic-tf ros-kinetic-urdf

  

 

posted @ 2019-04-28 11:56  kay880  阅读(1817)  评论(0编辑  收藏  举报