message-path

GitHub

提供 message-path 包深度知识,涵盖 ROS/Foxglove 消息的 DSL 路径语法、nearley 解析、嵌套数据提取及 React 缓存集成,支持 Plot 等面板的数据展示。

.github/skills/message-path/SKILL.md lichtblick-suite/lichtblick

触发场景

询问 message-path 路径语法或组件含义 需要解析 ROS/Foxglove 消息字段并提取数据 排查消息提取性能或 React 缓存问题

安装

npx skills add lichtblick-suite/lichtblick --skill message-path -g -y
更多选项

非标准路径

npx skills add https://github.com/lichtblick-suite/lichtblick/tree/develop/.github/skills/message-path -g -y

不安装直接使用

npx skills use lichtblick-suite/lichtblick@message-path

指定 Agent (Claude Code)

npx skills add lichtblick-suite/lichtblick --skill message-path -a claude-code -g -y

安装 repo 全部 skill

npx skills add lichtblick-suite/lichtblick --all -g -y

预览 repo 内 skill

npx skills add lichtblick-suite/lichtblick --list

SKILL.md

Frontmatter
{
    "name": "message-path",
    "description": "Deep knowledge about the message-path package: path syntax, parsing grammar, data extraction from nested messages, and React hook integration. Shared across Plot, RawMessages, StateTransitions, and general panel agents."
}

Message Path Skill

Overview

The message-path package (packages/message-path/) provides a DSL for addressing fields within ROS/Foxglove messages. It's the foundation for user-defined data extraction in multiple panels.

⚠️ Code is split across two locations: parsing/grammar lives in packages/message-path/src/ (e.g. parseMessagePath.ts), but the data-extraction helpers (simpleGetMessagePathDataItems.ts, useCachedGetMessagePathDataItems.ts) live in packages/suite-base/src/components/MessagePathSyntax/.

Path Syntax

/topic.field.nested_field
/topic.field[:]{value==42}
/topic.field[0]
/topic.field.@length

Components

  • Topic: /topic_name — selects messages from a topic
  • Field access: .field — navigates into message fields
  • Array index: [0], [1] — selects specific array element
  • Array slice: [:] — iterates over all array elements
  • Filter: {field_name==value} — filters array elements by field value
  • Special: .@length — returns array length instead of elements

Parsing

Located in packages/message-path/src/parseMessagePath.ts:

  • Uses nearley grammar for parsing (context-free grammar)
  • Parses path string → MessagePath AST
  • Results are cached (same string → same parsed object)

MessagePath Type

type MessagePath = {
  topicName: string;
  topicNameRepr: string;
  messagePath: MessagePathPart[];
  modifier?: string;
};

type MessagePathPart =
  | { type: "name"; name: string; repr: string }
  | { type: "slice"; start?: number; end?: number }
  | { type: "filter"; path: string[]; value: unknown; repr: string };

Data Extraction

packages/suite-base/src/components/MessagePathSyntax/simpleGetMessagePathDataItems.ts:

function simpleGetMessagePathDataItems(
  messages: MessageEvent[],
  path: MessagePath,
): MessagePathDataItem[];
  • Recursively traverses message objects following the parsed path
  • Handles nested fields, array slicing, filtering
  • Returns { value, path, constantName? } for each extracted datum

Performance Characteristics

  • Recursive traversal — depth depends on path complexity
  • Array slicing with filter can be O(n) per message
  • Used in hot paths (every render frame for Plot panel)
  • Memoization is critical — see React integration below

React Integration

packages/suite-base/src/components/MessagePathSyntax/useCachedGetMessagePathDataItems.ts:

function useCachedGetMessagePathDataItems(paths: string[]): CachedGetMessagePathDataItems;
  • React hook that caches extraction results
  • Uses global variable filling pattern for performance (avoids closure allocations)
  • Results are memoized per (path + message identity) — same messages + same path = cached result
  • Critical for panels displaying multiple paths (Plot with 10+ series)

Usage by Panels

Panel How it uses message-path
Plot Extracts numeric time series from messages for each configured path
RawMessages Navigates to specific fields for display/filtering
StateTransitions Extracts discrete state values for timeline visualization
General panels Any panel using useMessagesByPath or useMessageDataItem

Common Patterns

Panel settings with message paths

// User configures paths in panel settings
config.paths = ["/odom.pose.position.x", "/odom.twist.linear.x"];

Extracting data in a panel

const pathItems = useCachedGetMessagePathDataItems(config.paths);
// Returns extracted values for each path, memoized

Performance Tips

  1. Parse paths once and reuse the MessagePath object (parsing uses nearley, not free)
  2. Use useCachedGetMessagePathDataItems over manual extraction (handles memoization)
  3. Avoid deeply nested paths with array filters on high-frequency topics
  4. Path changes trigger full re-extraction — minimize path reconfiguration during playback

版本历史

  • 6435710 当前 2026-08-16 02:34
  • cab9317 2026-07-24 12:16

同 Skill 集合

.github/skills/3d-rendering/SKILL.md
.github/skills/caching-internals/SKILL.md
.github/skills/deserialization/SKILL.md
.github/skills/e2e-playwright-mcp/SKILL.md
.github/skills/electron-internals/SKILL.md
.github/skills/extensions-internals/SKILL.md
.github/skills/layouts-internals/SKILL.md
.github/skills/mcap-format/SKILL.md
.github/skills/message-pipeline/SKILL.md
.github/skills/panel-extension-api/SKILL.md
.github/skills/panel-image/SKILL.md
.github/skills/panel-log/SKILL.md
.github/skills/panel-map/SKILL.md
.github/skills/panel-raw-messages/SKILL.md
.github/skills/panel-state-transitions/SKILL.md
.github/skills/panel-user-scripts/SKILL.md
.github/skills/performance/SKILL.md
.github/skills/player-internals/SKILL.md
.github/skills/plot-internals/SKILL.md
.github/skills/release-process/SKILL.md
.github/skills/remote-caching/SKILL.md
.github/skills/test-conventions/SKILL.md
.github/skills/theme/SKILL.md
.github/skills/unit-testing/SKILL.md
.github/skills/web-workers/SKILL.md
.github/skills/websocket-connection/SKILL.md

元信息

文件数
0
版本
355014d
Hash
d57fecf8
收录时间
2026-07-24 12:16

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-31 03:18
浙ICP备14020137号-1 $访客地图$