Repository navigation
CodeAIR simulator: camera.take() returns a real picture, for pipe.image and the vision lessons - #176
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS5gJ3Ss35qTL2qEztbDud
# Conflicts: # CHANGELOG.md
|
Visit the preview URL for this PR (updated for commit 52ae554): https://firialabs-open-editor--pr176-codeair-camera-captu-l7kgjck9.web.app (expires Thu, 10 Dec 2026 16:45:49 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 81259a1fec315ca1af3747d225d9c7424890be3e |
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.
camera.take()on the simulated CodeAIR now returns a picture of what is under the drone, the way the device's does. CodeSpace's camera lessons (Recon, Line Patrol, Target Lock) now run in the simulator.A frame, drawn when asked for.
take()asks the page for a frame of the drone where it is at that simulated moment; the worker sends the drone's pose. The page draws it with the same camera as the live view (PR 171), off screen at twice the size, toned as the screen is. It averages that down and packs it as the camera's bytes, then sends them back. Nothing is drawn unless a program asks.Bytes as on the device. The frame is a read-only
displayio.Bitmap. It is RGB565 with each pixel's high byte first in memory, soframe[x, y]reads byte-swapped, as the lessons teach. Grey frames are 8-bit, aftercamera.reconfigure(pixel_format=GRAYSCALE). AnyFrameSizeworks, its field of view cut from the sensor's 4:3.img_utils.get_bitmap_bytesreturns those bytes, sopipe.image(camera.take())sends the record the device sends; it shows in the data panel once PR 172 lands.Time. A frame costs 25 ms of simulated time, an estimate of what
take()costs on the device, however long the page takes to draw it. While Python waits for the page, its own steps are not charged (engine.held, a small change to the sharedengine.js).Realism never touches the world. A frame is drawn at the Medium look whatever the realism setting, so a program reads the same picture on every machine.
Headless, or no page. In Node, or when the page cannot answer within 1.5 s, a frame is the floor map through the same lens, in grey. That keeps it deterministic, and tests can check the picture's orientation against tape laid on the floor.
What the lessons use, added:
camera.frame_availableas a property, plussensor_name,width,heightandreconfigure.displayio.Bitmap(w, h, value_count)to draw into.img_utils.detect_color_blob: the device's C, step for step, in JavaScript (bridge/codeair-camera.js), charged as C would cost.img_utils.save_bitmap_file: a 24-bit BMP. Paths on/sd/say no card is there, as the device does without one.Not simulated: Search Party's neural network (
tflite_detect).Tests.
tests/sim.mjs:0xce 0x79for the floor's grey) and read-only flag, and its 25 ms cost;detect_color_blobon a red patch, matching the C, debug bitmap included.tests/sim-ui.mjs: in the browser, a colour and a grey frame drawn by the page, 25 ms each.🤖 Generated with Claude Code