This commit is contained in:
hq 2026-08-13 13:55:34 +08:00
parent f7845219e7
commit a51a61d69e
3 changed files with 21 additions and 3 deletions

View File

@ -24,6 +24,16 @@ colcon build --packages-select ros_viz_adapter --symlink-install
ros2 launch ros_viz_adapter adapter.launch.py
```
点云可视化示例:
```bash
ros2 launch ros_viz_adapter adapter.launch.py \
input_fps_limit:=10 \
output_fps:=5 \
voxel_size_m:=0.10 \
max_points:=50000
```
参数:
```text

View File

@ -7,11 +7,19 @@ from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
DeclareLaunchArgument('output_namespace', default_value='/viz'),
DeclareLaunchArgument('input_fps_limit', default_value='30.0'),
DeclareLaunchArgument('output_fps', default_value='10.0'),
DeclareLaunchArgument('voxel_size_m', default_value='0.05'),
DeclareLaunchArgument('max_points', default_value='100000'),
Node(
package='ros_viz_adapter', executable='adapter',
name='ros_viz_adapter', output='screen',
parameters=[{
'output_namespace': LaunchConfiguration('output_namespace'),
'input_fps_limit': LaunchConfiguration('input_fps_limit'),
'output_fps': LaunchConfiguration('output_fps'),
'voxel_size_m': LaunchConfiguration('voxel_size_m'),
'max_points': LaunchConfiguration('max_points'),
}],
),
])

View File

@ -26,9 +26,9 @@ class Adapter final : public rclcpp::Node {
public:
Adapter() : Node("ros_viz_adapter") {
output_ns_ = declare_parameter<std::string>("output_namespace", "/viz");
input_fps_ = declare_parameter<double>("input_fps_limit", 30.0);
output_fps_ = declare_parameter<double>("output_fps", 10.0);
voxel_ = declare_parameter<double>("voxel_size_m", 0.05);
input_fps_ = std::max(0.0, declare_parameter<double>("input_fps_limit", 30.0));
output_fps_ = std::max(0.0, declare_parameter<double>("output_fps", 10.0));
voxel_ = std::max(0.0, declare_parameter<double>("voxel_size_m", 0.05));
max_points_ = std::max<int>(1, declare_parameter<int>("max_points", 100000));
qos_ = rclcpp::SensorDataQoS().keep_last(1);
discover();