Repository navigation
Conversation
…ts helper Add get_kinematic_model to Gripper with its client and server. The method is not pure virtual so existing gripper modules keep compiling, and a gripper that does not override it answers UNIMPLEMENTED, which is what viam-server falls back to geometries on. Add read_kinematic_model_file, a strict proto JSON reader for kinematic model files that makes the same checks and mesh reads as rdk's ReadKinematicModelFile, with a pinned copy of the rdk fixtures and a runner for them. Add narrow_joint_limits and joint_limits_from_attribute, following rdk's NarrowJointLimits, and drop_unrequested_mesh_bytes for a module that holds its model with every mesh loaded. The arm, gantry and gripper servers now always name the served model for the resource, as rdk does, instead of only when the name is empty. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A module is free to shape its config attributes however it likes, so the SDK should not assume the joint_limits layout. A module builds the map narrow_joint_limits takes from its own config. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Called with a std::string, an unqualified quoted also finds std::quoted through argument dependent lookup wherever <iomanip> has been pulled in. On CI's toolchain that overload won for a non const string and the concatenation failed to compile. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
FieldDescriptor::name returns a string view from protobuf 26 on, which cannot be added to a std::string. The Windows build uses such a version. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main took C++20 in #732, which swapped boost optional and variant for std::optional and std::variant in kinematics.hpp and defaulted the comparison operators. The gripper, loader and limits code written against boost follows: std::optional, std::nullopt, std::visit and std::get_if, with the hand written operator== set dropped in favour of the defaulted ones. Built and tested at gnu20 with conan, the four kinematics test binaries pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
| VIAMCPPSDK_TEST_TESTFILES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testfiles" | ||
| ) | ||
|
|
||
| # The fixture cases are a copy of rdk's referenceframe/testfiles/kinematic_models. The test gets |
There was a problem hiding this comment.
i don't like having to check in all the rdk's test files, my first question is if there's a need for us to test this stuff on our side, but if so i think it makes more sense to do some cmake scripting to grab the test directory from a specified commit and download it into the binary directory.
also we are not on c++14, std::filesystem is available
There was a problem hiding this comment.
set it up so we pull in the test files
| /// stands. A continuous joint given a min or a max becomes a revolute joint with that bound. A | ||
| /// mimic joint follows the joint it mimics and cannot be narrowed. | ||
| /// | ||
| /// @param model The model to narrow in place. It is left untouched when this throws. |
There was a problem hiding this comment.
this kinda looks like it should be a method on a KinematicModel rather than a free function. in hindsight maybe KinematicModel should have been class rather than struct, or a struct with a bunch of methods if we don't want it to be a breaking change. although the type is new enough that i don't think it's a huge deal for it to be a breaking change
There was a problem hiding this comment.
went ahead and switched to a class then
| /// type and loses its bytes. The geometry of a prismatic joint counts as a collision mesh. With | ||
| /// neither flag set the model is left whole, since such a request may come from a viam-server | ||
| /// that predates the flags and expects every mesh with its bytes. | ||
| void drop_unrequested_mesh_bytes(KinematicModel& model, const kinematics_options& options); |
There was a problem hiding this comment.
similarly this smells like a method
| /// resource name when the model is served. | ||
| /// | ||
| /// @throws Exception naming the file and the link, joint or mesh at fault. | ||
| KinematicModel read_kinematic_model_file(const std::string& path); |
There was a problem hiding this comment.
this seems like it would make more sense as a named constructor
| } | ||
|
|
||
| // the directory part of a path, empty when the file sits in the working directory | ||
| std::string directory_of(const std::string& path) { |
There was a problem hiding this comment.
this can be done with std::filesystem
| } | ||
|
|
||
| // the extension of the last element of a forward slash path, lowercased and without the dot | ||
| std::string extension_of(const std::string& source) { |
…ures The loader, the limits narrowing and the mesh bytes helper become KinematicModel::from_file, narrow_joint_limits and drop_unrequested_mesh_bytes, so kinematic_model_file.hpp is gone. The loader takes a std::filesystem::path and uses it for the model's directory and for mesh extensions. The rdk fixtures are no longer checked in. CMake fetches the one directory from rdk at a pinned commit into the build tree when tests are configured, and the test walks it with std::filesystem. A failed fetch warns and leaves the fixture test failing with the reason, so a build without the network still configures. VIAMCPPSDK_KINEMATIC_MODEL_FIXTURES_DIR points the test at an rdk checkout instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
KinematicModel was a struct anyone could fill with a tree that does not hold together, and only a model read from a file was checked. It is now a class built through a constructor that makes the same checks as the file loader: ids present, not "world" and not reused, parents that exist, no cycles, and mimic joints that name another joint and carry no limits of their own. The checks live in one function that both the constructor and the loader call. A model received over the wire skips the checks, since a client has to be able to hold whatever a server sent it. The fields are read through accessors, and changed through set_name, narrow_joint_limits and drop_unrequested_mesh_bytes, none of which can break the tree. The arm mock had a mimic joint with limits, which the constructor now refuses, so the mimic moves to the joint without any. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Part of the typed
GetKinematicswork (RSDK-14232). This fills in what the C++ SDK was still missing after #731.What changed
Gripper
GetKinematicsGripper::get_kinematic_model, with client and server support.k_not_supported, which the server answers as gRPCUNIMPLEMENTED. That is what viam-server already sees from C++ grippers and what it falls back to geometries on.Kinematic model file loader
KinematicModel::from_filereads the proto JSON of aKinematicModel.ReadKinematicModelFile: unknown fields, non finite numbers, ids, parents, cycles, mimic joints, mesh paths and content types.Shared fixtures
referenceframe/testfiles/kinematic_models) are not checked in. When tests are configured, CMake fetches that one directory from rdk at a pinned commit (cefbb7080) into the build tree.VIAMCPPSDK_KINEMATIC_MODEL_FIXTURES_DIRpoints the test at an rdk checkout instead.test_kinematic_model.cppruns all 32 cases and compares messages, not text.unknown_fieldandmalformed_jsonthe runner only checks that the parse failed and the mentions, since that wording is protobuf's and differs between versions.Joint limits
KinematicModel::narrow_joint_limitsfollows rdk'sNarrowJointLimits. A requested value can only narrow what the model holds.Mesh bytes
KinematicModel::drop_unrequested_mesh_bytesis for a module that holds its model with every mesh loaded. With either include flag set it clears the bytes of the role that was not asked for. With neither set it leaves the model whole, as rdk does for clients that predate the flags.Breaking change:
KinematicModelis a classKinematicModelwas a struct with public fields. It is now a class, built withKinematicModel(name, links, joints, output_frames, properties)orKinematicModel::from_file.worldand not reused, parents that exist, no cycles, and mimic joints that name another joint and carry no limits of their own.from_proto) skips the checks, so a client can hold whatever a server sent.name(),links(),joints(),output_frames()andproperties(), and changed only throughset_name,narrow_joint_limitsanddrop_unrequested_mesh_bytes.model.links = ...has to move to the constructor. The arm mock had a mimic joint with limits, which is now refused, so its mimic moved to the joint without any.Behaviour change for arm and gantry
The arm, gantry and gripper servers now always set the served model's name to the resource name, as rdk does. Before, arm and gantry only did so when the name was empty. A model read from a file always carries a name, so the old rule would have served the file's name.
Not in this PR
get_kinematics. Filling them from the model needs a model to SVA writer.ModelTablefrom aKinematicModel(RSDK-14033).After #732
Main moved to C++20 under this PR. The merge of main here moves the new code onto
std::optional,std::variant,std::visitandstd::get_if, which #732 chose forkinematics.hpp, and drops the hand written operator== set in favour of the defaulted ones. Built and tested at gnu20 with conan after the merge, the four test binaries pass, 62 cases.Testing
test_kinematic_model,test_gripper,test_armandtest_gantrypass locally.🤖 Generated with Claude Code