Repository navigation
Gimbal: the tilt negation is untested; make it a pure function with a test - #168
Merged
Merged
Conversation
Camera::answer read the device directly, so no test reached its arms. The poll is now poll_answer, which takes the selector-2 read as a closure and the gap as an argument; Camera::answer passes the device read and the same 50 ms gap, so what is sent and read on the camera is unchanged. Tests script the replies: a rejected answer returns Error::Rejected(command, code) at the first read, an empty answer returns an empty list, a stale answer runs through all 20 reads to NoAnswer, and failed reads are polled again until a value arrives. Fixes #151 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The test module already gets XU_SIZE through use super::*. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
full_status_with reads the device directly, so no test reached the arm that turns a rejected or unanswered tracking query (0x0104) into tracking: None. Tests now run it on a scripted Device (compiled in tests only, answering xu_get, xu_set, get_ctrl and ctrl_range from a table): a rejected tracking query returns Ok with tracking None and the other fields filled, an answered one fills tracking, and a failed write still fails the whole read. No status code and no byte sent to the camera changed. Fixes #152 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Do not claim how a camera treats an unknown query; the comment now says what the test double does (type 0x89, code -1) and why. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Camera::gimbal sent the tilt negated inline; no test covered it, so deleting the minus would have left every test green and made `gimbal --tilt 20` move the camera down. The negation (with the + 0.0 that keeps -0.0 off the wire) is now tilt_to_pitch, which gimbal calls. The bytes sent for any input are unchanged (byte guard and command-line guard pass unchanged). Tests: positive tilt up gives the negated value, 0 stays +0.0, None stays None, and the converted value builds the two pose frames of capture 18 byte for byte. Fixes #153 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
nofuturekid
force-pushed
the
fix/153-test-tilt-sign
branch
from
November 13, 2026 12:29
65160c1 to
d2d1358
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #153
What changed
Camera::gimbal(-t + 0.0) is now the private pure functiontilt_to_pitch(user tilt, positive up, in; wire pitch, positive down, out) incrates/obsbot-device/src/models/tiny2lite/camera.rs.gimbalcalls it. Nothing else ingimbalchanged; the tracking-mode command it sends first stays as it is.gimbal_tilt_tests(4 tests): tilt 20 gives -20 (and the reverse), 0 and -0.0 give +0.0 (checked by bits),NonestaysNone, andtilt_to_pitch(Some(30.0))/Some(0.0)build the two pose frames of capture 18 byte for byte (0x6444, seq 28 and 33).Verification (no camera, no device opened)
cargo fmt --check,cargo clippy --all-targets --locked -j 3 -- -D warnings,cargo test --locked --workspace -j 3: clean; 122 + 1 + 25 + 2 tests pass (118 before + the 4 new in the library).tests/byte_guard.rsandtests/cli_surface.rsand their fixtures are unchanged and pass, so no sent byte and no output changed.-intilt_to_pitch:tilt_up_is_sent_as_the_negated_pitchandthe_converted_tilt_builds_the_captured_pose_framesFAIL.+ 0.0:a_tilt_of_zero_is_sent_as_positive_zeroandthe_converted_tilt_builds_the_captured_pose_framesFAIL.gimbalcallstilt_to_pitchat all. That needs a camera (the call is followed by I/O); the byte guard does not exercisegimbaleither. The minus itself now lives in the tested function, so the cargo-mutants mutant "delete - in Camera::gimbal" no longer exists as such; the equivalent "delete - in tilt_to_pitch" is caught.tilt_to_pitchsits next totilt_to_pitch_rangeinmodels/tiny2lite/camera.rs, test modulegimbal_tilt_testsat the end of the file beforeangle_conversion_tests.🤖 Generated with Claude Code