From 4e15ed48bf8316dd1b5b9648763cd21d79159f58 Mon Sep 17 00:00:00 2001 From: li-shihao-code <2469171725@qq.com> Date: Thu, 26 Feb 2026 14:27:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=8C=E5=96=84=E4=BA=86=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A0=87=E5=AE=9A=E8=BD=A6=E9=97=B4=E7=9A=84=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => src/agv_calib_core}/CMakeLists.txt | 4 +- .../{ => src/agv_calib_core}/README.md | 0 .../{ => src/agv_calib_core}/package.xml | 2 +- .../proto/agv_calib_chassis.proto | 0 .../proto/agv_calib_control.proto | 0 .../proto/agv_calib_sensor.proto | 0 .../{ => agv_calib_core/src}/brain_node.cpp | 0 .../src/calibration_sim/CMakeLists.txt | 91 ++++++++++++++++ .../launch/calibration_system.launch.py | 73 +++++++++++++ .../src/calibration_sim/package.xml | 26 +++++ .../src/calibration_sim/urdf/agv.xacro | 72 +++++++++++++ .../urdf/calibration_board.xacro | 32 ++++++ .../urdf/workshop_sensors.xacro | 87 +++++++++++++++ .../worlds/calibration_room.world | 101 ++++++++++++++++++ 14 files changed, 485 insertions(+), 3 deletions(-) rename agv_calib_brain/{ => src/agv_calib_core}/CMakeLists.txt (97%) rename agv_calib_brain/{ => src/agv_calib_core}/README.md (100%) rename agv_calib_brain/{ => src/agv_calib_core}/package.xml (94%) rename agv_calib_brain/{ => src/agv_calib_core}/proto/agv_calib_chassis.proto (100%) rename agv_calib_brain/{ => src/agv_calib_core}/proto/agv_calib_control.proto (100%) rename agv_calib_brain/{ => src/agv_calib_core}/proto/agv_calib_sensor.proto (100%) rename agv_calib_brain/src/{ => agv_calib_core/src}/brain_node.cpp (100%) create mode 100644 agv_calib_brain/src/calibration_sim/CMakeLists.txt create mode 100644 agv_calib_brain/src/calibration_sim/launch/calibration_system.launch.py create mode 100644 agv_calib_brain/src/calibration_sim/package.xml create mode 100644 agv_calib_brain/src/calibration_sim/urdf/agv.xacro create mode 100644 agv_calib_brain/src/calibration_sim/urdf/calibration_board.xacro create mode 100644 agv_calib_brain/src/calibration_sim/urdf/workshop_sensors.xacro create mode 100644 agv_calib_brain/src/calibration_sim/worlds/calibration_room.world diff --git a/agv_calib_brain/CMakeLists.txt b/agv_calib_brain/src/agv_calib_core/CMakeLists.txt similarity index 97% rename from agv_calib_brain/CMakeLists.txt rename to agv_calib_brain/src/agv_calib_core/CMakeLists.txt index 21abe94..4950ca7 100644 --- a/agv_calib_brain/CMakeLists.txt +++ b/agv_calib_brain/src/agv_calib_core/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(agv_calib_brain) +project(agv_calib_core) # 1. 寻找 ROS 2 依赖 find_package(ament_cmake REQUIRED) @@ -46,4 +46,4 @@ ament_target_dependencies(brain_node rclcpp) target_link_libraries(brain_node agv_grpc_proto_lib) install(TARGETS brain_node DESTINATION lib/${PROJECT_NAME}) -ament_package() \ No newline at end of file +ament_package() diff --git a/agv_calib_brain/README.md b/agv_calib_brain/src/agv_calib_core/README.md similarity index 100% rename from agv_calib_brain/README.md rename to agv_calib_brain/src/agv_calib_core/README.md diff --git a/agv_calib_brain/package.xml b/agv_calib_brain/src/agv_calib_core/package.xml similarity index 94% rename from agv_calib_brain/package.xml rename to agv_calib_brain/src/agv_calib_core/package.xml index 3b8a58d..a227b83 100644 --- a/agv_calib_brain/package.xml +++ b/agv_calib_brain/src/agv_calib_core/package.xml @@ -1,7 +1,7 @@ - agv_calib_brain + agv_calib_core 0.0.0 TODO: Package description nvidia diff --git a/agv_calib_brain/proto/agv_calib_chassis.proto b/agv_calib_brain/src/agv_calib_core/proto/agv_calib_chassis.proto similarity index 100% rename from agv_calib_brain/proto/agv_calib_chassis.proto rename to agv_calib_brain/src/agv_calib_core/proto/agv_calib_chassis.proto diff --git a/agv_calib_brain/proto/agv_calib_control.proto b/agv_calib_brain/src/agv_calib_core/proto/agv_calib_control.proto similarity index 100% rename from agv_calib_brain/proto/agv_calib_control.proto rename to agv_calib_brain/src/agv_calib_core/proto/agv_calib_control.proto diff --git a/agv_calib_brain/proto/agv_calib_sensor.proto b/agv_calib_brain/src/agv_calib_core/proto/agv_calib_sensor.proto similarity index 100% rename from agv_calib_brain/proto/agv_calib_sensor.proto rename to agv_calib_brain/src/agv_calib_core/proto/agv_calib_sensor.proto diff --git a/agv_calib_brain/src/brain_node.cpp b/agv_calib_brain/src/agv_calib_core/src/brain_node.cpp similarity index 100% rename from agv_calib_brain/src/brain_node.cpp rename to agv_calib_brain/src/agv_calib_core/src/brain_node.cpp diff --git a/agv_calib_brain/src/calibration_sim/CMakeLists.txt b/agv_calib_brain/src/calibration_sim/CMakeLists.txt new file mode 100644 index 0000000..6f37ca2 --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/CMakeLists.txt @@ -0,0 +1,91 @@ +cmake_minimum_required(VERSION 3.8) +project(calibration_sim) + +# 1. 基础编译设置 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# 2. 寻找依赖库 +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) +find_package(sensor_msgs REQUIRED) # 用于 PointCloud2 +find_package(geometry_msgs REQUIRED) # 用于坐标变换 +find_package(tf2_ros REQUIRED) # 坐标变换工具 +find_package(tf2_geometry_msgs REQUIRED) +find_package(pcl_conversions REQUIRED)# ROS <-> PCL 转换桥梁 + +# 寻找系统级安装的 PCL 库 (非 ROS 包) +find_package(PCL REQUIRED COMPONENTS common io visualization filters registration segmentation) + +# 3. 定义可执行文件 (你的核心 C++ 节点) +# 假设你将来会写一个 lidar_fusion_node.cpp +#add_executable(lidar_fusion_node src/lidar_fusion_node.cpp) + +# 4. 配置头文件路径 +#target_include_directories(lidar_fusion_node PUBLIC +# $ + # $ + # ${PCL_INCLUDE_DIRS} # 必须包含 PCL 的头文件 +#) + +# 5. 链接库文件 +# 链接 ROS 相关的依赖 +#ament_target_dependencies(lidar_fusion_node + # rclcpp + # std_msgs + #sensor_msgs + #geometry_msgs + # tf2_ros + # tf2_geometry_msgs + # pcl_conversions +#) + +# 链接 PCL 相关的依赖 (PCL 不是 ament 包,需要单独链接) +#target_link_libraries(lidar_fusion_node + # ${PCL_LIBRARIES} +#) + +# 6. 安装规则 (至关重要!) + +# 安装可执行文件 (C++ 节点) +#install(TARGETS + # lidar_fusion_node +# DESTINATION lib/${PROJECT_NAME} +#) + +# 安装脚本文件 (如果你有 Python 节点) +# install(PROGRAMS +# scripts/my_python_script.py +# DESTINATION lib/${PROJECT_NAME} +# ) + +# 安装资源目录 (Launch, URDF, RViz, Worlds) +# 如果没有这步,你的 ros2 launch 命令会找不到文件 +install(DIRECTORY + launch + urdf + rviz + worlds + config + DESTINATION share/${PROJECT_NAME} +) + +# 7. 导出依赖与生成包 +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 the linter which checks for eccentric indentation + # comment the line when it conforms to defaults + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/agv_calib_brain/src/calibration_sim/launch/calibration_system.launch.py b/agv_calib_brain/src/calibration_sim/launch/calibration_system.launch.py new file mode 100644 index 0000000..9f17a6c --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/launch/calibration_system.launch.py @@ -0,0 +1,73 @@ +import os +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription, ExecuteProcess +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch_ros.actions import Node +import xacro + +def generate_launch_description(): + pkg_name = 'calibration_sim' + + # 1. 解析 URDF + infra_xacro = os.path.join(get_package_share_directory(pkg_name), 'urdf', 'workshop_sensors.xacro') + infra_doc = xacro.process_file(infra_xacro) + infra_xml = infra_doc.toxml() + + agv_xacro = os.path.join(get_package_share_directory(pkg_name), 'urdf', 'agv.xacro') + agv_doc = xacro.process_file(agv_xacro) + agv_xml = agv_doc.toxml() + + world_path = os.path.join( + get_package_share_directory('calibration_sim'), + 'worlds', + 'calibration_room.world' + ) + + # 2. 启动 Gazebo + gazebo = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]), + launch_arguments={'world': world_path}.items(), # 【关键】指定 world 参数 + ) + + # 3. 生成基础设施 (4个雷达) + spawn_infra = Node( + package='gazebo_ros', executable='spawn_entity.py', + arguments=['-topic', 'robot_description_infra', '-entity', 'workshop_sensors'], + output='screen' + ) + + # 发布基础设施的 State Publisher (为了TF树) + infra_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + name='infra_state_publisher', + parameters=[{'robot_description': infra_xml}], + remappings=[('robot_description', 'robot_description_infra')] + ) + + # 4. 生成 AGV + spawn_agv = Node( + package='gazebo_ros', executable='spawn_entity.py', + arguments=['-topic', 'robot_description_agv', '-entity', 'my_agv', '-z', '0.1'], + output='screen' + ) + + # 发布 AGV 的 State Publisher + agv_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + name='agv_state_publisher', + parameters=[{'robot_description': agv_xml}], + remappings=[('robot_description', 'robot_description_agv')] + ) + + return LaunchDescription([ + gazebo, + infra_state_publisher, + spawn_infra, + agv_state_publisher, + spawn_agv, + # 这里还可以加上 RViz 的节点 + ]) diff --git a/agv_calib_brain/src/calibration_sim/package.xml b/agv_calib_brain/src/calibration_sim/package.xml new file mode 100644 index 0000000..4b96452 --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/package.xml @@ -0,0 +1,26 @@ + + + + calibration_sim + 0.0.0 + Simulated environment for workshop calibration project + User + TODO: License declaration + + ament_cmake + + rclcpp + std_msgs + sensor_msgs + geometry_msgs + tf2_ros + tf2_geometry_msgs + pcl_conversions + + gazebo_ros ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/agv_calib_brain/src/calibration_sim/urdf/agv.xacro b/agv_calib_brain/src/calibration_sim/urdf/agv.xacro new file mode 100644 index 0000000..1d1032e --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/urdf/agv.xacro @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + left_wheel_joint + right_wheel_joint + 0.4 + 0.2 + true + true + odom + base_footprint + + + + diff --git a/agv_calib_brain/src/calibration_sim/urdf/calibration_board.xacro b/agv_calib_brain/src/calibration_sim/urdf/calibration_board.xacro new file mode 100644 index 0000000..f3f337c --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/urdf/calibration_board.xacro @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Checkerboard + + + + true + + + diff --git a/agv_calib_brain/src/calibration_sim/urdf/workshop_sensors.xacro b/agv_calib_brain/src/calibration_sim/urdf/workshop_sensors.xacro new file mode 100644 index 0000000..b5f887a --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/urdf/workshop_sensors.xacro @@ -0,0 +1,87 @@ + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/FlatBlack + + + 0 0 0 0 0 0 + false + 10 + + + 600 + 1 + -0.7854 + 0.7854 + + + + 128 + 1 + -0.2181 + 0.2251 + + + + + 0.5 210.0 + + + + gaussian + 0.0 + 0.03 + + + + + + /infrastructure + ~/out:=${name}/points + + sensor_msgs/PointCloud2 + ${name}_link + + + + + + + + + + + diff --git a/agv_calib_brain/src/calibration_sim/worlds/calibration_room.world b/agv_calib_brain/src/calibration_sim/worlds/calibration_room.world new file mode 100644 index 0000000..15ce2aa --- /dev/null +++ b/agv_calib_brain/src/calibration_sim/worlds/calibration_room.world @@ -0,0 +1,101 @@ + + + + + + 0.6 0.6 0.6 1.0 + 0.7 0.7 0.7 1.0 + true + + + model://ground_plane + + + true + 0 0 0 0 0 0 + 0 5 1.25 0 0 010.2 0.2 2.510.2 0.2 2.5 + 0 -5 1.25 0 0 010.2 0.2 2.510.2 0.2 2.5 + 5 0 1.25 0 0 00.2 10.0 2.50.2 10.0 2.5 + -5 0 1.25 0 0 00.2 10.0 2.50.2 10.0 2.5 + + + model://checkerboard_planeboard_n1-3.75 4.89 1.25 1.57 0 00.3125 0.3125 1 + model://checkerboard_planeboard_n2-1.25 4.89 1.25 1.57 0 00.3125 0.3125 1 + model://checkerboard_planeboard_n3 1.25 4.89 1.25 1.57 0 00.3125 0.3125 1 + model://checkerboard_planeboard_n4 3.75 4.89 1.25 1.57 0 00.3125 0.3125 1 + + model://checkerboard_planeboard_s1-3.75 -4.89 1.25 1.57 0 3.141590.3125 0.3125 1 + model://checkerboard_planeboard_s2-1.25 -4.89 1.25 1.57 0 3.141590.3125 0.3125 1 + model://checkerboard_planeboard_s3 1.25 -4.89 1.25 1.57 0 3.141590.3125 0.3125 1 + model://checkerboard_planeboard_s4 3.75 -4.89 1.25 1.57 0 3.141590.3125 0.3125 1 + + model://checkerboard_planeboard_e14.89 -3.75 1.25 1.57 0 -1.570.3125 0.3125 1 + model://checkerboard_planeboard_e24.89 -1.25 1.25 1.57 0 -1.570.3125 0.3125 1 + model://checkerboard_planeboard_e34.89 1.25 1.25 1.57 0 -1.570.3125 0.3125 1 + model://checkerboard_planeboard_e44.89 3.75 1.25 1.57 0 -1.570.3125 0.3125 1 + + model://checkerboard_planeboard_w1-4.89 -3.75 1.25 1.57 0 1.570.3125 0.3125 1 + model://checkerboard_planeboard_w2-4.89 -1.25 1.25 1.57 0 1.570.3125 0.3125 1 + model://checkerboard_planeboard_w3-4.89 1.25 1.25 1.57 0 1.570.3125 0.3125 1 + model://checkerboard_planeboard_w4-4.89 3.75 1.25 1.57 0 1.570.3125 0.3125 1 + + + + true + 0 0 2.5 0 0 0 + + 0-4.5 -4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-1.5 -4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 1.5 -4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 4.5 -4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-4.5 -1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-1.5 -1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 1.5 -1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 4.5 -1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-4.5 1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-1.5 1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 1.5 1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 4.5 1.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-4.5 4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0-1.5 4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 1.5 4.5 0 0 0 00.10.050.5 0.5 0.5 1 + 0 4.5 4.5 0 0 0 00.10.050.5 0.5 0.5 1 + + + + -4.5 -4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -1.5 -4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 1.5 -4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 4.5 -4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -4.5 -1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -1.5 -1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 1.5 -1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 4.5 -1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -4.5 1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -1.5 1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 1.5 1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 4.5 1.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -4.5 4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + -1.5 4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 1.5 4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + 4.5 4.5 2.45 0 0 00.3 0.3 0.3 10.1 0.1 0.1 160.20.050.10 + + + model://checkerboard_planefloor_n1-3.75 3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_n2-1.25 3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_n3 1.25 3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_n4 3.75 3.75 0.01 0 0 00.3125 0.3125 1 + + model://checkerboard_planefloor_s1-3.75 -3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_s2-1.25 -3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_s3 1.25 -3.75 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_s4 3.75 -3.75 0.01 0 0 00.3125 0.3125 1 + + model://checkerboard_planefloor_e13.75 -1.25 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_e23.75 1.25 0.01 0 0 00.3125 0.3125 1 + + model://checkerboard_planefloor_w1-3.75 -1.25 0.01 0 0 00.3125 0.3125 1 + model://checkerboard_planefloor_w2-3.75 1.25 0.01 0 0 00.3125 0.3125 1 + + +