问题根因:标定文件字段名称不匹配
从对话历史和社区案例 34849 看,StereoNet v2.4 的 custom 模式对 YAML 字段名称非常敏感,你的标定文件使用了错误的字段名导致节点崩溃。
最终解决方案
步骤 1:创建正确格式的标定文件
# 1. 备份原文件
cp /opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml \
/opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml.bak
# 2. 创建符合 StereoNet v2.4 要求的标定文件
cat > /opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml << 'EOF'
%YAML:1.0
image_width: 1280
image_height: 1088
left_camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [528.6953213954334, 0.0, 621.6598968327049,
0.0, 469.7443489102585, 344.7801912987854,
0.0, 0.0, 1.0]
left_distortion_coefficients: !!opencv-matrix
rows: 1
cols: 8
dt: d
data: [-0.19022404784416216, 0.08737900971037368, -0.00013633102684873613,
2.8387028454768084e-05, 0.037123187744979025, 0.1798687498557986,
-0.06820294642386052, 0.10684527621059339]
right_camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [529.2760196145524, 0.0, 654.6320151265384,
0.0, 470.4236596788936, 318.0571160826385,
0.0, 0.0, 1.0]
right_distortion_coefficients: !!opencv-matrix
rows: 1
cols: 8
dt: d
data: [-0.08168737119014227, 0.051348177058130356, 0.00010479656330654928,
-8.819143676712554e-06, 0.024544736926599094, 0.28711736495579887,
-0.06268635878956813, 0.07182651571052037]
R: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [0.9999771405493721, -0.0008865181729254466, -0.006703168223329922,
0.000844157865516232, 0.9999796745904039, -0.006319636347751682,
0.006708634451158759, 0.006313833352156998, 0.9999575639656925]
T: !!opencv-matrix
rows: 3
cols: 1
dt: d
data: [-0.06981825961809152, -0.00031854332254735906, -3.61077528349911e-05]
baseline: 0.06981825961809152
EOF
步骤 2:确认 run_stereo.sh 配置
vim /userdata/data/test/run_stereo.sh
确保以下配置:
use_mipi_cam=False
calib_method="custom"
stereo_calib_file_path="/opt/tros/humble/lib/mipi_cam/config/SC132gs_dual_calibration.yaml"
render_type="distance"
步骤 3:清理进程并重新运行
# 1. 清理所有残留进程
killall mipi_cam stereonet_model_node hobot_codec_republish websocket 2>/dev/null
sleep 3
# 2. 启动相机节点
bash run_cam.sh --rotation 90.0 --log_level INFO &
# 3. 等待 5 秒后启动 StereoNet
sleep 5
cd /userdata/data/test/
bash run_stereo.sh --stereonet_version v2.4 2>&1 | tee stereo_final.log
步骤 4:验证深度输出
# 新开终端检查
ros2 topic list | grep -E "depth|stereo"
ros2 topic hz /StereoNetNode/stereonet_depth
预期输出:
/StereoNetNode/stereonet_depth
/StereoNetNode/stereonet_pointcloud2
/StereoNetNode/rectify_left_image
/StereoNetNode/rectify_right_image
字段名称对照表(关键!)
camera_matrix_1 |
left_camera_matrix |
camera_matrix_2 |
right_camera_matrix |
distortion_1 |
left_distortion_coefficients |
distortion_2 |
right_distortion_coefficients |
rectification_1/2 |
(可选,可省略) |
projection_1/2 |
(可选,可省略) |
R |
R |
T |
T |
baseline |
baseline |
如果仍有问题
# 1. 查看 StereoNet 初始化日志
grep -A50 "init StereoNetNode" stereo_final.log
# 2. 检查标定文件加载
grep -i "calib\|baseline\|custom\|left_camera" stereo_final.log | tail -20
# 3. 检查崩溃原因
grep -E "ERROR|died|segmentation" stereo_final.log | tail -20
把以上输出补充到帖子,可以精准定位问题!
相关参考
- 自定义标定:RDK X5 + SC230ai 双目运行 run_stereo.sh 必现 exit code -11 - 同类问题完整讨论
- 132GS MIPI 双目相机如何自行标定 - 标定文件格式详解
核心修复点:字段名称必须用 left_camera_matrix/right_camera_matrix 和 left_distortion_coefficients/right_distortion_coefficients,这是 StereoNet v2.4 的硬性要求!
执行后把 ros2 topic hz /StereoNetNode/stereonet_depth 的输出贴出来,应该就能看到深度数据了!