⼆.路径规划---⼆维路径规划实车实现---
gmapping+amcl+map_serve。。。
专栏系列⽂章如下:
本次实验是利⽤gmapping只使⽤⼆维点云进⾏建图,利⽤move_base进⾏规划。
后期需要写⼀个三维点云实时转换栅格地图包(包可以实现选择性转换输出三维栅格和2.5-D⾼程栅格、⼆维栅格地图),进⾏gmapping 的功能替换就⾏,⾥程计就不⽤改,3D-SLAM的⾥程计直接可以拿来⽤,接⼝⼀样的。
1.先实现gmapping建图:
a.开启速腾聚创 rs_lidar_16雷达驱动(跟之前⼀样)
b.使⽤pointcloud_to_laserscan包实现三维转⼆维(编写pointcloudtoscan.launch)
<?xml version="1.0"?>
<launch>
<!-- run pointcloud_to_laserscan node -->
<include file="$(find rslidar_sdk)/launch/start.launch" />
<node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan">
<remap from="cloud_in" to="/rslidar_points"/>
<rosparam>
# target_frame: rslidar # Leave disabled to output scan in pointcloud frame
transform_tolerance: 0.01
min_height: -0.4
max_height: 1.0
angle_min: -3.1415926 # -M_PI
angle_max: 3.1415926 # M_PI
angle_increment: 0.003 # 0.17degree
scan_time: 0.1
range_min: 0.2
range_max: 100
use_inf: true
inf_epsilon: 1.0
# Concurrency level, affects number of pointclouds queued for processing and number of threads used
# 0 : Detect number of cores
# 1 : Single threaded
# 2->inf : Parallelism level
concurrency_level: 1
</rosparam>
</node>
</launch>
c.源码下载gmapping包,这⾥不要⽤apt去下载,因为要修改源码(gmapping源码不⽀持2048以上的点,需要修改下)
git clone github/ros-perception/openslam_gmapping.git
git clone github/ros-perception/slam_gmapping.git
在⽂件⽬录openslam_gmapping/include/gmapping/scanmatcher/scanmatcher.h⽂件中
#define LASER_MAXBEAMS 2048 设置为20480(⽐较⼤就⾏)
d.调⽤gmapping包和laser_scan_matcher包,并⽤tf包的static_transform_publisher进⾏gmapping需要的tf信息提供,⼜因为gmapping必须要⾥程计信息,⽽laser_scan_matcher包实现的是⼆维雷达前端⾥程计odom输出。编写demo_gmapping.launch:
<!--
Example launch file: uses laser_scan_matcher together with
slam_gmapping
-->
<launch>
#### set up data playback from bag >>>>>####
<param name="/use_sim_time" value="true"/>
#### publish an example base_link -> laser transform >>#
<include file="$(find mapping)/launch/pointcloudtoscan.launch" />
<node pkg="tf" type="static_transform_publisher" name="base_link_to_laser"
args="0.0 0.0 0.0 0.0 0.0 0.0 /base_link /rslidar 40" />
#### start rviz >>>>>>>>>###
<node pkg="rviz" type="rviz" name="rviz"
args="-d $(find laser_scan_matcher)/demo/demo_gmapping.rviz"/>
#### start the laser scan_matcher >>>>>>
<node pkg="laser_scan_matcher" type="laser_scan_matcher_node"
name="laser_scan_matcher_node" output="screen">
<param name="fixed_frame" value = "odom"/>
<param name="max_iterations" value="10"/>
</node>
#### start gmapping >>>>>>>>####
<node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
<param name="map_udpate_interval" value="1.0"/>
<param name="maxUrange" value="5.0"/>
<param name="sigma" value="0.1"/>
<param name="kernelSize" value="1"/>
<param name="lstep" value="0.15"/>
<param name="astep" value="0.15"/>
<param name="iterations" value="1"/>
<param name="lsigma" value="0.1"/>
<param name="ogain" value="3.0"/>
<param name="lskip" value="1"/>
<param name="srr" value="0.1"/>
<param name="srt" value="0.2"/>
<param name="str" value="0.1"/>
<param name="stt" value="0.2"/>
<param name="linearUpdate" value="1.0"/>
<param name="angularUpdate" value="0.5"/>
<param name="temporalUpdate" value="0.4"/>
<param name="resampleThreshold" value="0.5"/>
<param name="particles" value="10"/>
<param name="xmin" value="-5.0"/>
<param name="ymin" value="-5.0"/>
<param name="xmax" value="5.0"/>
<param name="ymax" value="5.0"/>
<param name="delta" value="0.02"/>
<param name="llsamplerange" value="0.01"/>
<param name="llsamplerange" value="0.01"/>
<param name="llsamplestep" value="0.05"/>
<param name="lasamplerange" value="0.05"/>
<param name="lasamplestep" value="0.05"/>
</node>
</launch>
这⾥要注意:
<param name="/use_sim_time" value="true"/>
跑bag这个标志为true,实物跑这个标志为false
实车效果:
2.再实现move_base路径规划
move_base的框图如下:
拷贝gmapping建图功能下⾯的功能包,包括雷达驱动、gmapping功能包到src。安装⼩车驱动依赖:
sudo apt install -y libasio-dev
sudo apt install -y ros-$ROS_DISTRO-teleop-twist-keyboard
设置CAN-To-USB模块
sudo modprobe gs_usb
第⼀次⽤⼩车驱动包则执⾏:
rosrun scout_bringup setup_can2usb.bash
不是第⼀次则执⾏:
rosrun scout_bringup bringup_can2usb.bash
键盘测试下⼩车运动,没问题则进⾏下⼀步:
github下载move_base包(集成在navigation):
将之前仿真的robot_sim包拷贝到src。
因为⽤laser_scan_matcher功能包⽣成的雷达odom没有数据(不知原因),所以⽤了⼩车⾃带的⾥程计。更改demo_mapping.launch如下:
<!--
Example launch file: uses laser_scan_matcher together with
slam_gmapping
-->
<launch>
#### set up data playback from bag >>>>>####
<param name="/use_sim_time" value="flase"/>
<include file="$(find mapping)/launch/pointcloudtoscan.launch" />
#### publish an example base_link -> laser transform >>#
<node pkg="tf" type="static_transform_publisher" name="base_link_to_laser"
args="0.0 0.0 0.0 -1.57 0.0 0.0 /base_link /rslidar 40" />
#### start rviz >>>>>>>>>###
<node pkg="rviz" type="rviz" name="rviz"
args="-d $(find mapping)/config/demo_gmapping.rviz"/>
<include file="$(find scout_bringup)/launch/scout_mini_robot_base.launch" />
#### start gmapping >>>>>>>>####
<node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">    <param name="base_frame" value="/base_link"/>
<param name="odom_frame" value="/odom" />
<param name="map_frame" value="/map" />
<param name="map_udpate_interval" value="1.0"/>
<param name="maxUrange" value="5.0"/>
<param name="sigma" value="0.1"/>
<param name="kernelSize" value="1"/>
<param name="lstep" value="0.15"/>
<param name="astep" value="0.15"/>
<param name="iterations" value="1"/>
<param name="lsigma" value="0.1"/>
<param name="ogain" value="3.0"/>
<param name="lskip" value="1"/>
param name<param name="srr" value="0.1"/>
<param name="srt" value="0.2"/>
<param name="str" value="0.1"/>
<param name="stt" value="0.2"/>
<param name="linearUpdate" value="1.0"/>
<param name="angularUpdate" value="0.5"/>
<param name="temporalUpdate" value="0.4"/>
<param name="resampleThreshold" value="0.5"/>
<param name="particles" value="10"/>
<param name="xmin" value="-5.0"/>
<param name="ymin" value="-5.0"/>
<param name="xmax" value="5.0"/>
<param name="ymax" value="5.0"/>
<param name="delta" value="0.02"/>
<param name="llsamplerange" value="0.01"/>
<param name="llsamplestep" value="0.05"/>
<param name="lasamplerange" value="0.05"/>
<param name="lasamplestep" value="0.05"/>
</node>
</launch>
这⾥要注意:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论