当前位置:网站首页>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 :
边栏推荐
- Use nodejs to determine which projects are packaged + released
- Get to know MySQL for the first time
- 增加 pdf 标题浮窗
- Amway wave C2 tools
- 刨析《C语言》【进阶】付费知识【一】
- AcWing 1140. 最短网络 (最小生成树)
- Machine learning: the difference between random gradient descent (SGD) and gradient descent (GD) and code implementation.
- Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)
- 开发中对集合里面的数据根据属性进行合并数量时犯的错误
- String to date object
猜你喜欢
今日问题-2022/7/4 lambda体中修改String引用类型变量
js如何快速创建一个长度为 n 的数组
AcWing 345. 牛站 题解(floyd的性质、倍增)
New job insights ~ leave the old and welcome the new~
Basic introduction and use of dvajs
开发中对集合里面的数据根据属性进行合并数量时犯的错误
新工作感悟~辞旧迎新~
Right mouse button customization
ROS学习(24)plugin插件
Comparison of picture beds of free white whoring
随机推荐
鼠标右键 自定义
JS ES5也可以创建常量?
各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror
The cradle of eternity
HDU 4661 message passing (wood DP & amp; Combinatorics)
WCF基金会
C language [23] classic interview questions [Part 2]
[advanced C language] 8 written questions of pointer
ROS学习(25)rviz plugin插件
AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
百度飞将BMN时序动作定位框架 | 数据准备与训练指南 (下)
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
AcWing 344. Solution to the problem of sightseeing tour (Floyd finding the minimum ring of undirected graph)
拖拽改变顺序
糊涂工具类(hutool)post请求设置body参数为json数据
Right mouse button customization
刨析《C语言》【进阶】付费知识【一】
AcWing 904. Wormhole solution (SPFA for negative rings)
Make DIY welding smoke extractor with lighting
AcWing 1148. Secret milk transportation problem solution (minimum spanning tree)