当前位置:网站首页>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 :
边栏推荐
- ZOJ problem set – 2563 long dominoes [e.g. pressure DP]
- Ros Learning (23) Action Communication Mechanism
- Appium基础 — Appium Inspector定位工具(一)
- Scenario practice: quickly build wordpress blog system based on function calculation
- 【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?
- Right mouse button customization
- AcWing 346. Solution to the problem of water splashing festival in the corridor (deduction formula, minimum spanning tree)
- ROS学习(23)action通信机制
- ZOJ Problem Set – 2563 Long Dominoes 【如压力dp】
- Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
猜你喜欢
ROS學習(23)action通信機制
AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
shell脚本快速统计项目代码行数
dvajs的基础介绍及使用
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 1)
454 Baidu Mianjing 1
JVM memory model
js如何快速创建一个长度为 n 的数组
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)
Appium基础 — Appium Inspector定位工具(一)
随机推荐
Basic introduction and use of dvajs
JS ES5也可以創建常量?
字符串的相关编程题
Mongodb checks whether the table is imported successfully
ROS学习(23)action通信机制
LeetCode:1175. Prime permutation
Add PDF Title floating window
Yunna | work order management measures, how to carry out work order management
公钥\私人 ssh避password登陆
The cradle of eternity
736. LISP syntax parsing: DFS simulation questions
Ros Learning (23) Action Communication Mechanism
图片打水印 缩放 和一个输入流的转换
Appium基础 — Appium Inspector定位工具(一)
json学习初体验–第三者jar包实现bean、List、map创json格式
AcWing 1140. Shortest network (minimum spanning tree)
场景实践:基于函数计算快速搭建Wordpress博客系统
ZOJ problem set – 2563 long dominoes [e.g. pressure DP]
糊涂工具类(hutool)post请求设置body参数为json数据
Image watermarking, scaling and conversion of an input stream