Skip to content

RSDK-14757 Typed kinematic model for arm, gantry and gripper - #1312

Merged
JohnN193 merged 2 commits into
mainfrom
RSDK-14757-kinematic-model
Nov 17, 2026
Merged

JohnN193 merged 2 commits into
mainfrom
RSDK-14757-kinematic-model

Conversation

@JohnN193

@JohnN193 JohnN193 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

What

Finishes the Python side of the typed kinematics API (RSDK-14757). The automated protos update #1291 already carried the raw KinematicModel through as an optional fourth tuple element of get_kinematics. This adds a typed way in and the helpers a module needs.

  • get_kinematic_model(include_collision_meshes=, include_visual_meshes=) on Arm, Gantry and Gripper, base, client and server. It returns the KinematicModel message, as get_kinematic_model does in the C++ SDK.
  • get_kinematics is deprecated in its docstring and keeps working for existing modules and clients.
  • New viam.kinematics:
    • read_kinematic_model_file(path), a strict loader for the kinematic model file format (the proto JSON of the message), a port of ReadKinematicModelFile in rdk.
    • narrow_joint_limits(model, limits), which narrows a model to the joint_limits attribute of a resource config and refuses a value that would widen a limit.
  • The three servers share one GetKinematics reply, with the same rules as KinematicsResponse in rdk:
    • a request with either mesh flag gets the model alone, with mesh bytes only for the roles asked for
    • a request with no flags gets the model with every mesh, plus the deprecated format and kinematics_data
    • the deprecated fields come from get_kinematics when the resource still implements it, and are otherwise written from the model as an SVA file. A model with a joint that has no position bound cannot be written, so it is served as the model alone, as rdk does.

Things to look at

  • Neither method is abstract. get_kinematics loses @abc.abstractmethod and get_kinematic_model is added without it, both raising MethodNotImplementedError by default. An existing module keeps working on upgrade and a new one implements only get_kinematic_model. The C++ SDK went the other way and made the new method pure virtual. If anything builds module stubs from the abstract methods it will now emit neither, I have not checked viam module generate.
  • A flagged request no longer carries the file fields, even from a resource that implements both methods. This matches rdk on purpose.
  • The server names the model for the resource, as rdk does. A model carried in the old four element tuple is passed through untouched.
  • .. deprecated:: 0.86.0 assumes the next release number.
  • docs/examples/my_cool_arm.py still implements get_kinematics only.

Testing

  • tests/test_kinematics.py runs the loader over the shared fixtures from rdk (referenceframe/testfiles/kinematic_models, copied to tests/data/kinematic_models at rdk cefbb7080). All 32 cases pass: 9 load to exactly expected.json, 23 are refused for the kind error.json names.
  • Tests for the limits helper, the SVA file writer, the server reply for each flag combination and each kind of resource, and the three clients.
  • The SVA files written from the fixtures were also read back with UnmarshalModelJSON in rdk and compared to the model built from expected.json. The 8 fixtures that can be written as a file all match. That check is not part of this repo.
  • make lint typecheck test: 1075 passed, 5 skipped (no viam-server locally).

🤖 Generated with Claude Code

Add get_kinematic_model to the arm, gantry and gripper, returning the
KinematicModel message, and deprecate get_kinematics, which stays for
modules and clients that still use the file bytes.

viam.kinematics holds the helpers a module needs to serve a model:
read_kinematic_model_file, a strict loader for the proto JSON file format,
and narrow_joint_limits, which narrows a model to a resource's config and
refuses anything that would widen a limit.

The three servers share one GetKinematics reply that follows rdk. A request
with a mesh flag gets the model alone, with bytes only for the roles asked
for. A request with no flags gets the model and the deprecated file fields,
which are written from the model as an SVA file when the resource no longer
implements get_kinematics.

The loader is held to the shared fixtures from rdk, copied into
tests/data/kinematic_models at rdk cefbb7080.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!

component function
base is_moving
board gpio_pin_by_name
button push
genericcomponent do_command
camera get_images
encoder get_position
motor is_moving
sensor get_readings
servo get_position
switch get_position
arm get_end_position
gantry get_lengths
gripper is_moving
movement_sensor get_linear_acceleration
input_controller get_controls
pose_tracker get_poses
power_sensor get_power
motion get_pose
vision get_properties
mlmodel metadata
genericservice do_command
slam get_point_cloud_map
audio_in get_properties
audio_out get_properties

@viambot

viambot commented Nov 12, 2026

Copy link
Copy Markdown
Member

👋 Thanks for requesting a review from the team!

We aim to review PRs within one business day. If this is urgent
or blocking you, please reach out in #team-sdk and
we'll prioritize it.

The fixtures are a pinned copy of rdk's, so GitHub collapses them in a
diff. The attribute goes in a root .gitattributes rather than the one in the
fixture directory so that the copy stays identical to rdk.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@JohnN193
JohnN193 merged commit 7b0121a into main Nov 17, 2026
13 checks passed
@JohnN193
JohnN193 deleted the RSDK-14757-kinematic-model branch November 17, 2026 16:54
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.

3 participants