Skip to content

[Test build] Satellites, moving target follow and polar alignment with INDI mount control - #700

Draft
mrosseel wants to merge 812 commits into
brickbots:mainfrom
mrosseel:test/device-build
Draft

mrosseel wants to merge 812 commits into
brickbots:mainfrom
mrosseel:test/device-build

Conversation

@mrosseel

@mrosseel mrosseel commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Test build, not for merge

This draft PR exists so that a PiFinder can install a build of mrosseel:test/device-build from the unstable channel. The review of the work happens in five PRs on mrosseel/PiFinder, in this merge order:

  1. [1/4] feat: INDI mount control over USB and WiFi (simplified #367 design) mrosseel/PiFinder#125 INDI mount control
  2. [2/4] feat(satellites): satellite catalog, selectable groups, pass prediction and web TLE entry mrosseel/PiFinder#127 Satellite catalog
  3. [3/4] feat(mount): polar alignment with the mount turning the RA axis mrosseel/PiFinder#128 Polar alignment with the mount
  4. [4/4] feat(mount): follow moving targets with user correction, lunar and solar rates mrosseel/PiFinder#129 Follow of moving targets
  5. feat(indi): PiFinder as an INDI telescope device for SkySafari 7 mrosseel/PiFinder#138 PiFinder as an INDI telescope device for SkySafari 7

The branch merges #128, #129 and #138, so it holds all five PRs. It is based on the asteroids branch (#534), so the diff against main also holds the asteroid, Gaia chart and NixOS work.

What to test on a device

  • Objects > By Catalog > Satellites... > Sat groups: select CelesTrak groups. A group without a file downloads at once.
  • The Satellites list: the PASS sort lists the satellites above the horizon first.
  • The /satellites web page: groups, custom element sets, the "In the sky now" table, the pass table.
  • With an INDI mount: key 5 on a satellite follows it. The arrow keys correct the path. A corrected element set is stored when the follow ends.
  • With an equatorial INDI mount: the polar alignment wizard turns the RA axis between the three captures.

SkySafari 7 or later over INDI (#138)

Set up a SkySafari telescope preset: connection INDI, address pifinder.local or the IP address from the Status screen, port 7624. Let SkySafari look for devices and select PiFinder.

  • The crosshair shows the plate-solve position, also while the mount moves.
  • GoTo: with mount control on, the mount slews and PiFinder centers the object. Without a mount, the object goes to the observing list.
  • Stop and the direction buttons move or stop the mount.
  • Align: center an object in the eyepiece, select it in SkySafari and press Align. The PiFinder shows "Aligned!" or "Alignment failed". An object more than 5 degrees from the camera center is refused.

The LX200 connection on port 4030 does not change.

Tested with SkySafari 7 and 8 against the INDI telescope simulator. Not tested on a real mount yet, and Align not yet with a real camera.

🤖 Generated with Claude Code

mrosseel and others added 30 commits September 27, 2026 12:42
)

- The confirm screen offers Install only on USB-C power. The charger
  (bq25895, rev4) reports it; hardware without the charger cannot tell and
  keeps Install. On battery it shows "Plug in USB-C power".
- While the upgrade runs, the screen does not dim. A module on top of the
  menu stack sets keep_awake; PowerManager then counts it as activity.
- migration-e2e: MIGRATION_E2E_QEMU selects another QEMU. QEMU 11.1 stops
  at start with "Failed to initialize io_uring" on this host.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
After the patches, the rest of a download is often under 1 MB, and the
screen showed "0/0 MB". format_amount picks the unit by the total: KB
below 1 MB, MB with one decimal below 10 MB, MB up to 1 GB, GB above.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The amount under the bar ("150/300 KB", "12 to go") was in the base
font, dim gray, with the lower third of the screen empty. It is the main
fact on that screen, so it is now in the large font at full brightness;
the package name stays small below it.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#88 draws the download amount in the large font; the stand-in font set
of test_draw_upgrading_every_phase had no large, so five cases failed.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
QEMU emulates the SPI0 controller, but no display answers. The kernel
driver then waited for ever inside boot-splash ("soft lockup" for more
than 30 minutes), the watchdog that calls boot-splash never ended, and
the ext2_saved cleanup after it never ran. The harness now disables
spi@7e204000 in its device tree copies, so boot-splash finds no
/dev/spidev0.0 and stops at once.

With this, the full stage passes: "PASS: Pi OS -> NixOS migration boots
the full system" (2026-09-27, the password and ext2_saved checks
included).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The device sends all missing paths in one POST /deltas and reads the
answer as a stream of JSON lines. Each patch is downloaded and applied
as soon as its line arrives, while the server computes the others, so
there are no fixed waits between rounds. The paths the stream leaves
open (a cut stream, an older server without /deltas, or still computing
at the end) are asked again with /delta in the rounds as before.

Needs pifinder-differ with /deltas (mrosseel/pifinder-server#8); with an
older server the device uses the rounds only.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ad of a moving block (#92)

- nix installs the patched paths from the local cache before it
  downloads anything; that took several seconds on a Pi 4 while the
  screen stood at "Downloading 0/16 KB". It is now the step "Installing
  patches" with a bar and "12/45 patches" (status "installing d/t
  <package>", from the copyPath events of the local cache).
- "Making patches" shows "5/40 patches" (decided out of all) with a
  real bar, instead of "32 to go" and a block moving back and forth.
  The moving block stays only for Preparing and Checking.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A py-spy profile on the CM4 while opening the Messier list: the UI thread
spent its time in create_locate_text -> aim_degrees, and there in
shared_state.solution(), .location() and .datetime(): three round trips
to the multiprocessing manager per visible row, on every frame. The
slide-in animation draws many frames, so it was choppy. The background
threads used about 1% of a core; the GIL was not the cause.

pointing_snapshot() reads the three values once; the object list takes
one snapshot per frame and passes it to aim_degrees for every row.
aim_degrees without a snapshot reads it itself, as before.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… tuples (#94)

CompressedIndex read each run directory into a list of (start, offset)
tuples: about 132 bytes per run in Python against 12 on disk. The full
catalog has 1,216,019 runs in six bands: about 161 MB of RAM for 15 MB
of index. On the CM4 (asteroids build) the Gaia step of the start added
157 MB of anonymous memory.

The run directory is now a numpy view on the mmap (packed 12-byte
records); only the start tile ids are copied, 4 bytes per run, for
np.searchsorted. All six indexes now take 4.6 MB. Checked on the real
catalog: 0 mismatches against the old lookup in about 120,000 lookups,
and each lookup is as fast or faster (2.3 to 7.0 us against 2.2 to
10.5 us). The tile id goes into searchsorted as uint32; a Python int made
numpy convert the whole array at each call.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
"Installing patches" stayed at 0/41 while the package names changed:
nix sends a copyPath stop as {"action": "stop", "id": ...}, with no
type (checked with nix build --log-format internal-json). feed() passed
a stop on only when its type was 100, so no copy ever ended in the count.
Every stop now goes to _on_stop, which ignores the ids it does not track.
The tests use the real stop format.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Software screen reads /run/pifinder/upgrade-status every frame.
write_status truncated the file and then wrote it, so a read in between
found an empty status and the screen drew one frame of its default. The
screen flickered, most during Applying patches, which writes the status
once per patch. write_status now writes a temporary file in the same
directory and os.replace()s it.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… loop (#97)

A py-spy profile on the CM4 while opening the Messier list: the UI thread
was busy 91% of the time. About 7 s of 40 went to ImageDraw.text in the
text menu, which rasterized every line again on every frame, and about
5 s to the GPS block of the main loop, which made a round trip to the
shared state for each GPS message.

- ui_utils.draw_text_cached keeps the rendered text of a (text, font)
  pair as a grey mask (LRU, 512) and pastes it with the colour.
  Pixel-identical to ImageDraw.text in RGBA mode (tests with the real
  fonts, 128 and 176 panels). The text menu uses it.
- drain_gps_queue drains the GPS queue first and keeps one message per
  kind: the fix with the smallest error (the result the one-by-one loop
  gave), the newest time (force if any was time_force), the newest
  satellites and comms. Resets act first and drop older pending
  messages. Fix and time go to the shared state at once; satellites and
  comms at most once a second.

Checked: 1747 unit tests, 6 new drain tests and 13 text tests; a
headless run on nixtop reaches the event loop and applies the fake GPS
fixes with falling error.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ezoneFinder build (#98)

A py-spy profile on the CM4 (menus slow after a boot): 36% of the UI
thread's time was waiting on the shared state, 21% on one call,
set_location. set_location waited for the TimezoneFinder build (10.6 s
on the CM4) and then ran timezone_at on every call: 180 ms per call for
Belgium on the CM4. While the GPS converges, a fix with a smaller error
comes about every second, and the UI thread waited for each lookup.

- The zone is looked up again only after a move of more than
  TZ_MOVE_DEG (0.05 degrees, about 5 km); GPS jitter reuses it.
- set_location never waits for the build. Until it is ready a location
  keeps the last known zone (or UTC), and the build thread fills in the
  zone of the current location when it ends.
- wait_for_timezone_finder() for tests and tools.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rsion (#99)

The rollback list named each generation by its store path, which only
carries the NixOS version (26.05.20260924.c508844): the same for every
build on one nixpkgs. The upgrade now keeps the build label by store
path in /var/lib/pifinder/build-labels.json (at most 20, atomic write):
the new build, and the build it leaves (from current-build.json), the
likely rollback target. The rollback list uses the label when it has
one, else the NixOS version as before. The file is for display only; a
missing or broken file gives the old list.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The row count came from a fixed MAX_VISIBLE of 4 and the list stopped at
y 128. On the 176 and 320 panels the list showed 4 or 5 versions and left
the rest of the screen empty.

The row height now comes from the base font. The list bottom comes from
the screen height, less the status line while it shows. The draw computes
the visible rows and key_down scrolls by that number. On the 128 panel the
layout stays the same, pixel for pixel.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A profile on the CM4 with the Messier list open showed that most of
the list's frame time went to FreeType glyph rendering (getmask2). The
list drew each row name, each second column and the two header lines
again on every frame.

These draws now use draw_text_cached, as the text menus do. The result
is the same pixel for pixel. On nixtop a frame of seven rows takes
0.03 ms instead of 1.06 ms.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ng (#101)

The checking step ran nix-store --realise --dry-run. The dry run gives no
progress, so the screen showed a moving block.

The differ's /update-start reply now lists the target closure with NAR
sizes. The device checks that list against its store in batches of 100
paths with nix-store --check-validity and writes "checking <done>/<total>"
after each batch. The missing paths and the sum of their NAR sizes give the
same estimate as the dry run. The screen shows "Checking paths", a % bar
and the count.

An older differ sends no closure. Then, and when a check fails, the device
uses the dry run as before.

delta-e2e compares the local check with the dry run when the test store
holds the target closure from an earlier run.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mrosseel and others added 10 commits November 19, 2026 06:27
The boot splash drove both panels at 40 MHz. Newer 1.5" SSD1351 panels
stay blank at 40 MHz, which is about twice the datasheet clock. brickbots#701 set
the app to 20 MHz for this panel.

The splash now uses the clock of the detected panel: 20 MHz for the
SSD1351 and 40 MHz for the SSD1333, the same as displays.py.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…se guide (#132)

- release.yml: for a fork source, create the release tag on the built commit through the GitHub API. If the API refuses, warn and continue.
- nixos/RELEASE.md: point to release_notes/RELEASE-PLAYBOOK.md, start releases from brickbots main, add a beta example, the 90-day rule and a tag check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings brickbots#697 (rebuilt catalog database), brickbots#703 (an alignment point for each
telescope), brickbots#704 (Obs Lists picker layout) and brickbots#706 (migration progress
panel type).

- main.py: the reload_config handler sets the target pixel of the active
  telescope. nixos has no catalogs_fully_loaded handler.
- text_menu.py: _draw_item_text draws with draw_text_cached.
- pifinder_objects.db: rebuilt from a fresh file with
  python -m PiFinder.catalog_imports.main. Two builds with different
  PYTHONHASHSEED values are byte-identical. 23 catalogs (main's 22 and PK).
- test_obs_list_layout.py: records the draw_text_cached rows.
- test_target_pixel_wiring.py: stubs the lazy timezonefinder module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Hold SQUARE at power-on: pifinder-recovery-hold.service scans the keypad and starts the app with only the Software screen (Rollback first).
- A rollback pick becomes the boot default. A recovery app that fails its health check rolls back to the newest confirmed generation.
- The trial rollback finds a confirmed camera specialisation (#136).
- ADR 0038, troubleshooting and user guide describe recovery mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- user guide: Update Software describes the NixOS Software screen, with three rev4 screenshots
- docs/source/nixos_migration.rst: the move to PiFinder software 3
- ADR 0022 §4.3: the per-frame optical-black pedestal; the separate ADR is removed
- ADR 0039 and 0041: status lines describe what is built
- delete version.txt and docs/ax/nixos/HANDOVER.md
- the API reports the version from utils.get_version()
- pf_remote.py finds cedar-detect-server on the PATH of the dev shell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
INDI clients see a telescope device named PiFinder on port 7624. Its
position is the plate solve in JNow. A GoTo goes to PiFinder mount
control, or to the observing list when there is no mount. Stop, the
direction buttons and the slew rate go to mount control. An Align from
the client does the PiFinder alignment on the object, within 5 degrees
of the camera center. It does not sync the mount.

The mount driver moves to a local indiserver on port 7625. A public
indiserver on port 7624 runs only a socat relay to the PiFinder device
socket, so a client cannot command the mount around PiFinder. The two
servers use different local sockets (-u).

The sky simulator now treats a manual move (TELESCOPE_MOTION_NS/WE) as
motion, not as a sync.

Tested with SkySafari 7 and 8 against the INDI telescope simulator.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mrosseel and others added 2 commits December 1, 2026 15:29
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The sky simulator fix for manual moves comes from the polar alignment
branch. This branch keeps only the INDI_PORT default of the simulator.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mrosseel and others added 2 commits December 2, 2026 11:59
…e failure (#139)

A tester's update failed with "Update failed!". After the restart the
old build did not start, and the update log was lost. A full SD card can
cause both faults, and the device did not report it.

- The upgrade compares the free space with the download before it starts.
  When the space is too small, it deletes the unused store paths, then the
  old generations except the two newest (not in recovery mode). If the
  space stays too small, the status is "nospace <needed> <free>" and the
  Software screen shows "SD card full" with both sizes.
- A "No space left on device" from the build or a later step gives the
  same status. The upgrade then deletes what the failed download left.
- The upgrade keeps the status, the error and the nix log tail of a
  failure in /var/lib/pifinder/last-upgrade-failure.json. The log download
  of the web interface contains it.
- pifinder-space-guard runs before pifinder.service. Below 256 MiB free it
  deletes the unused store paths, so that the app and recovery mode can
  start. VM test: nixos/tests/space-guard.
- The watchdog advisory adds "SD CARD FULL" when the card is full.
- Recovery mode: the Software screen reads the WiFi mode from
  NetworkManager (the wifi_status.txt in the store is always "Client"),
  and the Rollback list shows the generation that boots now with ">".

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Brings recovery mode (#135) and the full SD card fixes (#139) to the
test build. Fixes for the merge:

- config: the satellite filter migration writes through _persist; nixos
  removed dump_config.
- main: keep the mount control reload and the per-telescope alignment
  point on reload_config.
- tests: the persist tests ignore the migration markers, and the
  observing list picker test sets _menu_type, which the text menu reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mrosseel and others added 10 commits December 2, 2026 19:23
The device listed each directory in /nix/store as a possible base. A
directory that the nix database does not list is a partial copy, for
example after a power loss during a download. The delta server makes
the patch against the cache copy of that path, so the patch does not
apply to the partial copy: zstd stops with "Data corruption detected"
and the path downloads in full.

The prefetch now asks nix-store --check-validity for the candidate
bases, in one call, and offers only the valid ones. When the check
cannot run, no base is offered and all paths download in full.

delta-e2e, bb6d2cf to f3104f0, with a test store that has partial
paths: the old code failed on 15 of 50 patches, this code on none.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t the app (#140)

* feat(nixos): one diagnostics record for each failure, readable without the app

A tester's PiFinder did not start after a failed update. The web log
download runs in the app, the journal is in RAM, and for a confirmed
generation the watchdog wrote nothing. So no log was left.

pifinder-diagnostics (nixos/pkgs/diagnostics.nix) writes one text record:
the event, the generation, the free space, the state of pifinder.service,
an attachment and the end of the journal. Each failure path calls it:

- an update failure and a full card (nixos_upgrade, with the error and
  the nix log tail); a missing build or cache writes no record
- a trial rollback and a recovery failure (watchdog)
- a confirmed generation whose app does not start (watchdog)
- a boot counter fallback (watchdog)
- the space guard, when it freed space

The record goes to /var/lib/pifinder/diagnostics, to PiFinder_data/
diagnostics on the Samba share (as the pifinder user), and as
PIFINDER-DIAG.TXT to the FAT partition, which any PC with a card reader
shows. Each place keeps the 5 newest. A record is at most 1 MiB, and the
script always exits 0. Recovery mode shows the newest record as
"Last fault", and the web log download contains the records.

This replaces the failed-boot logs of the watchdog and the
last-upgrade-failure.json of #139. VM test: nixos/tests/diagnostics.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: tidy the diagnostics review faults and name the NixOS SMB share

- software.py: the attribute that holds the recovery fault line is
  _last_fault. It had the same name as the function _fault_line.
- test_recovery.py: the imports are at the top of the file. The test of
  recovery mode now checks the fault line that active() sets.
- The NixOS Samba share is PiFinder_data, not shared. connectivity.rst
  names both: software 2.x uses shared. The migration page keeps shared,
  because the backup is made on 2.x.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(nixos): harden diagnostics on full card, keep FAT history, filter nix progress

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…143)

SkySafari and Stellarium send only RA and Dec, over LX200 and over INDI.
The PiFinder showed a PUSH object with only the position, and an INDI
GoTo with a mount connected did not show the target at all.

The LX200 server and the INDI device now send the J2000 position to the
main process. The main process finds the nearest catalog object within
0.1 degrees, in all catalogs with no filter. Of objects at the same
place (within 30 arcseconds), M wins over NGC over the rest. It shows
that object and puts it on the recent list. With no object there, it
shows a PUSH object, as before.

An INDI GoTo with a mount now moves the mount and shows the target.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ses push

The web interface puts a satellite on the recent list and sends
push_object, so the main loop still shows the recent list for it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… network (#144)

- GoTo Names (default On): a GoTo from SkySafari or Stellarium shows the
  catalog object at its position. Off shows a PUSH object, as before.
- Mount Network (default Off): the firewall opens the mount indiserver
  (port 7625), so an INDI client such as KStars/Ekos can use the mount
  directly. PiFinder creates /var/lib/pifinder/indi/mount-network, the
  firewall adds the rule while the file exists, and a path unit reloads
  the firewall when the file changes. A firewall restart keeps the choice.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…144) into test/device-build

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mrosseel mrosseel added testable Ready for testing via PiFinder software update and removed testable Ready for testing via PiFinder software update labels Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testable Ready for testing via PiFinder software update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants