ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

Rerun Blueprints 完全指南:用代码与文件掌控 Viewer 布局与可视化配置

Rerun Blueprints 完全指南:用代码与文件掌控 Viewer 布局与可视化配置 Rerun Blueprints 完全指南用代码与文件掌控 Viewer 布局与可视化配置【免费下载链接】rerunVisualize, query, and stream to train on multimodal robotics data.项目地址: https://gitcode.com/GitHub_Trending/re/rerun导读Blueprints蓝图是 Rerun Viewer 中定义视图布局与可视化默认值的一等公民机制recording 提供你要可视化的数据blueprint 决定数据如何被展示。本文以 Rerun 官方概念文档为核心系统讲解 blueprints 的定位、控制范围、与 Application ID 的绑定关系、两种重置行为、三种使用方式交互式、.rbl文件、编程式并深入源码说明其蓝图即数据的架构与 Viewer 的确定性渲染流程最后给出机器人调试、团队协作、数据模板化与动态 Viewer 配置等实战场景。Blueprints 是什么在 Rerun Viewer 中工作时理解 blueprints 是建立一致性 Viewer 体验的关键。可以这样看待 Rerun Viewrecording提供你正在可视化的实际数据blueprint决定这些数据如何被显示。两者缺一不可。没有 recording就没有内容可显示没有 blueprint就没有办法显示内容。即使你不显式加载任何 blueprintViewer 也会自动为你创建一个。相关概念可参考 recordings 与 entity-component 文档。Blueprints 控制什么Blueprints 赋予你对 Viewer 布局与配置的完全控制权面板可见性蓝图面板Blueprint panel、选择面板Selection panel、时间面板Time panel等面板是展开还是折叠布局结构视图如何通过容器Grid、Horizontal、Vertical、Tabs进行排列视图类型与配置用哪种视图展示数据2D/3D 空间视图、地图、图表、文本日志等及其具体设置视觉属性背景、颜色、缩放级别、时间范围、可视边界等样式。一般而言只要你能通过 Viewer 修改某个外观方面你实际上就在修改 blueprint。在 Python SDK 中这些能力被封装为rerun.blueprint模块。从源码看该模块由 api.py视图、面板、Blueprint 顶层类、containers.pyHorizontal、Vertical、Grid、Tabs四类容器以及views/、components/、archetypes/、visualizers/等子模块组成与文档所述的布局能力一一对应。Application ID将 blueprint 绑定到数据Application ID 是 blueprint 连接数据的钥匙这是一个关键概念所有共享同一个 Application ID 的 recording 将使用同一个 blueprint。这种 blueprint 与 recording 之间的松散耦合意味着你可以保持 blueprint 不变而更换 recording从而以一致的视图比较不同数据集你可以保持 recording 不变而更换 blueprint以不同方式查看同一份数据当你通过 Viewer 保存 blueprint 更改时这些更改将应用到所有具有该 Application ID 的 recording。如果你希望多个 recording 共享同一布局就给它们相同的 Application ID。重置行为启发式与默认Viewer 提供两种 blueprint 重置方式均可从蓝图面板访问重置为启发式 blueprintReset to heuristic blueprint根据当前数据自动生成一个新 blueprint。Viewer 会分析你已记录的内容并使用内置启发式规则创建合适的布局。当你希望从头开始、让 Rerun 自动推断一个合理布局时非常有用。重置为默认 blueprintReset to default blueprint返回你以编程方式指定的 blueprint从代码发送或已保存的 blueprint 文件.rbl。如果你通过rr.send_blueprint()发送过 blueprint或加载过.rbl文件这将成为你的默认。蓝图面板中的重置按钮会在需要时恢复这个默认值。当未设置默认 blueprint 时重置按钮将改用启发式 blueprint。使用 Blueprints 的三种方式1. 交互式Interactively直接在 Viewer UI 中修改 blueprint拖放视图以重新排列使用按钮添加新视图或容器水平、垂直或网格状拆分视图更改容器类型Grid、Horizontal、Vertical、Tabs重命名视图和容器显示、隐藏或移除元素。这是试验布局最快的方式。完整的交互指南见 Configure the Viewer 及其中 navigating-the-viewer 一节。交互操作对应的 UI 细节重置按钮、 添加视图、蓝图树、眼睛图标显隐、- 移除、右键上下文菜单可参考 Blueprint Panel Reference。2. 保存与加载文件.rbl将 blueprint 配置保存为.rbl文件使用文件菜单中的 Save blueprint… 保存当前布局使用 Open… 加载 blueprint或将.rbl文件直接拖入 Viewer与团队成员共享 blueprint 文件确保每个人以相同方式查看数据跨会话、跨不同 recording使用相同 Application ID复用 blueprint。Blueprint 文件是可移植的可以随代码一起进行版本控制。值得一提的是Blueprint类也提供了代码保存能力见 api.py 中的save(application_id, path)方法而加载.rbl则可通过log_file_from_pathAPI 实现Rust、C SDK 也能用此方式加载详见 build-a-blueprint-programmatically。3. 编程式Programmatically编写 blueprint 代码自动配置 Viewer使用rerun.blueprintAPI 在 Python 中定义布局通过rr.send_blueprint()或default_blueprint参数发送 blueprint基于你的数据动态生成布局非常适合为特定调试场景创建一致的视图。例如你可以根据应用中检测到的问题自动发送不同的 blueprint比如机器人进入错误状态时浮现出正确的 blueprint 来帮助你调试import rerun as rr import rerun.blueprint as rrb if robot_error: # Show diagnostic views for debugging blueprint rrb.Grid( rrb.Spatial3DView(nameRobot view, origin/world/robot), rrb.TextLogView(nameError Logs, origin/diagnostics), rrb.TimeSeriesView(nameSensor Data, origin/sensors), ) rr.send_blueprint(blueprint, make_activeTrue)从源码看rr.send_blueprint定义于 sinks.pyRecordingStream上也有同名方法recording_stream.py顶层Blueprint类api.py接受auto_layout、auto_views、collapse_panels等构造参数其中collapse_panelsTrue会完全隐藏蓝图/选择面板并显示简化版时间面板。视图基类View支持origin、contents、visible、defaults、overrides、properties等参数分别控制视图原点、内容查询表达式、可见性、组件默认值与可视化器覆盖详见 api.py。编程式构建 Blueprint 的进阶用法以下内容来自仓库中的 build-a-blueprint-programmatically 教程可作为蓝图 API 的实操延伸。创建简单视图与面板控制# Create a single chart and collapse the selection and time panels: blueprint rrb.Blueprint( rrb.TimeSeriesView(nameAAPL, origin/stocks/AAPL), rrb.BlueprintPanel(stateexpanded), rrb.SelectionPanel(statecollapsed), rrb.TimePanel(statecollapsed), ) rr.send_blueprint(blueprint)origin参数将视图限定到特定的实体子树BlueprintPanel/SelectionPanel/TimePanel的state参数可分别取expanded或collapsed。用容器组合多个视图Vertical容器纵向堆叠视图row_shares控制相对尺寸blueprint rrb.Blueprint( rrb.Vertical( rrb.TextDocumentView(nameInfo, origin/stocks/AAPL/info), rrb.TimeSeriesView(nameChart, origin/stocks/AAPL), row_shares[1, 4], ), rrb.BlueprintPanel(stateexpanded), rrb.SelectionPanel(statecollapsed), rrb.TimePanel(statecollapsed), ) rr.send_blueprint(blueprint)用 contents 表达式精确指定视图内容contents参数支持从多个数据源取数并可用$origin与/**通配符包含/排除子树# Create a chart for AAPL and filter out the peaks: blueprint rrb.Blueprint( rrb.TimeSeriesView( nameAAPL, origin/stocks/AAPL, contents[ $origin/**, - $origin/peaks/**, ], ), rrb.BlueprintPanel(stateexpanded), rrb.SelectionPanel(statecollapsed), rrb.TimePanel(statecollapsed), ) rr.send_blueprint(blueprint)内容表达式语法详见 entity-queries。动态生成布局由于 blueprint 本质是 Python 代码可以基于运行时数据动态生成# Iterate over all symbols and days to create a comprehensive grid blueprint rrb.Blueprint( rrb.Vertical( contents[ rrb.Horizontal( contents[ rrb.TextDocumentView( namef{symbol}, originf/stocks/{symbol}/info, ), ] [ rrb.TimeSeriesView( namef{day}, originf/stocks/{symbol}/{day}, ) for day in dates ], namesymbol, ) for symbol in symbols ] ), rrb.BlueprintPanel(stateexpanded), rrb.SelectionPanel(statecollapsed), rrb.TimePanel(statecollapsed), ) rr.send_blueprint(blueprint)高级视图定制Blueprint 支持对视图属性进行深度定制例如 3D 视图的相机与时间序列视图的坐标轴# Configure a 3D view with custom camera settings rrb.Spatial3DView( nameRobot view, origin/world/robot, background[100, 149, 237], # Light blue eye_controlsrrb.EyeControls3D( kindrrb.Eye3DKind.FirstPerson, speed20.0, ), ) # Configure a time series view with custom axis and time ranges rrb.TimeSeriesView( nameSensor Data, origin/sensors, axis_yrrb.ScalarAxis(range(-10.0, 10.0), zoom_lockTrue), plot_legendrrb.PlotLegend(visibleFalse), time_ranges[ rrb.VisibleTimeRange( time, startrrb.TimeRangeBoundary.cursor_relative(seq-100), endrrb.TimeRangeBoundary.cursor_relative(), ), ], )常见使用场景调试特定场景创建针对特定问题诊断而优化的 blueprint。例如调试机器人感知时你可能想要一个同时展示以下内容的 blueprint2D 相机视图带检测物体的 3D 世界时间序列图中的检测置信度分数文本面板中的错误日志。与团队共享布局保存一个 blueprint 文件并与团队共享。任何加载该 blueprint 并匹配 recording 的人都会以相同方式看到数据从而更容易讨论发现与协作。相关概念可参考 customize-views 中的组件映射component mappings与覆盖overrides机制——blueprint 中的每个视图都可以按实体覆盖组件值例如强制为/trig/sin额外启用SeriesPoints可视化器。为不同数据类型做模板化为不同类型的 recording 创建不同的 blueprint 模板。例如为自动驾驶数据设计强调地图视图与传感器融合的 blueprint为机器人操作数据设计突出关节角与机械臂相机画面的 blueprint为计算机视觉数据设计并排对比不同模型的 blueprint。动态 Viewer 配置基于运行时条件以编程方式生成 blueprint。例如为每个检测到的异常自动创建一个视图或根据激活的数据源数量调整布局。Blueprint 架构蓝图即数据在底层blueprints 只是数据。它们使用与 recording 相同的 Entity Component System 进行结构化但使用 blueprint 专属的 archetypes 和独立的 blueprint timeline。这一架构带来多个优势你在 Viewer 中修改的任何内容都可以保存并共享为 blueprint 文件Blueprint 可以仅使用 Rerun SDK 以编程方式生成无需依赖 ViewerBlueprint 数据具有完全的表达力支持与记录数据同等强大的 blueprint overrides完整的时间序列特性简化了快照、撤销/重做等未来功能Rerun 数据的调试工具可以像检查 recording 数据一样检查 blueprint 状态。从仓库源码可以印证这一点Rust SDK 中 blueprint 的原语定义位于 crates/store/re_sdk_types/src/blueprint其中包含container_blueprint、view_blueprint、viewport_blueprint、panel_blueprint、background、eye_controls3d、scalar_axis、plot_legend、map_background、map_zoom等大量 blueprint 专属 archetypes以及 Python 侧对应的rerun.blueprint.archetypes模块。这些 archetype 与 recording 数据共用同一套 ECS 数据模型只是带有blueprint 命名空间与独立的 blueprint timeline。Viewer 的确定性操作Viewer 被设计为确定性的。每一帧Viewer 执行以下步骤取当前激活的 blueprint 与激活的 recording从 blueprint 中查询容器与视图 archetypes基于当前 blueprint timeline 的 revision使用这些视图规范从 recording 查询所需数据渲染结果将任何用户交互作为新的 blueprint 事件排队到 blueprint timeline 上。这意味着Viewer 的输出是 blueprint 与 recording 的确定性函数帧与帧之间只保留极少的持久化状态。下一步学习使用 blueprints参见 Configure the Viewer 的动手教程覆盖交互式、文件与编程式工作流理解 UI查阅 Blueprint Panel Reference 了解 UI 控件的细节定制可视化学习 Visualizers and Overrides掌握按实体进行高级定制编程式构建参考 build-a-blueprint-programmatically 中的股票数据完整示例含style_plot、style_peak等样式辅助函数与rr.init(rerun_example_blueprint_stocks, spawnTrue)的完整可运行脚本以及 navigating-the-viewer 中的编程式 blueprint 示例探索 API浏览 Pythonrerun.blueprint模块源码api.py、containers.py、views获取编程控制的完整接口清单。【免费下载链接】rerunVisualize, query, and stream to train on multimodal robotics data.项目地址: https://gitcode.com/GitHub_Trending/re/rerun创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表