feat(minco_ws): 车辆专用 RViz 配置,bringup 支持 launch_rviz:=true

仓库自带的 default.rviz 是上游四旋翼 demo(Fixed Frame world 但话题为
quad_0/cloud、pct_path、pct_tomogram 等),与本车链路完全不匹配,直接用一片空白。

新增:
- rviz/vehicle.rviz:Fixed Frame world;显示 /cloud_registered_for_scan、
  /grid_map/occupancy_inflate、/grid_map/sliding_map_bbox、goal_pose、clicked_point。
- launch/vehicle_rviz.launch.py:单独起 RViz。
- vehicle_bringup 增加 launch_rviz 参数(默认 false),为 true 时一并启动 RViz。
- CMakeLists:补 rviz/vehicle.rviz 的 install 条目(原来只装 launch/ 下那两份)。

⚠️ 关键坑:grid_map 与 step_blocker 的点云都用 SensorDataQoS()(best effort),
而 RViz 的 PointCloud2 默认 Reliable —— 不匹配时**收不到任何消息且不报错**。
配置里已把两个点云的 Reliability Policy 设为 Best Effort。
This commit is contained in:
walunt5
2026-10-25 17:47:45 +08:00
parent b2452b5ea3
commit e2ab7cdf11
4 changed files with 307 additions and 2 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ install(TARGETS
DESTINATION lib/${PROJECT_NAME}) DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY include/ DESTINATION include) install(DIRECTORY include/ DESTINATION include)
install(DIRECTORY launch config DESTINATION share/${PROJECT_NAME} OPTIONAL) install(DIRECTORY launch config DESTINATION share/${PROJECT_NAME} OPTIONAL)
install(FILES launch/default.rviz launch/building.rviz install(FILES launch/default.rviz launch/building.rviz rviz/vehicle.rviz
DESTINATION share/${PROJECT_NAME}/rviz OPTIONAL) DESTINATION share/${PROJECT_NAME}/rviz OPTIONAL)
install(PROGRAMS install(PROGRAMS
scripts/keypoint_recorder.py scripts/keypoint_recorder.py
@@ -71,6 +71,8 @@ def generate_launch_description():
description='是否启动 SCAN(只测 LIO 时可关)'), description='是否启动 SCAN(只测 LIO 时可关)'),
DeclareLaunchArgument('launch_blocker', default_value='true', DeclareLaunchArgument('launch_blocker', default_value='true',
description='是否启动台阶封堵(把台阶从点云里堵死)'), description='是否启动台阶封堵(把台阶从点云里堵死)'),
DeclareLaunchArgument('launch_rviz', default_value='false',
description='同时启动 RViz(用 rviz/vehicle.rviz 车辆专用配置)'),
DeclareLaunchArgument('scan_delay', default_value='5.0', DeclareLaunchArgument('scan_delay', default_value='5.0',
description='等点云/odom 有数据的秒数'), description='等点云/odom 有数据的秒数'),
DeclareLaunchArgument('navi_mode', default_value='1'), DeclareLaunchArgument('navi_mode', default_value='1'),
@@ -177,5 +179,15 @@ def generate_launch_description():
condition=IfCondition(launch_chassis), condition=IfCondition(launch_chassis),
) )
# ---- 6. RViz(可选)-----------------------------------------------------
# 用车辆专用配置 rviz/vehicle.rviz(Fixed Frame world,点云 QoS 已设 Best Effort)。
# 注意:仓库自带的 default.rviz 是上游四旋翼 demo,话题对不上本车链路。
rviz = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
FindPackageShare('scan_planner'), '/launch', '/vehicle_rviz.launch.py',
]),
condition=IfCondition(LaunchConfiguration('launch_rviz')),
)
return LaunchDescription( return LaunchDescription(
declared + [lio, tf_bridge, body_odom_node, blocker, scan, chassis]) declared + [lio, tf_bridge, body_odom_node, blocker, scan, chassis, rviz])
@@ -0,0 +1,40 @@
"""Start RViz2 with the **vehicle** display configuration.
与 `rviz.launch.py`(上游四旋翼 demo 的 default.rviz,Fixed Frame `world` 但话题是
`quad_0/cloud`、`pct_path` 等)不同,本配置针对本车链路:
- Fixed Frame: `world`(与 `grid_map.frame_id` 一致;`camera_init` 之间有恒等 TF)
- `/cloud_registered_for_scan` — step_blocker 输出的点云
- `/grid_map/occupancy_inflate` — 膨胀后的占据栅格(避障测试主要看这个)
- `/grid_map/sliding_map_bbox` — 滑动窗口范围
- `/goal_pose` / `/clicked_point` — 发目标、点选台阶区域
⚠️ 各 PointCloud2 显示的 Reliability Policy 已设为 **Best Effort**。
grid_map 与 step_blocker 都用 `SensorDataQoS()`(best effort),
若改回 RViz 默认的 Reliable,会收不到任何消息且不报错 —— 这是最容易踩的坑。
"""
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
config = os.path.join(get_package_share_directory("scan_planner"), "rviz", "vehicle.rviz")
return LaunchDescription(
[
DeclareLaunchArgument("use_sim_time", default_value="false"),
Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="screen",
arguments=["-d", config],
parameters=[{"use_sim_time": LaunchConfiguration("use_sim_time")}],
),
]
)
@@ -0,0 +1,253 @@
Panels:
- Class: rviz_common/Displays
Help Height: 85
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /TF1
- /TF1/Tree1
- /PointCloud21
- /PointCloud22
Splitter Ratio: 0.5
Tree Height: 515
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Goal Pose1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: PointCloud2
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
- Class: rviz_default_plugins/TF
Enabled: true
Frame Timeout: 15
Frames:
All Enabled: true
base_link:
Value: true
body:
Value: true
camera_init:
Value: true
slambase:
Value: true
sliding_map:
Value: true
world:
Value: true
Marker Scale: 1
Name: TF
Show Arrows: true
Show Axes: true
Show Names: false
Tree:
world:
camera_init:
base_link:
{}
body:
{}
slambase:
{}
sliding_map:
{}
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/PointCloud2
Color: 255; 255; 255
Color Transformer: Intensity
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: PointCloud2
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.05000000074505806
Style: Boxes
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Best Effort
Value: /grid_map/occupancy_inflate
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: Intensity
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: PointCloud2
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Flat Squares
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Best Effort
Value: /cloud_registered_for_scan
Use Fixed Frame: true
Use rainbow: true
Value: true
- Class: rviz_default_plugins/Marker
Enabled: true
Name: Marker
Namespaces:
sliding_map: true
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /grid_map/sliding_map_bbox
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: world
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/Interact
Hide Inactive Objects: true
- 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/SetGoal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /goal_pose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 9.067728996276855
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0
Y: 0
Z: 0
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.9903981685638428
Target Frame: <Fixed Frame>
Value: Orbit (rviz_default_plugins)
Yaw: 1.5953954458236694
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 846
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd0000000400000000000001610000029ffc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006e00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000000470000029f000000f100fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000029ffc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007300000000470000029f000000c200fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b000000040fc0100000002fb0000000800540069006d00650100000000000004b00000038100fffffffb0000000800540069006d00650100000000000004500000000000000000000003480000029f00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1200
X: 848
Y: 139