fix(camera): scope ROS parsing to mipi cam
This commit is contained in:
parent
98a9f55c6b
commit
5c9f511e10
@ -27,3 +27,10 @@
|
||||
- `session_time_epoch_ms` 使用日志首行的 epoch 秒值转换为毫秒;session id 取 ROS 日志路径末段。
|
||||
- `cap capture init failture` 按真实日志拼写匹配,未擅自纠正原始信号。
|
||||
- 工作树对 Vitest 配置临时文件有权限限制,最终验证使用了授权运行;代码与测试未引入额外依赖。
|
||||
|
||||
## Fix round 1:多节点 ROS launch 归因修复
|
||||
|
||||
- 变更:新增多节点 launch 回归测试;`parseRosLaunchLog` 现在仅从 `[mipi_cam-<n>]` 行解析 process started / died、PID、退出码和可执行文件,避免前置节点污染 Camera 信号。
|
||||
- RED:`npm test -- tests/parsers/camera-ros-log.test.ts`;3 tests 中 1 failed,收到 `expected 17000 to be 17201`,证明旧实现错误选取 `image_proc-1`。
|
||||
- GREEN:focused `npm test -- tests/parsers/camera-ros-log.test.ts`;3/3 passed。全量 `npm test`;2 files、9/9 tests passed。`npm run typecheck` 通过。
|
||||
- 审阅结论:修复限定在 Parser 的节点身份过滤,未扩大 Task 1 范围。
|
||||
|
||||
@ -6,6 +6,7 @@ import type {
|
||||
|
||||
const LOG_PATH = /All log files can be found below\s+(\S+)/;
|
||||
const TIMESTAMP = /^(\d+(?:\.\d+)?)/;
|
||||
const MIPI_CAM = /\[mipi_cam-\d+\]/;
|
||||
const STARTED = /process started with pid \[(\d+)\]/;
|
||||
const DIED = /process has died \[pid (\d+), exit code (-?\d+), cmd '([^']+)'\]/;
|
||||
|
||||
@ -14,8 +15,8 @@ export function parseRosLaunchLog(text: string): RosLaunchSignal {
|
||||
const sessionLine = lines.find((line) => LOG_PATH.test(line));
|
||||
const sessionPath = sessionLine?.match(LOG_PATH)?.[1] ?? null;
|
||||
const timestamp = sessionLine?.match(TIMESTAMP)?.[1];
|
||||
const started = lines.find((line) => STARTED.test(line))?.match(STARTED);
|
||||
const died = lines.find((line) => DIED.test(line))?.match(DIED);
|
||||
const started = lines.find((line) => MIPI_CAM.test(line) && STARTED.test(line))?.match(STARTED);
|
||||
const died = lines.find((line) => MIPI_CAM.test(line) && DIED.test(line))?.match(DIED);
|
||||
|
||||
return {
|
||||
session_id: sessionPath?.split("/").pop() ?? null,
|
||||
|
||||
@ -33,4 +33,17 @@ describe("S100 ROS camera log parser", () => {
|
||||
|
||||
expect(correlateCameraRun(launch, { ...camera, process_id: 99999 }).correlated).toBe(false);
|
||||
});
|
||||
|
||||
it("parses the mipi_cam process when another node starts and dies first", () => {
|
||||
const launch = parseRosLaunchLog(`
|
||||
1786701536.4 [INFO] [image_proc-1]: process started with pid [17000]
|
||||
1786701536.5 [ERROR] [image_proc-1]: process has died [pid 17000, exit code 1, cmd '/opt/ros/image_proc'].
|
||||
1786701536.6 [INFO] [mipi_cam-1]: process started with pid [17201]
|
||||
1786701536.7 [ERROR] [mipi_cam-1]: process has died [pid 17201, exit code -6, cmd '/opt/tros/humble/lib/mipi_cam/mipi_cam --ros-args ...'].
|
||||
`);
|
||||
|
||||
expect(launch.process_id).toBe(17201);
|
||||
expect(launch.exit_code).toBe(-6);
|
||||
expect(launch.executable).toBe("/opt/tros/humble/lib/mipi_cam/mipi_cam");
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user