当前位置:网站首页>ROS learning (XIX) robot slam function package cartographer
ROS learning (XIX) robot slam function package cartographer
2022-07-07 01:52:00 【Ice cream with code】
List of articles
Preface
cartographer The core is cartographer_node node , When running this node , Need one Lua Compiling .lua file , The main function of this file is to configure parameters , This is related to gmapping、hector stay launch The direct configuration parameters in the file are different .
cartographer The highlight of is code standardization and engineering , Suitable for commercial application and secondary development , It can effectively avoid the interference of moving objects in the environment during the mapping process , Support multi-sensor data mapping , Support 2D-slam and 3D-slam Drawing .
I customized a robot model before , Later in use cartographer In the process , It feels like something's wrong , But I can't solve this problem , I don't know if it's a configuration problem , still TF The problem of , ha-ha . So at the beginning of this article , Discard the previously customized robot model , Re customize a robot model , That is, use teacher Zhao's model , It is also convenient for follow-up kinect Use . Of the model xacro You can go to Baidu online , I will not introduce .
One 、cartographer_2d.launch file
launch The contents of the document are as follows :
<!-- Copyright 2016 The Cartographer Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<launch>
<param name="/use_sim_time" value="true" />
<node name="cartographer_node" pkg="cartographer_ros" type="cartographer_node" args=" -configuration_directory $(find robot_slam_cartographer)/configuration_files -configuration_basename rplidar.lua" output="screen">
<remap from="scan" to="scan" />
<param name="base_link" value="base_footprint"/>
</node>
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros" type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
<node name="rviz" pkg="rviz" type="rviz" required="true" args="-d $(find robot_slam_cartographer)/config/default.rviz" />
</launch>
This document mainly includes two parts , First, operation cartographer_node node , Two is to start rviz Visual interface . When running cartographer_node Node time , Need to use a by lua Written code file rplidar.lua, Configure parameters ,lua The contents of the document will be introduced later .
Two 、mbot_sim_gazebo_navigation_world.launch file
launch The contents of the document are as follows :
<?xml version="1.0"?>
<launch>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="worlds/mbot_sim_gazebo_navigation.world"/>
<arg name="paused" value="false"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="headless" value="false"/>
<arg name="debug" value="false"/>
</include>
</launch>
3、 ... and 、robot_gazebo_navigation.launch file
launch The contents of the document are as follows :
<?xml version="1.0"?>
<launch>
<!-- function gazebo Simulation environment -->
<include file="$(find gazebo_ros)/launch/mbot_sim_gazebo_navigation_world.launch">
</include>
<!-- Robot parameter settings -->
<arg name="model" default="$(find xacro)/xacro --inorder '$(find robot_slam_cartographer)/urdf/xacro/robot.xacro'" />
<!--robot_description The parameter name is preset by the parameter server , Can't change -->
<param name="robot_description" command="$(arg model)" />
<!-- function joint_state_publisher node , Release the joint status of the robot -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<!-- function robot_state_publisher node , Release tf -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
<!-- stay gazebo Loading robot model in -->
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen" args="-urdf -model mrobot -param robot_description"/>
<!--<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_slam_cartographer)/config/default.rviz"/>-->
<!--gmapping The package realizes synchronous positioning and map establishment <node name="slam_gmapping" pkg="gmapping" type="slam_gmapping"> <remap from="scan" to="/scan"/> <param name="base_link" value="base_footprint"/> </node>-->
<include file="$(find robot_slam_cartographer)/launch/cartographer_2d.launch"/>
</launch>
Four 、rplidar.lua file
The contents of the document are as follows :
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",
tracking_frame = "base_link",
published_frame = "base_link",
odom_frame = "odom",
provide_odom_frame = true,
use_odometry = false,
num_laser_scans = 1,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
trajectory_publish_period_sec = 30e-3,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
SPARSE_POSE_GRAPH.optimize_every_n_scans = 35
SPARSE_POSE_GRAPH.constraint_builder.min_score = 0.65
return options
5、 ... and 、 Compile operation
Every modification lua After the document , All need to be compiled , The order is as follows :
catkin_make_isolated --install --use-ninja

function launch file , The order is as follows :
roslaunch robot_slam_cartographer robot_gazebo_navigation.launch
then , Then run the keyboard control startup file , The order is as follows :
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Last , The effect of drawing is as follows :
6、 ... and 、 Save the map
Method 1、 Use map_saver Save directly as pgm and yaml file
Switch to map Catalog , newly build map_saver_map Folder , Execute the following command :
rosrun map_server map_saver -f myMapFile
Method 2、 Save it as .pbstream file , Convert to pgm and yaml file
Steps are as follows :
1、 Stop map building
rosservice call /finish_trajectory 0
2、 Generate .pbstream file
rosservice call /write_state "{filename: '${HOME}/catkin_google_ws/src/robot_slam_cartographer/map/carto_map.pbstream'}"
3、 take pbstream Turn into pgm and yaml file
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=${
HOME}/catkin_google_ws/src/robot_slam_cartographer/map/myMapFile -pbstream_filename=${
HOME}/catkin_google_ws/src/robot_slam_cartographer/map/carto_map.pbstream -resolution=0.05
The implementation effect is as follows :
The location of the map in the function pack is as follows :
边栏推荐
- AcWing 346. Solution to the problem of water splashing festival in the corridor (deduction formula, minimum spanning tree)
- 各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror
- 使用nodejs完成判断哪些项目打包+发版
- Scenario practice: quickly build wordpress blog system based on function calculation
- JS es5 peut également créer des constantes?
- What does security capability mean? What are the protection capabilities of different levels of ISO?
- LeetCode:1175. Prime permutation
- Comparison of picture beds of free white whoring
- Appium automation test foundation uiautomatorviewer positioning tool
- AcWing 344. 观光之旅题解(floyd求无向图的最小环问题)
猜你喜欢

一起看看matlab工具箱内部是如何实现BP神经网络的

BigDecimal 的正确使用方式

Gin introduction practice

Analyze "C language" [advanced] paid knowledge [End]

AcWing 361. Sightseeing cow problem solution (SPFA seeking positive ring)
![[advanced C language] 8 written questions of pointer](/img/d4/c9bb2c8c9fd8f54a36e463e3eb2fe0.png)
[advanced C language] 8 written questions of pointer

Yunna | work order management measures, how to carry out work order management

ROS学习(23)action通信机制

LeetCode. 剑指offer 62. 圆圈中最后剩下的数

Scenario practice: quickly build wordpress blog system based on function calculation
随机推荐
454 Baidu Mianjing 1
Ds-5/rvds4.0 variable initialization error
ROS学习(十九)机器人SLAM功能包——cartographer
Amway wave C2 tools
ZOJ Problem Set – 2563 Long Dominoes 【如压力dp】
AcWing 361. Sightseeing cow problem solution (SPFA seeking positive ring)
设置Wordpress伪静态连接(无宝塔)
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
What does front-end processor mean? What is the main function? What is the difference with fortress machine?
场景实践:基于函数计算快速搭建Wordpress博客系统
JS how to quickly create an array with length n
图片打水印 缩放 和一个输入流的转换
golang 基础 —— 数据类型
curl 命令
对C语言数组的再认识
Drag to change order
Yunna | work order management measures, how to carry out work order management
Add PDF Title floating window
How can I code for 8 hours without getting tired.
各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror