@[TOC]
1. 概述
采用树莓派/RK3288/RK3399/X86工控机/TK1/TX1/TX2
作为上位ROS
主控,基于ROS
开发适配导航建图算法
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默认配置打开,如果需要重新配置,只需要执行
cd ~/pibot_ros/third_party/create_ap && ./config_ap.sh && sudo make install && cd ~/pibot_ros && ./pibot_ap.sh start
如需要关闭ap模式,改为连接wifi,只需要执行
cd ~/pibot_ros && ./pibot_ap.sh stop
后重启
如需要打开ap模式, 开启则执行cd ~/pibot_ros && ./pibot_ap.sh start
后重启
4.1 安装xshell
网盘中下载xshell
并安装
通过Xshell
连接树莓派/RK3288/RK3399
输入IP
和用户名密码
-
树莓派3B/3B+
为pibot
-
firefly RK3288、RK3399
为firefly
-
nanopi 3399
为pi
5. 用户主机
需要一个PC
安装ROS
环境,用来显示查看地图或者玩转模拟器等,PIBOT
提供了一个一键安装ROS
的脚本pibot_install_ros
,可以直接在Ubuntu
下安装ROS
用户主机
环境Ubuntu
或者Windows7/10+Vmvare+Ubuntu
虚拟机Ros kinetic
环境, 安装ROS
参见Windows下安装Ubuntu虚拟机及ROS相关章节
6. 多机通讯
用户主机与树莓派/RK3288/RK3399/TK1/TX1/TX2/X86主机
怎么建立ROS
通讯的,PIBOT
提供了一键配置脚本pibot_init_env
-
设备端
-
主机端
7. ROS驱动开发
7.1 概述
下位机及通过串口与树莓派/RK3288/RK3399/TK1/TX1/TX2/X86主机
通讯,PIBOT
提供了一个简单的协议,通讯协议具体请参见协议文档
7.2 驱动开发及PID参数动态调整
PID
参数已在出厂时候配置,如需了解细节请参考PIBOT的driver的实现及动态PID调节
7.3 目录结构简介
建议拷贝提供的压缩文件至目标设备(
树莓派/RK3288/RK3399/X86工控机/TK1/TX1/TX2
)上解压或者直接git clone
,不然会遇到一些问题,具体问题见Q&A
PIBOT
的ROS workspace
目录如下图
-
arbotix_ros
模拟器 -
pibot
工具集
-
pibot_bringup
pibot驱动包
-
pibot_description
pibot urdf文件
-
pibot_navigation
建图导航相关配置项
-
pibot_simulator
pibot导航模拟器
-
rplidar_ros
rplidar激光雷达驱动包 -
ydlidar-1.2.1
eai激光雷达驱动包
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校准
参见PIBOT的控制及校准
IMU校准
参见PIBOT的IMU校准
9. ROS建图与导航
9.1 概述
ROS
驱动中提供了cmd_vel
的订阅及odom
的发布,至此再需要一个激光雷达就可以完成建图了
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
命令执行使用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原命令添加参数即可,如下
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
则使用默认参数,nav.launch
文件中可以设置默认使用的地图文件
多点导航
可以通过修改pibot/scripts
中的navigation_demo.py
的python
脚本完成单点和多点的导航
具体可以参考
使用rospy启动launch与定点导航
基于rospy的多点导航的python实现
11. 模拟器
PIBOT包内置了模拟器,可以直接运行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相关功能
保证手机跟跟PC
或者树莓派/RK3288/RK3399
连接同一个网络,保证手机能够访问到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
可以发出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的相关包使用
装有IMU
的PIBOT
系列小车,底层提供IMU
的数据采集,上层提供了IMU
的互补滤波以及融合里程计和IMU
的扩展的卡尔曼滤波包robot_pose_ekf
启动时只需相应的with_imu
的launch
文件, 具体参见pibot_
命令