c08e1d9e6e
This change introduces two new USD API schema: * MjcEqualityAPI - base API for representing MuJoCo equality constraints in USD, this will typically be applied to joints such as UsdPhysicsFixedJoint. * MjcEqualityWeldAPI - extends MjcEqualityAPI for MuJoCo's weld equality constraints with an attribute for torqueScale. The usd_decoder is updated to parse UsdPhysicsFixedJoints and convert the new schema attributes into the appropriate mjsEquality data fields. PiperOrigin-RevId: 856723634 Change-Id: I0982fd3168b643f8e91d87bb5ae5933e526b63a1
53 lines
2.0 KiB
C++
53 lines
2.0 KiB
C++
// Copyright 2025 DeepMind Technologies Limited
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef MUJOCO_PLUGIN_USD_DECODER_KINEMATIC_TREE_H_
|
|
#define MUJOCO_PLUGIN_USD_DECODER_KINEMATIC_TREE_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include <pxr/usd/sdf/path.h>
|
|
#include <pxr/usd/usdPhysics/joint.h>
|
|
|
|
// A struct to represent a node in the kinematic tree.
|
|
// Using a struct with a vector of children preserves the order of bodies,
|
|
// which is important for things like keyframes and policy compatibility.
|
|
struct Node {
|
|
pxr::SdfPath body_path;
|
|
pxr::SdfPath physics_scene;
|
|
std::vector<pxr::SdfPath> actuators;
|
|
std::vector<pxr::SdfPath> constraints;
|
|
std::vector<pxr::SdfPath> joints;
|
|
std::vector<pxr::SdfPath> visual_gprims;
|
|
std::vector<pxr::SdfPath> colliders;
|
|
std::vector<pxr::SdfPath> sites;
|
|
std::vector<pxr::SdfPath> tendons;
|
|
std::vector<pxr::SdfPath> keyframes;
|
|
std::vector<std::unique_ptr<Node>> children;
|
|
};
|
|
|
|
// A kinematic edge represents a joint.
|
|
using JointVec = std::vector<pxr::UsdPhysicsJoint>;
|
|
|
|
// Builds a single kinematic tree from a list of directed edges.
|
|
// The DFS order of bodies in the tree is determined by the order of bodies in
|
|
// `all_body_paths`.
|
|
// All bodies, including static and floating-base bodies, are organized under a
|
|
// single world root. An empty 'from' path in an edge represents the world body.
|
|
// Returns the root of the kinematic tree, or `nullptr` for invalid structures.
|
|
std::unique_ptr<Node> BuildKinematicTree(const pxr::UsdStageRefPtr stage);
|
|
|
|
#endif // MUJOCO_PLUGIN_USD_DECODER_KINEMATIC_TREE_H_
|