Skip to content

Fix Linux desktop replay and add C3/C4 recording support - #185

Open
mgxqc wants to merge 5 commits into
firestar5683:StarPilotfrom
mgxqc:StarPilot
Open

mgxqc wants to merge 5 commits into
firestar5683:StarPilotfrom
mgxqc:StarPilot

Conversation

@mgxqc

@mgxqc mgxqc commented Sep 21, 2026 •

Copy link
Copy Markdown

Summary

Fix Linux desktop UI runtime preparation for C3/C4.

This addresses two separate issues found while testing the desktop launchers on Arch Linux x86_64.

1. BLASFEO executable stack

The bundled x86_64 third_party/acados/x86_64/lib/libblasfeo.so has its GNU_STACK program header marked RWE (read/write/execute).

On systems that reject shared libraries requiring an executable stack, this prevents BLASFEO from loading and causes both the lateral and longitudinal ACADOS Python extensions to fail at import time with:

libblasfeo.so: cannot enable executable stack as shared object requires: Invalid argument

The C3/C4 desktop launchers now detect GNU_STACK ... RWE on Linux x86_64 and use patchelf --clear-execstack to change the stack requirement from RWE to RW before loading the ACADOS runtime.

2. msgq / VisionIPC linkage

The C3/C4 launchers were building the msgq Python extensions using msgq_repo's standalone SConstruct. That environment does not provide StarPilot's common library, so visionipc_pyx.so was linked without common/libcommon.a.

This caused the extension to fail at runtime with an unresolved cloudlog_e symbol:

undefined symbol: _Z10cloudlog_eiPKciS0_S0_z

The msgq extensions are now built through StarPilot's root SConstruct instead. This correctly links common/libcommon.a and resolves the missing symbol.

Initial Testing

Tested on Arch Linux x86_64.

  • BLASFEO GNU_STACK is changed from RWE to RW.
  • Lateral and longitudinal ACADOS Python extensions load successfully.
  • msgq.ipc_pyx and msgq.visionipc.visionipc_pyx load successfully.
  • ./onroad --c4 --demo successfully prepares the runtime, loads the demo route, initializes the camera streams, and launches the C4 UI.

Desktop Replay Recording

This PR also adds optional recording features to the Linux desktop replay workflow.

The additional recording modes are guarded by the existing PC runtime detection and are not enabled on comma hardware.

Both desktop interfaces can be launched with:

./onroad --c3 <route-name>
./onroad --c4 <route-name>

Recording options

Recording is enabled with RECORD=1.

Variable Description
RECORD_COMBINED=1 Record the camera and complete rendered UI/HUD together
RECORD_HUD_ONLY=1 Record the HUD with a transparent background
RECORD_CAMERA_ONLY=1 Record the transformed camera view on C4/Mici
RECORD_METRIC=1 Force metric units during desktop recording
RECORD_CAMERA_VIEW=auto Use automatic camera selection
RECORD_CAMERA_VIEW=standard Force the standard road camera
RECORD_CAMERA_VIEW=wide Force the wide road camera
RECORD_CAMERA_RESOLUTION=render Use the normal rendered UI resolution
RECORD_CAMERA_RESOLUTION=source Use the near-source C4/Mici recording scale
RECORD_DURATION=<seconds> Stop after the corresponding number of rendered recording frames
RECORD_OUTPUT=<path> Select the recording output path
RECORD_QUALITY=<crf> Set H.264 CRF quality
RECORD_BITRATE=<bitrate> Set an H.264 target bitrate instead of CRF

RECORD_CAMERA_VIEW supports auto, standard, and wide on both the C3 and C4 desktop interfaces.

Combined camera + HUD recording

RECORD_COMBINED=1 records the camera and complete rendered interface together.

Example for C4:

RECORD=1 \
RECORD_COMBINED=1 \
RECORD_METRIC=1 \
RECORD_CAMERA_VIEW=standard \
RECORD_CAMERA_RESOLUTION=source \
RECORD_DURATION=20 \
RECORD_OUTPUT="$HOME/StarPilotRoutes/c4-combined" \
RECORD_QUALITY=16 \
./onroad --c4 "00000040--d083928baf" \
  --data_dir="$HOME/StarPilotRoutes"

Combined recordings use H.264 in an MP4 container.

C3 recording

The C3 desktop UI has a native 2160x1080 canvas.

It can be recorded at that resolution using SCALE=1:

SCALE=1 \
RECORD=1 \
RECORD_COMBINED=1 \
RECORD_METRIC=1 \
RECORD_CAMERA_VIEW=wide \
RECORD_DURATION=20 \
RECORD_OUTPUT="$HOME/StarPilotRoutes/c3-wide" \
RECORD_QUALITY=16 \
./onroad --c3 "00000040--d083928baf" \
  --data_dir="$HOME/StarPilotRoutes"

Transparent HUD recording

RECORD_HUD_ONLY=1 records the rendered HUD without the camera pixels.

Camera frames continue to be processed internally so camera geometry, calibration, and model transformations remain correctly aligned.

The output uses lossless PNG/RGBA frames in a Matroska container, preserving the alpha channel.

Example:

RECORD=1 \
RECORD_HUD_ONLY=1 \
RECORD_METRIC=1 \
RECORD_CAMERA_VIEW=standard \
RECORD_OUTPUT="$HOME/StarPilotRoutes/hud" \
./onroad --c4 "00000040--d083928baf" \
  --data_dir="$HOME/StarPilotRoutes"

The resulting .mkv can be composited over another video while retaining HUD transparency.

Camera-only recording

On the C4/Mici UI, RECORD_CAMERA_ONLY=1 stops rendering after the transformed camera frame, omitting the HUD and other UI elements.

The output uses lossless FFVHUFF in a Matroska container.

Example:

RECORD=1 \
RECORD_CAMERA_ONLY=1 \
RECORD_CAMERA_VIEW=wide \
RECORD_CAMERA_RESOLUTION=source \
RECORD_OUTPUT="$HOME/StarPilotRoutes/camera-wide" \
./onroad --c4 "00000040--d083928baf" \
  --data_dir="$HOME/StarPilotRoutes"

C4 near-source rendering

The C4/Mici UI uses a 536x240 base canvas.

For camera or combined recording:

RECORD_CAMERA_RESOLUTION=source

uses a 2.5x rendering scale and produces a 1340x600 canvas.

This preserves the C4/Mici UI aspect ratio and geometry so the camera transformations and model overlays remain aligned.

It is intentionally not a raw 1344x760 camera export.

For a higher-resolution rendered C4 UI, normal scaling remains available. For example:

SCALE=4.5

produces a 2412x1080 C4/Mici canvas.

Recording duration

RECORD_DURATION stops recording based on the number of rendered recording frames rather than wall-clock time.

For example:

RECORD=1 RECORD_COMBINED=1 RECORD_DURATION=30 ...

stops after the number of rendered frames corresponding to 30 seconds at the normal recording frame rate.

Output formats

Mode Container Codec
Normal RECORD MP4 H.264
RECORD_COMBINED MP4 H.264
RECORD_HUD_ONLY MKV PNG/RGBA
RECORD_CAMERA_ONLY MKV FFVHUFF

Local Routes from a comma Device

Desktop replay can also use route data copied directly from a comma device.

This makes it possible to work with local recordings without first downloading the route through a comma account.

Route location on the device

Recorded segments are stored under:

/data/media/0/realdata/

A route is split into numbered segment directories. For example:

/data/media/0/realdata/00000040--d083928baf--0/
/data/media/0/realdata/00000040--d083928baf--1/
/data/media/0/realdata/00000040--d083928baf--2/
...

A segment can contain files such as:

rlog.zst
qlog.zst
fcamera.hevc
ecamera.hevc
dcamera.hevc
qcamera.ts

Copy a route over SSH

With SSH access already enabled on the comma, the route can be copied to the desktop with rsync.

For example:

mkdir -p ~/StarPilotRoutes

rsync -av --progress \
  'comma@<comma-ip>:/data/media/0/realdata/00000040--d083928baf--*' \
  ~/StarPilotRoutes/

This produces local directories such as:

~/StarPilotRoutes/00000040--d083928baf--0/
~/StarPilotRoutes/00000040--d083928baf--1/
~/StarPilotRoutes/00000040--d083928baf--2/
...

Replay the copied route

The complete route can then be loaded directly:

./onroad --c4 "00000040--d083928baf" \
  --data_dir="$HOME/StarPilotRoutes"

The local-route fallback added in this PR recognizes this comma route naming format when SegmentRange does not.

This also allows the desktop replay configuration to load logged route parameters instead of silently falling back to desktop defaults.


Logged route configuration restoration

Previously, this local route format was accepted by replay itself but was not recognized by SegmentRange while preparing the desktop onroad configuration. As a result, logged route parameters could fail to load and the desktop UI could silently use its local/default configuration instead.

The fallback now locates initData from these local routes and restores the logged parameters available to the desktop replay configuration.

In the tested route, this fixed driving-model identification: the route contained:

DrivingModel = pop223
DrivingModelName = Pop Model V2
DrivingModelVersion = v11
Model = pop223
ModelVersion = v11

and the desktop C3/C4 UI correctly identified Pop Model V2 after the local-route fallback was added.

Other configuration values present in the logged route data can likewise be restored through the existing replay configuration path instead of being replaced by desktop defaults.


Additional Testing

Tested using local comma route data on Arch Linux x86_64.

C4/Mici

  • Combined camera + HUD recording.
  • Standard camera selection.
  • Wide camera selection.
  • Near-source 1340x600 recording.
  • 2412x1080 rendered recording using SCALE=4.5.
  • Transparent HUD-only recording with alpha.
  • Lossless FFVHUFF camera-only recording.
  • Metric display override.
  • Local route parameter restoration.

C3

  • Combined camera + HUD recording.
  • Native 2160x1080 recording using SCALE=1.
  • Standard camera selection.
  • Wide camera selection.
  • Logged route/model parameters loaded during replay.

Recording duration

A RECORD_DURATION=5 test at 60 FPS produced:

nb_frames=300
duration=5.000000

Hardware isolation

The additional recording modes use the existing PC runtime detection.

The optional desktop recording flags therefore cannot enable these modes on comma hardware. Shared rendering paths retain their normal behavior when the desktop recording modes are disabled.


Commits

  • 256ba5822 — Fix BLASFEO loading on Linux desktop
  • d32b0a348 — Fix msgq host extension linkage
  • 215f647d1 — Add desktop replay recording and local route support
  • bce28c0cd — Document desktop replay recording
  • 721df3e6b — Document local comma route replay

mgxqc

This comment was marked as duplicate.

@mgxqc mgxqc changed the title Fix BLASFEO loading on Linux desktop Fix Linux desktop replay and add C3/C4 recording support Sep 23, 2026
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