Pose registry files๏
Read and atomically replace YAML registries of six-joint poses.
mtc_gui.pose_io ยท Source
Operator GUI ยท Guide ยท Symbol index
How it is used๏
Use read_poses() and write_poses() for registry files without creating Qt widgets. PosesPanel uses these functions for its load, save, and delete operations. Pose angles are in degrees. Reading retains six-element lists but does not validate their numeric values or joint limits.
Writing replaces the whole registry through a temporary file in the same directory. It removes YAML comments and does not lock out other writers; merge changes with the latest file before saving.
Start here๏
Callable |
Purpose |
|---|---|
Read a YAML pose registry, retaining only entries with six-element lists. |
|
Write the complete pose registry and atomically replace the destination file. |
Example๏
# Requires PyYAML; no Qt, ROS, or hardware. Writes only inside a temporary directory.
from pathlib import Path
from tempfile import TemporaryDirectory
from mtc_gui.pose_io import read_poses, write_poses
with TemporaryDirectory() as directory:
path = Path(directory) / "poses.yaml"
write_poses(path, {"inspection": [0, -90, 90, -90, -90, 0]})
assert read_poses(path)["inspection"] == [0, -90, 90, -90, -90, 0]
Functions๏
read_poses()๏
Read a YAML pose registry, retaining only entries with six-element lists.
Entry point ยท Source
read_poses(path)
Parameter |
Meaning |
|---|---|
|
Registry filesystem path; false or nonexistent paths are treated as an empty registry. |
Returns: A new mapping containing retained name-to-list entries, or {} for missing paths and nonmapping YAML roots. Names and list element types are unchanged.
Errors: File-open, YAML parse, and invalid-path errors propagate; no numeric or joint-limit validation occurs.
Side effects: Reads the YAML file when it exists.
Referenced in source (3)
PosesPanel.delete_poseโ mtc_gui.poses_panelPosesPanel.load_from_fileโ mtc_gui.poses_panelPosesPanel.save_poseโ mtc_gui.poses_panel
write_poses()๏
Write the complete pose registry and atomically replace the destination file.
Entry point ยท Source
write_poses(path, poses)
Parameter |
Meaning |
|---|---|
|
Destination YAML path; its resolved parent directory is created if necessary. |
|
Object to serialize, normally a mapping from pose name to six joint angles in degrees; not validated here. |
Returns: None.
Errors: On any BaseException inside serialization/replacement, removes the temporary file if it still exists and re-raises. Parent-directory creation and temporary-file creation failures also propagate.
Side effects: Creates parent directories and a same-directory temporary file, replaces the destination, and does not preserve YAML comments.
Referenced in source (2)
PosesPanel.delete_poseโ mtc_gui.poses_panelPosesPanel.save_poseโ mtc_gui.poses_panel