Files
OrbbecSDK_ROS2/zh/_sources/source/6_benchmark/benchmark_usage.md.txt
T

116 lines
3.2 KiB
Plaintext
Raw Normal View History

2025-10-22 03:11:03 +00:00
# 性能基准测试使用
2025-09-25 13:04:20 +00:00
2025-10-22 03:11:03 +00:00
本节介绍如何在 C++ 和 Python 中使用性能基准测试工具,并提供示例 YAML 配置文件。
2025-09-25 13:04:20 +00:00
2025-10-22 03:11:03 +00:00
## 使用通用基准测试节点
2025-09-25 13:04:20 +00:00
```
ros2 run orbbec_camera common_benchmark_node.py \
2025-10-22 03:11:03 +00:00
--run_time 2h \
--csv_file /path/to/log.csv
2025-09-25 13:04:20 +00:00
```
2025-10-22 03:11:03 +00:00
* **参数**
* **--run_time**:监控持续时间,指定为时间字符串,如 `"10s"`、`"5m"`、`"1h"`、`"2d"`。默认为 10 秒。
* **--csv_file**:输出 CSV 文件的路径。默认情况下,它保存在工作空间目录中,名称为 "camera_monitor_log.csv"。
2025-09-25 13:04:20 +00:00
2025-10-22 03:11:03 +00:00
## 使用服务基准测试节点
2025-09-25 13:04:20 +00:00
### ROS2 C++
2025-10-22 03:11:03 +00:00
* **单个服务基准测试**
2025-09-25 13:04:20 +00:00
```
ros2 run orbbec_camera service_benchmark_node \
2025-10-22 03:11:03 +00:00
--ros-args \
-p service_name:=/camera/get_depth_gain \
-p service_type:=orbbec_camera_msgs/srv/GetInt32 \
-p count:=10
2025-09-25 13:04:20 +00:00
```
2025-10-22 03:11:03 +00:00
* **多个服务基准测试(YAML 配置)**
2025-09-25 13:04:20 +00:00
```
ros2 run orbbec_camera service_benchmark_node \
2025-10-22 03:11:03 +00:00
--ros-args \
-p yaml_file:=/path/to/default_service_cpp.yaml
2025-09-25 13:04:20 +00:00
```
### ROS2 Python
2025-10-22 03:11:03 +00:00
* **单个服务基准测试**
2025-09-25 13:04:20 +00:00
```
ros2 run orbbec_camera service_benchmark_node.py --service /camera/get_depth_gain --count 10
```
2025-10-22 03:11:03 +00:00
* **多个服务基准测试(YAML 配置)**
2025-09-25 13:04:20 +00:00
```
ros2 run orbbec_camera service_benchmark_node.py --yaml_file /path/to/default_service.yaml
```
2025-10-22 03:11:03 +00:00
### **示例 YAML 配置**
2025-09-25 13:04:20 +00:00
2025-10-22 03:11:03 +00:00
我们提供了一个示例 YAML 配置,位于 `scripts` 目录中,名为 `service_default.yaml`。
2025-09-25 13:04:20 +00:00
```yaml
default_count: 50
services:
- name: /camera/get_auto_white_balance
type: orbbec_camera_msgs/srv/GetInt32
- name: /camera/get_color_exposure
type: orbbec_camera_msgs/srv/GetInt32
- name: /camera/get_color_gain
type: orbbec_camera_msgs/srv/GetInt32
- name: /camera/get_depth_exposure
type: orbbec_camera_msgs/srv/GetInt32
- name: /camera/get_depth_gain
type: orbbec_camera_msgs/srv/GetInt32
- name: /camera/get_device_info
type: orbbec_camera_msgs/srv/GetDeviceInfo
- name: /camera/send_software_trigger
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_auto_white_balance
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_color_ae_roi
type: orbbec_camera_msgs/srv/SetArrays
request: {data_param: [0,1279,0,719]}
- name: /camera/set_color_auto_exposure
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_color_exposure
type: orbbec_camera_msgs/srv/SetInt32
request: {data: 30}
- name: /camera/set_color_flip
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_color_gain
type: orbbec_camera_msgs/srv/SetInt32
request: {data: 20}
- name: /camera/set_color_mirror
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_color_rotation
type: orbbec_camera_msgs/srv/SetInt32
request: {data: 90}
- name: /camera/set_depth_ae_roi
type: orbbec_camera_msgs/srv/SetArrays
request: {data_param: [0,1279,0,719]}
- name: /camera/set_depth_auto_exposure
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_depth_exposure
type: orbbec_camera_msgs/srv/SetInt32
request: {data: 3000}
- name: /camera/set_depth_flip
type: std_srvs/srv/SetBool
request: {data: false}
- name: /camera/set_depth_gain
type: orbbec_camera_msgs/srv/SetInt32
request: {data: 200}
```