1
0
forked from zbw/yiliao2026

new file: .gitignore

new file:   .vscode/settings.json
	deleted:    zbw_slamtoolbox/CMakeLists.txt
	deleted:    zbw_slamtoolbox/config/mapper_params_online_async.yaml
	deleted:    zbw_slamtoolbox/config/mapper_params_online_sync copy.yaml
	deleted:    zbw_slamtoolbox/config/navigation.yaml
	deleted:    zbw_slamtoolbox/launch/navigation.launch.py
	deleted:    zbw_slamtoolbox/launch/slamtoolbox.launch.py
	deleted:    zbw_slamtoolbox/package.xml
This commit is contained in:
2026-03-05 10:27:22 +08:00
parent 7fbddb15c2
commit b45049f18b
9 changed files with 7 additions and 261 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
log
build
install

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"cmake.ignoreCMakeListsMissing": true
}

View File

@@ -1,31 +0,0 @@
cmake_minimum_required(VERSION 3.8)
project(zbw_slamtoolbox)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
install(
DIRECTORY launch config
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()

View File

@@ -1,22 +0,0 @@
slam_toolbox:
ros__parameters:
# Plugin params
solver_plugin: solver_plugins::CeresSolver
ceres_linear_solver: SPARSE_NORMAL_CHOLESKY
ceres_preconditioner: SCHUR_JACOBI
ceres_trust_strategy: LEVENBERG_MARQUARDT
ceres_dogleg_type: TRADITIONAL_DOGLEG
ceres_loss_function: None
# ROS Parameters
odom_frame: odom
map_frame: map
base_frame: base_link
scan_topic: /scan
transform_timeout: 5.0
tf_buffer_duration: 30.0
minimum_range: 0.2 # 雷达硬件最小测距
queue_size: 50

View File

@@ -1,77 +0,0 @@
slam_toolbox:
ros__parameters:
# Plugin params
solver_plugin: solver_plugins::CeresSolver
ceres_linear_solver: SPARSE_NORMAL_CHOLESKY
ceres_preconditioner: SCHUR_JACOBI
ceres_trust_strategy: LEVENBERG_MARQUARDT
ceres_dogleg_type: TRADITIONAL_DOGLEG
ceres_loss_function: None
# ROS Parameters
odom_frame: odom
map_frame: map
base_frame: base_link
scan_topic: /scan
use_map_saver: true
mode: mapping #localization
# if you'd like to immediately start continuing a map at a given pose
# or at the dock, but they are mutually exclusive, if pose is given
# will use pose
#map_file_name: test_steve
#map_start_pose: [0.0, 0.0, 0.0]
#map_start_at_dock: true
debug_logging: false
throttle_scans: 2
transform_publish_period: 0.02 #if 0 never publishes odometry
map_update_interval: 5.0
resolution: 0.05
min_laser_range: 0.0 #for rastering images
max_laser_range: 20.0 #for rastering images
minimum_time_interval: 0.5
transform_timeout: 0.2
tf_buffer_duration: 30.
stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps
enable_interactive_mode: true
# General Parameters
use_scan_matching: true
use_scan_barycenter: true
minimum_travel_distance: 0.5
minimum_travel_heading: 0.5
scan_buffer_size: 10
scan_buffer_maximum_scan_distance: 10.0
link_match_minimum_response_fine: 0.1
link_scan_maximum_distance: 1.5
loop_search_maximum_distance: 3.0
do_loop_closing: true
loop_match_minimum_chain_size: 10
loop_match_maximum_variance_coarse: 3.0
loop_match_minimum_response_coarse: 0.35
loop_match_minimum_response_fine: 0.45
# Correlation Parameters - Correlation Parameters
correlation_search_space_dimension: 0.5
correlation_search_space_resolution: 0.01
correlation_search_space_smear_deviation: 0.1
# Correlation Parameters - Loop Closure Parameters
loop_search_space_dimension: 8.0
loop_search_space_resolution: 0.05
loop_search_space_smear_deviation: 0.03
# Scan Matcher Parameters
distance_variance_penalty: 0.5
angle_variance_penalty: 1.0
fine_search_angle_offset: 0.00349
coarse_search_angle_offset: 0.349
coarse_angle_resolution: 0.0349
minimum_angle_penalty: 0.9
minimum_distance_penalty: 0.5
use_response_expansion: true
min_pass_through: 2
occupancy_threshold: 0.1

View File

@@ -1,86 +0,0 @@
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
# 获取包路径
cyy_navigation2_dir = get_package_share_directory('cyy_navigation2')
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
# 声明参数
use_sim_time = LaunchConfiguration('use_sim_time', default='False')
slam = LaunchConfiguration('slam', default='False')
localization = LaunchConfiguration('localization', default='False')
# 定义文件路径
map_yaml_path = os.path.join(cyy_navigation2_dir, 'maps', 'cyy_map.yaml')
nav2_param_path = os.path.join(cyy_navigation2_dir, 'param', 'nav2_params.yaml')
slam_params_file = os.path.join(cyy_navigation2_dir, 'param', 'slam_toolbox_localization.yaml')
# 定义地图基础路径(用于 .posegraph 文件)
map_base_path = os.path.join(cyy_navigation2_dir, 'maps', 'cyy_map')
# 检查 .posegraph 文件是否存在
posegraph_path = map_base_path + '.posegraph'
if not os.path.exists(posegraph_path):
print(f"警告: .posegraph 文件不存在: {posegraph_path}")
print("将使用 AMCL 替代")
use_slam_toolbox = False
else:
use_slam_toolbox = True
print(f"找到 .posegraph 文件: {posegraph_path}")
# 创建启动描述
ld = LaunchDescription([
DeclareLaunchArgument('use_sim_time', default_value='False'),
DeclareLaunchArgument('slam', default_value='False'),
DeclareLaunchArgument('localization', default_value='False'),
])
# 如果使用 slam_toolbox
if use_slam_toolbox:
slam_toolbox_node = Node(
package='slam_toolbox',
executable='localization_slam_toolbox_node',
name='slam_toolbox',
output='screen',
parameters=[
slam_params_file,
{'use_sim_time': use_sim_time},
{'map_file_name': map_base_path},
{'map_start_pose': [0.0, 0.0, 0.0]}
],
remappings=[('/scan', '/scan')]
)
ld.add_action(slam_toolbox_node)
# 使用 slam_toolbox 时Nav2 不启用定位
localization_arg = 'False'
else:
# 使用 AMCL
localization_arg = 'True'
# Nav2 启动 - 使用正确的路径
nav2_launch_path = os.path.join(nav2_bringup_dir, 'launch', 'bringup_launch.py')
if not os.path.exists(nav2_launch_path):
print(f"错误: 找不到 Nav2 启动文件: {nav2_launch_path}")
return ld
nav2_bringup_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(nav2_launch_path),
launch_arguments={
'map': map_yaml_path,
'use_sim_time': use_sim_time,
'params_file': nav2_param_path,
'slam': slam,
'localization': localization_arg,
'autostart': 'True',
}.items(),
)
ld.add_action(nav2_bringup_launch)
return ld

View File

@@ -1,27 +0,0 @@
#!/usr/bin/env python3
from launch import LaunchDescription
from launch_ros.actions import Node, SetParameter
from ament_index_python.packages import get_package_share_directory
import os
def generate_launch_description():
# 获取参数文件路径
pkg_share = get_package_share_directory('zbw_slamtoolbox')
params_file = os.path.join(pkg_share, 'config', 'mapper_params_online_async.yaml')
set_use_sim_time = SetParameter(name='use_sim_time', value=False)
# 创建SLAM Toolbox节点
slam_toolbox_node = Node(
package='slam_toolbox',
executable='async_slam_toolbox_node', # 或 sync_slam_toolbox_node
name='slam_toolbox',
output='screen',
parameters=[params_file]
)
return LaunchDescription([
set_use_sim_time,
slam_toolbox_node
])

View File

@@ -1,18 +0,0 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>zbw_slamtoolbox</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="sunrise@todo.todo">sunrise</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>