diff --git a/minco_ws/src/scan/plan_manage/CMakeLists.txt b/minco_ws/src/scan/plan_manage/CMakeLists.txt index 49bfa2a..4434d28 100644 --- a/minco_ws/src/scan/plan_manage/CMakeLists.txt +++ b/minco_ws/src/scan/plan_manage/CMakeLists.txt @@ -52,7 +52,7 @@ install(TARGETS DESTINATION lib/${PROJECT_NAME}) install(DIRECTORY include/ DESTINATION include) 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) install(PROGRAMS scripts/keypoint_recorder.py diff --git a/minco_ws/src/scan/plan_manage/launch/vehicle_bringup.launch.py b/minco_ws/src/scan/plan_manage/launch/vehicle_bringup.launch.py index 75e0385..3144b6c 100644 --- a/minco_ws/src/scan/plan_manage/launch/vehicle_bringup.launch.py +++ b/minco_ws/src/scan/plan_manage/launch/vehicle_bringup.launch.py @@ -71,6 +71,8 @@ def generate_launch_description(): description='是否启动 SCAN(只测 LIO 时可关)'), DeclareLaunchArgument('launch_blocker', default_value='true', description='是否启动台阶封堵(把台阶从点云里堵死)'), + DeclareLaunchArgument('launch_rviz', default_value='false', + description='同时启动 RViz(用 rviz/vehicle.rviz 车辆专用配置)'), DeclareLaunchArgument('scan_delay', default_value='5.0', description='等点云/odom 有数据的秒数'), DeclareLaunchArgument('navi_mode', default_value='1'), @@ -177,5 +179,15 @@ def generate_launch_description(): 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( - declared + [lio, tf_bridge, body_odom_node, blocker, scan, chassis]) + declared + [lio, tf_bridge, body_odom_node, blocker, scan, chassis, rviz]) diff --git a/minco_ws/src/scan/plan_manage/launch/vehicle_rviz.launch.py b/minco_ws/src/scan/plan_manage/launch/vehicle_rviz.launch.py new file mode 100644 index 0000000..d99a383 --- /dev/null +++ b/minco_ws/src/scan/plan_manage/launch/vehicle_rviz.launch.py @@ -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")}], + ), + ] + ) diff --git a/minco_ws/src/scan/plan_manage/rviz/vehicle.rviz b/minco_ws/src/scan/plan_manage/rviz/vehicle.rviz new file mode 100644 index 0000000..6dc86ee --- /dev/null +++ b/minco_ws/src/scan/plan_manage/rviz/vehicle.rviz @@ -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: + 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: + 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