当前位置:   article > 正文

ros1仿真导航机器人 hector_mapping gmapping

ros1仿真导航机器人 hector_mapping gmapping

仅为学习记录和一些自己的思考,不具有参考意义。

1 hector_mapping

建图过程

(1)gazebo仿真

roslaunch why_simulation why_slam.launch 

  1. <launch>
  2. <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
  3. <include file="$(find gazebo_ros)/launch/empty_world.launch">
  4. <arg name="world_name" value="$(find why_simulation)/worlds/slam_simple.world"/>
  5. <arg name="paused" value="false"/>
  6. <arg name="use_sim_time" value="true"/>
  7. <arg name="gui" value="true"/>
  8. <arg name="recording" value="false"/>
  9. <arg name="debug" value="false"/>
  10. </include>
  11. <!-- Spawn a robot into Gazebo -->
  12. <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/wpb_home.model -urdf -x -0.0 -y -0.0 -model wpb_home" />
  13. <!-- tf -->
  14. <arg name="model" default="$(find why_simulation)/models/wpb_home.model"/>
  15. <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
  16. <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
  17. <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  18. </launch>

(2)启动建图节点

rosrun hector_mapping hector_mapping

(3)rviz

rviz

将所需要的模块添加进去之后,保存为hector.rviz文件。

(4)控制机器人运动

rosrun rqt_robot_steering rqt_robot_steering

建图结果

launch

新建一个launch文件,将以上四条指令添加到launch文件中。

  1. <launch>
  2. <include file="$(find why_simulation)/launch/why_slam.launch"/>
  3. <node name="hector_mapping" pkg="hector_mapping" type="hector_mapping" />
  4. <node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/hector.rviz"/>
  5. <node name="rqt_robot_steering" pkg="rqt_robot_steering " type="rqt_robot_steering " />
  6. </launch>

查找参数

ROS Indexa community-maintained index of robotics softwareicon-default.png?t=N7T8https://index.ros.org/

(1)搜索hector_mapping

(2)选择Website

即可查看到有哪些参数可以设置

设置参数

  1. <launch>
  2. <include file="$(find why_simulation)/launch/why_slam.launch"/>
  3. <node name="hector_mapping" pkg="hector_mapping" type="hector_mapping" output="screen">
  4. <param name="map_update_distance_thresh" value="0.1"/>
  5. <param name="map_update_angle_thresh " value="0.1"/>
  6. <param name="map_pub_period " value="0.1"/>
  7. </node>
  8. <node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/hector.rviz"/>
  9. <node name="rqt_robot_steering" pkg="rqt_robot_steering " type="rqt_robot_steering " />
  10. </launch>

2 gmapping

建图过程

(1)gazebo环境

roslaunch why_simulation why_robocup.launch 

  1. <launch>
  2. <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
  3. <include file="$(find gazebo_ros)/launch/empty_world.launch">
  4. <arg name="world_name" value="$(find why_simulation)/worlds/why_robocup.world"/>
  5. <arg name="paused" value="false"/>
  6. <arg name="use_sim_time" value="true"/>
  7. <arg name="gui" value="true"/>
  8. <arg name="recording" value="false"/>
  9. <arg name="debug" value="false"/>
  10. </include>
  11. <!-- Spawn the objects into Gazebo -->
  12. <node name="bed" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/bed.model -x 5.0 -y -3.9 -z 0 -Y 3.14159 -urdf -model bed" />
  13. <node name="sofa" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/sofa.model -x -1.0 -y -3.9 -z 0 -Y 1.57 -urdf -model sofa" />
  14. <node name="tea_table" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/tea_table.model -x -2.1 -y -2.2 -z 0 -Y 1.57 -urdf -model tea_table" />
  15. <node name="bookshelft" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/bookshelft.model -x 2.0 -y -0.55 -z 0 -Y -1.57 -urdf -model bookshelft" />
  16. <node name="kitchen_table" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/table.model -x -3.5 -y 3.7 -z 0 -Y 1.57 -urdf -model kitchen_table" />
  17. <node name="cupboard_0" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/cupboard.model -x -2.0 -y 0.7 -z 0 -Y 1.57 -urdf -model cupboard_0" />
  18. <node name="cupboard_1" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/cupboard.model -x -1.3 -y 3.7 -z 0 -Y -1.57 -urdf -model cupboard_1" />
  19. <node name="dinning_table_0" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/table.model -x 1.5 -y 1.5 -z 0 -Y 1.57 -urdf -model dinning_table_0" />
  20. <node name="dinning_table_1" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/table.model -x 1.5 -y 2.0 -z 0 -Y 1.57 -urdf -model dinning_table_1" />
  21. <node name="dinning_table_2" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/table.model -x 2.7 -y 1.5 -z 0 -Y 1.57 -urdf -model dinning_table_2" />
  22. <node name="dinning_table_3" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/table.model -x 2.7 -y 2.0 -z 0 -Y 1.57 -urdf -model dinning_table_3" />
  23. <node name="chair_0" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/chair.model -x 1.5 -y 1.2 -z 0 -Y 1.57 -urdf -model chair_0" />
  24. <node name="chair_1" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/chair.model -x 1.5 -y 2.3 -z 0 -Y -1.57 -urdf -model chair_1" />
  25. <node name="chair_2" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/chair.model -x 2.7 -y 1.2 -z 0 -Y 1.57 -urdf -model chair_2" />
  26. <node name="chair_3" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/chair.model -x 2.7 -y 2.3 -z 0 -Y -1.57 -urdf -model chair_3" />
  27. <!-- Spawn a robot into Gazebo -->
  28. <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-file $(find why_simulation)/models/wpb_home.model -urdf -x 0.0 -y -0.0 -model wpb_home" />
  29. <!-- tf -->
  30. <arg name="model" default="$(find why_simulation)/models/wpb_home.model"/>
  31. <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
  32. <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
  33. <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  34. <!-- lidar filter-->
  35. <node pkg="why_simulation" type="lidar_filter" name="lidar_filter" />
  36. </launch>

(2)启动gmapping节点

rosrun gmapping slam_gmapping

(3)rviz

rviz

保存成gmapping.rviz

(4)控制机器人移动

rosrun why_simulation keyboard_vel_ctrl

建图结果

launch

新建launch文件gmapping.launch,接上述指令添加到launch文件里

  1. <launch>
  2. <include file="$(find why_simulation)/launch/why_robocup.launch"/>
  3. <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping"/>
  4. <node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/gmapping.rviz"/>
  5. <node name="why_simulation" pkg="keyboard_vel_ctrl " type="keyboard_vel_ctrl " />
  6. </launch>

设置参数

  1. <launch>
  2. <include file="$(find why_simulation)/launch/why_robocup.launch"/>
  3. <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping">
  4. <param name="map_update_interval" value="0.5"/>
  5. <param name="linearUpdate " value="0.1"/>
  6. </node>
  7. <node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/gmapping.rviz"/>
  8. <node name="why_simulation" pkg="keyboard_vel_ctrl " type="keyboard_vel_ctrl " />
  9. </launch>

3保存地图

rosrun map_server map_saver -f map

4加载地图

roscore

rosrun map_server map_server map.yaml

rviz

5 对比

hector_mapping不使用里程计,长直的路径存在建图错误,gmapping使用里程计。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/786149
推荐阅读
相关标签
  

闽ICP备14008679号