Skip to content

fix(extras): allow SET_ZERO_REFERENCE_POSITION to be called without having a beacon#125

Merged
tg73 merged 1 commit intoRat-OS:v2.1.x-developmentfrom
tg73:topic/devpub/fix-set-zero-ref-pos
Mar 1, 2026
Merged

fix(extras): allow SET_ZERO_REFERENCE_POSITION to be called without having a beacon#125
tg73 merged 1 commit intoRat-OS:v2.1.x-developmentfrom
tg73:topic/devpub/fix-set-zero-ref-pos

Conversation

@tg73
Copy link
Collaborator

@tg73 tg73 commented Mar 1, 2026

…aving a beacon

- Fixes Rat-OS#124
- Moved the implementation from a beacon-specific module to the general-purpose [ratos] module
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

The SET_ZERO_REFERENCE_POSITION G-code command is relocated from the beacon-specific beacon_mesh.py module to the main RatOS class, removing the beacon probe as a dependency for this functionality. The command implementation logic remains functionally equivalent.

Changes

Cohort / File(s) Summary
Beacon Mesh Command Removal
configuration/klippy/beacon_mesh.py
Removed command registration, handler method cmd_SET_ZERO_REFERENCE_POSITION, and associated descriptor constant for setting the zero reference position.
RatOS Command Addition
configuration/klippy/ratos.py
Added BedMesh import alias, registered SET_ZERO_REFERENCE_POSITION G-code command, and implemented handler that validates bed mesh availability, reads X/Y coordinates, rebuilds the mesh with new zero reference position, and persists the profile. Minor formatting adjustment in cmd_CAMERA_SNAPSHOT.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A command hops from beacon's nest,
To RatOS where it serves them best,
No probe required, just mesh and will,
The reference stands, position's still! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving SET_ZERO_REFERENCE_POSITION implementation from beacon-specific to general module to allow calling it without beacon.
Linked Issues check ✅ Passed The PR successfully addresses issue #124 by moving SET_ZERO_REFERENCE_POSITION from beacon_mesh.py to ratos.py, making the command available regardless of beacon installation.
Out of Scope Changes check ✅ Passed All changes are in scope: removal of command from beacon module, addition to ratos module, and a minor formatting change in camera snapshot handling are all aligned with moving the functionality.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

@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.

🧹 Nitpick comments (1)
configuration/klippy/ratos.py (1)

422-422: Optional lint cleanup for long inline error message.

At Line 422, consider moving the long error string to a class-level constant for cleaner exception sites and consistency with TRY003-style lint expectations.

♻️ Optional cleanup
+	ERR_BED_MESH_NOT_CONFIGURED = (
+		"The bed_mesh module is not configured. This command requires a [bed_mesh] "
+		"section in the printer configuration."
+	)
+
 	def cmd_SET_ZERO_REFERENCE_POSITION(self, gcmd):
 		if not self.bed_mesh:
-			raise gcmd.error("The bed_mesh module is not configured. This command requires a [bed_mesh] section in the printer configuration.")
+			raise gcmd.error(self.ERR_BED_MESH_NOT_CONFIGURED)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@configuration/klippy/ratos.py` at line 422, Extract the long inline error
message used in the gcmd.error raise (the "The bed_mesh module is not
configured..." string) into a class-level constant (e.g.,
BED_MESH_NOT_CONFIGURED) near the top of the class or module, then replace the
inline literal in the raise site with that constant; update any nearby/related
error-raise sites to reuse the constant for consistency and lint compliance
(refer to the raise invoking gcmd.error and the "bed_mesh" module check to
locate the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@configuration/klippy/ratos.py`:
- Line 422: Extract the long inline error message used in the gcmd.error raise
(the "The bed_mesh module is not configured..." string) into a class-level
constant (e.g., BED_MESH_NOT_CONFIGURED) near the top of the class or module,
then replace the inline literal in the raise site with that constant; update any
nearby/related error-raise sites to reuse the constant for consistency and lint
compliance (refer to the raise invoking gcmd.error and the "bed_mesh" module
check to locate the change).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 675adcb and 8580453.

📒 Files selected for processing (2)
  • configuration/klippy/beacon_mesh.py
  • configuration/klippy/ratos.py
💤 Files with no reviewable changes (1)
  • configuration/klippy/beacon_mesh.py

@tg73 tg73 merged commit ddcab6c into Rat-OS:v2.1.x-development Mar 1, 2026
3 checks passed
@tg73 tg73 deleted the topic/devpub/fix-set-zero-ref-pos branch March 1, 2026 17:42
tg73 added a commit that referenced this pull request Mar 1, 2026
…aving a beacon (#125)

- Fixes #124
- Moved the implementation from a beacon-specific module to the general-purpose [ratos] module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant