Backend registry: single name → constructor dispatch
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Part of #886. Groundwork for the new backends; each backend issue is blocked by this one.
Problem
Backend selection is spread over several places:
backends.load_backend(): anif/elifover "swift", "pyplot", "pyplot2"BaseRobot._get_graphical_backend(): aLiteralof the same names, anisinstancechain to pick a default, a Pyodide special case, and Swift-specific fallback logicBaseRobot.plot():type(env).__name__ == "Swift"andisinstance(env, PyPlot)checks
Adding a backend means editing all of these. Also, default_backend isn't lowercased, so robot.default_backend = "Swift" fails with ValueError at plot time.
Proposal
- One registry in
roboticstoolbox.backends, mapping name → target, e.g."swift": "roboticstoolbox.backends.swift:Swift". Built-in backends are entries here. load_backend(name)looks the name up (case-insensitive). A string target is imported only when chosen. An unknown name gives an error listing the registered names. A missing optional package givesModuleNotFoundErrornaming the pip extra.register_backend(name, target, *, replace=False), public:targetis a lazy"module:Class"string, or a callable returning aConnector- registering an existing name raises unless
replace=True - registration is per process (call it before
plot()); entry-point discovery may come later - lets a backend be developed, tested and used outside the RTB tree, e.g.
register_backend("isaacsim", "rtb_isaacsim:IsaacSim"); once accepted into RTB, that call becomes a registry entry - backends that can't live in RTB (licence, GPU) can stay as separate packages
- Default choice stays in
_get_graphical_backend, but works only with names: explicit argument → robot/class default → robot kind → "pyplot". Defaults by robot kind pick only built-ins; a registered backend is used when named or set withset_default_backend(). Normalise case at every entry point. - Capability flags replace type checks. Add flags to
Connector, and usegetattr(env, flag, default)inplot():embeds_in_notebookreplaces__name__ == "Swift"supports_moviereplacesisinstance(env, PyPlot)- existing:
supports_teach,supports_ellipse
- Type hints. The
backendargument becomesstr, validated at runtime against the registry, so the names live in one place and registered names are valid too.
Out of scope
- Changing the
Connectorprotocol itself (#676) - Third-party discovery via entry points
Tests
- Lookup: case-insensitivity, unknown-name error, missing-package error
register_backendwith a string target and a callable target, the duplicate-name error, andreplace=True, all using a fake backend- Default resolution for each robot kind and for Pyodide
- Capability flags read with the right defaults
- The mocked Swift tests use
register_backendand no longer need a class namedSwift
Done when
- Adding a backend is one registry entry plus the backend module
- No
__name__or backendisinstancechecks remain inBaseRobot - Existing tests pass, including the Swift ones
- The docs list the registered backends and their flags, and show
register_backendusage
- 主要语言
- C++
- 星标
- 3.6k
- 派生
- 645
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 145
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
petercorke/robotics-toolbox-python 的其他 Issue
-
plt.pause(0) waits for ever: PoseGraph.plot_scan(pause=0) and Vehicle animation may hang可能已有人在做 @huxiaoyi-ovo 于 1 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
petercorke/robotics-toolbox-python#876 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
petercorke/robotics-toolbox-python#709 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
petercorke/robotics-toolbox-python#903 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
tech-debt
难度 4/5 1-2 天 新手友好度 55/100
petercorke/robotics-toolbox-python#898 ·
维护者通常 1 天内回复
-
LatticePlanner: integer headings, and motion primitives with finer turn steps (design first)可能已有人在做 @kVinsom 于 4 天前认领。 未关闭enhancement help wanted
难度 5/5 一周以上 新手友好度 25/100
petercorke/robotics-toolbox-python#895 · 2 条评论 ·
维护者通常 1 天内回复
查看 petercorke/robotics-toolbox-python 的全部 Issue
相似的 Issue
-
bug intrinsic medium priority rt_lib
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
OpenPrinting/splix#33 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
sumatrapdfreader/sumatrapdf#6417 · 3 条评论 ·
-
[BUG] Cython cache evicts most recent instead of oldest entry on cleanup可能已有人在做 @scoder 今天认领。 未关闭Build System defect
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100