概述
首先需要安裝hectorslam,方法如下:sudo apt-get install ros-indigo-hector-slam
然後安裝RPLIDAR的驅動,具體方法如下:
先插上lidar
ls -l /dev |grep ttyUSB
Add the authority of write: (such as /dev/ttyUSB0)
sudo chmod 666 /dev/ttyUSB0
Start a rplidar node and view the scan result in rviiz
$ roslaunch rplidar_ros view_rplidar.launch
Start a rplidar node and run rplidar client process to print the raw scan result
下面一行就可以單獨啓動rplidarA2了
$ roslaunch rplidar_ros rplidar.launch
接下來寫幾個關鍵的launch文件 在hector_slam_launch文件夾下添加吐下介個文件:
slam.launch
<launch>
<param name="/use_sim_time" value="false" />
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>
<include file="$(find hector_slam_launch)/launch/hector_mapping.launch" />
<include file="$(find hector_slam_launch)/launch/geotiff_mapper.launch">
<arg name="trajectory_source_frame_name" value="scanmatcher_frame"/>
</include>
</launch>
hector_mapping.launch
<launch>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">
<param name="pub_map_odom_transform" value="true" />
<param name="map_frame" value="map" />
<param name="base_frame" value="base_link" />
<param name="odom_frame" value="base_link" />
<param name="map_resolution" value="0.050"/>
<param name="map_size" value="1048"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />
</node>
<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 /base_link /laser 100" />
</launch>
geotiff_mapper.launch
<launch>
<arg
name="trajectory_source_frame_name" default="/base_link"/>
<arg
name="trajectory_update_rate" default="4"/>
<arg
name="trajectory_publish_rate" default="0.25"/>
<node pkg="hector_trajectory_server" type="hector_trajectory_server" name="hector_trajectory_server" output="screen">
<param name="target_frame_name" type="string" value="/map" />
<param name="source_frame_name" type="string" value="$(arg trajectory_source_frame_name)" />
<param name="trajectory_update_rate" type="double" value="$(arg trajectory_update_rate)" />
<param name="trajectory_publish_rate" type="double" value="$(arg trajectory_publish_rate)" />
</node>
<node pkg="hector_geotiff" type="geotiff_node" name="hector_geotiff_node" output="screen" launch-prefix="nice -n 15">
<remap from="map" to="/dynamic_map" />
<param name="map_file_path" type="string" value="$(find hector_geotiff)/maps" />
<param name="map_file_base_name" type="string" value="uprobotics" />
<param name="geotiff_save_period" type="double" value="0" />
<param name="draw_background_checkerboard" type="bool" value="true" />
<param name="draw_free_space_grid" type="bool" value="true" />
</node>
</launch>
上述建立好以後就可以使用hectorslam和rviz來查看結果了
$ roslaunch hector_slam_launch slam.launch
當掃描完以後就可以保存地圖了
Rosrun map_server map_saver –f /tmp/my_map
如果手上有turtlebot機器人的話,可以使用這個移動平臺來見圖,如何啓動移動平臺呢?方法如下:
roslaunch turtlebot_bringup minimal.launch --screen啓動turtlebot,然後執行
roslaunch turtlebot_teleop keyboard_teleop.launch
進行無線控制turtlebot
其實針對kobuki的機器人用下面的兩條語句更合適:
# This launches the minimal operation configuration > roslaunch kobuki_node minimal.launch # This launches the keyboard teloperation node # Probably you want to do this in another terminal > roslaunch kobuki_keyop keyop.launch
在安裝完ros後,建議執行一下命令安裝一些必要的ros包:
sudo apt-get install ros-indigo-turtlebot-bringup
ros-indigo-turtlebot-create-desktop ros-indigo-openni-*
ros-indigo-openni2-* ros-indigo-freenect-* ros-indigo-usb-cam
ros-indigo-laser-* ros-indigo-hokuyo-node
ros-indigo-audio-common gstreamer0.10-pocketsphinx
ros-indigo-pocketsphinx ros-indigo-slam-gmapping
ros-indigo-joystick-drivers python-rosinstall
ros-indigo-orocos-kdl ros-indigo-python-orocos-kdl
python-setuptools ros-indigo-dynamixel-motor-*
libopencv-dev python-opencv ros-indigo-vision-opencv
ros-indigo-depthimage-to-laserscan ros-indigo-arbotix-*
ros-indigo-turtlebot-teleop ros-indigo-move-base
ros-indigo-map-server ros-indigo-fake-localization
ros-indigo-amcl git subversion mercurial
最后
以上就是负责面包为你收集整理的使用RPLIDAR A2來跑hectorslam的全部内容,希望文章能够帮你解决使用RPLIDAR A2來跑hectorslam所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复