diffneusim 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffneusim/__init__.py +1 -0
- diffneusim/_cache.py +42 -0
- diffneusim/_paths.py +5 -0
- diffneusim/bindings/rew14_ext.cu +115 -0
- diffneusim/bindings/soft14_capi.cpp +443 -0
- diffneusim/bindings/soft14_engine_ext.cu +596 -0
- diffneusim/bindings/soft_capi.cpp +782 -0
- diffneusim/bindings/soft_engine_ext.cu +495 -0
- diffneusim/core/cpu_engine/build.sh +40 -0
- diffneusim/core/cpu_engine/fiber/cuda_runtime.h +445 -0
- diffneusim/core/cpu_engine/x14_cpu.cpp +283 -0
- diffneusim/core/diff/dual.h +126 -0
- diffneusim/core/include/diffneusim/macros.h +35 -0
- diffneusim/core/kin/kinematic_tree.h +273 -0
- diffneusim/core/math/so3.h +182 -0
- diffneusim/core/soft/adj/out_adj.h +102 -0
- diffneusim/core/soft/adj/rnea_adj.h +425 -0
- diffneusim/core/soft/adj/rows_adj.h +439 -0
- diffneusim/core/soft/adj/rows_functor.h +89 -0
- diffneusim/core/soft/adj/rows_lanes.h +443 -0
- diffneusim/core/soft/adj/shell_adj.h +243 -0
- diffneusim/core/soft/adj/tree_adj.h +356 -0
- diffneusim/core/soft/collide.h +183 -0
- diffneusim/core/soft/gpu/adj14.cuh +233 -0
- diffneusim/core/soft/gpu/adj14_mus.cuh +98 -0
- diffneusim/core/soft/gpu/adj_shell.cuh +50 -0
- diffneusim/core/soft/gpu/adj_tab.cuh +49 -0
- diffneusim/core/soft/gpu/body14.cuh +47 -0
- diffneusim/core/soft/gpu/chol_rn.cuh +458 -0
- diffneusim/core/soft/gpu/chol_small.cuh +123 -0
- diffneusim/core/soft/gpu/chol_split.cuh +193 -0
- diffneusim/core/soft/gpu/engine_launch.cuh +263 -0
- diffneusim/core/soft/gpu/fk_rn.cuh +109 -0
- diffneusim/core/soft/gpu/generated/body_019e20820f86_mmfloor.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_62f77a4bb16b_mmfloor.cuh +52 -0
- diffneusim/core/soft/gpu/generated/body_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +52 -0
- diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor.cuh +25 -0
- diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +25 -0
- diffneusim/core/soft/gpu/generated/g1_soft_5db44fd45286.cuh +74 -0
- diffneusim/core/soft/gpu/generated/split_62f77a4bb16b_mmfloor.cuh +18 -0
- diffneusim/core/soft/gpu/generated/split_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +18 -0
- diffneusim/core/soft/gpu/generated/x14_soft_019e20820f86_mmfloor.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_62f77a4bb16b_mmfloor.cuh +129 -0
- diffneusim/core/soft/gpu/generated/x14_soft_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +129 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/k_mus.cuh +1038 -0
- diffneusim/core/soft/gpu/k_mus_host.cuh +377 -0
- diffneusim/core/soft/gpu/k_pre.cuh +52 -0
- diffneusim/core/soft/gpu/kernel_p.cuh +490 -0
- diffneusim/core/soft/gpu/kp14.cuh +465 -0
- diffneusim/core/soft/gpu/l2v2.cuh +367 -0
- diffneusim/core/soft/gpu/l2x14.cuh +319 -0
- diffneusim/core/soft/gpu/l3.cuh +1483 -0
- diffneusim/core/soft/gpu/model_view.cuh +48 -0
- diffneusim/core/soft/gpu/mus_case_fits.h +15 -0
- diffneusim/core/soft/gpu/mus_classes.h +182 -0
- diffneusim/core/soft/gpu/mus_row_cf.h +44 -0
- diffneusim/core/soft/gpu/rew14.cuh +177 -0
- diffneusim/core/soft/gpu/rows_ctab.cuh +44 -0
- diffneusim/core/soft/gpu/tree_m.cuh +247 -0
- diffneusim/core/soft/gpu/x14_engine_kernels.cuh +260 -0
- diffneusim/core/soft/gpu/x14_rowcf.h +14 -0
- diffneusim/core/soft/hand.h +124 -0
- diffneusim/core/soft/impedance.h +115 -0
- diffneusim/core/soft/jvp.h +202 -0
- diffneusim/core/soft/kin.h +250 -0
- diffneusim/core/soft/muscle.h +1208 -0
- diffneusim/core/soft/newton.h +371 -0
- diffneusim/core/soft/rows.h +176 -0
- diffneusim/core/soft/step.h +188 -0
- diffneusim/core/soft/tape.h +313 -0
- diffneusim/core/soft/x14/collide14.h +69 -0
- diffneusim/core/soft/x14/jvp14.h +182 -0
- diffneusim/core/soft/x14/law14.h +453 -0
- diffneusim/core/soft/x14adj/collide14_adj.h +134 -0
- diffneusim/core/soft/x14adj/passive14_adj.h +162 -0
- diffneusim/core/soft/x14adj/reward14.h +484 -0
- diffneusim/core/soft/x14adj/rows14_adj.h +400 -0
- diffneusim/core/soft/x14adj/scan14.h +349 -0
- diffneusim/core/soft/x14adj/shell14_adj.h +122 -0
- diffneusim/core/soft/x14adj/sweep14.h +255 -0
- diffneusim/core/soft/x14adj/tree14_adj.h +500 -0
- diffneusim/core/soft/x14adj/x14adj_common.h +96 -0
- diffneusim/data/mirror/H1622v2k_geyer_hfdeq.npz +0 -0
- diffneusim/data/mirror/H1622v2k_hfd.npz +0 -0
- diffneusim/data/mirror/H1622v2k_millard_hfdeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str_rigid.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_calf2_pe.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfix.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01legs.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01lumbar.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfix.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfixlegs01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_hinge.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_lspine_girdle_osimeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_millard.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_osimeq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_compound_g14eq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_luispe.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_trunk0701.npz +0 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_axfix.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_axfixlegs01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01legs.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01lumbar.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfix.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfixlegs01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n1.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n1a.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n2.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_rom23.json +91 -0
- diffneusim/data/reference/musclemimic/myofullbody_mimic_sites.json +261 -0
- diffneusim/data/reference/pose3/pose3_scone.json +305 -0
- diffneusim/data/reference/pose3/pose3_scone.txt +3 -0
- diffneusim/data/reference/pose3/pose3_scone_gait.npz +0 -0
- diffneusim/data/reference/pose3/pose3_scone_mirror.npz +0 -0
- diffneusim/data/reference/pose3/pose3_scone_stand.npz +0 -0
- diffneusim/data/reference/x016run/MD5SUMS +241 -0
- diffneusim/data/reference/x016run/x016run_states.txt +240 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r3.npz +0 -0
- diffneusim/data/state_prior/lumbar_poly_fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/engine/__init__.py +0 -0
- diffneusim/engine/build_tag.py +52 -0
- diffneusim/engine/case_tables.py +46 -0
- diffneusim/engine/d16_body.py +80 -0
- diffneusim/engine/engine14.py +367 -0
- diffneusim/engine/gen_split.py +159 -0
- diffneusim/engine/hand_format.py +69 -0
- diffneusim/engine/live14.py +149 -0
- diffneusim/engine/phase_b_tree.py +137 -0
- diffneusim/engine/soft14.py +130 -0
- diffneusim/engine/soft_capi.py +373 -0
- diffneusim/engine/soft_engine.py +165 -0
- diffneusim/engine/step14.py +132 -0
- diffneusim/engine/tape_format.py +89 -0
- diffneusim/engine/x14cpu.py +163 -0
- diffneusim/env/__init__.py +0 -0
- diffneusim/env/absent.py +20 -0
- diffneusim/env/cpu14.py +105 -0
- diffneusim/env/e0loop14.py +224 -0
- diffneusim/env/env14.py +568 -0
- diffneusim/env/kin_contact14.py +193 -0
- diffneusim/env/mimic_sites_x14.json +366 -0
- diffneusim/env/old_count.py +78 -0
- diffneusim/env/rew14.py +114 -0
- diffneusim/env/rew14_hook.py +105 -0
- diffneusim/g1/__init__.py +1 -0
- diffneusim/g1/arm_a2.py +165 -0
- diffneusim/g1/arm_a3.py +576 -0
- diffneusim/g1/read_a3.py +79 -0
- diffneusim/g1/rg1_read.py +89 -0
- diffneusim/model/__init__.py +66 -0
- diffneusim/model/case.py +17 -0
- diffneusim/model/dnmodel.py +79 -0
- diffneusim/model/fuse_fixed.py +281 -0
- diffneusim/model/monitor.py +834 -0
- diffneusim/models/BODIES.toml +48 -0
- diffneusim/models/MANIFEST.toml +979 -0
- diffneusim/models/cases/G290/case.bin +0 -0
- diffneusim/models/cases/G290/case.json +1 -0
- diffneusim/models/cases/G356-SRC/case.bin +0 -0
- diffneusim/models/cases/G356-SRC/case.json +1 -0
- diffneusim/models/cases/G416/case.bin +0 -0
- diffneusim/models/cases/G416/case.json +1 -0
- diffneusim/models/cases/M290C-SRC/case.bin +0 -0
- diffneusim/models/cases/M290C-SRC/case.json +1 -0
- diffneusim/models/cases/M290R-SRC/case.bin +0 -0
- diffneusim/models/cases/M290R-SRC/case.json +1 -0
- diffneusim/models/cases/M356C-SRC/case.bin +0 -0
- diffneusim/models/cases/M356C-SRC/case.json +1 -0
- diffneusim/models/cases/M356R-SRC/case.bin +0 -0
- diffneusim/models/cases/M356R-SRC/case.json +1 -0
- diffneusim/models/cases/M416C-SRC/case.bin +0 -0
- diffneusim/models/cases/M416C-SRC/case.json +1 -0
- diffneusim/models/derived/d16_expanded_62f77a4bb16b1e67_mmfloor.xml +673 -0
- diffneusim/models/derived/d16_expanded_a1e8b196b2cd7b3c_mmfloor.xml +673 -0
- diffneusim/models/derived/d16_soft_law_019e20820f8633b9_mmfloor.json +7844 -0
- diffneusim/models/derived/d16_soft_law_62f77a4bb16b1e67_mmfloor.json +16855 -0
- diffneusim/models/derived/d16_soft_law_77dbb7213f26e821_mmfloor_rampsb3l_n6t12.json +7883 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rampsb3l_n6t12.json +7883 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsd05_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsdef_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsmjd_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_a1e8b196b2cd7b3c_mmfloor_rampsb3l_n6t12.json +16894 -0
- diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor.json +12655 -0
- diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor_rampsb3l_n6t12.json +12700 -0
- diffneusim/models/derived/unitree_g1_soft_law.json +15580 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +28913 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +29202 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +46970 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +38570 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +38923 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_meshes/1mc.stl +0 -0
- diffneusim/models/fullbody_meshes/2distph.stl +0 -0
- diffneusim/models/fullbody_meshes/2mc.stl +0 -0
- diffneusim/models/fullbody_meshes/2midph.stl +0 -0
- diffneusim/models/fullbody_meshes/2proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/3distph.stl +0 -0
- diffneusim/models/fullbody_meshes/3mc.stl +0 -0
- diffneusim/models/fullbody_meshes/3midph.stl +0 -0
- diffneusim/models/fullbody_meshes/3proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/4distph.stl +0 -0
- diffneusim/models/fullbody_meshes/4mc.stl +0 -0
- diffneusim/models/fullbody_meshes/4midph.stl +0 -0
- diffneusim/models/fullbody_meshes/4proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/5distph.stl +0 -0
- diffneusim/models/fullbody_meshes/5mc.stl +0 -0
- diffneusim/models/fullbody_meshes/5midph.stl +0 -0
- diffneusim/models/fullbody_meshes/5proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/NOTICE +2 -0
- diffneusim/models/fullbody_meshes/capitate.stl +0 -0
- diffneusim/models/fullbody_meshes/clavicle.stl +0 -0
- diffneusim/models/fullbody_meshes/hamate.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_cervical.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_jaw.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_skull.stl +0 -0
- diffneusim/models/fullbody_meshes/humerus.stl +0 -0
- diffneusim/models/fullbody_meshes/l_bofoot.stl +0 -0
- diffneusim/models/fullbody_meshes/l_femur.stl +0 -0
- diffneusim/models/fullbody_meshes/l_fibula.stl +0 -0
- diffneusim/models/fullbody_meshes/l_foot.stl +0 -0
- diffneusim/models/fullbody_meshes/l_patella.stl +0 -0
- diffneusim/models/fullbody_meshes/l_pelvis.stl +0 -0
- diffneusim/models/fullbody_meshes/l_talus.stl +0 -0
- diffneusim/models/fullbody_meshes/l_tibia.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar1.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar2.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar3.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar4.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar5.stl +0 -0
- diffneusim/models/fullbody_meshes/lunate.stl +0 -0
- diffneusim/models/fullbody_meshes/pisiform.stl +0 -0
- diffneusim/models/fullbody_meshes/r_bofoot.stl +0 -0
- diffneusim/models/fullbody_meshes/r_femur.stl +0 -0
- diffneusim/models/fullbody_meshes/r_fibula.stl +0 -0
- diffneusim/models/fullbody_meshes/r_foot.stl +0 -0
- diffneusim/models/fullbody_meshes/r_patella.stl +0 -0
- diffneusim/models/fullbody_meshes/r_pelvis.stl +0 -0
- diffneusim/models/fullbody_meshes/r_talus.stl +0 -0
- diffneusim/models/fullbody_meshes/r_tibia.stl +0 -0
- diffneusim/models/fullbody_meshes/radius.stl +0 -0
- diffneusim/models/fullbody_meshes/sacrum.stl +0 -0
- diffneusim/models/fullbody_meshes/scaphoid.stl +0 -0
- diffneusim/models/fullbody_meshes/scapula.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic10_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic11_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic12_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic1_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic2_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic3_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic4_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic5_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic6_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic7_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic8_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic9_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thorax.stl +0 -0
- diffneusim/models/fullbody_meshes/thumbdist.stl +0 -0
- diffneusim/models/fullbody_meshes/thumbprox.stl +0 -0
- diffneusim/models/fullbody_meshes/trapezium.stl +0 -0
- diffneusim/models/fullbody_meshes/trapezoid.stl +0 -0
- diffneusim/models/fullbody_meshes/triquetrum.stl +0 -0
- diffneusim/models/fullbody_meshes/ulna.stl +0 -0
- diffneusim/models/source/myo_fullbody/UPSTREAM.md +91 -0
- diffneusim/models/source/myoleg/UPSTREAM.md +52 -0
- diffneusim/models/source/unitree_g1/LICENSE.mjlab +202 -0
- diffneusim/models/source/unitree_g1/UPSTREAM.md +38 -0
- diffneusim/models/source/unitree_g1/assets/head_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_ankle_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_ankle_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_elbow_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_knee_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_rubber_hand.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/logo_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/pelvis.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/pelvis_contour_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_ankle_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_ankle_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_elbow_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_knee_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_rubber_hand.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/torso_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/waist_roll_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/waist_yaw_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/dump_mjlab_reference.py +30 -0
- diffneusim/models/source/unitree_g1/g1.xml +308 -0
- diffneusim/models/source/unitree_g1/g1_constants.py +298 -0
- diffneusim/models/source/unitree_g1/mjlab_compiled_reference.json +857 -0
- diffneusim/models/unitree_g1.dnmodel +4393 -0
- diffneusim/models/unitree_g1_selfcol.dnmodel +20824 -0
- diffneusim/rl/__init__.py +2 -0
- diffneusim/rl/dynsyn_layer.py +146 -0
- diffneusim/rl/footstep_plan.py +337 -0
- diffneusim/rl/g1_bm_env.py +572 -0
- diffneusim/rl/g1_bm_eval.py +168 -0
- diffneusim/rl/g1_bm_fused.py +275 -0
- diffneusim/rl/g1_bm_ppo.py +622 -0
- diffneusim/rl/g1_bm_sapo.py +551 -0
- diffneusim/rl/g1_ppo.py +395 -0
- diffneusim/rl/g1_sapo_soft.py +240 -0
- diffneusim/rl/g1_soft_env.py +452 -0
- diffneusim/rl/g1_soft_grad.py +145 -0
- diffneusim/rl/geyer_curves_torch.py +108 -0
- diffneusim/rl/gpu_fullbody_vec_env.py +1241 -0
- diffneusim/rl/imitation.py +2027 -0
- diffneusim/rl/imitation_reward_v2.py +248 -0
- diffneusim/rl/imitation_reward_v3.py +349 -0
- diffneusim/rl/latent_task.py +175 -0
- diffneusim/rl/llc_reward.py +316 -0
- diffneusim/rl/millard_curves_torch.py +154 -0
- diffneusim/rl/mirror_symmetry.py +212 -0
- diffneusim/rl/model_path.py +35 -0
- diffneusim/rl/mvae_recon.py +123 -0
- diffneusim/rl/nets_shac.py +599 -0
- diffneusim/rl/reset_pool.py +154 -0
- diffneusim/rl/sapo_capture.py +873 -0
- diffneusim/rl/sapo_vec.py +1051 -0
- diffneusim/rl/shac_vec.py +346 -0
- diffneusim/rl/state_prior.py +151 -0
- diffneusim/rl/step_library.py +105 -0
- diffneusim/rl/task_walk_env.py +1793 -0
- diffneusim/rl/task_walk_reward.py +3300 -0
- diffneusim/run.py +23 -0
- diffneusim/run_env.py +46 -0
- diffneusim/tasks/__init__.py +147 -0
- diffneusim/tasks/legacy_names.py +63 -0
- diffneusim/tasks/paths.py +79 -0
- diffneusim/tasks/settings.py +202 -0
- diffneusim/third_party/instantmimic_947430ee/LICENSE +202 -0
- diffneusim/third_party/instantmimic_947430ee/NOTICE +19 -0
- diffneusim/third_party/instantmimic_947430ee/README.md +31 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/benchmark_protocol.py +106 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/metrics.py +214 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/reference.py +513 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/motion/quaternion.py +193 -0
- diffneusim/train/__init__.py +0 -0
- diffneusim/train/eval_ckpt.py +239 -0
- diffneusim/train/eval_mimic.py +133 -0
- diffneusim/train/gait_report.py +203 -0
- diffneusim/train/gcot_chain.py +51 -0
- diffneusim/train/levers.py +135 -0
- diffneusim/train/masked_reset.py +314 -0
- diffneusim/train/rl_algorithm_suite.py +917 -0
- diffneusim/train/train14.py +240 -0
- diffneusim/train/train_tw14.py +674 -0
- diffneusim/viz/__init__.py +5 -0
- diffneusim/viz/__main__.py +41 -0
- diffneusim/viz/camera.py +115 -0
- diffneusim/viz/dnrec.py +118 -0
- diffneusim/viz/dnrec_io.py +686 -0
- diffneusim/viz/hud.py +565 -0
- diffneusim/viz/meshes.py +458 -0
- diffneusim/viz/play.py +237 -0
- diffneusim/viz/record.py +74 -0
- diffneusim/viz/render.py +1402 -0
- diffneusim/viz/renderer.py +268 -0
- diffneusim/viz/rl_env_render.py +635 -0
- diffneusim/viz/snapshot.py +54 -0
- diffneusim/viz/strobe.py +124 -0
- diffneusim/viz/to_mp4.py +58 -0
- diffneusim/viz/ui.py +481 -0
- diffneusim/viz/viewer.py +2086 -0
- diffneusim-1.0.0.dist-info/METADATA +226 -0
- diffneusim-1.0.0.dist-info/RECORD +682 -0
- diffneusim-1.0.0.dist-info/WHEEL +5 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSE +201 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-ARMS-hand-wrist-4.3.txt +20 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-MoBL-ARMS.txt +25 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/CC-BY-3.0-OpenSim-geometry.txt +25 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Christophy2012-lumbarspine.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lai2017-model-high-flex.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lee2015-hand_muscle.txt +11 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Rajagopal2016-full_body.txt +11 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Uhlrich2022-fbmodpassivecal.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/NOTICE +274 -0
- diffneusim-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
"""Unitree G1 one-clip tracking on the D16 soft law (line 23, docs/training/campaigns/g1/seconds.md; the design's G1 trainer port).
|
|
2
|
+
|
|
3
|
+
Physics is the production law (models/derived/unitree_g1_soft_law.json) in MuJoCo's native layout, batch-first:
|
|
4
|
+
qpos [n, 36] = root position, root quaternion (w x y z), the 29 joints; qvel [n, 35] = root linear velocity (world), root angular
|
|
5
|
+
velocity (body), the 29 joint rates; warm [n, 35] the solver's warm start; ctrl [n, 29] the position actuators' setpoints in the
|
|
6
|
+
law's ACTUATOR order (LawMap.ctrl permutes from the joint order). The law's joint order is the dnmodel's actuator order (asserted).
|
|
7
|
+
Backends share one signature (tools/d16/soft_capi.py Soft.control_step_batch):
|
|
8
|
+
CpuLaw the f64 CPU law (soft_capi), for the Mac's tests; values only
|
|
9
|
+
GpuLaw the production GPU extension (tools/d16_binding/soft_engine.py's ext), with one output / tape / foot-friction slot per
|
|
10
|
+
window step, so that step k's adjoint reads step k's own buffers (the reading of the extension, 11-10: the adjoint reads only
|
|
11
|
+
what it is passed, except the foot friction, which SoftEngine keeps global). Host-side only: no kernel is touched.
|
|
12
|
+
The env (G1SoftTrack) is the same for both arms:
|
|
13
|
+
action residual PD: setpoint = q_ref(t + 1) + half_range * a, clamped to the joint range (InstantMimic's
|
|
14
|
+
_apply_action_ref_kernel, with the next reference frame as NablaMimic's residual recipe)
|
|
15
|
+
reward InstantMimic's body-state power sum (envs/tracking/reward_kernels.py, base.yaml weights): E = 100 e_pos + 5 e_rot +
|
|
16
|
+
0.1 e_lin + 0.1 e_ang, each a mean over the tracked bodies and 3 components of the squared world-frame error (rotation:
|
|
17
|
+
the axis-angle of the quaternion difference), r = 1 / (1 + E). Deviation (labelled): their simulated linear velocity is
|
|
18
|
+
MuJoCo's cvel (at the root subtree's COM); here both sim and reference use the body origin's world velocity
|
|
19
|
+
terminate BeyondMimic's G1 terms (mjlab 15ebce88 tracking_env_cfg.py / config/g1/env_cfgs.py): anchor (torso_link) height
|
|
20
|
+
error > 0.25 m, anchor projected-gravity z error > 0.8, any end effector's height error > 0.25 m; plus, in training
|
|
21
|
+
only and when enabled, InstantMimic's early termination (reward < 0.15 for 4 consecutive steps)
|
|
22
|
+
observe obs_phc below: InstantMimic's feature set (snu_imitation/observation_runtime.py, future_observation_kernels.py
|
|
23
|
+
phc_v6: joint state; the bodies' heading-frame position, 6D rotation, linear and angular velocity; per future body
|
|
24
|
+
the 24 features diff pos / diff rot 6D / diff lin vel / diff ang vel / local ref pos / local ref rot 6D; the previous
|
|
25
|
+
action). Representation differences (labelled): joint angles raw (theirs 6D), body positions root-relative with the root
|
|
26
|
+
height apart (theirs relative to the root's ground point), velocities unscaled (theirs x 0.1; the standardiser absorbs
|
|
27
|
+
a scale), the 14 tracked bodies
|
|
28
|
+
reset the reference state at a frame, masked (torch.where; no host sync), warm start zeroed (mj_resetData)
|
|
29
|
+
"""
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import json
|
|
33
|
+
import pathlib
|
|
34
|
+
|
|
35
|
+
import numpy as np
|
|
36
|
+
import torch
|
|
37
|
+
|
|
38
|
+
from diffneusim._paths import ROOT as ROOT # (3a) the repo root
|
|
39
|
+
LAW = ROOT / "models" / "derived" / "unitree_g1_soft_law.json"
|
|
40
|
+
DNMODEL = ROOT / "models" / "unitree_g1.dnmodel"
|
|
41
|
+
NQ, NV, NU = 36, 35, 29
|
|
42
|
+
CONTROL_DT = 0.02
|
|
43
|
+
TRACKED = ("pelvis", "left_hip_roll_link", "left_knee_link", "left_ankle_roll_link", "right_hip_roll_link", "right_knee_link",
|
|
44
|
+
"right_ankle_roll_link", "torso_link", "left_shoulder_roll_link", "left_elbow_link", "left_wrist_yaw_link",
|
|
45
|
+
"right_shoulder_roll_link", "right_elbow_link", "right_wrist_yaw_link") # mjlab's G1 motion body_names
|
|
46
|
+
ANCHOR = "torso_link"
|
|
47
|
+
EE = ("left_ankle_roll_link", "right_ankle_roll_link", "left_wrist_yaw_link", "right_wrist_yaw_link")
|
|
48
|
+
TERM_ANCHOR_Z, TERM_ANCHOR_ORI, TERM_EE_Z = 0.25, 0.8, 0.25
|
|
49
|
+
REW_W = dict(pos=100.0, rot=5.0, lin=0.1, ang=0.1) # InstantMimic humanoid/imitation/base.yaml reward.tracking.weights
|
|
50
|
+
ET_REWARD, ET_STEPS = 0.15, 4 # its termination.early (type reward)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _load_json_c(path):
|
|
54
|
+
t = pathlib.Path(path).read_text()
|
|
55
|
+
return json.loads("\n".join(l for l in t[t.index("{"):].splitlines() if not l.lstrip().startswith("//")))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# ---------------------------------------------------------------------------------------------- quaternions (w x y z), batch-last
|
|
59
|
+
def qmul(a, b):
|
|
60
|
+
aw, ax, ay, az = a.unbind(-1)
|
|
61
|
+
bw, bx, by, bz = b.unbind(-1)
|
|
62
|
+
return torch.stack([aw * bw - ax * bx - ay * by - az * bz, aw * bx + ax * bw + ay * bz - az * by,
|
|
63
|
+
aw * by - ax * bz + ay * bw + az * bx, aw * bz + ax * by - ay * bx + az * bw], -1)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def qconj(q):
|
|
67
|
+
# no host constant: a tensor built from host data is a host-to-device copy, which CUDA graph capture forbids (W1's G4, 11-10)
|
|
68
|
+
return torch.cat([q[..., :1], -q[..., 1:]], -1)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def qrot(q, v):
|
|
72
|
+
u, w = q[..., 1:], q[..., :1]
|
|
73
|
+
t = 2.0 * torch.cross(u, v, dim=-1)
|
|
74
|
+
return v + w * t + torch.cross(u, t, dim=-1)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def qrot_inv(q, v):
|
|
78
|
+
return qrot(qconj(q), v)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def quat_axis_angle(q, eps=1e-8):
|
|
82
|
+
"""The rotation vector of unit quaternions (shortest rotation), differentiable at 0."""
|
|
83
|
+
q = torch.where(q[..., :1] < 0, -q, q)
|
|
84
|
+
s = q[..., 1:].norm(dim=-1, keepdim=True)
|
|
85
|
+
ang = 2.0 * torch.atan2(s, q[..., :1])
|
|
86
|
+
scale = torch.where(s > eps, ang / s.clamp_min(eps), 2.0 + 0.0 * s)
|
|
87
|
+
return q[..., 1:] * scale
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def quat_mat6(q):
|
|
91
|
+
"""The first two columns of the rotation matrix, [..., 6]."""
|
|
92
|
+
o = torch.ones_like(q[..., :1]) # the unit axes on the device (no host constant: capturable)
|
|
93
|
+
z = torch.zeros_like(o)
|
|
94
|
+
ex = qrot(q, torch.cat([o, z, z], -1))
|
|
95
|
+
ey = qrot(q, torch.cat([z, o, z], -1))
|
|
96
|
+
return torch.cat([ex, ey], -1)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def yaw_quat(q):
|
|
100
|
+
"""The heading of q as a rotation about world z: the yaw of its x axis, atan2(R10, R00) (PHC's calc_heading, mjlab's yaw_quat);
|
|
101
|
+
undefined when the x axis is vertical."""
|
|
102
|
+
w, x, y, z = q.unbind(-1)
|
|
103
|
+
yaw = torch.atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (y * y + z * z))
|
|
104
|
+
zero = torch.zeros_like(w)
|
|
105
|
+
return torch.stack([torch.cos(0.5 * yaw), zero, zero, torch.sin(0.5 * yaw)], -1)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# ---------------------------------------------------------------------------------------------- the law's layout
|
|
109
|
+
class LawMap:
|
|
110
|
+
def __init__(self, law_path=LAW, dnmodel_path=DNMODEL, device="cpu"):
|
|
111
|
+
L = json.loads(pathlib.Path(law_path).read_text())
|
|
112
|
+
jm = _load_json_c(dnmodel_path)
|
|
113
|
+
self.L = L
|
|
114
|
+
assert L["nq"] == NQ and L["nv"] == NV and len(L["actuators"]) == NU
|
|
115
|
+
self.joints = [j["name"] for j in L["joints"]]
|
|
116
|
+
assert all(j["dof"] == 6 + i and j["qadr"] == 7 + i for i, j in enumerate(L["joints"])), "joint i at qpos 7+i / qvel 6+i"
|
|
117
|
+
assert self.joints == [a["joint"] for a in jm["actuators"]], "the law's joint order is not the dnmodel's actuator order"
|
|
118
|
+
act_of_dof = {a["dof"]: a["index"] for a in L["actuators"]}
|
|
119
|
+
assert sorted(act_of_dof.values()) == list(range(NU)) and sorted(act_of_dof) == list(range(6, 6 + NU))
|
|
120
|
+
joint_of_act = [None] * NU
|
|
121
|
+
for d, k in act_of_dof.items():
|
|
122
|
+
joint_of_act[k] = d - 6
|
|
123
|
+
self.joint_of_act = torch.tensor(joint_of_act, dtype=torch.long, device=device) # ctrl[:, k] = sp[:, joint_of_act[k]]
|
|
124
|
+
self.act_of_joint = torch.tensor([act_of_dof[6 + i] for i in range(NU)], dtype=torch.long, device=device)
|
|
125
|
+
rng = torch.tensor([j["range"] for j in L["joints"]], dtype=torch.float64, device=device)
|
|
126
|
+
assert all(j["limited"] for j in L["joints"])
|
|
127
|
+
self.lo, self.hi = rng[:, 0], rng[:, 1]
|
|
128
|
+
self.half_range = 0.5 * (self.hi - self.lo)
|
|
129
|
+
self.body = {b["name"].removeprefix("robot/"): i for i, b in enumerate(L["bodies"])}
|
|
130
|
+
self.nb = len(L["bodies"])
|
|
131
|
+
assert len(L["train_foot_friction"]) == 1, L["train_foot_friction"]
|
|
132
|
+
self.train_foot_friction = float(L["train_foot_friction"][0])
|
|
133
|
+
|
|
134
|
+
def ids(self, names):
|
|
135
|
+
return [self.body[n] for n in names]
|
|
136
|
+
|
|
137
|
+
def ctrl(self, sp):
|
|
138
|
+
"""[n, 29] joint order -> [n, 29] the law's actuator order (a gather: differentiable)."""
|
|
139
|
+
return sp.index_select(1, self.joint_of_act)
|
|
140
|
+
|
|
141
|
+
def to_joint_order(self, u_act):
|
|
142
|
+
return u_act.index_select(1, self.act_of_joint)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# ---------------------------------------------------------------------------------------------- the reference
|
|
146
|
+
class Motion:
|
|
147
|
+
"""A 50 Hz motion file of tools/g1_lafan1_convert.py's format (mjlab's keys; bodies in MuJoCo order without the world, which is
|
|
148
|
+
the dnmodel's body order) mapped onto the law's body indices."""
|
|
149
|
+
|
|
150
|
+
def __init__(self, npz_path, lawmap, device="cpu", dtype=torch.float64, dnmodel_path=DNMODEL):
|
|
151
|
+
d = np.load(npz_path, allow_pickle=False)
|
|
152
|
+
assert int(d["fps"][0]) == 50, d["fps"]
|
|
153
|
+
jm = _load_json_c(dnmodel_path)
|
|
154
|
+
jnames = [b["name"] for b in jm["bodies"]]
|
|
155
|
+
T, nbj = d["body_pos_w"].shape[:2]
|
|
156
|
+
assert nbj == len(jnames), (nbj, len(jnames))
|
|
157
|
+
idx = [lawmap.body[n] for n in jnames]
|
|
158
|
+
self.T = T
|
|
159
|
+
t = lambda a: torch.as_tensor(np.asarray(a, np.float64), dtype=dtype, device=device) # noqa: E731
|
|
160
|
+
self.joint_pos, self.joint_vel = t(d["joint_pos"]), t(d["joint_vel"])
|
|
161
|
+
assert self.joint_pos.shape == (T, NU)
|
|
162
|
+
full = lambda a, w: torch.zeros(T, lawmap.nb, w, dtype=dtype, device=device).index_copy_(1, torch.tensor(idx, device=device), t(a)) # noqa: E731
|
|
163
|
+
self.bpos, self.bquat = full(d["body_pos_w"], 3), full(d["body_quat_w"], 4)
|
|
164
|
+
self.bvel, self.bang = full(d["body_lin_vel_w"], 3), full(d["body_ang_vel_w"], 3)
|
|
165
|
+
self.bquat[:, : min(idx)] = torch.tensor([1.0, 0, 0, 0], dtype=dtype, device=device) # world / terrain rows: identity
|
|
166
|
+
self.pelvis = lawmap.body["pelvis"]
|
|
167
|
+
assert self.pelvis == 2
|
|
168
|
+
|
|
169
|
+
def state(self, f):
|
|
170
|
+
"""The reference's law state at frames f [n] (long): qpos [n, 36], qvel [n, 35] (root angular velocity in the body frame)."""
|
|
171
|
+
p, q = self.bpos[f, self.pelvis], self.bquat[f, self.pelvis]
|
|
172
|
+
v, w = self.bvel[f, self.pelvis], self.bang[f, self.pelvis]
|
|
173
|
+
qpos = torch.cat([p, q, self.joint_pos[f]], -1)
|
|
174
|
+
qvel = torch.cat([v, qrot_inv(q, w), self.joint_vel[f]], -1)
|
|
175
|
+
return qpos, qvel
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# ---------------------------------------------------------------------------------------------- backends
|
|
179
|
+
class CpuLaw:
|
|
180
|
+
"""The f64 CPU law (soft_capi), values only; the Mac's reference backend for the env's tests."""
|
|
181
|
+
|
|
182
|
+
def __init__(self, bodies, law_path=None):
|
|
183
|
+
# (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16"))
|
|
184
|
+
from diffneusim.engine import soft_capi # noqa: E402
|
|
185
|
+
soft_capi.build()
|
|
186
|
+
self.soft = soft_capi.Soft(law_path) if law_path else soft_capi.Soft()
|
|
187
|
+
self.bodies = np.asarray(bodies, np.int32)
|
|
188
|
+
self.anchor_body = [i for i, b in enumerate(self.soft.L["bodies"]) if b["name"].removeprefix("robot/") == ANCHOR]
|
|
189
|
+
assert len(self.anchor_body) == 1, self.anchor_body
|
|
190
|
+
self.anchor_body = self.anchor_body[0]
|
|
191
|
+
self.anchor_ipos_offset = None
|
|
192
|
+
|
|
193
|
+
def set_anchor_ipos_offset(self, off):
|
|
194
|
+
"""COMDR (tools/g1_seconds/COMDR_DESIGN.md): the anchor body's (ANCHOR, torso_link) ipos += off[i] for world i of every later
|
|
195
|
+
step, set once after construction; off [n, 3] (m) in any float dtype / device, or None: nominal. Zeros go through the offset
|
|
196
|
+
path (the macro-on-at-zero gate). Mass, inertia, iquat and the invweight0-derived constants stay nominal."""
|
|
197
|
+
if off is None:
|
|
198
|
+
self.soft.set_anchor_ipos_offset(0, None)
|
|
199
|
+
self.anchor_ipos_offset = None
|
|
200
|
+
return
|
|
201
|
+
assert off.dim() == 2 and off.shape[1] == 3, tuple(off.shape)
|
|
202
|
+
self.soft.set_anchor_ipos_offset(self.anchor_body, off.detach().cpu().double().numpy())
|
|
203
|
+
self.anchor_ipos_offset = off.detach().clone()
|
|
204
|
+
|
|
205
|
+
def step(self, slot, qpos, qvel, warm, ctrl, foot):
|
|
206
|
+
o = self.soft.control_step_batch(qpos.detach().cpu().double().numpy(), qvel.detach().cpu().double().numpy(),
|
|
207
|
+
warm.detach().cpu().double().numpy(), ctrl.detach().cpu().double().numpy(),
|
|
208
|
+
foot.detach().cpu().double().numpy(), bodies=self.bodies)
|
|
209
|
+
dev, dt = qpos.device, qpos.dtype
|
|
210
|
+
return {k: torch.as_tensor(o[k], dtype=dt, device=dev) for k in ("qpos", "qvel", "warm", "xpos", "xquat", "xvel", "xangvel")}
|
|
211
|
+
|
|
212
|
+
def frames(self, qpos, qvel):
|
|
213
|
+
o = self.soft.body_frames(qpos.detach().cpu().double().numpy(), qvel.detach().cpu().double().numpy(), self.bodies)
|
|
214
|
+
return {k: torch.as_tensor(o[k], dtype=qpos.dtype, device=qpos.device) for k in o}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class GpuLaw:
|
|
218
|
+
"""The production GPU extension with per-slot buffers (one slot per window step; slots=1 for values-only rollouts). Every buffer
|
|
219
|
+
is allocated here once, so step() and adjoint() only launch (graph-capturable). Outputs are views of slot buffers: a caller that
|
|
220
|
+
keeps them past the slot's next use clones them."""
|
|
221
|
+
|
|
222
|
+
def __init__(self, n, bodies, slots=1, tape=False, device="cuda", com_dr=False):
|
|
223
|
+
# (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16_binding"))
|
|
224
|
+
from diffneusim.engine import soft_engine as SE # noqa: E402
|
|
225
|
+
self.SE = SE
|
|
226
|
+
self.com_dr = bool(com_dr) # COMDR (tools/g1_seconds/COMDR_DESIGN.md): the deck-only macro build
|
|
227
|
+
self.ext, self.soft = SE.load_ext(True, comdr=self.com_dr)
|
|
228
|
+
self.n, self.slots, self.taped = int(n), int(slots), bool(tape)
|
|
229
|
+
K = int(self.ext.tail()[0])
|
|
230
|
+
cc = tuple(torch.cuda.get_device_capability(torch.device(device)))
|
|
231
|
+
self.parts = SE.TA if (n > K and cc not in SE.ROWS_ARCHS) else SE.ROWS # SoftEngine's production dispatch
|
|
232
|
+
f = lambda *s: torch.zeros(*s, dtype=torch.float32, device=device) # noqa: E731
|
|
233
|
+
i = lambda *s, dt=torch.int32: torch.zeros(*s, dtype=dt, device=device) # noqa: E731
|
|
234
|
+
hw, tw = int(self.ext.hand_words()), int(self.ext.tape_words())
|
|
235
|
+
self.bodies = torch.as_tensor(np.asarray(bodies, np.int32), device=device)
|
|
236
|
+
nbt = len(self.bodies)
|
|
237
|
+
self.w = dict(hand=f(n, hw), nefc=i(n), a_adv=f(n, NV), qfrc_c=f(0), LH=f(0), LQ=f(0), zone=i(0), niter=i(n), kflags=i(n),
|
|
238
|
+
nls=i(n), nfact=i(n), cycles=i(n, dt=torch.int64), flags=i(n), stats=i(n, SE.NSUB, 6), order=i(n), nbig=i(1))
|
|
239
|
+
S = self.slots
|
|
240
|
+
self.o = dict(oq=f(S, n, NQ), ov=f(S, n, NV), ow=f(S, n, NV), sq=f(n, NQ), sv=f(n, NV), sw=f(n, NV),
|
|
241
|
+
xpos=f(S, n, nbt, 3), xquat=f(S, n, nbt, 4), xvel=f(S, n, nbt, 3), xangvel=f(S, n, nbt, 3))
|
|
242
|
+
self.tape = f(S, n, SE.NSUB, tw) if tape else f(0)
|
|
243
|
+
self.foot = torch.zeros(S, n, dtype=torch.float64, device=device)
|
|
244
|
+
self.adj = dict(q_bar=f(n, NV), v_bar=f(n, NV), u_bar=f(n, NU), aflags=i(n)) if tape else None
|
|
245
|
+
self.empty = f(0)
|
|
246
|
+
# the fix (c), 11-11: the adjoint's per-world aflags (bit 0 kShellBadRecord: some substep's tape record overflowed, its VJP
|
|
247
|
+
# the identity of the forward's hold; bit 8 kRowsNoContact) accumulated ON THE DEVICE after every adjoint call (static tensors:
|
|
248
|
+
# capture-safe); read_aflags() returns and zeroes them, one host read per update, outside the clock
|
|
249
|
+
self.aflag_bad = torch.zeros((), dtype=torch.long, device=device)
|
|
250
|
+
self.aflag_or = torch.zeros((), dtype=torch.int32, device=device)
|
|
251
|
+
ab = [i for i, b in enumerate(self.soft.L["bodies"]) if b["name"].removeprefix("robot/") == ANCHOR]
|
|
252
|
+
assert len(ab) == 1, ab
|
|
253
|
+
self.anchor_body = ab[0]
|
|
254
|
+
self.anchor_ipos_offset = None
|
|
255
|
+
# the worlds' anchor CoM offsets [n, 3], one static tensor (written in place: capture-safe), passed to every step and adjoint
|
|
256
|
+
self.ipo = f(n, 3) if self.com_dr else None
|
|
257
|
+
|
|
258
|
+
def set_anchor_ipos_offset(self, off):
|
|
259
|
+
"""COMDR: the anchor body's (ANCHOR) ipos += off[i] for world i of every later step and adjoint, set once after
|
|
260
|
+
construction; off [n, 3] (m), or None: nominal. A law built without com_dr=True refuses a nonzero offset."""
|
|
261
|
+
if off is None:
|
|
262
|
+
if self.com_dr:
|
|
263
|
+
self.ipo.zero_()
|
|
264
|
+
self.anchor_ipos_offset = None
|
|
265
|
+
return
|
|
266
|
+
assert off.dim() == 2 and tuple(off.shape) == (self.n, 3), tuple(off.shape)
|
|
267
|
+
if not self.com_dr:
|
|
268
|
+
assert not bool((off != 0).any()), "a nonzero anchor CoM offset on a law built without com_dr=True (the COMDR build)"
|
|
269
|
+
self.anchor_ipos_offset = off.detach().clone()
|
|
270
|
+
return
|
|
271
|
+
self.ipo.copy_(off.detach().to(self.ipo.dtype))
|
|
272
|
+
self.anchor_ipos_offset = off.detach().clone()
|
|
273
|
+
|
|
274
|
+
def step(self, slot, qpos, qvel, warm, ctrl, foot):
|
|
275
|
+
o, w = self.o, self.w
|
|
276
|
+
tape = self.tape[slot] if self.taped else self.empty
|
|
277
|
+
self.ext.control_step(qpos, qvel, warm, ctrl, foot, o["oq"][slot], o["ov"][slot], o["ow"][slot], o["sq"], o["sv"], o["sw"],
|
|
278
|
+
w["hand"], w["nefc"], w["a_adv"], w["qfrc_c"], w["LH"], w["LQ"], w["zone"], w["niter"], w["kflags"],
|
|
279
|
+
w["nls"], w["nfact"], w["cycles"], w["flags"], w["stats"], self.bodies, o["xpos"][slot],
|
|
280
|
+
o["xquat"][slot], o["xvel"][slot], o["xangvel"][slot], w["order"], w["nbig"], tape, self.SE.NSUB,
|
|
281
|
+
self.parts, *((self.ipo, self.anchor_body) if self.com_dr else ()))
|
|
282
|
+
if self.taped:
|
|
283
|
+
self.foot[slot].copy_(foot) # the adjoint reads the forward's friction in f64
|
|
284
|
+
return dict(qpos=o["oq"][slot], qvel=o["ov"][slot], warm=o["ow"][slot], xpos=o["xpos"][slot], xquat=o["xquat"][slot],
|
|
285
|
+
xvel=o["xvel"][slot], xangvel=o["xangvel"][slot])
|
|
286
|
+
|
|
287
|
+
def adjoint(self, slot, wq, wv, xpos_bar=None, xrot_bar=None, vb_bar=None, wb_bar=None):
|
|
288
|
+
"""Step `slot`'s VJP: wq, wv [n, 35] (the output q's cotangent in its tangent), the output frames' cotangents [n, 32, 3]
|
|
289
|
+
(world frame, every law body). Returns views of shared buffers (q_bar [n, 35] tangent, v_bar, u_bar [n, 29] actuator
|
|
290
|
+
order, aflags): clone before the next adjoint."""
|
|
291
|
+
assert self.taped, "GpuLaw(tape=True) first"
|
|
292
|
+
a, e = self.adj, self.empty
|
|
293
|
+
self.ext.adjoint(self.tape[slot], self.o["oq"][slot], self.o["ov"][slot], wq, wv, self.foot[slot],
|
|
294
|
+
e if xpos_bar is None else xpos_bar, e if xrot_bar is None else xrot_bar, e if vb_bar is None else vb_bar,
|
|
295
|
+
e if wb_bar is None else wb_bar, a["q_bar"], a["v_bar"], a["u_bar"], a["aflags"], e, self.SE.NSUB,
|
|
296
|
+
*((self.ipo, self.anchor_body) if self.com_dr else ()))
|
|
297
|
+
return a
|
|
298
|
+
|
|
299
|
+
def frames(self, qpos, qvel):
|
|
300
|
+
"""The tracked bodies' frames and world velocities at given states (no step), into buffers of their own."""
|
|
301
|
+
if not hasattr(self, "_fr"):
|
|
302
|
+
f = lambda *s: torch.zeros(*s, dtype=torch.float32, device=qpos.device) # noqa: E731
|
|
303
|
+
nbt = len(self.bodies)
|
|
304
|
+
self._fr = dict(xpos=f(self.n, nbt, 3), xquat=f(self.n, nbt, 4), xvel=f(self.n, nbt, 3), xangvel=f(self.n, nbt, 3))
|
|
305
|
+
r = self._fr
|
|
306
|
+
self.ext.frames(qpos, qvel, self.bodies, r["xpos"], r["xquat"], r["xvel"], r["xangvel"])
|
|
307
|
+
return dict(r)
|
|
308
|
+
|
|
309
|
+
def note_aflags(self):
|
|
310
|
+
"""After an adjoint call: the worlds with kShellBadRecord counted and every aflags bit OR-ed, in place on the device."""
|
|
311
|
+
af = self.adj["aflags"]
|
|
312
|
+
self.aflag_bad += ((af & 1) != 0).sum()
|
|
313
|
+
bits = torch.stack([((af >> b) & 1).amax() << b for b in range(16)]).sum().to(self.aflag_or.dtype)
|
|
314
|
+
self.aflag_or.copy_(self.aflag_or | bits)
|
|
315
|
+
|
|
316
|
+
def read_aflags(self):
|
|
317
|
+
"""(world-steps with kShellBadRecord, the OR of the aflags bits) since the last read; a host read, then both zeroed."""
|
|
318
|
+
v = (int(self.aflag_bad), int(self.aflag_or))
|
|
319
|
+
self.aflag_bad.zero_()
|
|
320
|
+
self.aflag_or.zero_()
|
|
321
|
+
return v
|
|
322
|
+
|
|
323
|
+
def flags(self):
|
|
324
|
+
"""The OR of every world's flag word since the last zero_flags (a host sync: read once per iteration)."""
|
|
325
|
+
return int(np.bitwise_or.reduce(self.w["flags"].cpu().numpy()))
|
|
326
|
+
|
|
327
|
+
def zero_flags(self):
|
|
328
|
+
self.w["flags"].zero_()
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
# ---------------------------------------------------------------------------------------------- the task
|
|
332
|
+
def obs_phc(lm, tracked, xpos, xquat, xvel, xang, qpos, qvel, a_prev, ref):
|
|
333
|
+
"""PHC-style observation in the sim root's heading frame H (yaw of the pelvis):
|
|
334
|
+
self: root height; tracked bodies' positions relative to the root, 6D rotations, linear and angular velocities (all in H);
|
|
335
|
+
joint positions and velocities
|
|
336
|
+
task: the next reference frame's tracked bodies: positions relative to the sim root, position errors, 6D of the reference
|
|
337
|
+
rotations and of the rotation errors, linear and angular velocity errors (all in H)
|
|
338
|
+
the previous action"""
|
|
339
|
+
root_p, root_q = xpos[:, :1], xquat[:, :1] # tracked[0] is the pelvis
|
|
340
|
+
H = yaw_quat(root_q).expand_as(xquat)
|
|
341
|
+
rel = lambda v: qrot_inv(H, v) # noqa: E731
|
|
342
|
+
n = xpos.shape[0]
|
|
343
|
+
rp, rq, rv, rw = ref
|
|
344
|
+
self_obs = [qpos[:, 2:3], rel(xpos - root_p).reshape(n, -1), quat_mat6(qmul(qconj(H), xquat)).reshape(n, -1),
|
|
345
|
+
rel(xvel).reshape(n, -1), rel(xang).reshape(n, -1), qpos[:, 7:], qvel[:, 6:]]
|
|
346
|
+
task_obs = [rel(rp - root_p).reshape(n, -1), rel(rp - xpos).reshape(n, -1), quat_mat6(qmul(qconj(H), rq)).reshape(n, -1),
|
|
347
|
+
quat_mat6(qmul(qconj(H), qmul(qmul(rq, qconj(xquat)), H))).reshape(n, -1), rel(rv - xvel).reshape(n, -1),
|
|
348
|
+
rel(rw - xang).reshape(n, -1)]
|
|
349
|
+
return torch.cat(self_obs + task_obs + [a_prev], -1)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class G1SoftTrack:
|
|
353
|
+
"""One clip, n worlds. State lives here; the arms drive step() (values) or their own differentiable wrapper over the same parts."""
|
|
354
|
+
|
|
355
|
+
def __init__(self, backend, motion, lawmap, n, foot_friction=None, early_termination=True, device="cpu", dtype=torch.float64):
|
|
356
|
+
self.be, self.m, self.lm, self.n = backend, motion, lawmap, int(n)
|
|
357
|
+
self.dev, self.dt = device, dtype
|
|
358
|
+
self.tr = lawmap.ids(TRACKED)
|
|
359
|
+
assert list(np.asarray(backend.bodies.cpu() if torch.is_tensor(backend.bodies) else backend.bodies)) == self.tr, \
|
|
360
|
+
"the backend's frame bodies must be TRACKED in order"
|
|
361
|
+
self.i_anchor, self.i_ee = TRACKED.index(ANCHOR), [TRACKED.index(e) for e in EE]
|
|
362
|
+
# index and constant tensors on the device: a Python list index or a host constant inside step() is a host-to-device
|
|
363
|
+
# copy, which CUDA graph capture forbids (W1's G4 failed on it, 11-10)
|
|
364
|
+
self.tr_t = torch.tensor(self.tr, dtype=torch.long, device=device)
|
|
365
|
+
self.i_ee_t = torch.tensor(self.i_ee, dtype=torch.long, device=device)
|
|
366
|
+
self.g_down = torch.tensor([0.0, 0.0, -1.0], dtype=dtype, device=device)
|
|
367
|
+
self.early = bool(early_termination)
|
|
368
|
+
# in the engine's dtype: the GPU forward takes its friction in f32 (GpuLaw keeps the adjoint's f64 copy per slot)
|
|
369
|
+
self.foot = torch.full((n,), lawmap.train_foot_friction if foot_friction is None else float(foot_friction), dtype=dtype,
|
|
370
|
+
device=device)
|
|
371
|
+
z = lambda *s, dt=dtype: torch.zeros(*s, dtype=dt, device=device) # noqa: E731
|
|
372
|
+
self.qpos, self.qvel, self.warm = z(n, NQ), z(n, NV), z(n, NV)
|
|
373
|
+
self.t = torch.zeros(n, dtype=torch.long, device=device)
|
|
374
|
+
self.a_prev = z(n, NU)
|
|
375
|
+
self.et_timer = torch.zeros(n, dtype=torch.long, device=device)
|
|
376
|
+
self.half = lawmap.half_range.to(device=device, dtype=dtype)
|
|
377
|
+
self.lo, self.hi = lawmap.lo.to(device=device, dtype=dtype), lawmap.hi.to(device=device, dtype=dtype)
|
|
378
|
+
self.frames = None
|
|
379
|
+
|
|
380
|
+
# -- reference at frames f
|
|
381
|
+
def ref(self, f):
|
|
382
|
+
tr = self.tr_t
|
|
383
|
+
return (self.m.bpos[f][:, tr], self.m.bquat[f][:, tr], self.m.bvel[f][:, tr], self.m.bang[f][:, tr])
|
|
384
|
+
|
|
385
|
+
def reset(self, mask, frames, q_noise=None, qd_noise=None):
|
|
386
|
+
"""Worlds under `mask` [n] bool start at the reference state of `frames` [n] (+ joint noise); others are untouched."""
|
|
387
|
+
qp, qv = self.m.state(frames)
|
|
388
|
+
if q_noise is not None:
|
|
389
|
+
qp = torch.cat([qp[:, :7], qp[:, 7:] + q_noise], -1)
|
|
390
|
+
if qd_noise is not None:
|
|
391
|
+
qv = torch.cat([qv[:, :6], qv[:, 6:] + qd_noise], -1)
|
|
392
|
+
mk = mask.view(-1, 1)
|
|
393
|
+
self.qpos = torch.where(mk, qp.to(self.dt), self.qpos)
|
|
394
|
+
self.qvel = torch.where(mk, qv.to(self.dt), self.qvel)
|
|
395
|
+
self.warm = torch.where(mk, torch.zeros_like(self.warm), self.warm)
|
|
396
|
+
self.a_prev = torch.where(mk, torch.zeros_like(self.a_prev), self.a_prev)
|
|
397
|
+
self.t = torch.where(mask, frames, self.t)
|
|
398
|
+
self.et_timer = torch.where(mask, torch.zeros_like(self.et_timer), self.et_timer)
|
|
399
|
+
self.frames = None
|
|
400
|
+
|
|
401
|
+
def setpoint(self, a):
|
|
402
|
+
"""Residual PD: q_ref(t + 1) + half_range * a, clamped to the joint range."""
|
|
403
|
+
t1 = (self.t + 1).clamp_max(self.m.T - 1)
|
|
404
|
+
return torch.minimum(torch.maximum(self.m.joint_pos[t1].to(self.dt) + self.half * a, self.lo), self.hi)
|
|
405
|
+
|
|
406
|
+
def reward(self, fr, f):
|
|
407
|
+
rp, rq, rv, rw = self.ref(f)
|
|
408
|
+
nb3 = 3.0 * len(self.tr)
|
|
409
|
+
e_pos = (fr["xpos"] - rp).square().sum((1, 2)) / nb3
|
|
410
|
+
e_rot = quat_axis_angle(qmul(fr["xquat"], qconj(rq))).square().sum((1, 2)) / nb3
|
|
411
|
+
e_lin = (fr["xvel"] - rv).square().sum((1, 2)) / nb3
|
|
412
|
+
e_ang = (fr["xangvel"] - rw).square().sum((1, 2)) / nb3
|
|
413
|
+
E = REW_W["pos"] * e_pos + REW_W["rot"] * e_rot + REW_W["lin"] * e_lin + REW_W["ang"] * e_ang
|
|
414
|
+
return (1.0 / (1.0 + E)).clamp_min(1e-6), dict(e_pos=e_pos, e_rot=e_rot, e_lin=e_lin, e_ang=e_ang)
|
|
415
|
+
|
|
416
|
+
def fails(self, fr, f):
|
|
417
|
+
"""BeyondMimic's G1 terminations at frames f: (anchor height, anchor orientation, end-effector height) masks [n]."""
|
|
418
|
+
rp, rq, _, _ = self.ref(f)
|
|
419
|
+
ia = self.i_anchor
|
|
420
|
+
g = self.g_down.to(fr["xpos"].dtype)
|
|
421
|
+
az = (fr["xpos"][:, ia, 2] - rp[:, ia, 2]).abs() > TERM_ANCHOR_Z
|
|
422
|
+
gs, gr = qrot_inv(fr["xquat"][:, ia], g.expand(self.n, 3)), qrot_inv(rq[:, ia], g.expand(self.n, 3))
|
|
423
|
+
ao = (gr[:, 2] - gs[:, 2]).abs() > TERM_ANCHOR_ORI
|
|
424
|
+
ee = (fr["xpos"][:, self.i_ee_t, 2] - rp[:, self.i_ee_t, 2]).abs().gt(TERM_EE_Z).any(1)
|
|
425
|
+
return az, ao, ee
|
|
426
|
+
|
|
427
|
+
def step(self, a, slot=0):
|
|
428
|
+
"""One control step under action a [n, 29] (joint order, values only). Returns (obs-ready frames, reward, terminated,
|
|
429
|
+
time_out, info); the state advances to t + 1. Worlds stay where they are: the caller resets under a mask."""
|
|
430
|
+
ctrl = self.lm.ctrl(self.setpoint(a))
|
|
431
|
+
o = self.be.step(slot, self.qpos, self.qvel, self.warm, ctrl.to(self.qpos.dtype), self.foot)
|
|
432
|
+
self.t = (self.t + 1).clamp_max(self.m.T - 1)
|
|
433
|
+
fr = {k: o[k] for k in ("xpos", "xquat", "xvel", "xangvel")}
|
|
434
|
+
r, terms = self.reward(fr, self.t)
|
|
435
|
+
az, ao, ee = self.fails(fr, self.t)
|
|
436
|
+
term = az | ao | ee
|
|
437
|
+
if self.early:
|
|
438
|
+
self.et_timer = torch.where(r < ET_REWARD, self.et_timer + 1, torch.zeros_like(self.et_timer))
|
|
439
|
+
term = term | (self.et_timer >= ET_STEPS)
|
|
440
|
+
time_out = self.t >= self.m.T - 1
|
|
441
|
+
nonfinite = ~torch.isfinite(o["qpos"]).all(1) | ~torch.isfinite(o["qvel"]).all(1)
|
|
442
|
+
# copies, not the backend's slot buffers: a state that aliased them would be the next step's input AND output buffer
|
|
443
|
+
self.qpos, self.qvel, self.warm = o["qpos"].clone(), o["qvel"].clone(), o["warm"].clone()
|
|
444
|
+
self.a_prev = a
|
|
445
|
+
self.frames = fr
|
|
446
|
+
return fr, r, term | nonfinite, time_out, dict(anchor_z=az, anchor_ori=ao, ee_z=ee, nonfinite=nonfinite, **terms)
|
|
447
|
+
|
|
448
|
+
def observe(self):
|
|
449
|
+
fr = self.frames if self.frames is not None else self.be.frames(self.qpos, self.qvel)
|
|
450
|
+
t1 = (self.t + 1).clamp_max(self.m.T - 1)
|
|
451
|
+
return obs_phc(self.lm, self.tr, fr["xpos"], fr["xquat"], fr["xvel"], fr["xangvel"], self.qpos, self.qvel, self.a_prev,
|
|
452
|
+
self.ref(t1))
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Arm B's differentiable G1 control step (line 23): one torch.autograd.Function over g1_soft_env's backends.
|
|
2
|
+
|
|
3
|
+
Forward: the law's control step (values, and on the GPU the step's own tape slot). Backward: the step's VJP with the cotangents of
|
|
4
|
+
the next state AND of the tracked bodies' frames, so a reward computed on the engine's frames needs no FK of its own.
|
|
5
|
+
|
|
6
|
+
Conventions (tools/d16/soft_capi.py; core/soft/adj/out_adj.h; the reading of the extension, 11-10):
|
|
7
|
+
state tangent [root world translation 3, root body-frame rotation d 3, joints 29]: dquat = 0.5 quat (x) (0, d)
|
|
8
|
+
raw qpos cotangent g -> tangent: g_d = 0.5 Im(conj(quat) (x) g) (the transpose of that map)
|
|
9
|
+
tangent cotangent -> raw: g = 2 quat (x) (0, g_d) (zero along quat: no radial component)
|
|
10
|
+
frame rotation the adjoint's xrot_bar is the cotangent of a world-frame rotation theta: dq_b = 0.5 (0, theta) (x) q_b, so a raw
|
|
11
|
+
quaternion cotangent g maps to g_theta = 0.5 Im(g (x) conj(q_b))
|
|
12
|
+
ctrl the law's actuator order (g1_soft_env.LawMap.ctrl gathers it from the joint order, autograd carries the rest)
|
|
13
|
+
constants the warm start and the foot friction (no gradient), as the binding's adjoint
|
|
14
|
+
Backends: GpuLaw (production, per-slot tapes) and CpuJacLaw (the f64 CPU law's full step Jacobian from its batched JVP, small n:
|
|
15
|
+
the reference for the tests and for the GPU gate).
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
import torch
|
|
21
|
+
|
|
22
|
+
from . import g1_soft_env as G
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _qm(a, b):
|
|
26
|
+
return G.qmul(a, b)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def quat_cot_raw_to_tangent(q, g):
|
|
30
|
+
"""[n, 4] quaternion and its raw cotangent -> the body-frame rotation's cotangent [n, 3]."""
|
|
31
|
+
return 0.5 * _qm(G.qconj(q), g)[..., 1:]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def quat_cot_tangent_to_raw(q, gd):
|
|
35
|
+
z = torch.zeros_like(gd[..., :1])
|
|
36
|
+
return 2.0 * _qm(q, torch.cat([z, gd], -1))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def frame_quat_cot_to_theta(q, g):
|
|
40
|
+
"""Raw cotangents of world-frame body quaternions [..., 4] -> world rotation cotangents [..., 3]."""
|
|
41
|
+
return 0.5 * _qm(g, G.qconj(q))[..., 1:]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def qpos_cot_to_tangent(qpos, g):
|
|
45
|
+
"""Raw qpos cotangent [n, 36] -> tangent cotangent [n, 35]."""
|
|
46
|
+
return torch.cat([g[:, :3], quat_cot_raw_to_tangent(qpos[:, 3:7], g[:, 3:7]), g[:, 7:]], -1)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def tangent_cot_to_qpos(qpos, gt):
|
|
50
|
+
"""Tangent cotangent [n, 35] -> raw qpos cotangent [n, 36] (zero along the root quaternion)."""
|
|
51
|
+
return torch.cat([gt[:, :3], quat_cot_tangent_to_raw(qpos[:, 3:7], gt[:, 3:6]), gt[:, 6:]], -1)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class CpuJacLaw:
|
|
55
|
+
"""The f64 CPU law with each step's full Jacobian (99 input directions: the state tangent, the velocities, the actuators;
|
|
56
|
+
outputs: the next state's tangent at the output qpos, its velocities, and the tracked frames with raw quaternions), built from
|
|
57
|
+
the batched JVP, 4 directions per call. For tests and the GPU gate at small n only."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, bodies, slots=1):
|
|
60
|
+
self.cpu = G.CpuLaw(bodies)
|
|
61
|
+
self.soft, self.bodies = self.cpu.soft, self.cpu.bodies
|
|
62
|
+
self.J = [None] * slots
|
|
63
|
+
|
|
64
|
+
def set_anchor_ipos_offset(self, off):
|
|
65
|
+
"""COMDR: CpuLaw.set_anchor_ipos_offset on the shared CPU model (the JVP batch reads it as the step does)"""
|
|
66
|
+
self.cpu.set_anchor_ipos_offset(off)
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def anchor_ipos_offset(self):
|
|
70
|
+
return self.cpu.anchor_ipos_offset
|
|
71
|
+
|
|
72
|
+
def step(self, slot, qpos, qvel, warm, ctrl, foot):
|
|
73
|
+
S = self.soft
|
|
74
|
+
q, v, w, c = (x.detach().cpu().double().numpy() for x in (qpos, qvel, warm, ctrl))
|
|
75
|
+
f = foot.detach().cpu().double().numpy()
|
|
76
|
+
n, nv, nu, nb = q.shape[0], G.NV, G.NU, len(self.bodies)
|
|
77
|
+
D = 2 * nv + nu
|
|
78
|
+
eye = np.eye(D)
|
|
79
|
+
cols = []
|
|
80
|
+
for k in range(0, D, 4):
|
|
81
|
+
d = eye[k:k + 4]
|
|
82
|
+
nd = d.shape[0]
|
|
83
|
+
vq = np.broadcast_to(d[:, :nv], (n, nd, nv)).copy()
|
|
84
|
+
vv = np.broadcast_to(d[:, nv:2 * nv], (n, nd, nv)).copy()
|
|
85
|
+
vu = np.broadcast_to(d[:, 2 * nv:], (n, nd, nu)).copy()
|
|
86
|
+
o = S.control_step_jvp_batch(q, v, w, c, vq, vv, vu, f, bodies=self.bodies)
|
|
87
|
+
dq_t = np.stack([S.qpos_raw_to_tangent(o["qpos"][i], o["dq"][i]) for i in range(n)]) # [n, nd, 35]
|
|
88
|
+
cols.append(np.concatenate([dq_t, o["dv"], o["dxpos"].reshape(n, nd, -1), o["dxquat"].reshape(n, nd, -1),
|
|
89
|
+
o["dxvel"].reshape(n, nd, -1), o["dxangvel"].reshape(n, nd, -1)], -1))
|
|
90
|
+
last = o
|
|
91
|
+
self.J[slot] = np.concatenate(cols, 1) # [n, D in, outputs]
|
|
92
|
+
self.nb = nb
|
|
93
|
+
dev, dt = qpos.device, qpos.dtype
|
|
94
|
+
return {k: torch.as_tensor(last[k], dtype=dt, device=dev) for k in ("qpos", "qvel", "warm", "xpos", "xquat", "xvel", "xangvel")}
|
|
95
|
+
|
|
96
|
+
def frames(self, qpos, qvel):
|
|
97
|
+
return self.cpu.frames(qpos, qvel)
|
|
98
|
+
|
|
99
|
+
def vjp(self, slot, qpos_out, wq, wv, gxpos, gxquat_raw, gxvel, gxang, xquat_out):
|
|
100
|
+
n = wq.shape[0]
|
|
101
|
+
g = torch.cat([wq, wv, gxpos.reshape(n, -1), gxquat_raw.reshape(n, -1), gxvel.reshape(n, -1), gxang.reshape(n, -1)], -1)
|
|
102
|
+
Jt = torch.as_tensor(self.J[slot], dtype=torch.float64)
|
|
103
|
+
r = torch.einsum("nio,no->ni", Jt, g.detach().cpu().double()).to(wq)
|
|
104
|
+
nv = G.NV
|
|
105
|
+
return r[:, :nv], r[:, nv:2 * nv], r[:, 2 * nv:]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def gpu_vjp(law, slot, qpos_out, wq, wv, gxpos, gxquat_raw, gxvel, gxang, xquat_out):
|
|
109
|
+
"""GpuLaw's adjoint with the frame cotangents scattered onto every law body (world frame) and the rotation converted."""
|
|
110
|
+
n, nb = wq.shape[0], law.ext_nb if hasattr(law, "ext_nb") else 32
|
|
111
|
+
idx = law.bodies.long()
|
|
112
|
+
full = lambda x: torch.zeros(n, nb, 3, dtype=x.dtype, device=x.device).index_copy_(1, idx, x) # noqa: E731
|
|
113
|
+
a = law.adjoint(slot, wq.contiguous(), wv.contiguous(), full(gxpos).contiguous(),
|
|
114
|
+
full(frame_quat_cot_to_theta(xquat_out, gxquat_raw)).contiguous(), full(gxvel).contiguous(),
|
|
115
|
+
full(gxang).contiguous())
|
|
116
|
+
law.note_aflags() # the fix (c): the overflowed-record count, on the device
|
|
117
|
+
return a["q_bar"].clone(), a["v_bar"].clone(), a["u_bar"].clone()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class StepFn(torch.autograd.Function):
|
|
121
|
+
"""(qpos [n, 36], qvel [n, 35], ctrl [n, 29] actuator order) -> (qpos', qvel', warm', xpos, xquat, xvel, xangvel)."""
|
|
122
|
+
|
|
123
|
+
@staticmethod
|
|
124
|
+
def forward(ctx, qpos, qvel, ctrl, law, slot, warm, foot):
|
|
125
|
+
o = law.step(slot, qpos.detach(), qvel.detach(), warm.detach(), ctrl.detach(), foot)
|
|
126
|
+
outs = tuple(o[k].clone() for k in ("qpos", "qvel", "warm", "xpos", "xquat", "xvel", "xangvel"))
|
|
127
|
+
ctx.law, ctx.slot = law, slot
|
|
128
|
+
ctx.save_for_backward(qpos.detach(), outs[0], outs[4])
|
|
129
|
+
ctx.mark_non_differentiable(outs[2])
|
|
130
|
+
return outs
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def backward(ctx, gq, gv, gw, gxp, gxq, gxv, gxa):
|
|
134
|
+
q_in, q_out, xq_out = ctx.saved_tensors
|
|
135
|
+
law = ctx.law
|
|
136
|
+
wq = qpos_cot_to_tangent(q_out, gq)
|
|
137
|
+
if isinstance(law, CpuJacLaw):
|
|
138
|
+
qb, vb, ub = law.vjp(ctx.slot, q_out, wq, gv, gxp, gxq, gxv, gxa, xq_out)
|
|
139
|
+
else:
|
|
140
|
+
qb, vb, ub = gpu_vjp(law, ctx.slot, q_out, wq, gv, gxp, gxq, gxv, gxa, xq_out)
|
|
141
|
+
return tangent_cot_to_qpos(q_in, qb), vb, ub, None, None, None, None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def step(law, slot, qpos, qvel, ctrl, warm, foot):
|
|
145
|
+
return StepFn.apply(qpos, qvel, ctrl, law, slot, warm, foot)
|