1. 程式人生 > >TurtleBot3例程小總結

TurtleBot3例程小總結

遠端終端

[turtleBot3]

sudo apt-get install ssh
sudo raspi-config
#選擇 Interfacing Options
#導航並選擇SSH
#選擇Yes
#選擇OK
#選擇Finish

[PC]

ssh couny(usrName)@IP_OF_TurtleBot3

輸入密碼就OK.

PC 端安裝TurtleBot3

安裝turtlebot3依賴包:
sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers

安裝turtlebot3原始碼:

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

環境設定:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

Turtlebot3-waffle_pi網路設定

時間同步:

#主從分別安裝chrony
sudo apt-get install chrony
#主從分別安裝ntpdate 
sudo apt-get install ntpdate
#主從分別同步時間
sudo ntpdate ntp.ubuntu.com
# 檢測時間是否同步
date

ROS需要IP地址在turtlebot和遠端PC之間進行通訊,要求在同一個wifi區域網下。分別在turtlebot和PC,執行如下命令獲得對應的IP地址:

ifconfig
#修改.bashrc
gedit ~/.bashrc

TURTLEBOT配置如下

export ROS_MASTER_URI=http://IP_OF_PC:11311
export ROS_HOSTNAME=IP_OF_TURTLEBOT

PC配置如下:

export ROS_MASTER_URI=http://IP_OF_PC:11311
export ROS_HOSTNAME=IP_OF_PC

ROS_MASTER <roscore請大師!> PC端。 讓環境生效:

source ~/.bashrc

Turtlebot3-waffle_pi-雷達安裝

[Remote PC]安裝驅動

sudo apt-get install ros-kinetic-hls-lfcd-lds-driver

[TurtelBot]設定許可權

sudo chmod a+rw /dev/ttyUSB0

[Remote PC]增加view_laser.launch,用於顯示鐳射雷達

roscd hls_lfcd_lds_driver
cd launch
sudo vim view_laser.launch

內容如下:

<launch>
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find hls_lfcd_lds_driver)/rviz/hlds_laser.rviz" />
</launch>

測試: [TurtelBot] 啟動雷達

roslaunch hls_lfcd_lds_driver hlds_laser.launch

[Remote PC] 啟動rviz

roslaunch hls_lfcd_lds_driver view_laser.launch

串列埠許可權問題 1、檢測串列埠

  ls -l /dev |grep ttyUSB

2、賦予許可權

sudo chmod 666 /dev/ttyUSB0

3、在編譯的ROS包中執行launch檔案

roslaunch rplidar_ros view_rplidar.launch

Turtlebot3-waffle_pi安裝樹莓派v2攝像頭

[TurtleBot] 在樹莓派上進行攝像頭設定: sudo raspi-config =>進入圖形介面Tab、空格、enter鍵選擇。

  • 選擇 3 Interfacing Options
  • 選擇 P1 Camera
  • Enable camera interface

[TurtleBot] 設定完之後測試以下是否能正常使用,輸入以下以下命令,正常情況下樹莓派系統的桌面上會生成一張攝像頭捕捉到的影象。

raspistill -v -o test.jpg

[TurtleBot] 安裝ros驅動包

cd ~/catkin_ws/src
git clone https://github.com/UbiquityRobotics/raspicam_node.git
sudo apt-get install ros-kinetic-compressed-image-transport ros-kinetic-camera-info-manager
gedit /etc/ros/rosdep/sources.list.d/30-ubiquity.list

新增下面這段話到 30-ubiquity.list 後儲存:

yaml https://raw.githubusercontent.com/UbiquityRobotics/rosdep/master/raspberry-pi.yaml

繼續

rosdep update
cd ~/catkin_ws
rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y
cd ~/catkin_ws && catkin_make

[TurtleBot] 執行raspicam節點

roslaunch turtlebot3_bringup turtlebot3_rpicamera.launch

或者執行下面這條命令進行測試

roslaunch raspicam_node camerav2_1280x960.launch

[Remote PC] 執行以下命令

rqt_image_view

桌面出現顯示攝像頭即時內容的gui介面時,說明已成功安裝.

Turtlebot3-Cartographer-turtlebot 安裝

庫安裝 推薦使用rosdep.但更快安裝推薦使用Ninja. 安裝依賴:

sudo apt-get install -y google-mock libboost-all-dev  libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libprotobuf-dev  libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx  ros-kinetic-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev

安裝步驟:

#Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build

#Create a new workspace in 'cartographer_ws'.
mkdir cartographer_ws
cd cartographer_ws
wstool init src

Merge the cartographer_turtlebot.rosinstall file and fetch code for dependencies.
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_turtlebot/master/cartographer_turtlebot.rosinstall

gedit src/.rosinstall
#更改ceres-solver中地址改為下面的地址:
#>>uri: https://github.com/ceres-solver/ceres-solver.git
wstool update -t src

#Install deb dependencies.
rosdep update

#install proto3
src/cartographer/scripts/install_proto3.sh
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

#Build and install.
catkin_make_isolated --install --use-ninja -j1
source install_isolated/setup.bash

#新增到.bashrc
echo "source ~/cartographer_ws/install_isolated/setup.bash" >> ~/.bashrc

Turtlebot3-waffle_pi建圖

[Remote PC] 開啟終端,然後執行SLAM啟動檔案和rviz

source devel/setup.bash
#<cartographer建圖>
echo "source ~/cartographer_ws/install_isolated/setup.bash" >> ~/.bashrc 
    # <cartographer建圖>
source install_isolated/setup.bash  
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping


#<!-- SLAM: Gmapping, Cartographer, Hector, Karto, Frontier_exploration, RTAB-Map -->

[Remote PC] 啟動鍵盤操作

source devel/setup.bash
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

[Remote PC] 開啟終端,然後執行地圖儲存節點

rosrun map_server map_saver -f ~/map
#map.pgm和map.yaml 在 ~/ 目錄裡建立