Skip to content

APP-18179: Fix the audio, motion and pose tracker code samples - #1295

Draft
Evgeni Dobranov (edobranov) wants to merge 1 commit into
mainfrom
app-18179-fix-the-sdks-sample-data-for-viam-python-sdk
Draft

Evgeni Dobranov (edobranov) wants to merge 1 commit into
mainfrom
app-18179-fix-the-sdks-sample-data-for-viam-python-sdk

Conversation

@edobranov

@edobranov Evgeni Dobranov (edobranov) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

https://viam.atlassian.net/browse/APP-18179

Background

examples/apis.json is the sample data app builds its Python code samples from. For each resource subtype it names the class to import, the method to call and the arguments to pass, and app's generator pastes those arguments verbatim into the call. App downloads the file from this repo's main on every frontend build (ui/scripts/postbuild.js), so a change here reaches app on its next deploy, with no SDK release involved.

Two features read it: the Connect tab's code samples, which are shown for copying, and the Control tab's code sandbox, which since APP-18068 runs the generated program inside a session sandbox whose Python image pins viam-sdk 0.80.0.

Problem

Checking every sample the sandbox can generate against that image found three entries whose programs cannot run:

  • audio generates from viam.components.audio import Audio, a module the SDK has never had, so the program fails with ModuleNotFoundError: No module named 'viam.components.audio'. The key dates from the 2023 code-samples reformat, but the audio input component's subtype was audio_input, so no real resource ever matched it; audio_in and audio_out have since replaced that component and have their own entries.
  • motion calls get_pose(), which raises for its missing component_name and destination_frame.
  • pose_tracker calls get_poses(), which raises for its missing body_names.

An import error stops the program before its first line runs, and a raised call stops it at that block, so on any machine whose config has a motion service or a pose tracker the sandbox never gets through its samples.

Fix

Removes audio and passes the required arguments by keyword, so the sample names the argument a user would change: get_pose(component_name="world", destination_frame="world") and get_poses(body_names=[]). Asking for the world frame's pose in world succeeds on any machine and returns a zero pose; a comment above the call says to change the component name to get a real one. An empty body list returns every tracked body. Also re-indents the audio_in and audio_out entries to match the rest of the file.

Verified by generating the sandbox program for a machine with one resource of every subtype in this file, the way app's connectSamplesPythonSandbox does, then importing it and binding every generated call to its method's signature, against viam-sdk 0.80.0 (the Python sandbox image's pin) and 0.84.0: everything imports and every call binds. The same program generated from main fails on the audio import, and without that entry, on the two calls above. The matching fixes are in viamrobotics/rdk#6666 and viamrobotics/viam-typescript-sdk#1039.

🤖 Generated with Claude Code

Drop the audio entry. The SDK has never had a viam.components.audio
module and no resource has an audio subtype: audio input was
audio_input, since replaced by audio_in and audio_out, which have their
own entries. The entry could only ever generate a failing import.

Give motion's get_pose and the pose tracker's get_poses the arguments
they require. Motion asks for the world frame's pose in the world frame,
which succeeds on any machine; the pose tracker passes an empty body
list, which returns every body.

Also indent the audio_in and audio_out entries like the rest of the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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