Skip to content

[MSD-548][fix] posture manager TFS3: bring back option to use old choreography#3449

Merged
pieleric merged 1 commit into
delmic:masterfrom
pieleric:fix-posture-manager-tfs3-bring-back-option-to-use-old-choreography
Apr 24, 2026
Merged

[MSD-548][fix] posture manager TFS3: bring back option to use old choreography#3449
pieleric merged 1 commit into
delmic:masterfrom
pieleric:fix-posture-manager-tfs3-bring-back-option-to-use-old-choreography

Conversation

@pieleric
Copy link
Copy Markdown
Member

Some SEMs don't like going to a little low Z before moving. So, to keep
compatibility with the current systems, revert to use the old, more direct, choreography by
default.
The new choreograph can be activated by adding explicitly a z_low
in the CALIB of the TFSv3 stage-bare metadata.

Copilot AI review requested due to automatic review settings April 20, 2026 16:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the previous (more direct) TFSv3 posture-switch choreography as the default to improve compatibility with SEMs that dislike the intermediate “go to low Z” step, while keeping the newer choreography available when z_low is explicitly provided in stage calibration metadata.

Changes:

  • Make TFSv3 posture switching use the “Hydra Bio” low-Z choreography only when z_low exists in MD_CALIB; otherwise fall back to the older direct choreography.
  • Update the TFSv3 simulator config to omit z_low by default so it exercises the old choreography.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/odemis/acq/move.py Adds conditional branching to select between old and new posture-switch choreography based on MD_CALIB["z_low"].
install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml Comments out z_low so the sim uses the old choreography by default.

Comment thread src/odemis/acq/move.py
Comment thread src/odemis/acq/move.py
Comment thread src/odemis/acq/move.py
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9bef795-5099-4a58-b6cc-27f330bc5497

📥 Commits

Reviewing files that changed from the base of the PR and between 9e66c77 and 1a3c491.

📒 Files selected for processing (2)
  • install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml
  • src/odemis/acq/move.py

📝 Walkthrough

Walkthrough

The changes make the TFS3 stage choreography conditional on the presence of the stage calibration field z_low. The code removes the global fallback Z_LOW and now checks md_calib for "z_low". When present, posture-switching follows a Hydra Bio–style sequence that moves Z to z_low before performing rotations and XY moves and then finalizing Z toward the target; when absent, it falls back to the older direct x/y/z then rx/rz choreography. The packaged YAML has z_low commented out, reflecting its optional status.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: reverting the posture manager to support the old choreography as an option for TFS3.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale for reverting to old choreography by default and how the new behavior is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/odemis/acq/move.py (1)

1144-1187: ⚠️ Potential issue | 🟠 Major

Validate z_low by value and keep the safety Z move conditional.

Using key presence enables the Hydra path even for z_low: null, and Line 1164 always moves to z_low while the reverse path correctly skips it when the current Z is already at/below the threshold.

Suggested fix
-                    z_low: float = md_calib.get("z_low")  # safe z to achieve before switching to SEM posture
+                    z_low: Optional[float] = md_calib.get("z_low")  # safe z to achieve before switching to SEM posture
+                    use_z_low = z_low is not None
@@
-                        if "z_low" in md_calib:
+                        if use_z_low:
@@
-                            sub_moves.append((self.stage, {"z": z_low}))
+                            if current_pos["z"] > z_low:
+                                sub_moves.append((self.stage, {"z": z_low}))
@@
-                        if "z_low" in md_calib:
+                        if use_z_low:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/odemis/acq/move.py` around lines 1144 - 1187, md_calib may contain z_low
set to None, so change the z_low checks to validate the actual value (use the
earlier z_low = md_calib.get("z_low") and test "if z_low is not None") and make
the safety Z move conditional like the reverse path: before appending
sub_moves.append((self.stage, {"z": z_low})) in the branch handling
current_label in [SEM_IMAGING, MILLING, FIB_IMAGING] -> target == FM_IMAGING,
only append that move when current_pos["z"] > z_low; do the same "if z_low is
not None" conditional in the opposite branch (current_label == FM_IMAGING) so
both paths consistently check the numeric z_low and skip the Z move when already
at/below threshold.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml`:
- Line 43: The TFS3 simulator config has z_low commented out which prevents
metadata-driven testing of the Hydra choreography; re-enable the z_low fixture
in meteor-tfs3-sim.odm.yaml by uncommenting or adding the "z_low" metadata key
(matching the format used in meteor-fibsem-sim.odm.yaml) so tests can exercise
the Hydra branch instead of relying on the hardcoded fallback Z_LOW in move.py;
ensure the metadata value is realistic (e.g., 27.e-3) and that any tests or
fixtures that read z_low still find and use the metadata key.

---

Outside diff comments:
In `@src/odemis/acq/move.py`:
- Around line 1144-1187: md_calib may contain z_low set to None, so change the
z_low checks to validate the actual value (use the earlier z_low =
md_calib.get("z_low") and test "if z_low is not None") and make the safety Z
move conditional like the reverse path: before appending
sub_moves.append((self.stage, {"z": z_low})) in the branch handling
current_label in [SEM_IMAGING, MILLING, FIB_IMAGING] -> target == FM_IMAGING,
only append that move when current_pos["z"] > z_low; do the same "if z_low is
not None" conditional in the opposite branch (current_label == FM_IMAGING) so
both paths consistently check the numeric z_low and skip the Z move when already
at/below threshold.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ca7be8-3aaa-4969-a35a-2509b499d273

📥 Commits

Reviewing files that changed from the base of the PR and between d87d7b7 and 9e66c77.

📒 Files selected for processing (2)
  • install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml
  • src/odemis/acq/move.py

Comment thread install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml
@pieleric pieleric changed the title [fix] posture manager TFS3: bring back option to use old choreography [MSD-548][fix] posture manager TFS3: bring back option to use old choreography Apr 20, 2026
Comment thread src/odemis/acq/move.py Outdated
Comment thread install/linux/usr/share/odemis/sim/meteor-tfs3-sim.odm.yaml
Comment thread src/odemis/acq/move.py Outdated
Some SEMs don't like going to a little low Z before moving. So, to keep
compatibility with the current systems, revert to use the old, more direct, choreography by
default.
The new choreograph can be activated by adding explicitly a z_low
in the CALIB of the TFSv3 stage-bare metadata.
@pieleric pieleric force-pushed the fix-posture-manager-tfs3-bring-back-option-to-use-old-choreography branch from 9e66c77 to 1a3c491 Compare April 24, 2026 11:29
@pieleric pieleric merged commit c27fd50 into delmic:master Apr 24, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants