当前位置:网站首页>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
- NPM install compilation times "cannot read properties of null (reading 'pickalgorithm')“
- 刨析《C语言》【进阶】付费知识【二】
- Reptile practice (VI): novel of climbing pen interesting Pavilion
- IDEA常用的快捷键
- 2022/0524/bookstrap
- Appium基础 — Appium Inspector定位工具(一)
- npm install 编译时报“Cannot read properties of null (reading ‘pickAlgorithm‘)“
- Yunna | work order management software, work order management software app
- 454 Baidu Mianjing 1
猜你喜欢
Today's question -2022/7/4 modify string reference type variables in lambda body
BigDecimal 的正确使用方式
tansig和logsig的差异,为什么BP喜欢用tansig
Mongodb checks whether the table is imported successfully
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
ROS学习(十九)机器人SLAM功能包——cartographer
JVM 内存模型
New job insights ~ leave the old and welcome the new~
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)
JS how to quickly create an array with length n
随机推荐
图片打水印 缩放 和一个输入流的转换
百度飞将BMN时序动作定位框架 | 数据准备与训练指南 (上)
WCF基金会
ROS学习(22)TF变换
The cradle of eternity
AcWing 1141. 局域网 题解(kruskalkruskal 求最小生成树)
AcWing 346. Solution to the problem of water splashing festival in the corridor (deduction formula, minimum spanning tree)
一文带你走进【内存泄漏】
JS Es5 can also create constants?
AcWing 345. Cattle station solution (nature and multiplication of Floyd)
【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?
736. LISP syntax parsing: DFS simulation questions
MySQL's most basic select statement
C语言关于链表的代码看不懂?一篇文章让你拿捏二级指针并深入理解函数参数列表中传参的多种形式
AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
Yunna | work order management software, work order management software app
7.6 simulation summary
Reptile practice (VI): novel of climbing pen interesting Pavilion
BigDecimal 的正确使用方式
ROS学习(21)机器人SLAM功能包——orbslam的安装与测试