当前位置:网站首页>基于ROS的SLAM建图、自动导航、避障(冰达机器人)
基于ROS的SLAM建图、自动导航、避障(冰达机器人)
2022-06-30 04:03:00 【01年的摸鱼老手】
SLAM是Simultaneous localization and mapping缩写,意为“同步定位与建图”,主要用于解决机器人在未知环境运动时的定位与地图构建问题。机器人在未知环境中从一个未知位置开始移动,在移动过程中根据位置和地图进行自身定位,同时在自身定位的基础上建造增量式地图,实现机器人的自主定位和导航。
小车可以运行ros中激光雷达功能包,在PC端的rviz中可以查看;在启动底盘、键盘控制后可以控制小车移动;根据SLAM算法对实验室的环境进行建图;可以保存、读取地图,在PC端控制小车从A点到B点实现路径规划并自动避障。
本文以冰达机器人小车为例,在实际使用过程中遇到了一些问题,总结出的较为详细的教程。
软件平台:Linux(Ubuntu18.04.6)。
硬件平台:冰达机器人。
语言版本:Python 2.7
一.安装ROS及配置环境
1.ROS安装
个人推荐使用小鱼的一键安装,可以解决99%的问题
一键安装指令:
wget http://fishros.com/install -O fishros && . fishros
官网:主页 | 鱼香ROS(但是教学以ROS2为主,冰达机器人只能用ROS1)
开源地址:https://github.com/fishros/install
2.工作区安装
首先从git上下载所需要的功能包到你的工作空间,我们还是以catkin_ws工作空间为例
mkdir -p ~/catkin_ws/src/
cd ~/catkin_ws/src/
git clone https://gitee.com/bingda-robot/base_control.git
git clone https://gitee.com/bingda-robot/lidar.git
git clone https://gitee.com/bingda-robot/robot_vision.git
git clone https://gitee.com/bingda-robot/robot_navigation.git
git clone https://gitee.com/bingda-robot/robot_simulation.git
拉取完成后编译工作空间
cd ~/catkin_ws/
catkin_make
然后来解决功能包依赖
如果你的rosdep可以正常使用(按照这个教程都可以正常使用),那么可以通过rosdep来检查依赖的包是否都满足
cd ~/catkin_ws/
rosdep check --from-path src
如果执行结果为“All system dependencies have been satisfied”,则所有依赖项目已经满足,无需安装
否则,再执行下面指令安装依赖包
rosdep install --from-path src -y
如果你的rosdep无法正常工作,那么你可以通过安装我们所提供的依赖清单来手动安装
sudo apt-get update
sudo apt-get install ros-$ROS_DISTRO-teleop-twist-keyboard ros-$ROS_DISTRO-amcl ros-$ROS_DISTRO-move-base ros-$ROS_DISTRO-slam-gmapping ros-$ROS_DISTRO-slam-karto ros-$ROS_DISTRO-cartographer ros-$ROS_DISTRO-cartographer-ros ros-$ROS_DISTRO-dwa-local-planner ros-$ROS_DISTRO-teb-local-planner ros-$ROS_DISTRO-uvc-camera ros-$ROS_DISTRO-map-server ros-$ROS_DISTRO-hector-slam* ros-$ROS_DISTRO-global-planner ros-$ROS_DISTRO-navfn -y
设置环境变量
cd /catkin_ws/devel
source setup.bash
二.配置分布式
- 连接机器人:ssh [email protected]
- 打开虚拟机终端输入,ifconfig查看Ubuntu的IP地址,让两个机器互ping,确保可以收到数据。
- 在PC端输入gedit .bashrc 对 .bashrc进行修改(名字、机器人ip),添加相关信息,如下图所示。
图1 .bashrc文件新增内容
三.同步小车时间
.因为robot没有断电保护,所以每次关机重启后,它的时间不能与真实时间对应上,而我们的pc是能够连接外网,能够通过ntp服务器进行时间校准
如果在实验中pc没有外网环境,先帮pc获取一个外网环境,然后安装一个ntp服务器:
[email protected]:sudo apt install ntp
把我们的pc当成一个ntp服务器,robot去根据pc进行自身的时间校准:
[email protected]:sudo ntpdate 192.168.x.x //每个人电脑分配的ip不同,这里以自己的pc的ip为准
如果发现robot无法通过pc进行时间校准,则手动校准时间:
[email protected]:sudo date --s=" 2022-06-21 11:12:00"
四.启动激光雷达
- 启动激光雷达:
[email protected]:roslaunch robot_navigation lidar.launch
- 查看发布的话题,寻找雷达:
[email protected]:rostopic list
3.打印雷达扫描的数据:
[email protected]:rostopic echo /scan
4.pc:用rviz查看图像:
[email protected]:roslaunch robot_navigation lidar_rviz.launch
图2 运行激光雷达
五.运行激光雷达和激光SLAM建图
1.运行激光雷达:
[email protected]:roslaunch robot_navigation robot_slam_laser.launch
2.启动底盘:
[email protected]:roslaunch base_control base_control.launch
3.启动键盘控制:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
4.用rviz查看图像:
[email protected]:roslaunch robot_navigation slam_rviz.launch
5.查看地图文件:
[email protected]:roscd robot_navigation/maps
6.保存map:
[email protected]:rosrun map_server map_saver -f map
图3 保存后的地图及结点
六.运行激光雷达和避障
1.运行激光雷达避障(会读取之前保存的地图):
[email protected]:roslaunch robot_navigation robot_navigation.launch
2.用rviz查看:
[email protected]:roslaunch robot_navigation navigation_rviz.launch
3.用2D Pose Estimate改变初试位置,让小车的雷达范围与之前保存的地图基本一致。
4.用2D Nav Goal指向我们的目标地,小车会自动规划路径并行驶到目标点处。
图4 读取地图
图5 路径规划
七.其他问题
1.没有地图数据
检查分布式配置(互ping);
检查Python版本,一定是Python2。
2.xxx is neither a launch file in package nor xxx is a launch file name
没有把工作区环境添加到.bashrc,或者在每次运行前去工作区目录source一下。
本文仅代表个人观点,如有错误,望读者指出。
边栏推荐
- The school training needs to make a registration page. It needs to open the database and save the contents entered on the registration page into the database
- [frequently asked questions] modularization of browser environment and node environment
- 【作业】2022.5.24 MySQL 查操作
- 深入浅出掌握grpc通信框架
- Error in conditional filter (if) syntax in sum function in SQL Server2005
- Installation and use of yarn
- 学校实训要做一个注册页面,要打开数据库把注册页面输入的内容存进数据库但是
- Hebb and delta learning rules
- How do college students make money by programming| My way to make money in College
- 尝试链接数据库时出现链接超时报错,如何解决?
猜你喜欢
巧用 Bitmap 实现亿级海量数据统计
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
The 5-year Android development interview took 20 days to join Alibaba
lego_loam 代码阅读与总结
Half a year after joining the company, I was promoted to a management post
【笔记】2022.5.27 通过pycharm操作MySQL
Smart use of bitmap to achieve 100 million level massive data statistics
When easycvr deploys a server cluster, what is the reason why one is online and the other is offline?
华为云原生——数据开发与DataFactory
【笔记】2022.6.7 数据分析概论
随机推荐
【云原生】AI云开发平台——AI Model Foundry介绍(开发者可免费体验AI训练模型)
lego_loam 代码阅读与总结
第九天 脚本與資源管理
基于海康EhomeDemo工具排查公网部署出现的视频播放异常问题
【图像融合】基于交叉双边滤波器和加权平均实现多焦点和多光谱图像融合附matlab代码
SQLyog导入数据库时报错,求帮解决!
Hebb and delta learning rules
[operation] MySQL query on May 24, 2022
Jour 9 Gestion des scripts et des ressources
【筆記】AB測試和方差分析
[operation] write CSV to database on May 28, 2022
Linear interpolation of spectral response function
MySQL updates JSON string in array form
Do280 private warehouse persistent storage and chapter experiment
Pytorch Profiler+ Tensorboard + VS Code
云原生入门+容器概念介绍
[Thesis reading | deep reading] dane:deep attributed network embedding
[0x0] open questions left by the principal
解决navicat连接数据库遇到的问题
如何利用FME 创建自己的功能软件