@[TOC]
1. 概述
采用樹莓派/RK3288/RK3399/X86工控機/TK1/TX1/TX2
作為上位ROS
主控,基于ROS
開發(fā)適配導航建圖算法
2. 軟件框架
3. Ubuntu的刷入、ROS(ROS2)的安裝
具體請參考樹莓派(raspberrypi 3b/4b)安裝ROS
tf卡啟動的
nanopi(RK3399)
則同樹莓派
一樣操作
4. ssh遠程連接
windows
中推薦安裝xshell
遠程連接
樹莓派/
nanopi rk3399
默認開啟了熱點ssid
和password
均為pibot_ap
,可以通過連接該熱點連接樹莓派/nanopi rk3399
臊泰,樹莓派/nanopi rk3399
的IP為192.168.12.1
ap默認配置打開防嗡,如果需要重新配置,只需要執(zhí)行
cd ~/pibot_ros/third_party/create_ap && ./config_ap.sh && sudo make install && cd ~/pibot_ros && ./pibot_ap.sh start
如需要關(guān)閉ap模式拍棕,改為連接wifi喻粹,只需要執(zhí)行
cd ~/pibot_ros && ./pibot_ap.sh stop
后重啟
如需要打開ap模式, 開啟則執(zhí)行cd ~/pibot_ros && ./pibot_ap.sh start
后重啟
4.1 安裝xshell
網(wǎng)盤中下載xshell
并安裝
通過Xshell
連接樹莓派/RK3288/RK3399
輸入IP
和用戶名密碼
-
樹莓派3B/3B+
為pibot
-
firefly RK3288坏快、RK3399
為firefly
-
nanopi 3399
為pi
5. 用戶主機
需要一個PC
安裝ROS
環(huán)境,用來顯示查看地圖或者玩轉(zhuǎn)模擬器等唯卖,PIBOT
提供了一個一鍵安裝ROS
的腳本pibot_install_ros
粱玲,可以直接在Ubuntu
下安裝ROS
用戶主機
環(huán)境Ubuntu
或者Windows7/10+Vmvare+Ubuntu
虛擬機Ros kinetic
環(huán)境, 安裝ROS
參見Windows下安裝Ubuntu虛擬機及ROS相關(guān)章節(jié)
6. 多機通訊
用戶主機與樹莓派/RK3288/RK3399/TK1/TX1/TX2/X86主機
怎么建立ROS
通訊的,PIBOT
提供了一鍵配置腳本pibot_init_env
-
設備端
-
主機端
7. ROS驅(qū)動開發(fā)
7.1 概述
下位機及通過串口與樹莓派/RK3288/RK3399/TK1/TX1/TX2/X86主機
通訊拜轨,PIBOT
提供了一個簡單的協(xié)議抽减,通訊協(xié)議具體請參見協(xié)議文檔
7.2 驅(qū)動開發(fā)及PID參數(shù)動態(tài)調(diào)整
PID
參數(shù)已在出廠時候配置,如需了解細節(jié)請參考PIBOT的driver的實現(xiàn)及動態(tài)PID調(diào)節(jié)
7.3 目錄結(jié)構(gòu)簡介
建議拷貝提供的壓縮文件至目標設備(
樹莓派/RK3288/RK3399/X86工控機/TK1/TX1/TX2
)上解壓或者直接git clone
橄碾,不然會遇到一些問題卵沉,具體問題見Q&A
PIBOT
的ROS workspace
目錄如下圖
-
arbotix_ros
模擬器 -
pibot
工具集
-
pibot_bringup
pibot驅(qū)動包
-
pibot_description
pibot urdf文件
-
pibot_navigation
建圖導航相關(guān)配置項
-
pibot_simulator
pibot導航模擬器
-
rplidar_ros
rplidar激光雷達驅(qū)動包 -
ydlidar-1.2.1
eai激光雷達驅(qū)動包
7.4 編譯與測試
編譯
cd ~/pibot_ros
git fetch # 拉取最新的代碼
git pull
# ros2 需要切換到ros分支,如 git checkout -b galactic-devel origin/galactic-devel
cd ~/pibot_ros/ros_ws
catkin_make # ros2 為 pbmake
測試
初始化配置
重新拔插USB口或者重啟樹莓派/RK3288/RK3399
ls /dev/pibot -l
開始測試
打開終端輸入pibot_
,再輸入2次tab
提示支持的命令
也可以輸入
"alias | grep pibot_"
查看所有命令的別名法牲,對應其ros的全命令史汗,如下圖
pibot@pibot~$ alias | grep pibot_
alias pibot_base='ros2 launch pibot_bringup robot_launch.py'
alias pibot_base_with_imu='ros2 launch pibot_bringup robot_launch.py'
alias pibot_bringup='ros2 launch pibot_bringup bringup_launch.py'
alias pibot_bringup_with_imu='ros2 launch pibot_bringup bringup_with_imu_launch.py'
alias pibot_cartographer='ros2 launch pibot_navigation cartographer.launch.py'
alias pibot_cartographer_with_odom='ros2 launch pibot_navigation cartographer.launch.py'
alias pibot_configure='ros2 run rqt_reconfigure rqt_reconfigure'
alias pibot_control='ros2 launch pibot_bringup keyboard_teleop_launch.py'
alias pibot_gmapping='ros2 launch pibot_navigation mapping.launch.py'
alias pibot_gmapping_with_imu='ros2 launch pibot_navigation mapping.launch.py'
alias pibot_holonomic_joystick='ros2 launch pibot_bringup joystick_launch.py joy_config:=joystick-holonomic'
alias pibot_joystick='ros2 launch pibot_bringup joystick_launch.py joy_config:=joystick'
alias pibot_lidar='ros2 launch pibot_lidar rplidar_launch.py'
alias pibot_mapping='ros2 launch pibot_navigation mapping.launch.py'
alias pibot_naviagtion='ros2 launch pibot_navigation navigation2.launch.py'
alias pibot_naviagtion_with_imu='ros2 launch pibot_navigation navigation2.launch.py'
alias pibot_save_map='ros2 launch pibot_navigation save_map.launch.py'
alias pibot_simulator='ros2 launch pibot_simulator nav_launch.py'
alias pibot_tf_tree='ros2 run rqt_tf_tree rqt_tf_tree'
alias pibot_view='rviz2 -d ${PIBOT_HOME}/ros_ws/src/pibot_navigation/rviz/nav2_default_view.rviz'
alias pibot_view_cartographer='rviz2 -d ${PIBOT_HOME}/ros_ws/src/pibot_navigation/rviz/nav2_default_view.rviz'
這些命令具體定義在
~/.pibotrc
文件,該文件是pibot_init_env
腳本自動生成的
8. 校準
無IMU校準
IMU校準
9. ROS建圖與導航
9.1 概述
ROS
驅(qū)動中提供了cmd_vel
的訂閱及odom
的發(fā)布,至此再需要一個激光雷達就可以完成建圖了
9.2 建圖
在樹莓派/RK3288/RK3399
運行pibot_gmapping
在用戶主機運行pibot_view
(ROS2中為``)
pibot_gmapping
和pibot_view
在ROS1/2分別對應下面的命令
- ROS1
roslaunch pibot_navigation gmapping.launch
roslaunch pibot_navigation view_nav.launch
- ROS2
ros2 launch pibot_navigation mapping.launch.py
rviz2 -d ${PIBOT_HOME}/ros_ws/src/pibot_navigation/rviz/nav2_default_view.rviz
另外還可以運行
pibot_cartographer
命令執(zhí)行使用google cartographer
建圖
ROS2中使用slam_box提供建圖
兩種建圖方法
- 運行
pibot_control
或者pibot_joystick
即可通過鍵盤或者遙控手柄開始建圖
pibot_control
和pibot_joystick
在ROS1/2分別對應下面的命令
- ROS1
roslaunch pibot keyboard_teleop.launch
roslaunch pibot joystick.launch
- ROS2
ros2 launch pibot_bringup keyboard_teleop_launch.py
ros2 launch pibot_bringup joystick_launch.py joy_config:=joystick
- 直接選擇導航的點(
2D Nav Goal
)開始建圖
保存地圖
- 運行下列
pibot_save_map
命令,如需手動指定路徑拒垃,可以使用ros原命令添加參數(shù)即可停撞,如下
pibot_save_map
在ROS1/2分別對應下面的命令
- ROS1
roslaunch pibot_navigation save_map.launch
roslaunch pibot_navigation save_map.launch map_name:=xxx
roscd pibot_navigation/maps/ && rosrun map_server map_saver -f xxx
- ROS2
ros2 launch pibot_navigation save_map.launch.py
ros2 launch pibot_navigation save_map.launch.py map:=xxx
可以看到生成2個文件
10 導航
單點導航測試
在樹莓派/RK3288/RK3399
輸入pibot_naviagtion
運行`
pibot_naviagtion
在ROS1/2分別對應下面的命令
- ROS1
roslaunch pibot_navigation nav.launch
roslaunch pibot_navigation nav.launch map_name:=xxx.yaml
- ROS2
ros2 launch pibot_navigation navigation2.launch.py
ros2 launch pibot_navigation navigation2.launch.py map:=xxx
在用戶主機運行pibot_view
,通過RViz
提供的功能既可以完成導航測試(這里需要先指定初始位置)
如果直接運行
pibot_naviagtion
則使用默認參數(shù)悼瓮,nav.launch
文件中可以設置默認使用的地圖文件
多點導航
可以通過修改pibot/scripts
中的navigation_demo.py
的python
腳本完成單點和多點的導航
具體可以參考
使用rospy啟動launch與定點導航
基于rospy的多點導航的python實現(xiàn)
11. 模擬器
PIBOT包內(nèi)置了模擬器怜森,可以直接運行pibot_simulator
啟動模擬器
pibot_simulator
在ROS1/2分別對應下面的命令
- ROS1
roslaunch pibot_simulator nav.launch
- ROS2
```bash
ros2 launch pibot_simulator nav_launch.py
這樣無需小車也可以模擬導航了
12. Android App
12.1相關(guān)功能
保證手機跟跟PC
或者樹莓派/RK3288/RK3399
連接同一個網(wǎng)絡,保證手機能夠訪問到roscore
(export ROS_IP=XXX.XXX.XXX.XXX
)具體參見ROS多機的通訊配置
修改
Master URI
選擇roscore
的URI
點擊CONNECT
切換
Camera View
與Map View
-
Set Pose
在地圖長按 相當于Rviz
中的2D Pose Estimate
-
Set Goal
在地圖長按 相當于Rviz
中的2D Nav Goal
- 左下角
Joystick
可以發(fā)出cmd_vel
topic
控制小車移動
12.2 顯示視頻
顯示視頻需要硬件攝像頭支持同時在PC
或者樹莓派/RK3288/RK3399
啟動roslaunch pibot usb_camera.launch
或者直接瀏覽器訪問192.168.12.1:8080選擇相應的Topic即可
192.168.12.1為設備地址, 以具體設備為準
手機APP ROS2 暫時不支持
13. IMU的相關(guān)包使用
裝有IMU
的PIBOT
系列小車谤牡,底層提供IMU
的數(shù)據(jù)采集副硅,上層提供了IMU
的互補濾波以及融合里程計和IMU
的擴展的卡爾曼濾波包robot_pose_ekf
啟動時只需相應的with_imu
的launch
文件, 具體參見pibot_
命令