Source code for rofunc.utils.datalab.poselib.generate_optitrack_fbx_tpose

# Copyright 2023, Junjia LIU, jjliu@mae.cuhk.edu.hk
#
# 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
#
#      https://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.

import os

import isaacgym
import torch

import rofunc as rf
from rofunc.utils.datalab.poselib.poselib.skeleton.skeleton3d import SkeletonState, SkeletonMotion
from rofunc.utils.datalab.poselib.poselib.visualization.common import plot_skeleton_state


[docs]def get_tpose_from_fbx(fbx_file_path, save_path, verbose=True): motion = SkeletonMotion.from_fbx( fbx_file_path=fbx_file_path, root_joint="Skeleton_Root", fps=120 ) zero_rotation = torch.zeros_like(motion.rotation[0]) zero_rotation[:, -1] = 1 source_tpose = SkeletonState.from_rotation_and_root_translation(motion.skeleton_tree, zero_rotation, motion.root_translation[0], is_local=True) source_tpose.to_file(save_path) if verbose: plot_skeleton_state(source_tpose, verbose=True)
if __name__ == '__main__': rofunc_path = rf.oslab.get_rofunc_path() data_dir = "/home/ubuntu/Github/Rofunc/rofunc/utils/datalab/poselib/data" # fbx_files = rf.oslab.list_absl_path(data_dir, suffix='.fbx') fbx_files = ["/home/ubuntu/Github/Rofunc/examples/data/hotu2/Take 2024-01-12 06.56.43 PM_FBXBinary.fbx"] for fbx in fbx_files: # fbx_name = os.path.basename(fbx).split('.')[0] save_path = os.path.join(data_dir, "source_optitrack_w_gloves_tpose.npy") get_tpose_from_fbx(fbx, save_path, verbose=True)