当前位置: 首页 > news >正文

ros1仿真导航机器人 hector_mapping gmapping

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

1 hector_mapping

建图过程

(1)gazebo仿真

roslaunch why_simulation why_slam.launch 

<launch><!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched --><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="$(find why_simulation)/worlds/slam_simple.world"/><arg name="paused" value="false"/><arg name="use_sim_time" value="true"/><arg name="gui" value="true"/><arg name="recording" value="false"/><arg name="debug" value="false"/></include><!-- Spawn a robot into Gazebo --><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" /><!-- tf --><arg name="model" default="$(find why_simulation)/models/wpb_home.model"/><param name="robot_description" command="$(find xacro)/xacro $(arg model)" /><node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /><node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" /></launch>

(2)启动建图节点

rosrun hector_mapping hector_mapping

(3)rviz

rviz

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

(4)控制机器人运动

rosrun rqt_robot_steering rqt_robot_steering

建图结果

launch

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

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

查找参数

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

(1)搜索hector_mapping

(2)选择Website

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

设置参数

<launch><include file="$(find why_simulation)/launch/why_slam.launch"/><node name="hector_mapping" pkg="hector_mapping" type="hector_mapping" output="screen"><param name="map_update_distance_thresh" value="0.1"/><param name="map_update_angle_thresh " value="0.1"/><param name="map_pub_period " value="0.1"/></node><node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/hector.rviz"/><node name="rqt_robot_steering" pkg="rqt_robot_steering " type="rqt_robot_steering " /></launch>

2 gmapping

建图过程

(1)gazebo环境

roslaunch why_simulation why_robocup.launch 

<launch><!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched --><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="$(find why_simulation)/worlds/why_robocup.world"/><arg name="paused" value="false"/><arg name="use_sim_time" value="true"/><arg name="gui" value="true"/><arg name="recording" value="false"/><arg name="debug" value="false"/></include><!-- Spawn the objects into Gazebo --><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" /><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" /><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" /><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" /><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" /> <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" /><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" /> <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" /><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" /><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" /><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" /><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" /><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" /><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" /><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" /><!-- Spawn a robot into Gazebo --><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" /><!-- tf --><arg name="model" default="$(find why_simulation)/models/wpb_home.model"/><param name="robot_description" command="$(find xacro)/xacro $(arg model)" /><node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /><node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" /><!-- lidar filter--><node pkg="why_simulation" type="lidar_filter" name="lidar_filter" /></launch>

(2)启动gmapping节点

rosrun gmapping slam_gmapping

(3)rviz

rviz

保存成gmapping.rviz

(4)控制机器人移动

rosrun why_simulation keyboard_vel_ctrl

建图结果

launch

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

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

设置参数

<launch><include file="$(find why_simulation)/launch/why_robocup.launch"/><node pkg="gmapping" type="slam_gmapping" name="slam_gmapping"><param name="map_update_interval" value="0.5"/><param name="linearUpdate " value="0.1"/></node><node name="rviz" pkg="rviz" type="rviz" args="-d $(find why_simulation)/rviz/gmapping.rviz"/><node name="why_simulation" pkg="keyboard_vel_ctrl " type="keyboard_vel_ctrl " /></launch>

3保存地图

rosrun map_server map_saver -f map

4加载地图

roscore

rosrun map_server map_server map.yaml

rviz

5 对比

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

http://www.lryc.cn/news/389693.html

相关文章:

  • 嵌入式实验---实验五 串口数据接收实验
  • ubuntu 22.04下编译安装glog共享库
  • Linux环境安装配置nginx服务流程
  • 设计模式-模板模式
  • 物理删除和逻辑删除区别
  • C# 警告 warning MSB3884: 无法找到规则集文件“MinimumRecommendedRules.ruleset”
  • Lua网站开发之文件表单上传
  • 千益畅行,旅游卡,如何赚钱?
  • Element-plus点击当前行之后获取数据显示跟随行数据
  • Docker与微服务实战2022 尚
  • Spring @Cacheable缓存注解用法说明
  • Redis如何实现主从复制
  • 正则表达式以及文本三剑客grep、sed、awk
  • HSRP热备份路由协议(VRRP虚拟路由冗余协议)配置以及实现负载均衡
  • 不同集成学习算法的比较:随机森林、AdaBoost、XGBoost、LightGBM
  • 【聊聊原子性,中断,以及nodejs中的具体示例】
  • 常见网络端口号
  • 【数值计算库-超长笔记】Python-Mpmath库:高精度数值计算
  • 昇思25天学习打卡营第6天|函数式自动微分
  • 作业7.2
  • PCL 点云聚类(基于体素连通性)
  • python自动化运维--DNS处理模块dnspython
  • 成人职场商务英语学习柯桥外语学校|邮件中的“备注”用英语怎么说?
  • AndroidStudio报错macMissing essential plugin
  • doris集群物理部署保姆级教程
  • 探囊取物之多形式登录页面(基于BootStrap4)
  • 【ONLYOFFICE】| 桌面编辑器从0-1使用初体验
  • 20、PHP字符串的排列(含源码)
  • Linux 标准IO的fopen和fclose
  • 一个计算密集小程序在不同CPU下的表现