Repository navigation
APP-18179: Fix the audio, motion and pose tracker code samples - #1295
Draft
Evgeni Dobranov (edobranov) wants to merge 1 commit into
Draft
Evgeni Dobranov (edobranov) wants to merge 1 commit into
Evgeni Dobranov (edobranov) wants to merge 1 commit into
Conversation
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
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.
https://viam.atlassian.net/browse/APP-18179
Background
examples/apis.jsonis 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'smainon 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-sdk0.80.0.Problem
Checking every sample the sandbox can generate against that image found three entries whose programs cannot run:
audiogeneratesfrom viam.components.audio import Audio, a module the SDK has never had, so the program fails withModuleNotFoundError: No module named 'viam.components.audio'. The key dates from the 2023 code-samples reformat, but the audio input component's subtype wasaudio_input, so no real resource ever matched it;audio_inandaudio_outhave since replaced that component and have their own entries.motioncallsget_pose(), which raises for its missingcomponent_nameanddestination_frame.pose_trackercallsget_poses(), which raises for its missingbody_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
audioand passes the required arguments by keyword, so the sample names the argument a user would change:get_pose(component_name="world", destination_frame="world")andget_poses(body_names=[]). Asking for theworldframe's pose inworldsucceeds 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 theaudio_inandaudio_outentries 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
connectSamplesPythonSandboxdoes, 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 frommainfails on theaudioimport, 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