初始化:RMUL 2027 哨兵导航仿真工程

- Gazebo Sim (Jetty 10.6) + ROS 2 Lyrical + Nav2 全栈
- 整车模型:URDF/SDF + 减面网格(SolidWorks 装配体实测尺寸)
- 场地:RMUL 2027 官方包(2D 栅格地图 + 3D 场地模型),放在 field/
- sentry_nav C++ 包:self_filter 点云自滤 / patrol 航点巡逻
- 文档:README(含本机开发环境实测)、MID-360 接入说明

已排除:build/ install/ log/ 缓存目录,以及 115 MB 的原始高模
(仿真实际用的是 meshes/base.stl 减面版,约 25.7 万面)
This commit is contained in:
mzx committed 2026-11-14 21:18:04 +08:00
1 parent ed31ccc39f
commit f7412ec369
142 files changed
+58958 -2

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.16)
project(sentry_sim)
find_package(ament_cmake REQUIRED)
# 网格/世界/URDF/配置/launch 原样安装(colcon build --symlink-install 时不会复制,省 180MB)
install(DIRECTORY meshes models urdf worlds launch config scripts
DESTINATION share/${PROJECT_NAME}
)
install(PROGRAMS scripts/odom_tf.py scripts/run_gz.sh scripts/spawn_robot.sh scripts/sentry_up.sh scripts/bridge_after_gz.sh scripts/cmd_vel_relay.py
DESTINATION lib/${PROJECT_NAME}
)
ament_package()
+27
View File
@@ -0,0 +1,27 @@
# src/sentry_sim/ (ROS 2 包)
哨兵导航仿真的核心包。
| 目录 | 内容 |
|---|---|
| `urdf/` | 整车 URDF(xacro),**改尺寸/质量/传感器位置都在这里** |
| `models/sentry/` | Gazebo 用的模型(由 `tools/gen_sdf.sh` 从 URDF 生成,别手改) |
| `worlds/` | 仿真世界(RMUL 场地 + 哨兵) |
| `meshes/` | 减面后的网格;`full/` 存原始高模 + 布局数据 |
| `config/` | Nav2 参数、RViz 配置 |
| `launch/` | `ros2 launch` 版本启动文件(主入口是 `scripts/sentry_up.sh`) |
| `scripts/` | 启动/桥接/转发用的 shell 与 python 脚本 |
## 改完东西的标准流程
```bash
# 改 urdf/sentry.urdf.xacro 之后
source install/setup.bash && ./tools/gen_sdf.sh # URDF -> models/sentry/model.sdf
colcon build --symlink-install --packages-select sentry_sim
```
## 跑起来
```bash
cd ~/Gazebo_projects/sentry_nav_dev && HEADLESS=0 scripts/sentry_up.sh
```
+20
View File
@@ -0,0 +1,20 @@
# config/
| 文件 | 说明 |
|---|---|
| `nav2_params.yaml` | Nav2 全部参数(代价地图、MPPI 控制器、AMCL、行为树…) |
| `sentry.rviz` | RViz 布局(Map / LaserScan / TF / Costmap 已配好) |
## nav2_params.yaml 里改过的关键项
| 参数 | 值 | 为什么 |
|---|---|---|
| `footprint` | `[[0.325,0.270],[0.325,-0.270],[-0.325,-0.270],[-0.325,0.270]]` | 车体 0.578×0.521 实测 |
| `inflation_radius` | `0.45`(默认 0.70 会把 12×8 场地填死) | 场地太小 |
| `consider_footprint` | `true` | 与矩形 footprint 对齐,否则 MPPI 判碰撞不一致 |
| `enable_stamped_cmd_vel` | `false`(7 个节点都关了) | 本版本默认发 TwistStamped,而 ros_gz 桥只认 Twist |
| `default_server_timeout` / `wait_for_service_timeout` | `15000` | 本机启动慢,否则 BT 建树失败 |
| local costmap `plugins` | 只有 `inflation_layer` | 2D 雷达会扫到车身自身,参与代价地图会把自己围死 |
| global costmap `plugins` | `static_layer` + `inflation_layer` | 场地是静态的,用地图就够 |
> 改之前先看一眼注释,里面写了每处的原因。
+616
View File
@@ -0,0 +1,616 @@
amcl:
ros__parameters:
alpha1: 0.2
alpha2: 0.2
alpha3: 0.2
alpha4: 0.2
alpha5: 0.2
base_frame_id: "base_link"
beam_skip_distance: 0.5
beam_skip_error_threshold: 0.9
beam_skip_threshold: 0.3
do_beamskip: false
global_frame_id: "map"
lambda_short: 0.1
laser_likelihood_max_dist: 2.0
laser_max_range: 100.0
laser_min_range: -1.0
laser_model_type: "likelihood_field"
max_beams: 60
max_particles: 2000
min_particles: 500
odom_frame_id: "odom"
pf_err: 0.05
pf_z: 0.99
recovery_alpha_fast: 0.0
recovery_alpha_slow: 0.0
random_seed: -1
resample_interval: 1
robot_model_type: "nav2_amcl::DifferentialMotionModel"
save_pose_rate: 0.5
sigma_hit: 0.2
tf_broadcast: true
transform_tolerance: 1.0
introspection_mode: "disabled"
update_min_a: 0.2
update_min_d: 0.25
z_hit: 0.5
z_max: 0.05
z_rand: 0.5
z_short: 0.05
scan_topic: scan
# ---- 本工程:开机即给初始位姿(RMUL 场地红方出生点)
set_initial_pose: true
initial_pose:
x: 0.9
y: 4.0
z: 0.0
yaw: 0.0
bt_navigator:
ros__parameters:
enable_stamped_cmd_vel: false
global_frame: map
robot_base_frame: base_link
odom_topic: odom
bt_loop_duration: 10
filter_duration: 0.3
# 本机激活较慢:放宽动作服务等待,避免 bringup 期间 BT 建树失败
default_server_timeout: 15000
default_cancel_timeout: 50
wait_for_service_timeout: 15000
introspection_mode: "disabled"
navigators: ["navigate_to_pose", "navigate_through_poses"]
navigate_to_pose:
plugin: "nav2_bt_navigator::NavigateToPoseNavigator"
enable_groot_monitoring: false
groot_server_port: 1667
search_window: 2.0
navigate_through_poses:
plugin: "nav2_bt_navigator::NavigateThroughPosesNavigator"
enable_groot_monitoring: false
groot_server_port: 1669
search_window: 2.0
bt_search_directories:
- $(find-pkg-share nav2_bt_navigator)/behavior_trees
# 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults:
# nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml
# nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml
# They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2.
# plugin_lib_names is used to add custom BT plugins to the executor (vector of strings).
# Built-in plugins are added automatically
# plugin_lib_names: []
error_code_name_prefixes:
- assisted_teleop
- backup
- compute_path
- dock_robot
- drive_on_heading
- follow_object
- follow_path
- nav_thru_poses
- nav_to_pose
- route
- spin
- smoother
- undock_robot
- wait
controller_server:
ros__parameters:
enable_stamped_cmd_vel: false # 用普通 Twist(ros_gz 桥只认 Twist)
controller_frequency: 20.0
costmap_update_timeout: 0.30
min_x_velocity_threshold: 0.001
min_y_velocity_threshold: 0.5
min_theta_velocity_threshold: 0.001
failure_tolerance: 0.3
progress_checker_plugins: ["progress_checker"]
goal_checker_plugins: ["general_goal_checker"] # "precise_goal_checker"
controller_plugins: ["FollowPath"]
path_handler_plugins: ["PathHandler"]
use_realtime_priority: false
speed_limit_topic: "speed_limit"
# Progress checker parameters
progress_checker:
plugin: "nav2_controller::SimpleProgressChecker"
required_movement_radius: 0.5
movement_time_allowance: 10.0
# Goal checker parameters
#precise_goal_checker:
# plugin: "nav2_controller::SimpleGoalChecker"
# xy_goal_tolerance: 0.25
# yaw_goal_tolerance: 0.25
# stateful: true
general_goal_checker:
stateful: true
plugin: "nav2_controller::SimpleGoalChecker"
xy_goal_tolerance: 0.25
yaw_goal_tolerance: 0.25
path_length_tolerance: 1.0
PathHandler:
plugin: "nav2_controller::FeasiblePathHandler"
prune_distance: 2.0
enforce_path_inversion: false
enforce_path_rotation: false
inversion_xy_tolerance: 0.2
inversion_yaw_tolerance: 0.4
minimum_rotation_angle: 0.785
reject_unit_path: false
FollowPath:
plugin: "nav2_mppi_controller::MPPIController"
time_steps: 56
model_dt: 0.05
model_delay_vx: 0.0
model_delay_vy: 0.0
model_delay_wz: 0.0
batch_size: 2000
open_loop: false
ax_max: 3.0
ax_min: -3.0
ay_max: 3.0
ay_min: -3.0
az_max: 3.5
vx_std: 0.2
vy_std: 0.2
wz_std: 0.4
vx_max: 0.5
vx_min: -0.35
vy_max: 0.5
wz_max: 1.9
iteration_count: 1
temperature: 0.3
gamma: 0.015
visualize: true
publish_optimal_trajectory: true
regenerate_noises: true
motion_model: "diff_drive"
diff_drive:
plugin: "mppi::OmniMotionModel"
TrajectoryVisualizer:
trajectory_step: 5
time_step: 3
TrajectoryValidator:
# The validator can be configured with additional parameters if needed.
plugin: "mppi::DefaultOptimalTrajectoryValidator"
collision_lookahead_time: 2.0 # Time to look ahead to check for collisions
consider_footprint: true # 与代价地图的矩形 footprint 保持一致
critics:
[
"ConstraintCritic",
"CostCritic",
"GoalCritic",
"GoalAngleCritic",
"PathAlignCritic",
"PathFollowCritic",
"PathAngleCritic",
"PreferForwardCritic",
]
ConstraintCritic:
enabled: true
cost_power: 1
cost_weight: 4.0
GoalCritic:
enabled: true
cost_power: 1
cost_weight: 5.0
threshold_to_consider: 1.4
GoalAngleCritic:
enabled: true
cost_power: 1
cost_weight: 3.0
threshold_to_consider: 0.5
PreferForwardCritic:
enabled: true
cost_power: 1
cost_weight: 5.0
threshold_to_consider: 0.5
CostCritic:
enabled: true
cost_power: 1
cost_weight: 3.81
near_collision_cost: 253
critical_cost: 300.0
consider_footprint: true
collision_cost: 1000000.0
near_goal_distance: 1.0
trajectory_point_step: 2
PathAlignCritic:
enabled: true
cost_power: 1
cost_weight: 14.0
max_path_occupancy_ratio: 0.05
trajectory_point_step: 4
threshold_to_consider: 0.5
offset_from_furthest: 20
use_path_orientations: false
PathFollowCritic:
enabled: true
cost_power: 1
cost_weight: 5.0
offset_from_furthest: 5
threshold_to_consider: 1.4
PathAngleCritic:
enabled: true
cost_power: 1
cost_weight: 2.0
offset_from_furthest: 4
threshold_to_consider: 0.5
max_angle_to_furthest: 1.0
mode: 0
# TwirlingCritic:
# enabled: true
# twirling_cost_power: 1
# twirling_cost_weight: 10.0
local_costmap:
local_costmap:
ros__parameters:
update_frequency: 5.0
publish_frequency: 2.0
global_frame: odom
robot_base_frame: base_link
rolling_window: true
width: 6
height: 6
resolution: 0.05
footprint: "[[0.325, 0.270], [0.325, -0.270], [-0.325, -0.270], [-0.325, 0.270]]"
# MID-360 的 3D 点云已接入(/scan/points,PointCloud2)
# MID-360 点云经 sentry_nav/self_filter 自滤(剔除车身包围盒内的点)后接入
plugins: ["voxel_layer", "inflation_layer"]
voxel_layer:
plugin: "nav2_costmap_2d::VoxelLayer"
enabled: True
publish_voxel_map: False
origin_z: 0.0
z_resolution: 0.05
z_voxels: 16
max_obstacle_height: 1.2
mark_threshold: 0
observation_sources: pointcloud
pointcloud:
topic: /scan/points_filtered
data_type: "PointCloud2"
min_obstacle_height: 0.02
max_obstacle_height: 1.2
obstacle_min_range: 0.20
obstacle_max_range: 4.5
raytrace_min_range: 0.20
raytrace_max_range: 12.0
clearing: True
marking: True
filters: ["keepout_filter"]
keepout_filter:
plugin: "nav2_costmap_2d::KeepoutFilter"
enabled: KEEPOUT_ZONE_ENABLED
filter_info_topic: "keepout_costmap_filter_info"
override_lethal_cost: true
lethal_override_cost: 200
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 2.0
inflation_radius: 0.45
static_layer:
plugin: "nav2_costmap_2d::StaticLayer"
map_subscribe_transient_local: true
always_send_full_costmap: true
introspection_mode: "disabled"
global_costmap:
global_costmap:
ros__parameters:
update_frequency: 5.0
publish_frequency: 1.0
global_frame: map
robot_base_frame: base_link
footprint: "[[0.325, 0.270], [0.325, -0.270], [-0.325, -0.270], [-0.325, 0.270]]"
resolution: 0.05
track_unknown_space: true
plugins: ["static_layer", "obstacle_layer", "inflation_layer"]
obstacle_layer:
plugin: "nav2_costmap_2d::ObstacleLayer"
enabled: True
observation_sources: pointcloud
pointcloud:
topic: /scan/points_filtered
data_type: "PointCloud2"
min_obstacle_height: 0.02
max_obstacle_height: 1.2
obstacle_min_range: 0.20
obstacle_max_range: 4.5
raytrace_min_range: 0.20
raytrace_max_range: 12.0
clearing: True
marking: True
filters: ["keepout_filter", "speed_filter"]
keepout_filter:
plugin: "nav2_costmap_2d::KeepoutFilter"
enabled: KEEPOUT_ZONE_ENABLED
filter_info_topic: "keepout_costmap_filter_info"
override_lethal_cost: true
lethal_override_cost: 200
speed_filter:
plugin: "nav2_costmap_2d::SpeedFilter"
enabled: SPEED_ZONE_ENABLED
filter_info_topic: "speed_costmap_filter_info"
speed_limit_topic: "speed_limit"
static_layer:
plugin: "nav2_costmap_2d::StaticLayer"
map_subscribe_transient_local: true
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 2.0
inflation_radius: 0.45
always_send_full_costmap: true
introspection_mode: "disabled"
# The yaml_filename does not need to be specified since it going to be set by defaults in launch.
# If you'd rather set it in the yaml, remove the default "map" value in the launch file(s).
# file & provide full path to map below. If CLI map configuration or launch default is provided, that will be used.
map_server:
ros__parameters:
# yaml_filename: ""
introspection_mode: "disabled"
keepout_filter_mask_server:
ros__parameters:
topic_name: "keepout_filter_mask"
# yaml_filename: ""
keepout_costmap_filter_info_server:
ros__parameters:
type: 0
filter_info_topic: "keepout_costmap_filter_info"
mask_topic: "keepout_filter_mask"
base: 0.0
multiplier: 1.0
speed_filter_mask_server:
ros__parameters:
topic_name: "speed_filter_mask"
# yaml_filename: ""
speed_costmap_filter_info_server:
ros__parameters:
type: 1
filter_info_topic: "speed_costmap_filter_info"
mask_topic: "speed_filter_mask"
base: 100.0
multiplier: -1.0
map_saver:
ros__parameters:
save_map_timeout: 5.0
free_thresh_default: 0.25
occupied_thresh_default: 0.65
map_subscribe_transient_local: true
introspection_mode: "disabled"
planner_server:
ros__parameters:
allow_partial_planning: false
expected_planner_frequency: 20.0
planner_plugins: ["GridBased"]
costmap_update_timeout: 1.0
introspection_mode: "disabled"
GridBased:
plugin: "nav2_navfn_planner::NavfnPlanner"
tolerance: 0.5
use_astar: false
max_cycles_factor: 4
allow_unknown: true
smoother_server:
ros__parameters:
smoother_plugins: ["simple_smoother", "route_smoother"]
simple_smoother:
plugin: "nav2_smoother::SimpleSmoother"
tolerance: 1.0e-10
max_its: 1000
refinement_num: 2
# True for Hybrid A* or State Lattice to not smooth over directional changes
enforce_path_inversion: true
do_refinement: true
route_smoother:
plugin: "nav2_smoother::SimpleSmoother"
tolerance: 1.0e-10
max_its: 1000
refinement_num: 5
# False for Route Server or others where smoothing out sharp corners is OK
enforce_path_inversion: false
do_refinement: true
behavior_server:
ros__parameters:
enable_stamped_cmd_vel: false # 用普通 Twist(ros_gz 桥只认 Twist)
local_costmap_topic: local_costmap/costmap_raw
global_costmap_topic: global_costmap/costmap_raw
local_footprint_topic: local_costmap/published_footprint
global_footprint_topic: global_costmap/published_footprint
cycle_frequency: 10.0
behavior_plugins:
["spin", "backup", "drive_on_heading", "assisted_teleop", "wait"]
spin:
plugin: "nav2_behaviors::Spin"
backup:
plugin: "nav2_behaviors::BackUp"
acceleration_limit: 2.5
deceleration_limit: -2.5
minimum_speed: 0.10
drive_on_heading:
plugin: "nav2_behaviors::DriveOnHeading"
acceleration_limit: 2.5
deceleration_limit: -2.5
minimum_speed: 0.10
wait:
plugin: "nav2_behaviors::Wait"
assisted_teleop:
plugin: "nav2_behaviors::AssistedTeleop"
local_frame: odom
global_frame: map
robot_base_frame: base_link
transform_tolerance: 0.1
simulate_ahead_time: 2.0
max_rotational_vel: 1.0
min_rotational_vel: 0.4
rotational_acc_lim: 3.2
waypoint_follower:
ros__parameters:
loop_rate: 20
stop_on_failure: false
introspection_mode: "disabled"
waypoint_task_executor_plugin: "wait_at_waypoint"
wait_at_waypoint:
plugin: "nav2_waypoint_follower::WaitAtWaypoint"
enabled: true
waypoint_pause_duration: 200
route_server:
ros__parameters:
enable_stamped_cmd_vel: false
# The graph_filepath does not need to be specified since it going to be set by defaults in launch.
# If you'd rather set it in the yaml, remove the default "graph" value in the launch file(s).
# file & provide full path to map below. If graph config or launch default is provided, it is used
# graph_filepath: $(find-pkg-share nav2_route)/graphs/aws_graph.geojson
boundary_radius_to_achieve_node: 1.0
radius_to_achieve_node: 2.0
smooth_corners: true
operations: ["AdjustSpeedLimit", "ReroutingService", "CollisionMonitor"]
ReroutingService:
plugin: "nav2_route::ReroutingService"
AdjustSpeedLimit:
plugin: "nav2_route::AdjustSpeedLimit"
CollisionMonitor:
plugin: "nav2_route::CollisionMonitor"
max_collision_dist: 3.0
edge_cost_functions: ["DistanceScorer", "CostmapScorer"]
DistanceScorer:
plugin: "nav2_route::DistanceScorer"
CostmapScorer:
plugin: "nav2_route::CostmapScorer"
velocity_smoother:
ros__parameters:
enable_stamped_cmd_vel: false # 用普通 Twist(ros_gz 桥只认 Twist)
smoothing_frequency: 20.0
scale_velocities: false
feedback: "OPEN_LOOP"
max_velocity: [0.5, 0.0, 2.0]
min_velocity: [-0.5, 0.0, -2.0]
max_accel: [3.0, 0.0, 3.5]
max_decel: [-3.0, 0.0, -3.5]
odom_topic: "odom"
odom_duration: 0.1
deadband_velocity: [0.0, 0.0, 0.0]
velocity_timeout: 1.0
collision_monitor:
ros__parameters:
enable_stamped_cmd_vel: false # 用普通 Twist(ros_gz 桥只认 Twist)
enabled: true
base_frame_id: "base_link"
odom_frame_id: "odom"
cmd_vel_in_topic: "cmd_vel_smoothed"
cmd_vel_out_topic: "cmd_vel"
state_topic: "collision_monitor_state"
transform_tolerance: 0.2
source_timeout: 1.0
base_shift_correction: true
stop_pub_timeout: 2.0
# Polygons represent zone around the robot for "stop", "slowdown" and "limit" action types,
# and robot footprint for "approach" action type.
polygons: ["FootprintApproach"]
FootprintApproach:
type: "polygon"
action_type: "approach"
footprint_topic: "local_costmap/published_footprint"
time_before_collision: 1.2
simulation_time_step: 0.1
min_points: 6
visualize: false
enabled: true
observation_sources: ["scan"]
scan:
type: "scan"
topic: "scan"
min_height: 0.15
max_height: 2.0
enabled: true
docking_server:
ros__parameters:
enable_stamped_cmd_vel: false
controller_frequency: 50.0
initial_perception_timeout: 5.0
wait_charge_timeout: 5.0
dock_approach_timeout: 30.0
undock_linear_tolerance: 0.05
undock_angular_tolerance: 0.1
max_retries: 3
base_frame: "base_link"
fixed_frame: "odom"
dock_prestaging_tolerance: 0.5
introspection_mode: "disabled"
# Types of docks
dock_plugins: ["simple_charging_dock"]
simple_charging_dock:
plugin: "opennav_docking::SimpleChargingDock"
docking_threshold: 0.05
staging_x_offset: -0.7
use_external_detection_pose: true
use_battery_status: false # true
use_stall_detection: false # true
dock_direction: "forward"
external_detection_timeout: 1.0
external_detection_translation_x: -0.18
external_detection_translation_y: 0.0
external_detection_rotation_roll: -1.57
external_detection_rotation_pitch: -1.57
external_detection_rotation_yaw: 0.0
filter_coef: 0.1
# Dock instances
# The following example illustrates configuring dock instances.
# docks: ['home_dock'] # Input your docks here
# home_dock:
# type: 'simple_charging_dock'
# frame: map
# pose: [0.0, 0.0, 0.0]
controller:
k_phi: 3.0
k_delta: 2.0
v_linear_min: 0.15
v_linear_max: 0.15
use_collision_detection: true
costmap_topic: "local_costmap/costmap_raw"
footprint_topic: "local_costmap/published_footprint"
transform_tolerance: 0.1
projection_time: 5.0
simulation_step: 0.1
dock_collision_threshold: 0.3
loopback_simulator:
ros__parameters:
base_frame_id: "base_link"
odom_frame_id: "odom"
map_frame_id: "map"
scan_frame_id: "base_scan" # tb4_loopback_simulator.launch.py remaps to 'rplidar_link'
update_duration: 0.02
scan_range_min: 0.05
scan_range_max: 30.0
scan_angle_min: -3.1415
scan_angle_max: 3.1415
scan_angle_increment: 0.02617
scan_use_inf: true
# 本工程补充:following_server 默认会发 TwistStamped,和 ros_gz 桥的 Twist 冲突
following_server:
ros__parameters:
enable_stamped_cmd_vel: false
+641
View File
@@ -0,0 +1,641 @@
Panels:
- Class: rviz_common/Displays
Help Height: 0
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /TF1/Frames1
- /TF1/Tree1
- /MarkerArray2/Status1
- /MarkerArray2/Topic1
Splitter Ratio: 0.5833333134651184
Tree Height: 287
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.3333333432674408
- Class: nav2_rviz_plugins/Navigation 2
Name: Navigation 2
- Class: nav2_rviz_plugins/Selector
Name: Selector
- Class: nav2_rviz_plugins/Docking
Name: Docking
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz_default_plugins/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Class: rviz_default_plugins/RobotModel
Collision Enabled: false
Description File: ""
Description Source: Topic
Description Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: robot_description
Enabled: false
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: ""
Mass Properties:
Inertia: false
Mass: false
Name: RobotModel
TF Prefix: ""
Update Interval: 0
Value: false
Visual Enabled: true
- Class: rviz_default_plugins/TF
Enabled: true
Filter (blacklist): ""
Filter (whitelist): ""
Frame Timeout: 15
Frames:
All Enabled: false
base_footprint:
Value: true
base_link:
Value: true
base_scan:
Value: true
camera_depth_frame:
Value: true
camera_depth_optical_frame:
Value: true
camera_link:
Value: true
camera_rgb_frame:
Value: true
camera_rgb_optical_frame:
Value: true
caster_back_left_link:
Value: true
caster_back_right_link:
Value: true
imu_link:
Value: true
odom:
Value: true
wheel_left_link:
Value: true
wheel_right_link:
Value: true
Marker Scale: 1
Name: TF
Show Arrows: true
Show Axes: true
Show Names: false
Tree:
{}
Update Interval: 0
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/LaserScan
Color: 255; 255; 255
Color Transformer: Intensity
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 0
Min Color: 0; 0; 0
Min Intensity: 0
Name: LaserScan
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Points
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Best Effort
Value: scan
Use Fixed Frame: true
Use rainbow: true
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/PointCloud2
Color: 255; 255; 255
Color Transformer: ""
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 4096
Min Color: 0; 0; 0
Min Intensity: 0
Name: MID360点云
Position Transformer: ""
Selectable: true
Size (Pixels): 3
Size (m): 0.02
Style: Points
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Best Effort
Value: /scan/points
Use Fixed Frame: true
Use rainbow: true
Value: true
- Alpha: 1
Binary representation: false
Binary threshold: 100
Class: rviz_default_plugins/Map
Color Scheme: map
Draw Behind: true
Enabled: true
Name: Map
Topic:
Depth: 1
Durability Policy: Transient Local
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: map
Update Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: map_updates
Use Timestamp: false
Value: true
- Alpha: 0.699999988079071
Binary representation: false
Binary threshold: 100
Class: rviz_default_plugins/Map
Color Scheme: map
Draw Behind: true
Enabled: true
Name: Map
Topic:
Depth: 5
Durability Policy: Transient Local
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: speed_filter_mask
Update Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: speed_filter_mask_updates
Use Timestamp: false
Value: true
- Alpha: 1
Class: nav2_rviz_plugins/ParticleCloud
Color: 0; 180; 0
Enabled: true
Max Arrow Length: 0.30000001192092896
Min Arrow Length: 0.019999999552965164
Name: Amcl Particle Swarm
Shape: Arrow (Flat)
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Best Effort
Value: particle_cloud
Value: true
- Class: rviz_common/Group
Displays:
- Alpha: 0.30000001192092896
Binary representation: false
Binary threshold: 100
Class: rviz_default_plugins/Map
Color Scheme: costmap
Draw Behind: false
Enabled: true
Name: Global Costmap
Topic:
Depth: 1
Durability Policy: Transient Local
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: global_costmap/costmap
Update Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: global_costmap/costmap_updates
Use Timestamp: false
Value: true
- Alpha: 0.30000001192092896
Binary representation: false
Binary threshold: 100
Class: rviz_default_plugins/Map
Color Scheme: costmap
Draw Behind: false
Enabled: true
Name: Downsampled Costmap
Topic:
Depth: 1
Durability Policy: Transient Local
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: downsampled_costmap
Update Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: downsampled_costmap_updates
Use Timestamp: false
Value: true
- Alpha: 1
Buffer Length: 1
Class: rviz_default_plugins/Path
Color: 255; 0; 0
Enabled: true
Head Diameter: 0.019999999552965164
Head Length: 0.019999999552965164
Length: 0.30000001192092896
Line Style: Lines
Line Width: 0.029999999329447746
Name: Path
Offset:
X: 0
Y: 0
Z: 0
Pose Color: 255; 85; 255
Pose Style: Arrows
Radius: 0.029999999329447746
Shaft Diameter: 0.004999999888241291
Shaft Length: 0.019999999552965164
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: plan
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/PointCloud2
Color: 125; 125; 125
Color Transformer: FlatColor
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 4096
Min Color: 0; 0; 0
Min Intensity: 0
Name: VoxelGrid
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.05000000074505806
Style: Boxes
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: global_costmap/voxel_marked_cloud
Use Fixed Frame: true
Use rainbow: true
Value: true
- Alpha: 1
Class: rviz_default_plugins/Polygon
Color: 25; 255; 0
Enabled: false
Name: Polygon
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: global_costmap/published_footprint
Value: false
Enabled: true
Name: Global Planner
- Class: rviz_common/Group
Displays:
- Alpha: 0.699999988079071
Binary representation: false
Binary threshold: 100
Class: rviz_default_plugins/Map
Color Scheme: costmap
Draw Behind: false
Enabled: true
Name: Local Costmap
Topic:
Depth: 1
Durability Policy: Transient Local
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: local_costmap/costmap
Update Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: local_costmap/costmap_updates
Use Timestamp: false
Value: true
- Alpha: 1
Buffer Length: 1
Class: rviz_default_plugins/Path
Color: 0; 12; 255
Enabled: true
Head Diameter: 0.30000001192092896
Head Length: 0.20000000298023224
Length: 0.30000001192092896
Line Style: Lines
Line Width: 0.029999999329447746
Name: Local Plan
Offset:
X: 0
Y: 0
Z: 0
Pose Color: 255; 85; 255
Pose Style: None
Radius: 0.029999999329447746
Shaft Diameter: 0.10000000149011612
Shaft Length: 0.10000000149011612
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: transformed_global_plan
Value: true
- Class: rviz_default_plugins/MarkerArray
Enabled: false
Name: Trajectories
Namespaces:
{}
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: marker
Value: false
- Alpha: 1
Class: rviz_default_plugins/Polygon
Color: 25; 255; 0
Enabled: true
Name: Polygon
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: local_costmap/published_footprint
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/PointCloud2
Color: 255; 255; 255
Color Transformer: RGB8
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 4096
Min Color: 0; 0; 0
Min Intensity: 0
Name: VoxelGrid
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Flat Squares
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: local_costmap/voxel_marked_cloud
Use Fixed Frame: true
Use rainbow: true
Value: true
Enabled: true
Name: Controller
- Class: rviz_common/Group
Displays:
- Class: rviz_default_plugins/Image
Enabled: true
Max Value: 1
Median window: 5
Min Value: 0
Name: RealsenseCamera
Normalize Range: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: intel_realsense_r200_depth/image_raw
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/PointCloud2
Color: 255; 255; 255
Color Transformer: RGB8
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 4096
Min Color: 0; 0; 0
Min Intensity: 0
Name: RealsenseDepthImage
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Flat Squares
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: intel_realsense_r200_depth/points
Use Fixed Frame: true
Use rainbow: true
Value: true
Enabled: false
Name: Realsense
- Class: rviz_default_plugins/MarkerArray
Enabled: true
Name: MarkerArray
Namespaces:
{}
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: waypoints
Value: true
- Class: rviz_default_plugins/MarkerArray
Enabled: true
Name: MarkerArray
Namespaces:
route_graph: true
route_graph_ids: true
Topic:
Depth: 5
Durability Policy: Transient Local
History Policy: Keep Last
Reliability Policy: Reliable
Value: route_graph
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: map
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/MoveCamera
- Class: rviz_default_plugins/Select
- Class: rviz_default_plugins/FocusCamera
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Covariance x: 0.25
Covariance y: 0.25
Covariance yaw: 0.06853891909122467
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: initialpose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: clicked_point
- Class: nav2_rviz_plugins/GoalTool
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Angle: -0.0008007669821381569
Class: rviz_default_plugins/TopDownOrtho
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Scale: 54
Target Frame: <Fixed Frame>
Value: TopDownOrtho (rviz_default_plugins)
X: -5.409999847412109
Y: 0
Saved: ~
Window Geometry:
Displays:
collapsed: false
Docking:
collapsed: false
Height: 893
Hide Left Dock: false
Hide Right Dock: false
Navigation 2:
collapsed: false
QMainWindow State: 000000ff00000000fd00000004000000000000015600000327fc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb000000100044006900730070006c006100790073010000003b0000015a000000c700fffffffb00000018004e0061007600690067006100740069006f006e00200032010000019b000001c7000001c700fffffffb0000001e005200650061006c00730065006e0073006500430061006d00650072006100000002c6000000c10000002800ffffff000000010000014700000327fc0200000005fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b00000143000000a000fffffffb0000000e0044006f0063006b0069006e006701000001840000011e0000011e00fffffffb0000001000530065006c006500630074006f007201000002a8000000ba000000ba00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000003a10000032700000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
RealsenseCamera:
collapsed: false
Selection:
collapsed: false
Selector:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1610
X: 1091
Y: 222
+20
View File
@@ -0,0 +1,20 @@
# launch/
`ros2 launch sentry_sim sentry_sim.launch.py` 用的启动文件。
**注意**:这是**备用入口**。实际推荐用 `scripts/sentry_up.sh`(单进程树、启动顺序可控),
因为 `ros2 launch` 在这里遇到过跨进程 gz-transport 发现的问题。
## 参数
| 参数 | 默认 | 说明 |
|---|---|---|
| `headless` | `false` | `true` = 无界面 |
| `nav2` | `true` | 是否起 Nav2 |
| `rviz` | `true` | 是否起 RViz |
| `world` | `sentry_arena.sdf` | `worlds/` 下的世界文件名 |
| `map` | 迁移包的栅格图 | Nav2 用的地图 yaml |
```bash
ros2 launch sentry_sim sentry_sim.launch.py headless:=true rviz:=false
```
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env python3
"""哨兵导航仿真一键启动。
拉起内容:
1. Gazebo(系统版 10.6,见 scripts/run_gz.sh)+ RMUL 2027 场地 + 哨兵模型
2. robot_state_publisher(TF:base_link -> wheel_*/lidar_link/gimbal_link/imu_link)
3. ros_gz 桥(/cmd_vel、/odom、/scan、/imu、/clock)
4. odom_tf(补 odom -> base_link,Gazebo 的麦轮插件不发这段 TF)
5. Nav2(AMCL + 栅格图定位)
常用:
ros2 launch sentry_sim sentry_sim.launch.py # 全部(含 GUI/RViz)
ros2 launch sentry_sim sentry_sim.launch.py headless:=true rviz:=false
ros2 launch sentry_sim sentry_sim.launch.py nav2:=false # 只看仿真
"""
import os
from pathlib import Path
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
ExecuteProcess,
TimerAction,
IncludeLaunchDescription,
OpaqueFunction,
SetEnvironmentVariable,
)
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
DEFAULT_FIELD_ROOT = os.environ.get(
'SENTRY_FIELD_ROOT',
str(Path.home() / 'Gazebo_projects' /
'RMUL2027_map_transfer_20261016_STEP_R1'))
DEFAULT_MAP_YAML = os.environ.get(
'SENTRY_MAP_YAML',
str(Path(DEFAULT_FIELD_ROOT) / 'src' / 'guodong_sentry_sim' / 'maps' /
'rmul_2027' / 'rmul_2027.yaml'))
def launch_setup(context, *args, **kwargs):
pkg = Path(get_package_share_directory('sentry_sim'))
nav2_launch = (Path(get_package_share_directory('nav2_bringup')) /
'launch' / 'bringup_launch.py')
headless = LaunchConfiguration('headless').perform(context).lower() in ('true', '1')
nav2 = LaunchConfiguration('nav2').perform(context).lower() in ('true', '1')
rviz = LaunchConfiguration('rviz').perform(context).lower() in ('true', '1')
world = pkg / 'worlds' / LaunchConfiguration('world').perform(context)
map_yaml = LaunchConfiguration('map').perform(context)
if not world.exists():
raise FileNotFoundError(f'找不到世界文件: {world}')
field_models = Path(LaunchConfiguration('field_models').perform(context)) / 'models'
resource_path = f'{pkg / "models"}:{field_models}'
if os.environ.get('GZ_SIM_RESOURCE_PATH'):
resource_path += f':{os.environ["GZ_SIM_RESOURCE_PATH"]}'
gz_args = ['-r', '--force-version', '10']
if headless:
gz_args = ['-s', '--force-version', '10', '-r']
actions = [
SetEnvironmentVariable('GZ_SIM_RESOURCE_PATH', resource_path),
# Gazebo 用系统版:wrapper 会清掉 LD_LIBRARY_PATH(原因见 run_gz.sh 注释)
ExecuteProcess(
cmd=[str(pkg / 'scripts' / 'run_gz.sh'), 'sim'] + gz_args + [str(world)],
name='gazebo',
output='screen',
),
# TF 树(URDF -> TF)
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{
'robot_description': ParameterValue(
Command(['xacro ', str(pkg / 'urdf' / 'sentry.urdf.xacro')]),
value_type=str),
'use_sim_time': True,
}],
),
# Gazebo <-> ROS 桥:等 gz 的 /clock 出现后再订阅(见 scripts/bridge_after_gz.sh)
ExecuteProcess(
cmd=[str(pkg / 'scripts' / 'bridge_after_gz.sh')],
name='ros_gz_bridge',
output='screen',
),
# odom -> base_link(延迟 22s,保证 /odom 已在流)
TimerAction(period=22.0, actions=[Node(
package='sentry_sim',
executable='odom_tf.py',
name='sentry_odom_tf',
output='screen',
parameters=[{'use_sim_time': True}],
)]),
]
if nav2:
nav2_include = IncludeLaunchDescription(
PythonLaunchDescriptionSource(str(nav2_launch)),
launch_arguments={
'map': map_yaml,
'use_sim_time': 'true',
'params_file': str(pkg / 'config' / 'nav2_params.yaml'),
'use_composition': 'False',
'slam': 'False',
}.items(),
)
actions.append(TimerAction(period=35.0, actions=[nav2_include]))
if rviz:
actions.append(
Node(
package='rviz2', executable='rviz2', name='rviz2',
arguments=['-d', str(pkg / 'config' / 'sentry.rviz')],
parameters=[{'use_sim_time': True}],
output='screen',
condition=IfCondition(LaunchConfiguration('rviz')),
)
)
return actions
def generate_launch_description():
return LaunchDescription([
DeclareLaunchArgument('world', default_value='sentry_arena.sdf'),
DeclareLaunchArgument('headless', default_value='false'),
DeclareLaunchArgument('nav2', default_value='true'),
DeclareLaunchArgument('rviz', default_value='true'),
DeclareLaunchArgument('map', default_value=DEFAULT_MAP_YAML),
DeclareLaunchArgument(
'field_models',
default_value=str(Path(DEFAULT_FIELD_ROOT) / 'src' / 'guodong_sentry_sim'),
description='迁移包 guodong_sentry_sim 目录(含 models/)'),
OpaqueFunction(function=launch_setup),
])
+26
View File
@@ -0,0 +1,26 @@
# meshes/
仿真实际使用的网格(**已减面**,2.5 mm 顶点聚类)。
| 文件 | 内容 | 面数 |
|---|---|---|
| `base.stl` | 车体(含云台、MID-360、悬挂等,除 4 个轮子外全部) | 约 25.7 万 |
| `wheel.stl` | 单个麦轮(四个轮子几何相同) | 约 3.1 万 |
| `transform.json` | 旧版(底盘+云台分别导入)的转换参数,仅作参考 |
| `gimbal_transform.json` | 同上,云台那套的转换参数 |
| `full/` | 原始高模 + 装配体实测布局,见其 README |
## 坐标系
已转到 REP-103(X 前、Y 左、Z 上),原点 = 车体几何中心的地面投影。
SW 装配体是 Y 向上:`ROS_x = SW_z`、`ROS_y = SW_x`、`ROS_z = SW_y`;车头 = +SW_z。
## 重新生成
```bash
python3 tools/build_vehicle.py --src "<SW导出目录>" --out src/sentry_sim/meshes/full
python3 tools/decimate.py src/sentry_sim/meshes/full/base.stl src/sentry_sim/meshes/base.stl --grid 0.0025
python3 tools/decimate.py src/sentry_sim/meshes/full/wheel.stl src/sentry_sim/meshes/wheel.stl --grid 0.0025
```
> ⚠️ 不减面的话,250 万面的车体会让 Gazebo 加载超过 150 秒甚至起不来。
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
# meshes/full/
**原始高模 + 装配体实测数据**,不直接给仿真用(仿真用上一层的减面版)。
| 文件 | 说明 |
|---|---|
| `base.stl` | 车体原始网格(约 242 万面,13 MB→90 MB 级别) |
| `wheel.stl` | 轮子原始网格(34.7 万面) |
| `vehicle_layout.json` | **装配体实测布局**:四轮位置、MID-360 位置、车体尺寸、地面高度 |
## vehicle_layout.json 是改 URDF 的依据
```json
{
"size_ros_m": [0.5209, 0.5005, 0.577],
"wheels_ros_m": {
"wheel1": [0.16634, 0.21288, 0.0762],
"wheel2": [0.16553, -0.21352, 0.0762],
"wheel3": [-0.16663, -0.21288, 0.0762],
"wheel4": [-0.16582, 0.21352, 0.0762]
},
"mid360_ros_m": [-0.0935, -0.1512, 0.4052]
}
```
机械重新导出装配体后,跑 `tools/build_vehicle.py` 会刷新这个文件,然后按它对
`urdf/sentry.urdf.xacro` 里的 `<xacro:property>`。
@@ -0,0 +1,50 @@
{
"source_dir": "/run/media/mzxiang/CPBA_X64FRE/装配车",
"origin_sw_mm": [
31386.39,
57.88,
10455.35
],
"ground_sw_y_mm": 57.88,
"size_ros_m": [
0.5209,
0.5005,
0.577
],
"wheels_ros_m": {
"wheel1": [
0.16634,
0.21288,
0.0762
],
"wheel2": [
0.16553,
-0.21352,
0.0762
],
"wheel3": [
-0.16663,
-0.21288,
0.0762
],
"wheel4": [
-0.16582,
0.21352,
0.0762
]
},
"mid360_ros_m": [
-0.0935,
-0.1512,
0.4052
],
"mid360_size_m": [
0.0837,
0.0682,
0.082
],
"yaw_axis_ros_xy_m": [
0.08986,
-0.00017
]
}
@@ -0,0 +1,30 @@
{
"source_dir": "/run/media/mzxiang/CPBA_X64FRE/云台",
"parts_used": 81,
"parts_skipped": [
"装配体 - 弹仓前1-3.STL",
"装配体 - 新哨兵-云台-弹仓底B-1.STL"
],
"triangles": 432346,
"ros_bbox_min_m": [
-0.2893,
-0.1117,
-0.0
],
"ros_bbox_max_m": [
0.1668,
0.1922,
0.3821
],
"ros_bbox_size_m": [
0.4561,
0.304,
0.3821
],
"origin_sw_mm": [
30900.0,
5769.4,
6500.0
],
"note": "云台导出 Y 轴朝下,已翻正(det=+1,无镜像);原点=安装面+yaw轴"
}
+47
View File
@@ -0,0 +1,47 @@
{
"source_dir": "/run/media/mzxiang/CPBA_X64FRE/底盘",
"sw_bbox_min_mm": [
2.6,
49.99,
3.42
],
"sw_bbox_max_mm": [
522.6,
324.88,
634.39
],
"origin_sw_mm": [
262.6,
49.99,
318.91
],
"ros_bbox_size_m": [
0.52,
0.2749,
0.631
],
"wheels_ros_m": {
"wheel_1": [
0.193245,
-0.2132,
0.076673
],
"wheel_2": [
-0.139096,
-0.2132,
0.076196
],
"wheel_3": [
0.193245,
0.2132,
0.076673
],
"wheel_4": [
-0.139096,
0.2132,
0.076196
]
},
"wheel_radius_m": 0.0762,
"note": "ROS_x=SW_z, ROS_y=SW_x, ROS_z=SW_y;单位 mm->m"
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
# models/
Gazebo 模型目录的根,`model://xxx` 就从这里解析。
```
models/sentry/ 哨兵模型(见其 README)
```
## 说明
Gazebo 通过环境变量 `GZ_SIM_RESOURCE_PATH` 找模型,`scripts/sentry_up.sh` 会自动设置:
```bash
export GZ_SIM_RESOURCE_PATH=<包>/models:<迁移包>/src/guodong_sentry_sim/models
```
> ⚠️ 新增模型目录后要确认 `CMakeLists.txt` 的 `install(DIRECTORY ... models ...)`
> 包含它,否则安装后运行时找不到(踩过这个坑)。
+33
View File
@@ -0,0 +1,33 @@
# models/sentry/
哨兵在 Gazebo 里的模型(SDF 格式)。
| 文件 | 说明 |
|---|---|
| `model.config` | 模型元信息(名字、SDF 版本、作者) |
| `model.sdf` | **自动生成,不要手改** |
## 生成方式
`model.sdf` 由 URDF 转换而来:
```bash
source install/setup.bash
./tools/gen_sdf.sh # xacro -> gz sdf -p -> 本目录/model.sdf
```
## 为什么 URDF 和 SDF 要各存一份
- URDF 给 ROS 用(`robot_state_publisher` 发 TF、RViz 显示、改参数都在这里)
- SDF 给 Gazebo 用(世界文件里 `<include><uri>model://sentry</uri>`)
两者必须同步:**改完 URDF 记得重跑 `gen_sdf.sh`**,否则车的样子会不一致。
## 生成时出现的告警
```
XML Element[gz_frame_id] ... not defined in SDF
```
这是 gz 自己的扩展元素(用于给消息指定 frame_id),sdformat 解析时总会提示,
**无害**,不用管。
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<model>
<name>sentry</name>
<version>0.1</version>
<sdf version="1.12">model.sdf</sdf>
<author><name>sentry_nav_dev</name><email>sentry.sim@example.com</email></author>
<description>由 sentry.urdf.xacro 经 `gz sdf -p` 转换的静态模型(Gazebo 用)。</description>
</model>
+391
View File
@@ -0,0 +1,391 @@
<sdf version='1.12'>
<model name='sentry'>
<link name='base_link'>
<inertial>
<pose>-0.0011065088757396451 -0.001789349112426035 0.18260591715976329 0 0 0</pose>
<mass>25.350000000000001</mass>
<inertia>
<ixx>1.108330048903353</ixx>
<ixy>-0.00419096875739645</ixy>
<ixz>0.0062437640236686397</ixz>
<iyy>1.234650669205128</iyy>
<iyz>0.010096867597633129</iyz>
<izz>1.2710893212169621</izz>
</inertia>
</inertial>
<collision name='base_link_fixed_joint_lump__chassis_collision_collision'>
<pose>0 0 0.125 0 0 0</pose>
<geometry>
<box>
<size>0.57799999999999996 0.52100000000000002 0.25</size>
</box>
</geometry>
</collision>
<collision name='base_link_fixed_joint_lump__gimbal_collision_collision_1'>
<pose>0.12 0 0.375 0 0 0</pose>
<geometry>
<box>
<size>0.40000000000000002 0.29999999999999999 0.25</size>
</box>
</geometry>
</collision>
<visual name='base_link_visual'>
<pose>0 0 0 0 0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/mzxiang/Gazebo_projects/sentry_nav_dev/install/sentry_sim/share/sentry_sim/meshes/base.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.187500015 0.187500015 0.212500006 1</diffuse>
<ambient>0.187500015 0.187500015 0.212500006 1</ambient>
</material>
</visual>
<visual name='base_link_fixed_joint_lump__lidar_link_visual_1'>
<pose>-0.0935 -0.1512 0.4052 0 0 0</pose>
<geometry>
<box>
<size>0.084000000000000005 0.068000000000000005 0.082000000000000003</size>
</box>
</geometry>
<material>
<diffuse>0.125 0.3125 0.75000006 1</diffuse>
<ambient>0.125 0.3125 0.75000006 1</ambient>
</material>
</visual>
<sensor name='imu' type='imu'>
<topic>imu</topic>
<update_rate>100</update_rate>
<always_on>true</always_on>
<pose>0 0 0.14999999999999999 0 0 0</pose>
<gz_frame_id>imu_link</gz_frame_id>
<imu/>
</sensor>
<sensor name='lidar' type='lidar'>
<topic>scan</topic>
<update_rate>10</update_rate>
<always_on>true</always_on>
<visualize>true</visualize>
<ray>
<scan>
<horizontal>
<samples>360</samples>
<resolution>1</resolution>
<min_angle>-3.1415926500000002</min_angle>
<max_angle>3.1415926500000002</max_angle>
</horizontal>
<vertical>
<samples>16</samples>
<resolution>1</resolution>
<min_angle>-0.26200000000000001</min_angle>
<max_angle>0.26200000000000001</max_angle>
</vertical>
</scan>
<range>
<min>0.10000000000000001</min>
<max>12</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<mean>0</mean>
<stddev>0.01</stddev>
</noise>
</ray>
<pose>-0.0935 -0.1512 0.4052 0 0 0</pose>
<gz_frame_id>lidar_link</gz_frame_id>
</sensor>
</link>
<joint name='wheel_bl_joint' type='revolute'>
<pose relative_to='base_link'>-0.16582 0.21351999999999999 0.076200000000000004 0 0 0</pose>
<parent>base_link</parent>
<child>wheel_bl</child>
<axis>
<xyz>0 1 0</xyz>
<limit>
<lower>-10000000000000000</lower>
<upper>10000000000000000</upper>
<effort>80</effort>
<velocity>50</velocity>
</limit>
<dynamics>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='wheel_bl'>
<pose relative_to='wheel_bl_joint'>0 0 0 0 0 0</pose>
<inertial>
<pose>0 0 0 0 0 0</pose>
<mass>1.5</mass>
<inertia>
<ixx>0.0028453662500000001</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0043548300000000014</iyy>
<iyz>0</iyz>
<izz>0.0028453662500000001</izz>
</inertia>
</inertial>
<collision name='wheel_bl_collision'>
<pose>0 0 0 1.5708 0 0</pose>
<geometry>
<cylinder>
<length>0.073099999999999998</length>
<radius>0.076200000000000004</radius>
</cylinder>
</geometry>
<surface>
<contact>
<ode/>
</contact>
<friction>
<ode>
<mu>1.2</mu>
<mu2>1.2</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name='wheel_bl_visual'>
<pose>0 0 0 0 0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/mzxiang/Gazebo_projects/sentry_nav_dev/install/sentry_sim/share/sentry_sim/meshes/wheel.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.187500015 0.187500015 0.212500006 1</diffuse>
<ambient>0.187500015 0.187500015 0.212500006 1</ambient>
</material>
</visual>
</link>
<joint name='wheel_br_joint' type='revolute'>
<pose relative_to='base_link'>-0.16663 -0.21288000000000001 0.076200000000000004 0 0 0</pose>
<parent>base_link</parent>
<child>wheel_br</child>
<axis>
<xyz>0 1 0</xyz>
<limit>
<lower>-10000000000000000</lower>
<upper>10000000000000000</upper>
<effort>80</effort>
<velocity>50</velocity>
</limit>
<dynamics>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='wheel_br'>
<pose relative_to='wheel_br_joint'>0 0 0 0 0 0</pose>
<inertial>
<pose>0 0 0 0 0 0</pose>
<mass>1.5</mass>
<inertia>
<ixx>0.0028453662500000001</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0043548300000000014</iyy>
<iyz>0</iyz>
<izz>0.0028453662500000001</izz>
</inertia>
</inertial>
<collision name='wheel_br_collision'>
<pose>0 0 0 1.5708 0 0</pose>
<geometry>
<cylinder>
<length>0.073099999999999998</length>
<radius>0.076200000000000004</radius>
</cylinder>
</geometry>
<surface>
<contact>
<ode/>
</contact>
<friction>
<ode>
<mu>1.2</mu>
<mu2>1.2</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name='wheel_br_visual'>
<pose>0 0 0 0 0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/mzxiang/Gazebo_projects/sentry_nav_dev/install/sentry_sim/share/sentry_sim/meshes/wheel.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.187500015 0.187500015 0.212500006 1</diffuse>
<ambient>0.187500015 0.187500015 0.212500006 1</ambient>
</material>
</visual>
</link>
<joint name='wheel_fl_joint' type='revolute'>
<pose relative_to='base_link'>0.16633999999999999 0.21288000000000001 0.076200000000000004 0 0 0</pose>
<parent>base_link</parent>
<child>wheel_fl</child>
<axis>
<xyz>0 1 0</xyz>
<limit>
<lower>-10000000000000000</lower>
<upper>10000000000000000</upper>
<effort>80</effort>
<velocity>50</velocity>
</limit>
<dynamics>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='wheel_fl'>
<pose relative_to='wheel_fl_joint'>0 0 0 0 0 0</pose>
<inertial>
<pose>0 0 0 0 0 0</pose>
<mass>1.5</mass>
<inertia>
<ixx>0.0028453662500000001</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0043548300000000014</iyy>
<iyz>0</iyz>
<izz>0.0028453662500000001</izz>
</inertia>
</inertial>
<collision name='wheel_fl_collision'>
<pose>0 0 0 1.5708 0 0</pose>
<geometry>
<cylinder>
<length>0.073099999999999998</length>
<radius>0.076200000000000004</radius>
</cylinder>
</geometry>
<surface>
<contact>
<ode/>
</contact>
<friction>
<ode>
<mu>1.2</mu>
<mu2>1.2</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name='wheel_fl_visual'>
<pose>0 0 0 0 0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/mzxiang/Gazebo_projects/sentry_nav_dev/install/sentry_sim/share/sentry_sim/meshes/wheel.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.187500015 0.187500015 0.212500006 1</diffuse>
<ambient>0.187500015 0.187500015 0.212500006 1</ambient>
</material>
</visual>
</link>
<joint name='wheel_fr_joint' type='revolute'>
<pose relative_to='base_link'>0.16553000000000001 -0.21351999999999999 0.076200000000000004 0 0 0</pose>
<parent>base_link</parent>
<child>wheel_fr</child>
<axis>
<xyz>0 1 0</xyz>
<limit>
<lower>-10000000000000000</lower>
<upper>10000000000000000</upper>
<effort>80</effort>
<velocity>50</velocity>
</limit>
<dynamics>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='wheel_fr'>
<pose relative_to='wheel_fr_joint'>0 0 0 0 0 0</pose>
<inertial>
<pose>0 0 0 0 0 0</pose>
<mass>1.5</mass>
<inertia>
<ixx>0.0028453662500000001</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0043548300000000014</iyy>
<iyz>0</iyz>
<izz>0.0028453662500000001</izz>
</inertia>
</inertial>
<collision name='wheel_fr_collision'>
<pose>0 0 0 1.5708 0 0</pose>
<geometry>
<cylinder>
<length>0.073099999999999998</length>
<radius>0.076200000000000004</radius>
</cylinder>
</geometry>
<surface>
<contact>
<ode/>
</contact>
<friction>
<ode>
<mu>1.2</mu>
<mu2>1.2</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name='wheel_fr_visual'>
<pose>0 0 0 0 0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/mzxiang/Gazebo_projects/sentry_nav_dev/install/sentry_sim/share/sentry_sim/meshes/wheel.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.187500015 0.187500015 0.212500006 1</diffuse>
<ambient>0.187500015 0.187500015 0.212500006 1</ambient>
</material>
</visual>
</link>
<plugin name='gz::sim::systems::MecanumDrive' filename='gz-sim-mecanum-drive-system'>
<front_left_joint>wheel_fl_joint</front_left_joint>
<front_right_joint>wheel_fr_joint</front_right_joint>
<back_left_joint>wheel_bl_joint</back_left_joint>
<back_right_joint>wheel_br_joint</back_right_joint>
<wheel_separation>0.4263</wheel_separation>
<wheelbase>0.3323</wheelbase>
<wheel_radius>0.0762</wheel_radius>
<max_linear_velocity>2.0</max_linear_velocity>
<max_angular_velocity>4.0</max_angular_velocity>
<odom_topic>/odom</odom_topic>
<odom_publish_frequency>50</odom_publish_frequency>
<frame_id>odom</frame_id>
</plugin>
<frame name='imu_joint' attached_to='base_link'>
<pose>0 0 0.14999999999999999 0 0 0</pose>
</frame>
<frame name='imu_link' attached_to='imu_joint'>
<pose>0 0 0 0 0 0</pose>
</frame>
<frame name='lidar_joint' attached_to='base_link'>
<pose>-0.0935 -0.1512 0.4052 0 0 0</pose>
</frame>
<frame name='lidar_link' attached_to='lidar_joint'>
<pose>0 0 0 0 0 0</pose>
</frame>
</model>
</sdf>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<model>
<name>test_box</name>
<version>1.0</version>
<sdf version="1.12">model.sdf</sdf>
<author><name>sentry_nav_dev</name><email>sentry.sim@example.com</email></author>
<description>避障测试用的障碍箱(0.5×0.5×0.6 m)</description>
</model>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<sdf version="1.12">
<model name="test_box">
<static>true</static>
<link name="box_link">
<collision name="col"><geometry><box><size>0.5 0.5 0.6</size></box></geometry></collision>
<visual name="vis">
<geometry><box><size>0.5 0.5 0.6</size></box></geometry>
<material><diffuse>0.9 0.35 0.1 1</diffuse></material>
</visual>
</link>
</model>
</sdf>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<package format="3">
<name>sentry_sim</name>
<version>0.1.0</version>
<description>
RMUL 2027 哨兵导航仿真包:SolidWorks 底盘转换出的 URDF(含麦轮/雷达/IMU 插件)
+ RMUL 场地世界 + ros_gz 桥 + Nav2(AMCL 用迁移包栅格图定位)。
</description>
<maintainer email="sentry.sim@example.com">sentry_nav_dev</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>launch</exec_depend>
<exec_depend>launch_ros</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>ros_gz_sim</exec_depend>
<exec_depend>ros_gz_bridge</exec_depend>
<exec_depend>rclpy</exec_depend>
<exec_depend>tf2_ros</exec_depend>
<exec_depend>nav2_bringup</exec_depend>
<exec_depend>rviz2</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
+31
View File
@@ -0,0 +1,31 @@
# scripts/
启动链路的脚本。**主入口是 `sentry_up.sh`**。
| 脚本 | 作用 |
|---|---|
| `sentry_up.sh` | ★ 一键启动:Gazebo → 桥 → TF → odom_tf → map→odom → **map_server** → Nav2 → RViz |
| `run_gz.sh` | 用系统版 Gazebo 启动并清掉 ROS vendor 的 `LD_LIBRARY_PATH` |
| `bridge_after_gz.sh` | 轮询 `/clock`,等 Gazebo 真正就绪后再启动 ros_gz 桥 |
| `odom_tf.py` | 把 `/odom` 广播成 TF `odom -> base_link`(Gazebo 不发这段 TF) |
| `cmd_vel_relay.py` | 把 Nav2 的 `/cmd_vel` 改名转发到 `/model/sentry/cmd_vel` |
| (内联于 `sentry_up.sh`) | `map_server` + `lifecycle_manager`:关掉 AMCL 后 Nav2 不带地图服务,必须单独起 |
| `spawn_robot.sh` | 用 URDF 动态生成实体(当前方案用世界 include,本脚本备用) |
## 为什么这么绕
| 脚本 | 不这么做会怎样 |
|---|---|
| `run_gz.sh` 清库路径 | source 过 ROS 后 `gz` 会指向 vendor 版 10.5,行为不一致 |
| `bridge_after_gz.sh` | 桥先于 gz 话题存在就订阅,实测收不到数据 |
| `odom_tf.py` | Nav2 缺 `odom -> base_link`,直接报 TF 超时 |
| `cmd_vel_relay.py` | 插件话题带模型名前缀,而桥只支持两端同名 → 车不动 |
## 环境变量
| 变量 | 默认 | 说明 |
|---|---|---|
| `HEADLESS` | `0` | `1` = 无界面 |
| `NAV2` / `RVIZ` | `1` | 是否起 Nav2 / RViz |
| `ROS_DOMAIN_ID` | `0` | 两个终端必须一致 |
| `GZ_PARTITION` | `sentry` | 多套仿真并存时隔离用 |
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# 等 Gazebo 真正在发 /clock(世界已加载完)之后,再启动 ros_gz 桥。
#
# 为什么需要:ros_gz_bridge 如果在 gz 话题出现之前就订阅,实测会一直收不到数据
# (gz-transport 的发现不回补)。先轮询 /clock,再 exec 桥。
set -e
TIMEOUT_SECONDS="${BRIDGE_WAIT_TIMEOUT:-180}"
for _ in $(seq 1 "$((TIMEOUT_SECONDS / 2))"); do
if gz topic -l 2>/dev/null | grep -qx '/clock'; then
echo "[bridge_after_gz] Gazebo 已就绪,启动桥"
break
fi
sleep 2
done
echo "[bridge_after_gz] GZ_PARTITION=${GZ_PARTITION:-<unset>} ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-<unset>} RMW=${RMW_IMPLEMENTATION:-<unset>}"
echo "[bridge_after_gz] LD_LIBRARY_PATH=${LD_LIBRARY_PATH:0:80}"
echo "[bridge_after_gz] gz 话题数=$(gz topic -l 2>/dev/null | wc -l)"
exec ros2 run ros_gz_bridge parameter_bridge \
'/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock' \
'/model/sentry/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist' \
'/odom@nav_msgs/msg/Odometry[gz.msgs.Odometry' \
'/scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan' \
'/imu@sensor_msgs/msg/Imu[gz.msgs.IMU' \
'/scan/points@sensor_msgs/msg/PointCloud2[gz.msgs.PointCloudPacked' \
--ros-args -p use_sim_time:=true
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""把 Nav2 的 /cmd_vel 转发到 ros_gz 桥用的 /model/sentry/cmd_vel。
为什么需要:Gazebo 的 MecanumDrive 插件订阅的是「模型名/cmd_vel」(即
/model/sentry/cmd_vel),而 ros_gz_bridge 只支持「两端同名」的桥接,
它无法把 ROS 的 /cmd_vel 映射到 gz 的 /model/sentry/cmd_vel。
所以这里做一次 ROS 侧的改名转发:/cmd_vel -> /model/sentry/cmd_vel,
再由 parameter_bridge 送进 Gazebo。
"""
import rclpy
from geometry_msgs.msg import Twist
from rclpy.node import Node
class CmdVelRelay(Node):
def __init__(self):
super().__init__('cmd_vel_relay')
self.declare_parameter('out_topic', '/model/sentry/cmd_vel')
# Nav2 的实际输出可能是 /cmd_vel_smoothed(速度平滑器)或 /cmd_vel_nav(控制器),
# 取决于 launch 里启用哪些节点,所以这几个都监听,转发到同一个出口。
self.declare_parameter('in_topics', [
'/cmd_vel_smoothed', '/cmd_vel', '/cmd_vel_nav'])
out_topic = self.get_parameter('out_topic').value
in_topics = self.get_parameter('in_topics').value
self.pub = self.create_publisher(Twist, out_topic, 10)
for topic in in_topics:
self.create_subscription(Twist, topic, self.on_twist, 10)
self.get_logger().info(f'cmd_vel_relay: {in_topics} -> {out_topic}')
def on_twist(self, msg: Twist):
self.pub.publish(msg)
def main():
rclpy.init()
node = CmdVelRelay()
try:
rclpy.spin(node)
except KeyboardInterrupt:
pass
finally:
node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""把 Gazebo 的 /odom 广播成 ROS TF:odom -> base_link。
为什么需要:Gazebo 的 MecanumDrive 插件只发 odometry 消息、不发 TF,
而 Nav2 需要完整 TF 树(map -> odom -> base_link)。这个节点补上 odom -> base_link。
同时把 frame_id 归一化:Gazebo 里可能是 sentry/base_link 这种带模型名前缀的写法。
"""
import rclpy
from geometry_msgs.msg import TransformStamped
from nav_msgs.msg import Odometry
from rclpy.node import Node
from tf2_ros import TransformBroadcaster
class OdomTf(Node):
def __init__(self):
super().__init__('sentry_odom_tf')
self.declare_parameter('odom_frame', 'odom')
self.declare_parameter('base_frame', 'base_link')
self.declare_parameter('odom_topic', '/odom')
self.odom_frame = self.get_parameter('odom_frame').value
self.base_frame = self.get_parameter('base_frame').value
topic = self.get_parameter('odom_topic').value
self.br = TransformBroadcaster(self)
self.create_subscription(Odometry, topic, self.on_odom, 10)
self.get_logger().info(
f'odom_tf: 订阅 {topic},广播 {self.odom_frame} -> {self.base_frame}')
def on_odom(self, msg: Odometry):
t = TransformStamped()
t.header.stamp = msg.header.stamp
t.header.frame_id = self.odom_frame
t.child_frame_id = self.base_frame
t.transform.translation.x = msg.pose.pose.position.x
t.transform.translation.y = msg.pose.pose.position.y
t.transform.translation.z = msg.pose.pose.position.z
t.transform.rotation = msg.pose.pose.orientation
self.br.sendTransform(t)
def main():
rclpy.init()
node = OdomTf()
try:
rclpy.spin(node)
except KeyboardInterrupt:
pass
finally:
node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# 用「系统版 Gazebo(10.6)」启动仿真。
#
# 为什么需要这个包装脚本:
# source 过 ROS 2 之后,LD_LIBRARY_PATH 会指向 /opt/ros/lyrical/opt/gz_*_vendor/lib
# (vendor 版 gz-sim 10.5),此时连 /usr/bin/gz 也会加载 vendor 的库,
# 而 vendor 没有 cpu-lidar 系统插件,导致雷达传感器创建失败。
# 所以这里清掉 LD_LIBRARY_PATH,强制用系统 10.6。
#
# 用法:scripts/run_gz.sh sim -r <world.sdf>
set -e
exec env -u LD_LIBRARY_PATH /usr/bin/gz "$@"
+134
View File
@@ -0,0 +1,134 @@
#!/usr/bin/env bash
# 一键启动哨兵仿真 + 桥 + TF + Nav2(单进程树,和你在自己的终端里手敲等价)。
#
# 用法:
# scripts/sentry_up.sh # 开 GUI + RViz(需要显卡)
# HEADLESS=1 scripts/sentry_up.sh # 无界面(服务器/CI)
# NAV2=0 scripts/sentry_up.sh # 只起仿真和桥,不起导航
#
# Ctrl+C 退出会一起收掉所有子进程。
set -e
SELF="$(readlink -f "${BASH_SOURCE[0]}")"
WS="$(cd -- "$(dirname -- "$SELF")/../../.." && pwd)"
# 场地包位置:优先用仓库自带的 field/(git clone 下来就有),找不到才退回本机旧路径。
# 注意这里用 if 而不是 `[ -d ... ] && A=B`:脚本开了 set -e,
# 条件不成立时后一种写法会让整个脚本静默退出。
FIELD_DEFAULT="$HOME/Gazebo_projects/RMUL2027_map_transfer_20261016_STEP_R1"
if [ -d "$WS/field/RMUL2027_map_transfer_20261016_STEP_R1" ]; then
FIELD_DEFAULT="$WS/field/RMUL2027_map_transfer_20261016_STEP_R1"
fi
FIELD_ROOT="${SENTRY_FIELD_ROOT:-$FIELD_DEFAULT}"
MAP_YAML="${SENTRY_MAP_YAML:-${FIELD_ROOT}/src/guodong_sentry_sim/maps/rmul_2027/rmul_2027.yaml}"
HEADLESS="${HEADLESS:-0}"
NAV2="${NAV2:-1}"
RVIZ="${RVIZ:-1}"
source /opt/ros/lyrical/setup.bash
source "${WS}/install/setup.bash"
PKG_SHARE="$(ros2 pkg prefix sentry_sim)/share/sentry_sim"
export GZ_SIM_RESOURCE_PATH="${PKG_SHARE}/models:${FIELD_ROOT}/src/guodong_sentry_sim/models"
export GZ_PARTITION="${GZ_PARTITION:-sentry}"
export ROS_DOMAIN_ID="${ROS_DOMAIN_ID:-0}" # 默认用 0,跟普通终端一致;要隔离时自己设
WORLD="${PKG_SHARE}/worlds/sentry_arena.sdf"
PIDS=()
cleanup() {
echo "[sentry_up] 收尾..."
for p in "${PIDS[@]}"; do kill "$p" 2>/dev/null || true; done
wait 2>/dev/null || true
}
trap cleanup EXIT INT TERM
# ---------- 1. Gazebo(系统版,清掉 ROS vendor 的库路径)----------
GZ_ARGS=(-r --force-version 10)
[ "$HEADLESS" = "1" ] && GZ_ARGS=(-s --force-version 10 -r)
echo "[sentry_up] 启动 Gazebo: ${WORLD}"
env -u LD_LIBRARY_PATH /usr/bin/gz sim "${GZ_ARGS[@]}" "${WORLD}" &
PIDS+=($!)
# ---------- 2. 等 Gazebo 就绪(/clock 出现)----------
echo -n "[sentry_up] 等 Gazebo 就绪"
for _ in $(seq 1 120); do
if gz topic -l 2>/dev/null | grep -qx '/clock'; then break; fi
echo -n "."
sleep 1
done
echo " OK"
# ---------- 3. ros_gz 桥 ----------
echo "[sentry_up] 启动 ros_gz 桥"
ros2 run ros_gz_bridge parameter_bridge \
'/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock' \
'/model/sentry/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist' \
'/odom@nav_msgs/msg/Odometry[gz.msgs.Odometry' \
'/scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan' \
'/imu@sensor_msgs/msg/Imu[gz.msgs.IMU' \
'/scan/points@sensor_msgs/msg/PointCloud2[gz.msgs.PointCloudPacked' \
--ros-args -p use_sim_time:=true &
PIDS+=($!)
# ---------- 4. robot_state_publisher(TF 树)----------
echo "[sentry_up] 启动 robot_state_publisher"
ros2 run robot_state_publisher robot_state_publisher --ros-args \
-p robot_description:="$(xacro "${PKG_SHARE}/urdf/sentry.urdf.xacro")" \
-p use_sim_time:=true &
PIDS+=($!)
# ---------- 5. odom -> base_link ----------
echo "[sentry_up] 启动 odom_tf"
ros2 run sentry_sim odom_tf.py --ros-args -p use_sim_time:=true &
PIDS+=($!)
# ---------- 5.5 /cmd_vel 转发(Nav2 -> ros_gz 桥用的话题名)----------
echo "[sentry_up] 启动 cmd_vel 转发"
ros2 run sentry_sim cmd_vel_relay.py --ros-args -p use_sim_time:=true &
PIDS+=($!)
# ---------- 5.55 点云自滤(剔除车身自身回波,Nav2 避障用)----------
echo "[sentry_up] 启动点云自滤"
ros2 run sentry_nav self_filter --ros-args -p use_sim_time:=true &
PIDS+=($!)
# ---------- 5.6 map->odom 静态变换(仿真用里程计当真值,替代 AMCL)----------
# 出生点在场地 (0.9, 4.0),odom 原点就在出生点,因此 map->odom 是固定平移
echo "[sentry_up] 启动 map->odom 静态变换"
ros2 run tf2_ros static_transform_publisher \
--x 0.9 --y 4.0 --z 0.0 --yaw 0.0 --pitch 0.0 --roll 0.0 \
--frame-id map --child-frame-id odom --ros-args -p use_sim_time:=true &
PIDS+=($!)
# ---------- 5.7 静态地图服务(关掉 AMCL 后 bringup 不再带 map_server,得自己起)----------
# 场地是固定的栅格图,Nav2 的静态层需要它,否则代价地图会退回 100x100 默认尺寸
echo "[sentry_up] 启动 map_server($MAP_YAML)"
ros2 run nav2_map_server map_server --ros-args \
-p yaml_filename:="${MAP_YAML}" -p use_sim_time:=true -p frame_id:=map &
PIDS+=($!)
ros2 run nav2_lifecycle_manager lifecycle_manager --ros-args \
-p node_names:="['map_server']" -p autostart:=true -p bond_timeout:=10.0 &
PIDS+=($!)
# ---------- 6. Nav2 ----------
if [ "$NAV2" = "1" ]; then
echo "[sentry_up] 启动 Nav2(AMCL + 栅格图)"
ros2 launch nav2_bringup bringup_launch.py \
map:="${MAP_YAML}" \
use_sim_time:=true \
params_file:="${PKG_SHARE}/config/nav2_params.yaml" \
use_composition:=True \
use_localization:=False \
slam:=False &
PIDS+=($!)
if [ "$RVIZ" = "1" ] && [ "$HEADLESS" != "1" ]; then
echo "[sentry_up] 启动 RViz"
ros2 run rviz2 rviz2 -d "${PKG_SHARE}/config/sentry.rviz" --ros-args -p use_sim_time:=true &
PIDS+=($!)
fi
fi
echo "[sentry_up] 全部启动完成。发目标点示例:"
echo " ros2 topic pub --once /goal_pose geometry_msgs/msg/PoseStamped \\"
echo " \"{header: {frame_id: map}, pose: {position: {x: 2.0, y: 2.0}, orientation: {w: 1.0}}}\""
wait
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# 等 Gazebo 就绪后,用 URDF 在场地里生成哨兵。
#
# 为什么单独一个脚本:xacro 要先展开成 .urdf 文件,Gazebo 的 create 服务只认文件路径;
# 而且必须等 gz server 起来(launch 里用 TimerAction 延迟调用本脚本)。
set -e
pkg_share="$(ros2 pkg prefix sentry_sim)/share/sentry_sim"
cache_dir="${HOME}/.cache/sentry_sim"
mkdir -p "$cache_dir"
urdf_file="${cache_dir}/sentry_robot.urdf"
echo "[spawn_robot] 展开 xacro -> ${urdf_file}"
xacro "${pkg_share}/urdf/sentry.urdf.xacro" > "$urdf_file"
echo "[spawn_robot] 生成实体(world=rmul_arena, x=${SPAWN_X:-0.9}, y=${SPAWN_Y:-4.0})"
ros2 run ros_gz_sim create \
-name sentry \
-file "$urdf_file" \
-x "${SPAWN_X:-0.9}" \
-y "${SPAWN_Y:-4.0}" \
-z "${SPAWN_Z:-0.02}"
+37
View File
@@ -0,0 +1,37 @@
# urdf/
`sentry.urdf.xacro` —— **整车描述,改参数的唯一入口**。
## 结构
```
base_link(车体 + 云台 + 悬挂 + MID-360 外形,整体刚体)
├── wheel_fl / wheel_fr / wheel_bl / wheel_br revolute 关节,轴 = Y(横向)
├── lidar_link fixed,位置 = MID-360 实测位置
└── imu_link fixed
```
## 参数区(文件顶部)
| 属性 | 当前值 | 来源 |
|---|---|---|
| `wheel_radius` / `wheel_width` | 0.0762 / 0.0731 | 麦轮 Ø152.4 实测 |
| `wheel_front_left` 等四个 | FL(0.166,0.213) FR(0.166,−0.214) BL(−0.166,0.214) BR(−0.167,−0.213) | 装配体实测 |
| `body_l/w/h` | 0.578 / 0.521 / 0.500 | 装配体 bbox |
| `body_mass` / `wheel_mass` | 25.0 / 1.5 kg | ⚠️ **估算,待机械提供** |
| `lidar_x/y/z` | −0.0935 / −0.1512 / 0.4052 | MID-360 实测位置 |
| 雷达垂直视场 | ±15° / 16 线 | ⚠️ **仿真抽象**:真机是 −7°~+52°,照搬会全部打向天空 |
| 碰撞体 | 底盘盒(z 0~0.25)+ 云台盒(z 0.25~0.5) | 不能用一个大盒包住整车,否则雷达射线全打在盒内壁 |
## 约定
- **车头 = +X**(相机/枪口侧),左 = +Y,上 = +Z,原点在车体中心的地面投影
- 云台做成刚体(导航不需要它转)。要做自瞄时再用
`tools/build_vehicle.py --split-gimbal` 拆 yaw/pitch
## 改完必须做
```bash
source install/setup.bash && ./tools/gen_sdf.sh
colcon build --symlink-install --packages-select sentry_sim
```
+236
View File
@@ -0,0 +1,236 @@
<?xml version="1.0"?>
<!--
哨兵整车 URDF —— 由「整车装配体」SolidWorks STL 直接生成(tools/build_vehicle.py)
相比早先分别导入「底盘」「云台」两套文件的版本,这一版的关键改进:
* 所有零件来自同一个装配体坐标系,云台/底盘/轮子的相对位置与真车一致
* 云台作为整车刚体的一部分(导航阶段不需要云台转动)
* 四个轮子位置从装配体量出来,不再靠推测
坐标系:REP-103(X 前、Y 左、Z 上),原点 = 车体几何中心的地面投影。
SW 装配体是 Y 向上:ROS_x = SW_z、ROS_y = SW_x、ROS_z = SW_y。
⚠️ PLACEHOLDER(等机械给真实数据后替换):
- 整车质量 25 kg、质心高度 0.18 m、惯量按长方体估算
- 轮子质量 1.5 kg
- 雷达安装位置(本装配体里没有雷达模型,位置未知)
-->
<robot name="sentry" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- ================= 参数区 ================= -->
<xacro:property name="wheel_radius" value="0.0762"/>
<xacro:property name="wheel_width" value="0.0731"/>
<!-- 四轮位置(ROS,米)—— 整车装配体实测;斜置悬挂,四个位置互不相同 -->
<!-- 前 = +X(相机/枪口侧),左 = +Y -->
<xacro:property name="wheel_front_left" value=" 0.16634 0.21288 0.07620"/>
<xacro:property name="wheel_front_right" value=" 0.16553 -0.21352 0.07620"/>
<xacro:property name="wheel_rear_left" value="-0.16582 0.21352 0.07620"/>
<xacro:property name="wheel_rear_right" value="-0.16663 -0.21288 0.07620"/>
<!-- 车体包络(米):宽 0.6225 × 高 0.5008 × 长 0.8734(含枪管外伸) -->
<xacro:property name="body_l" value="0.578"/> <!-- 车体前后长(装配体实测) -->
<xacro:property name="body_w" value="0.521"/>
<xacro:property name="body_h" value="0.500"/>
<xacro:property name="body_mass" value="25.0"/>
<xacro:property name="wheel_mass" value="1.5"/>
<!-- 雷达 = MID-360 的实际安装位置(装配体实测:ROS xyz=(-0.0935, -0.1512, 0.4052))。
⚠️ 仿真里目前用 2D 单层扫描代替 MID-360(真机是 3D 激光,含竖直方向 7 线);
该高度 0.405 m 略低于场地围挡 0.42 m,射线擦着围挡上沿走,因此避障数据质量一般,
导航阶段用静态地图兜底。等需要 3D 点云时再换 gpu_lidar + vertical 通道。 -->
<xacro:property name="lidar_x" value="-0.0935"/>
<xacro:property name="lidar_y" value="-0.1512"/>
<xacro:property name="lidar_z" value="0.4052"/>
<material name="dark_gray"><color rgba="0.15 0.15 0.17 1"/></material>
<material name="rm_blue"><color rgba="0.10 0.25 0.60 1"/></material>
<!-- ================= 车体(含云台,刚体) ================= -->
<link name="base_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<mesh filename="$(find sentry_sim)/meshes/base.stl"/>
</geometry>
<material name="dark_gray"/>
</visual>
<!-- 碰撞体用两个简化盒:底盘(下半)+ 云台(上半靠前)。
不能用一个大盒子包住整车——MID-360 在 z=0.405,会被包在盒子内部,
雷达射线全打在盒子内壁上(实测距离只有 0.2~0.4 m)。 -->
<collision name="chassis_collision">
<origin xyz="0 0 0.125" rpy="0 0 0"/>
<geometry>
<box size="${body_l} ${body_w} 0.25"/>
</geometry>
</collision>
<collision name="gimbal_collision">
<origin xyz="0.12 0 0.375" rpy="0 0 0"/>
<geometry>
<box size="0.40 0.30 0.25"/>
</geometry>
</collision>
<inertial>
<origin xyz="0 0 0.18" rpy="0 0 0"/>
<mass value="${body_mass}"/>
<inertia
ixx="${body_mass/12*(body_w*body_w + body_h*body_h)}"
ixy="0" ixz="0"
iyy="${body_mass/12*(body_l*body_l + body_h*body_h)}"
iyz="0"
izz="${body_mass/12*(body_l*body_l + body_w*body_w)}"/>
</inertial>
</link>
<!-- ================= 四个麦轮 ================= -->
<xacro:macro name="wheel_link" params="name xyz">
<link name="${name}">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<mesh filename="$(find sentry_sim)/meshes/wheel.stl"/>
</geometry>
<material name="dark_gray"/>
</visual>
<collision>
<!-- 圆柱体绕 Y 轴(横向) -->
<origin xyz="0 0 0" rpy="1.5708 0 0"/>
<geometry>
<cylinder radius="${wheel_radius}" length="${wheel_width}"/>
</geometry>
</collision>
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="${wheel_mass}"/>
<inertia
ixx="${wheel_mass/12*(3*wheel_radius*wheel_radius + wheel_width*wheel_width)}"
ixy="0" ixz="0"
iyy="${wheel_mass*wheel_radius*wheel_radius/2}"
iyz="0"
izz="${wheel_mass/12*(3*wheel_radius*wheel_radius + wheel_width*wheel_width)}"/>
</inertial>
</link>
<joint name="${name}_joint" type="revolute">
<parent link="base_link"/>
<child link="${name}"/>
<origin xyz="${xyz}" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="-1e16" upper="1e16" effort="80" velocity="50"/>
</joint>
</xacro:macro>
<xacro:wheel_link name="wheel_fl" xyz="${wheel_front_left}"/>
<xacro:wheel_link name="wheel_fr" xyz="${wheel_front_right}"/>
<xacro:wheel_link name="wheel_bl" xyz="${wheel_rear_left}"/>
<xacro:wheel_link name="wheel_br" xyz="${wheel_rear_right}"/>
<!-- ================= 雷达 / IMU 安装点 ================= -->
<link name="lidar_link">
<visual>
<geometry>
<box size="0.084 0.068 0.082"/>
</geometry>
<material name="rm_blue"/>
</visual>
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.3"/>
<inertia ixx="0.00012" ixy="0" ixz="0" iyy="0.00012" iyz="0" izz="0.0002"/>
</inertial>
</link>
<joint name="lidar_joint" type="fixed">
<parent link="base_link"/>
<child link="lidar_link"/>
<origin xyz="${lidar_x} ${lidar_y} ${lidar_z}" rpy="0 0 0"/>
</joint>
<link name="imu_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.05"/>
<inertia ixx="1e-5" ixy="0" ixz="0" iyy="1e-5" iyz="0" izz="1e-5"/>
</inertial>
</link>
<joint name="imu_joint" type="fixed">
<parent link="base_link"/>
<child link="imu_link"/>
<origin xyz="0 0 0.15" rpy="0 0 0"/>
</joint>
<!-- ================= Gazebo 扩展 ================= -->
<gazebo reference="wheel_fl"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
<gazebo reference="wheel_fr"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
<gazebo reference="wheel_bl"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
<gazebo reference="wheel_br"><mu1>1.2</mu1><mu2>1.2</mu2></gazebo>
<gazebo>
<plugin filename="gz-sim-mecanum-drive-system" name="gz::sim::systems::MecanumDrive">
<front_left_joint>wheel_fl_joint</front_left_joint>
<front_right_joint>wheel_fr_joint</front_right_joint>
<back_left_joint>wheel_bl_joint</back_left_joint>
<back_right_joint>wheel_br_joint</back_right_joint>
<!-- 斜置悬挂:取前后 / 左右的平均距离 -->
<wheel_separation>0.4263</wheel_separation>
<wheelbase>0.3323</wheelbase>
<wheel_radius>${wheel_radius}</wheel_radius>
<max_linear_velocity>2.0</max_linear_velocity>
<max_angular_velocity>4.0</max_angular_velocity>
<odom_topic>/odom</odom_topic>
<odom_publish_frequency>50</odom_publish_frequency>
<frame_id>odom</frame_id>
</plugin>
</gazebo>
<!-- 2D 激光雷达(PLACEHOLDER:type="lidar" 走 CPU 射线,不依赖 GPU) -->
<gazebo reference="lidar_link">
<sensor name="lidar" type="lidar">
<pose>0 0 0 0 0 0</pose>
<topic>scan</topic>
<gz_frame_id>lidar_link</gz_frame_id>
<update_rate>10</update_rate>
<always_on>true</always_on>
<visualize>true</visualize>
<ray>
<scan>
<horizontal>
<samples>360</samples>
<resolution>1</resolution>
<min_angle>-3.14159265</min_angle>
<max_angle>3.14159265</max_angle>
</horizontal>
<!-- ⚠️ 仿真抽象:真机 MID-360 垂直 FOV 是 -7°~+52°(朝上多、非重复扫描),
直接照搬的话绝大多数射线打向天空,对导航没用。
这里改成对称 ±15°、16 线:中间那层正好水平(/scan 因此可用),
下层能看到地面和围挡底部。需要更接近真机时可把 min/max 改回 -0.122/0.907。 -->
<vertical>
<samples>16</samples>
<resolution>1</resolution>
<min_angle>-0.262</min_angle>
<max_angle>0.262</max_angle>
</vertical>
</scan>
<range>
<min>0.10</min>
<max>12.0</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.01</stddev>
</noise>
</ray>
</sensor>
</gazebo>
<gazebo reference="imu_link">
<sensor name="imu" type="imu">
<topic>imu</topic>
<gz_frame_id>imu_link</gz_frame_id>
<update_rate>100</update_rate>
<always_on>true</always_on>
</sensor>
</gazebo>
</robot>
+19
View File
@@ -0,0 +1,19 @@
# worlds/
| 文件 | 说明 |
|---|---|
| `sentry_arena.sdf` | RMUL 2027 场地 + 哨兵(世界名 `rmul_arena`) |
## 世界内容
- 场地模型 `model://rmul_2027`(来自迁移包 `RMUL2027_map_transfer_20261016_STEP_R1`)
- 哨兵 `model://sentry`,出生点 **场地坐标 (0.9, 4.0)**
- 插件:Physics / UserCommands / SceneBroadcaster / **CpuLidar** / Imu
- 光照、阴影、GUI 相机
## 注意
- 场地模型不在本工程里,需要设置 `GZ_SIM_RESOURCE_PATH` 指向迁移包的 `models` 目录
(`scripts/sentry_up.sh` 自动处理)
- 这个场地**自带**一个 `field_only.sdf`,但那个只有场地没有机器人;本工程用的是自己的世界文件
- 场地围挡高度约 **0.42 m**,这是雷达高度选型的硬约束(详见根目录 README §7)
+62
View File
@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<sdf version="1.12">
<!-- 开发用世界:RMUL 2027 场地 + 哨兵(URDF 由 create 服务生成)
场地模型来自 ~/Gazebo_projects/RMUL2027_map_transfer_20261016_STEP_R1
运行需 GZ_SIM_RESOURCE_PATH 包含:
<迁移包>/src/guodong_sentry_sim/models -->
<world name="rmul_arena">
<physics name="physics" type="ignored">
<max_step_size>0.002</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>
<gravity>0 0 -9.81</gravity>
<plugin filename="gz-sim-physics-system" name="gz::sim::systems::Physics" />
<plugin filename="gz-sim-user-commands-system" name="gz::sim::systems::UserCommands" />
<plugin filename="gz-sim-scene-broadcaster-system" name="gz::sim::systems::SceneBroadcaster" />
<!-- CPU 雷达不依赖渲染,无 GPU 的 headless 环境也能出数据 -->
<plugin filename="gz-sim-cpu-lidar-system" name="gz::sim::systems::CpuLidar" />
<plugin filename="gz-sim-imu-system" name="gz::sim::systems::Imu" />
<scene>
<ambient>0.75 0.75 0.75 1</ambient>
<background>0.16 0.17 0.19 1</background>
<shadows>true</shadows>
</scene>
<light name="sun" type="directional">
<pose>6 4 10 0 0 0</pose>
<direction>-0.3 0.2 -1</direction>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.15 0.15 0.15 1</specular>
<cast_shadows>true</cast_shadows>
</light>
<include>
<uri>model://rmul_2027</uri>
<name>rmul_2027</name>
<pose>0 0 0 0 0 0</pose>
</include>
<!-- 哨兵(模型由 tools/gen_sdf.sh 从 urdf/sentry.urdf.xacro 生成) -->
<include>
<uri>model://sentry</uri>
<name>sentry</name>
<pose>0.9 4.0 0.0 0 0 0</pose>
</include>
<gui fullscreen="false">
<plugin filename="MinimalScene" name="3D View">
<engine>ogre2</engine>
<scene>scene</scene>
<ambient_light>0.75 0.75 0.75</ambient_light>
<background_color>0.16 0.17 0.19</background_color>
<camera_pose>1.6 -2.5 1.8 0 0.35 1.4</camera_pose>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager" />
<plugin filename="InteractiveViewControl" name="Interactive view control" />
<plugin filename="SelectEntities" name="Select Entities" />
<plugin filename="WorldStats" name="World stats" />
</gui>
</world>
</sdf>