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,373 @@
|
|
|
1
|
+
"""ctypes loader of bindings/soft_capi.cpp (D16 C1 / C2's test binding over core/soft/), and the model arrays from
|
|
2
|
+
models/derived/unitree_g1_soft_law.json. Builds the library on first use when it is older than its sources.
|
|
3
|
+
"""
|
|
4
|
+
import ctypes
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import pathlib
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
from diffneusim._paths import ROOT as ROOT # (3a) the repo root
|
|
12
|
+
SRC = [ROOT / "bindings" / "soft_capi.cpp"] + sorted((ROOT / "core" / "soft").glob("*.h"))
|
|
13
|
+
# SOFT_CAPI_EXTRA: extra compiler flags (e.g. -ffp-contract=off for a no-FMA corpus); the flags are part of the build's content tag,
|
|
14
|
+
# so such a build never replaces or is mistaken for the default one
|
|
15
|
+
EXTRA = os.environ.get("SOFT_CAPI_EXTRA", "").split()
|
|
16
|
+
LIB = None # set by build(): the library in the user's build cache (diffneusim._cache), never inside the package
|
|
17
|
+
LAW_PROD = ROOT / "models" / "derived" / "unitree_g1_soft_law.json"
|
|
18
|
+
# D16_G1_LAW: another law file for the same G1 (E3's floor-only law, tools/d16_e2/floor_only_law.py); soft_engine.py asserts
|
|
19
|
+
# that it differs from the production law in its pairs only. Unset: the production law, as before.
|
|
20
|
+
LAW = pathlib.Path(os.environ["D16_G1_LAW"]) if os.environ.get("D16_G1_LAW") else LAW_PROD
|
|
21
|
+
|
|
22
|
+
D = ctypes.POINTER(ctypes.c_double)
|
|
23
|
+
I = ctypes.POINTER(ctypes.c_int)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def build():
|
|
27
|
+
"""the library, built once per content tag (sources + flags + compiler) into the build cache"""
|
|
28
|
+
global LIB
|
|
29
|
+
if LIB is None:
|
|
30
|
+
from diffneusim import _cache
|
|
31
|
+
LIB = _cache.build_lib("build-soft", "libsoftcapi.so", SRC, ["c++", "-std=c++17", "-O2", "-fPIC", "-shared"] + EXTRA
|
|
32
|
+
+ ["-I", str(ROOT / "core"), "-I", str(ROOT / "core" / "include"), str(SRC[0])])
|
|
33
|
+
return LIB
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def ptr(a, kind):
|
|
37
|
+
return a.ctypes.data_as(D if kind == "d" else I)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Soft:
|
|
41
|
+
def __init__(self, law_path=LAW, solimp0=None):
|
|
42
|
+
"""solimp0: override solimp[0] (d0) of every pair and joint (the 10-31 training setting d0 = 0, which MuJoCo's
|
|
43
|
+
getsolparam clamps to mjMINIMP = 1e-4); None keeps the scene's."""
|
|
44
|
+
build()
|
|
45
|
+
self.lib = ctypes.CDLL(str(LIB))
|
|
46
|
+
self.lib.soft_model_new.restype = ctypes.c_void_p
|
|
47
|
+
self.L = json.loads(pathlib.Path(law_path).read_text())
|
|
48
|
+
if solimp0 is not None:
|
|
49
|
+
for x in self.L["pairs"] + self.L["joints"]:
|
|
50
|
+
x["solimp"][0] = float(solimp0)
|
|
51
|
+
B = self.L["bodies"]
|
|
52
|
+
self.nb, self.nq, self.nv = len(B), self.L["nq"], self.L["nv"]
|
|
53
|
+
f = lambda k, w: np.ascontiguousarray(np.array([b[k] for b in B], np.float64).reshape(len(B), w)) # noqa: E731
|
|
54
|
+
i = lambda k: np.ascontiguousarray(np.array([b[k] for b in B], np.int32)) # noqa: E731
|
|
55
|
+
self._keep = dict(parent=i("parent"), jt=i("jnt_type"), qadr=i("qadr"), dadr=i("dadr"), pos=f("pos", 3),
|
|
56
|
+
quat=f("quat", 4), ipos=f("ipos", 3), iquat=f("iquat", 4), mass=f("mass", 1),
|
|
57
|
+
inertia=f("inertia", 3), axis=f("axis", 3), invw=f("invweight0", 2),
|
|
58
|
+
arm=np.ascontiguousarray([d["armature"] for d in self.L["dofs"]], np.float64),
|
|
59
|
+
grav=np.ascontiguousarray(self.L["opt"]["gravity"], np.float64))
|
|
60
|
+
k = self._keep
|
|
61
|
+
self.h = ctypes.c_void_p(self.lib.soft_model_new(
|
|
62
|
+
self.nb, self.nq, self.nv, ptr(k["parent"], "i"), ptr(k["jt"], "i"), ptr(k["qadr"], "i"), ptr(k["dadr"], "i"),
|
|
63
|
+
ptr(k["pos"], "d"), ptr(k["quat"], "d"), ptr(k["ipos"], "d"), ptr(k["iquat"], "d"), ptr(k["mass"], "d"),
|
|
64
|
+
ptr(k["inertia"], "d"), ptr(k["axis"], "d"), ptr(k["invw"], "d"), ptr(k["arm"], "d"), ptr(k["grav"], "d")))
|
|
65
|
+
# the law and the actuators are pushed here, eagerly: a model without them steps with no actuator term (a silent
|
|
66
|
+
# zero engine B hit on its first run, 2026-11-02); the C side now also refuses a step on a model missing either
|
|
67
|
+
_init_law(self)
|
|
68
|
+
_init_act(self)
|
|
69
|
+
self.anchor = None # COMDR: (body, off [n, 3]) once set_anchor_ipos_offset ran
|
|
70
|
+
|
|
71
|
+
def smooth(self, qpos, qvel, anchor_ipos_offset=None, anchor_body=None):
|
|
72
|
+
"""xpos, xquat, M, qfrc_bias at one state; with anchor_ipos_offset [3] (m) the body anchor_body's ipos shifted by it
|
|
73
|
+
(COMDR, tools/g1_seconds/COMDR_DESIGN.md; line 23's MuJoCo parity of M and qfrc_bias)"""
|
|
74
|
+
qpos = np.ascontiguousarray(qpos, np.float64)
|
|
75
|
+
qvel = np.ascontiguousarray(qvel, np.float64)
|
|
76
|
+
xpos, xquat = np.zeros((self.nb, 3)), np.zeros((self.nb, 4))
|
|
77
|
+
M, bias = np.zeros((self.nv, self.nv)), np.zeros(self.nv)
|
|
78
|
+
if anchor_ipos_offset is None:
|
|
79
|
+
assert anchor_body is None, "anchor_body without anchor_ipos_offset"
|
|
80
|
+
self.lib.soft_smooth(self.h, ptr(qpos, "d"), ptr(qvel, "d"), ptr(xpos, "d"), ptr(xquat, "d"), ptr(M, "d"),
|
|
81
|
+
ptr(bias, "d"))
|
|
82
|
+
else:
|
|
83
|
+
off = np.ascontiguousarray(anchor_ipos_offset, np.float64)
|
|
84
|
+
assert off.shape == (3,) and anchor_body is not None and 1 <= int(anchor_body) < self.nb, (off.shape, anchor_body)
|
|
85
|
+
self.lib.soft_smooth_anchor(self.h, int(anchor_body), ptr(off, "d"), ptr(qpos, "d"), ptr(qvel, "d"), ptr(xpos, "d"),
|
|
86
|
+
ptr(xquat, "d"), ptr(M, "d"), ptr(bias, "d"))
|
|
87
|
+
return xpos, xquat, M, bias
|
|
88
|
+
|
|
89
|
+
def set_anchor_ipos_offset(self, body, off):
|
|
90
|
+
"""COMDR: body `body`'s ipos += off[i] for world i of every later batch call (control_step_batch and its JVP); off
|
|
91
|
+
[n, 3] f64 (m), or None: nominal again. The single-env entry points refuse while it is set (no world index there)."""
|
|
92
|
+
if off is None:
|
|
93
|
+
self.lib.soft_set_anchor_ipos_offset(self.h, 0, 0, None)
|
|
94
|
+
self.anchor = None
|
|
95
|
+
return
|
|
96
|
+
off = np.ascontiguousarray(off, np.float64)
|
|
97
|
+
assert off.ndim == 2 and off.shape[1] == 3 and off.shape[0] > 0 and np.isfinite(off).all(), off.shape
|
|
98
|
+
assert 1 <= int(body) < self.nb, body
|
|
99
|
+
self.lib.soft_set_anchor_ipos_offset(self.h, int(body), off.shape[0], ptr(off, "d"))
|
|
100
|
+
self.anchor = (int(body), off.copy())
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _law_arrays(L):
|
|
104
|
+
"""The law's geom / pair / joint tables as the C API's flat arrays; pairs remapped from MuJoCo geom ids to the
|
|
105
|
+
geom table's rows."""
|
|
106
|
+
G = L["geoms"]
|
|
107
|
+
row = {g["id"]: i for i, g in enumerate(G)}
|
|
108
|
+
g_int = np.ascontiguousarray([[g["body"], g["type"]] for g in G], np.int32)
|
|
109
|
+
g_dbl = np.ascontiguousarray([g["size"] + g["pos"] + g["quat"] for g in G], np.float64)
|
|
110
|
+
P = L["pairs"]
|
|
111
|
+
p_int = np.ascontiguousarray([[row[p["g1"]], row[p["g2"]], p["condim"], row[p["foot_geom"]] if p["foot_geom"] >= 0 else -1]
|
|
112
|
+
for p in P], np.int32)
|
|
113
|
+
p_dbl = np.ascontiguousarray([p["friction"] + p["solref"] + p["solimp"] + [p["margin"], p["gap"]] for p in P], np.float64)
|
|
114
|
+
J = L["joints"]
|
|
115
|
+
j_int = np.ascontiguousarray([[j["dof"], j["qadr"], int(j["limited"])] for j in J], np.int32)
|
|
116
|
+
j_dbl = np.ascontiguousarray([j["range"] + j["solref"] + j["solimp"] + [j["margin"]] for j in J], np.float64)
|
|
117
|
+
dinv = np.ascontiguousarray([d["invweight0"] for d in L["dofs"]], np.float64)
|
|
118
|
+
return dict(g_int=g_int, g_dbl=g_dbl, p_int=p_int, p_dbl=p_dbl, j_int=j_int, j_dbl=j_dbl, dinv=dinv, row=row)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _init_law(self):
|
|
122
|
+
a = self._law = _law_arrays(self.L)
|
|
123
|
+
self.lib.soft_model_law(self.h, len(a["g_int"]), ptr(a["g_int"], "i"), ptr(a["g_dbl"], "d"), len(a["p_int"]),
|
|
124
|
+
ptr(a["p_int"], "i"), ptr(a["p_dbl"], "d"), len(a["j_int"]), ptr(a["j_int"], "i"),
|
|
125
|
+
ptr(a["j_dbl"], "d"), ptr(a["dinv"], "d"), ctypes.c_double(self.L["opt"]["timestep"]),
|
|
126
|
+
ctypes.c_double(self.L["opt"]["impratio"]))
|
|
127
|
+
self.pair_geoms = np.array([[p["g1"], p["g2"]] for p in self.L["pairs"]], np.int32) # MuJoCo geom ids
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def rows(self, qpos, qvel, foot_friction=-1.0, cap=512, ccap=128):
|
|
131
|
+
"""The rows and contacts of one state: dict(type, id, J, pos, aref, D, R) and contacts (g1, g2 MuJoCo ids, slot,
|
|
132
|
+
dist, pos, frame)."""
|
|
133
|
+
qpos = np.ascontiguousarray(qpos, np.float64)
|
|
134
|
+
qvel = np.ascontiguousarray(qvel, np.float64)
|
|
135
|
+
nv = self.nv
|
|
136
|
+
t, i_ = np.zeros(cap, np.int32), np.zeros(cap, np.int32)
|
|
137
|
+
J, pos, aref, D, R = np.zeros((cap, nv)), np.zeros(cap), np.zeros(cap), np.zeros(cap), np.zeros(cap)
|
|
138
|
+
cp, cs, cd = np.zeros(ccap, np.int32), np.zeros(ccap, np.int32), np.zeros(ccap)
|
|
139
|
+
cpos, cfr = np.zeros((ccap, 3)), np.zeros((ccap, 9))
|
|
140
|
+
nc = ctypes.c_int(0)
|
|
141
|
+
n = self.lib.soft_rows(self.h, ptr(qpos, "d"), ptr(qvel, "d"), ctypes.c_double(foot_friction), cap, ptr(t, "i"),
|
|
142
|
+
ptr(i_, "i"), ptr(J, "d"), ptr(pos, "d"), ptr(aref, "d"), ptr(D, "d"), ptr(R, "d"), ccap,
|
|
143
|
+
ptr(cp, "i"), ptr(cs, "i"), ptr(cd, "d"), ptr(cpos, "d"), ptr(cfr, "d"), ctypes.byref(nc))
|
|
144
|
+
assert n >= 0 and nc.value <= ccap, (n, nc.value)
|
|
145
|
+
k = nc.value
|
|
146
|
+
con = dict(g1=self.pair_geoms[cp[:k], 0], g2=self.pair_geoms[cp[:k], 1], slot=cs[:k], dist=cd[:k], pos=cpos[:k],
|
|
147
|
+
frame=cfr[:k])
|
|
148
|
+
return dict(type=t[:n], id=i_[:n], J=J[:n], pos=pos[:n], aref=aref[:n], D=D[:n], R=R[:n]), con
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Soft.rows = rows
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _init_act(self):
|
|
155
|
+
qadr = {j["dof"]: j["qadr"] for j in self.L["joints"]}
|
|
156
|
+
A = sorted(self.L["actuators"], key=lambda a: a["index"])
|
|
157
|
+
assert [a["index"] for a in A] == list(range(len(A)))
|
|
158
|
+
a_int = np.ascontiguousarray([[a["dof"], qadr[a["dof"]], int(a["forcelimited"])] for a in A], np.int32)
|
|
159
|
+
a_dbl = np.ascontiguousarray([[a["kp"], a["kd"], a["forcerange"][0], a["forcerange"][1]] for a in A], np.float64)
|
|
160
|
+
self._act = (a_int, a_dbl)
|
|
161
|
+
o = self.L["opt"]
|
|
162
|
+
self.lib.soft_model_act(self.h, len(A), ptr(a_int, "i"), ptr(a_dbl, "d"), o["iterations"], o["ls_iterations"],
|
|
163
|
+
ctypes.c_double(o["tolerance"]), ctypes.c_double(o["ls_tolerance"]))
|
|
164
|
+
self.nu = len(A)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def control_step(self, qpos, qvel, warm, ctrl, foot_friction=-1.0, nsub=None, iterations=0, tolerance=0.0):
|
|
168
|
+
"""One control step (nsub substeps, ctrl held) from a state: returns (qpos, qvel, warm, stats [nsub, 4])."""
|
|
169
|
+
assert self.anchor is None, "a per-world anchor offset is set (COMDR): the single-env step has no world index; use the batch"
|
|
170
|
+
nsub = nsub or self.L["opt"]["decimation"]
|
|
171
|
+
q, v, w = (np.array(x, np.float64) for x in (qpos, qvel, warm))
|
|
172
|
+
c = np.ascontiguousarray(ctrl, np.float64)
|
|
173
|
+
st = np.zeros((nsub, 6), np.int32)
|
|
174
|
+
self.lib.soft_control_step(self.h, ptr(q, "d"), ptr(v, "d"), ptr(w, "d"), ptr(c, "d"), ctypes.c_double(foot_friction),
|
|
175
|
+
nsub, iterations, ctypes.c_double(tolerance), ptr(st, "i"))
|
|
176
|
+
return q, v, w, st
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Soft.control_step = control_step
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def control_step_jvp(self, qpos, qvel, warm, ctrl, vq, vv, vu, foot_friction=-1.0, nsub=None, iterations=0, tolerance=0.0):
|
|
183
|
+
"""One control step and its JVP along up to 4 input directions (vq: qpos tangent [ndir, nv], vv [ndir, nv], vu
|
|
184
|
+
[ndir, nu]): returns (qpos, qvel, warm, dq [ndir, nq], dv [ndir, nv], flags [nsub, 5])."""
|
|
185
|
+
assert self.anchor is None, "a per-world anchor offset is set (COMDR): the single-env entry points have no world index"
|
|
186
|
+
nsub = nsub or self.L["opt"]["decimation"]
|
|
187
|
+
q, v, w = (np.array(x, np.float64) for x in (qpos, qvel, warm))
|
|
188
|
+
c = np.ascontiguousarray(ctrl, np.float64)
|
|
189
|
+
vq, vv, vu = (np.ascontiguousarray(x, np.float64) for x in (vq, vv, vu))
|
|
190
|
+
ndir = vq.shape[0]
|
|
191
|
+
assert ndir <= 4
|
|
192
|
+
dq, dv = np.zeros((ndir, self.nq)), np.zeros((ndir, self.nv))
|
|
193
|
+
fl = np.zeros((nsub, 5), np.int32)
|
|
194
|
+
self.lib.soft_control_step_jvp(self.h, ptr(q, "d"), ptr(v, "d"), ptr(w, "d"), ptr(c, "d"),
|
|
195
|
+
ctypes.c_double(foot_friction), nsub, iterations, ctypes.c_double(tolerance), ndir,
|
|
196
|
+
ptr(vq, "d"), ptr(vv, "d"), ptr(vu, "d"), ptr(dq, "d"), ptr(dv, "d"), ptr(fl, "i"))
|
|
197
|
+
return q, v, w, dq, dv, fl
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
Soft.control_step_jvp = control_step_jvp
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def substep_tape(self, qpos, qvel, warm, ctrl, foot_friction=-1.0, iterations=0, tolerance=0.0, cap=512, ccap=128):
|
|
204
|
+
"""One substep with its tape record (core/soft/step.h SubstepTape): returns (qpos, qvel, warm) after it and the record."""
|
|
205
|
+
assert self.anchor is None, "a per-world anchor offset is set (COMDR): the single-env entry points have no world index"
|
|
206
|
+
nv = self.nv
|
|
207
|
+
q, v, w = (np.array(x, np.float64) for x in (qpos, qvel, warm))
|
|
208
|
+
c = np.ascontiguousarray(ctrl, np.float64)
|
|
209
|
+
a_star, a_adv, LH, LQ = np.zeros(nv), np.zeros(nv), np.zeros((nv, nv)), np.zeros((nv, nv))
|
|
210
|
+
zone, clamp = np.zeros(cap, np.int32), np.zeros(nv, np.int32)
|
|
211
|
+
cp, cs, ints, mn = np.zeros(ccap, np.int32), np.zeros(ccap, np.int32), np.zeros(6, np.int32), np.zeros(1)
|
|
212
|
+
M, fs, as_ = np.zeros((nv, nv)), np.zeros(nv), np.zeros(nv)
|
|
213
|
+
self.lib.soft_substep_tape(self.h, ptr(q, "d"), ptr(v, "d"), ptr(w, "d"), ptr(c, "d"), ctypes.c_double(foot_friction),
|
|
214
|
+
iterations, ctypes.c_double(tolerance), ptr(a_star, "d"), ptr(a_adv, "d"), ptr(LH, "d"),
|
|
215
|
+
ptr(LQ, "d"), cap, ptr(zone, "i"), ptr(clamp, "i"), ccap, ptr(cp, "i"), ptr(cs, "i"),
|
|
216
|
+
ptr(ints, "i"), ptr(mn, "d"), ptr(M, "d"), ptr(fs, "d"), ptr(as_, "d"))
|
|
217
|
+
assert ints[4] == 0, "tape over capacity"
|
|
218
|
+
ncon, nefc = int(ints[0]), int(ints[1])
|
|
219
|
+
rec = dict(a_star=a_star, a_adv=a_adv, L_H=np.tril(LH), L_Q=np.tril(LQ), zone=zone[:nefc].copy(), clamp=clamp,
|
|
220
|
+
con_pair=cp[:ncon].copy(), con_slot=cs[:ncon].copy(), ncon=ncon, nefc=nefc, nlim=int(ints[2]),
|
|
221
|
+
niter=int(ints[3]), min_nu=float(mn[0]), M=M, qfrc_smooth=fs, qacc_smooth=as_, flags=int(ints[5]),
|
|
222
|
+
ints=ints.copy())
|
|
223
|
+
return q, v, w, rec
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Soft.substep_tape = substep_tape
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def qpos_raw_to_tangent(self, q, dq):
|
|
230
|
+
"""A qpos-space derivative dq (raw, nq, at qpos q) to the tangent (nv): the root's translation as is, its rotation
|
|
231
|
+
delta = 2 Im(conj(quat) * dquat) (the inverse of dquat = 0.5 quat * (0, delta), mj_integratePos's local convention),
|
|
232
|
+
hinges by their dof address. dq may be [..., nq]."""
|
|
233
|
+
dq = np.asarray(dq)
|
|
234
|
+
out = np.zeros(dq.shape[:-1] + (self.nv,))
|
|
235
|
+
for b in self.L["bodies"]:
|
|
236
|
+
if b["jnt_type"] == 0:
|
|
237
|
+
a, d = b["qadr"], b["dadr"]
|
|
238
|
+
out[..., d:d + 3] = dq[..., a:a + 3]
|
|
239
|
+
w, x, y, z = q[a + 3:a + 7]
|
|
240
|
+
dw, dx, dy, dz = (dq[..., a + 3 + k] for k in range(4))
|
|
241
|
+
# Im(conj(q) * dq), conj(q) = (w, -x, -y, -z)
|
|
242
|
+
out[..., d + 3] = 2 * (w * dx - x * dw - y * dz + z * dy)
|
|
243
|
+
out[..., d + 4] = 2 * (w * dy + x * dz - y * dw - z * dx)
|
|
244
|
+
out[..., d + 5] = 2 * (w * dz - x * dy + y * dx - z * dw)
|
|
245
|
+
elif b["jnt_type"] == 3:
|
|
246
|
+
out[..., b["dadr"]] = dq[..., b["qadr"]]
|
|
247
|
+
return out
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def control_step_jvp_tan(self, qpos, qvel, warm, ctrl, vq, vv, vu, foot_friction=-1.0, nsub=None, iterations=0, tolerance=0.0):
|
|
251
|
+
"""control_step_jvp with the qpos output in the tangent (the agreed VJP convention, 59 11:2x): returns (qpos, qvel, warm,
|
|
252
|
+
dq_tan [ndir, nv], dv [ndir, nv], flags). The tangent is taken at the OUTPUT qpos."""
|
|
253
|
+
q1, v1, w1, dq, dv, fl = self.control_step_jvp(qpos, qvel, warm, ctrl, vq, vv, vu, foot_friction, nsub, iterations, tolerance)
|
|
254
|
+
return q1, v1, w1, self.qpos_raw_to_tangent(q1, dq), dv, fl
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
Soft.qpos_raw_to_tangent = qpos_raw_to_tangent
|
|
258
|
+
Soft.control_step_jvp_tan = control_step_jvp_tan
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def body_ids(self, names):
|
|
262
|
+
"""the law's body indices of the given body names (e.g. 'robot/torso_link')"""
|
|
263
|
+
idx = {b["name"]: i for i, b in enumerate(self.L["bodies"])}
|
|
264
|
+
missing = [n for n in names if n not in idx]
|
|
265
|
+
assert not missing, f"bodies not in the law: {missing}"
|
|
266
|
+
return np.ascontiguousarray([idx[n] for n in names], np.int32)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
Soft.body_ids = body_ids
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def _batch_inputs(self, qpos, qvel, warm, ctrl, foot_friction):
|
|
273
|
+
q, v, w = (np.array(x, np.float64, order="C") for x in (qpos, qvel, warm)) # copies: the call steps them in place
|
|
274
|
+
n = q.shape[0]
|
|
275
|
+
assert q.shape == (n, self.nq) and v.shape == (n, self.nv) and w.shape == (n, self.nv), (q.shape, v.shape, w.shape)
|
|
276
|
+
c = np.ascontiguousarray(ctrl, np.float64)
|
|
277
|
+
assert c.shape == (n, self.nu), c.shape
|
|
278
|
+
f = np.asarray(foot_friction, np.float64)
|
|
279
|
+
if f.ndim == 0:
|
|
280
|
+
fp, fs = None, float(f)
|
|
281
|
+
else:
|
|
282
|
+
assert f.shape == (n,), f.shape
|
|
283
|
+
f = np.ascontiguousarray(f)
|
|
284
|
+
fp, fs = f, -1.0
|
|
285
|
+
return q, v, w, c, fp, fs
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def control_step_batch(self, qpos, qvel, warm, ctrl, foot_friction, nsub=None, iterations=0, tolerance=0.0, nthreads=1,
|
|
289
|
+
bodies=None):
|
|
290
|
+
"""d5's API (A) +: one control step for n envs in MuJoCo's native layout. qpos [n, nq], qvel [n, nv], warm [n, nv],
|
|
291
|
+
ctrl [n, nu], foot_friction scalar or [n]; bodies: body indices (Soft.body_ids) whose frames at the output state are
|
|
292
|
+
returned. Returns dict(qpos, qvel, warm, stats [n, nsub, 6] (ncon, nefc, niter, warm_used, decision hash lo / hi),
|
|
293
|
+
xpos [n, nbt, 3], xquat [n, nbt, 4], and the bodies' world velocities at the output state as the trainer defines them
|
|
294
|
+
(diffneusim.model.monitor.body_twists_from_poses): xvel [n, nbt, 3] (the body origin's linear velocity), xangvel [n, nbt, 3]).
|
|
295
|
+
The GPU path keeps this signature (device arrays)."""
|
|
296
|
+
q, v, w, c, fp, fs = _batch_inputs(self, qpos, qvel, warm, ctrl, foot_friction)
|
|
297
|
+
n = q.shape[0]
|
|
298
|
+
nsub = nsub or self.L["opt"]["decimation"]
|
|
299
|
+
st = np.zeros((n, nsub, 6), np.int32)
|
|
300
|
+
b = np.zeros(0, np.int32) if bodies is None else np.ascontiguousarray(bodies, np.int32)
|
|
301
|
+
xp, xq = np.zeros((n, len(b), 3)), np.zeros((n, len(b), 4))
|
|
302
|
+
xv, xw = np.zeros((n, len(b), 3)), np.zeros((n, len(b), 3))
|
|
303
|
+
nb = len(b)
|
|
304
|
+
fn = self.lib.soft_control_step_batch
|
|
305
|
+
if self.anchor is not None: # COMDR: world i on a model with the anchor's ipos shifted by its offset
|
|
306
|
+
assert self.anchor[1].shape[0] == n, ("the anchor offset was set for another number of worlds", self.anchor[1].shape, n)
|
|
307
|
+
fn = self.lib.soft_control_step_batch_anc
|
|
308
|
+
fn(self.h, n, ptr(q, "d"), ptr(v, "d"), ptr(w, "d"), ptr(c, "d"),
|
|
309
|
+
None if fp is None else ptr(fp, "d"), ctypes.c_double(fs), nsub, iterations,
|
|
310
|
+
ctypes.c_double(tolerance), nthreads, ptr(st, "i"), nb,
|
|
311
|
+
ptr(b, "i") if nb else None, ptr(xp, "d") if nb else None,
|
|
312
|
+
ptr(xq, "d") if nb else None, ptr(xv, "d") if nb else None, ptr(xw, "d") if nb else None)
|
|
313
|
+
return dict(qpos=q, qvel=v, warm=w, stats=st, xpos=xp, xquat=xq, xvel=xv, xangvel=xw)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
Soft.control_step_batch = control_step_batch
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def control_step_jvp_batch(self, qpos, qvel, warm, ctrl, vq, vv, vu, foot_friction, nsub=None, iterations=0, tolerance=0.0,
|
|
320
|
+
nthreads=1, bodies=None, pose_jvp=True):
|
|
321
|
+
"""the batched control step with its JVP along ndir <= 4 directions per env: vq [n, ndir, nv] (qpos tangent: root world
|
|
322
|
+
translation, root body-frame rotation, hinges), vv [n, ndir, nv], vu [n, ndir, nu]. Returns control_step_batch's
|
|
323
|
+
values (stats replaced by flags [n, nsub, 5]) plus dq [n, ndir, nq] (raw qpos; qpos_raw_to_tangent maps it to the
|
|
324
|
+
tangent), dv [n, ndir, nv], and with bodies the tracked poses and velocities with their JVP: dxpos [n, ndir, nbt, 3],
|
|
325
|
+
dxquat [n, ndir, nbt, 4] (raw quaternion), dxvel / dxangvel [n, ndir, nbt, 3]."""
|
|
326
|
+
q, v, w, c, fp, fs = _batch_inputs(self, qpos, qvel, warm, ctrl, foot_friction)
|
|
327
|
+
n = q.shape[0]
|
|
328
|
+
vq, vv, vu = (np.ascontiguousarray(x, np.float64) for x in (vq, vv, vu))
|
|
329
|
+
ndir = vq.shape[1]
|
|
330
|
+
assert 1 <= ndir <= 4 and vq.shape == (n, ndir, self.nv) and vv.shape == (n, ndir, self.nv) and \
|
|
331
|
+
vu.shape == (n, ndir, self.nu), (vq.shape, vv.shape, vu.shape)
|
|
332
|
+
nsub = nsub or self.L["opt"]["decimation"]
|
|
333
|
+
dq, dv, fl = np.zeros((n, ndir, self.nq)), np.zeros((n, ndir, self.nv)), np.zeros((n, nsub, 5), np.int32)
|
|
334
|
+
b = np.zeros(0, np.int32) if bodies is None else np.ascontiguousarray(bodies, np.int32)
|
|
335
|
+
nb = len(b)
|
|
336
|
+
xp, xq = np.zeros((n, nb, 3)), np.zeros((n, nb, 4))
|
|
337
|
+
dxp, dxq = np.zeros((n, ndir, nb, 3)), np.zeros((n, ndir, nb, 4))
|
|
338
|
+
xv, xw, dxv, dxw = np.zeros((n, nb, 3)), np.zeros((n, nb, 3)), np.zeros((n, ndir, nb, 3)), np.zeros((n, ndir, nb, 3))
|
|
339
|
+
want = nb and pose_jvp
|
|
340
|
+
fn = self.lib.soft_control_step_jvp_batch
|
|
341
|
+
if self.anchor is not None: # COMDR, as control_step_batch
|
|
342
|
+
assert self.anchor[1].shape[0] == n, ("the anchor offset was set for another number of worlds", self.anchor[1].shape, n)
|
|
343
|
+
fn = self.lib.soft_control_step_jvp_batch_anc
|
|
344
|
+
fn(
|
|
345
|
+
self.h, n, ptr(q, "d"), ptr(v, "d"), ptr(w, "d"), ptr(c, "d"), None if fp is None else ptr(fp, "d"),
|
|
346
|
+
ctypes.c_double(fs), nsub, iterations, ctypes.c_double(tolerance), nthreads, ndir, ptr(vq, "d"), ptr(vv, "d"),
|
|
347
|
+
ptr(vu, "d"), ptr(dq, "d"), ptr(dv, "d"), ptr(fl, "i"), nb, ptr(b, "i") if nb else None,
|
|
348
|
+
ptr(xp, "d") if nb else None, ptr(xq, "d") if nb else None, ptr(dxp, "d") if want else None,
|
|
349
|
+
ptr(dxq, "d") if want else None, ptr(xv, "d") if nb else None, ptr(xw, "d") if nb else None,
|
|
350
|
+
ptr(dxv, "d") if want else None, ptr(dxw, "d") if want else None)
|
|
351
|
+
out = dict(qpos=q, qvel=v, warm=w, flags=fl, dq=dq, dv=dv, xpos=xp, xquat=xq, xvel=xv, xangvel=xw)
|
|
352
|
+
if want:
|
|
353
|
+
out.update(dxpos=dxp, dxquat=dxq, dxvel=dxv, dxangvel=dxw)
|
|
354
|
+
return out
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
Soft.control_step_jvp_batch = control_step_jvp_batch
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def body_frames(self, qpos, qvel, bodies):
|
|
361
|
+
"""the bodies' frames and world velocities at given states (no step): qpos [n, nq], qvel [n, nv] -> dict(xpos, xquat,
|
|
362
|
+
xvel, xangvel), the definitions of control_step_batch's outputs"""
|
|
363
|
+
q, v = np.ascontiguousarray(qpos, np.float64), np.ascontiguousarray(qvel, np.float64)
|
|
364
|
+
n = q.shape[0]
|
|
365
|
+
b = np.ascontiguousarray(bodies, np.int32)
|
|
366
|
+
nb = len(b)
|
|
367
|
+
xp, xq, xv, xw = np.zeros((n, nb, 3)), np.zeros((n, nb, 4)), np.zeros((n, nb, 3)), np.zeros((n, nb, 3))
|
|
368
|
+
self.lib.soft_body_frames(self.h, n, ptr(q, "d"), ptr(v, "d"), nb, ptr(b, "i"), ptr(xp, "d"), ptr(xq, "d"), ptr(xv, "d"),
|
|
369
|
+
ptr(xw, "d"))
|
|
370
|
+
return dict(xpos=xp, xquat=xq, xvel=xv, xangvel=xw)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
Soft.body_frames = body_frames
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""The soft law's GPU control step (bindings/soft_engine_ext.cu) behind tools/d16/soft_capi.py's API, on device tensors.
|
|
2
|
+
eng = SoftEngine(n, bodies=None, dtype=torch.float32, fmad=True)
|
|
3
|
+
out = eng.control_step_batch(qpos, qvel, warm, ctrl, foot_friction) # dict(qpos, qvel, warm, stats, xpos, xquat, xvel, xangvel)
|
|
4
|
+
eng.flags() # the OR of every world's flag word since the last eng.zero_flags(); read once per iteration (a host sync)
|
|
5
|
+
All buffers are allocated once here; control_step_batch launches only (graph-capturable). The extension's name carries the model
|
|
6
|
+
header's hash and a hash of its nvcc flags (memory: ext-build-name-must-be-unique-per-flag-set)."""
|
|
7
|
+
import hashlib
|
|
8
|
+
import os
|
|
9
|
+
import pathlib
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import torch
|
|
13
|
+
|
|
14
|
+
from diffneusim._paths import ROOT as ROOT # (3a) the repo root
|
|
15
|
+
# (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16"))
|
|
16
|
+
from diffneusim.engine import hand_format # noqa: E402
|
|
17
|
+
from diffneusim.engine import tape_format # noqa: E402
|
|
18
|
+
from diffneusim.engine import soft_capi # noqa: E402
|
|
19
|
+
|
|
20
|
+
MODEL_ID = "g1_soft_5db44fd45286"
|
|
21
|
+
NQ, NV, NU, NSUB = 36, 35, 29, 4
|
|
22
|
+
ROWS, IDENTITY, ALLBIG = 31, 15, 47 # control_step parts: the row-count order + big kernel (v10b's production dispatch); v0's
|
|
23
|
+
# identity; every world on the big kernel
|
|
24
|
+
ORDER_IT, TAIL_PAD = 16384, 32768 # v15 arms: k_order_it (rows x previous iterations); the padded heavy launch + fork-join
|
|
25
|
+
TA = ROWS | ORDER_IT | TAIL_PAD # v15b's tail-aware dispatch (substeps 1-3; substep 0 keeps the row order): production since
|
|
26
|
+
# 2026-11-02 21:2x (the review's GO) wherever it is defined (f32, one chunk, n > the extension's K); its outputs, tape and adjoint
|
|
27
|
+
# are bitwise ROWS' (b3 TA)
|
|
28
|
+
ROWS_ARCHS = {(9, 0)} # the devices whose production dispatch is the row order although TA is defined: sm_90 (the H200), where
|
|
29
|
+
# the row order measured faster (diag job 11609408, 11-04 03:1x, 4096 worlds, one process, A/B/A at 1,980 MHz: forward 2.047 vs
|
|
30
|
+
# 2.203 ms on c4096_long13 and 2.040 vs 2.271 on the held-out corpus, step + gradient 2.986 vs 3.152 and 3.076 vs 3.319); TA
|
|
31
|
+
# stays on sm_89 (the 4090, 1.200 vs 1.228 ms: prod_c75aea8c's b3) and on every device not measured. The outputs, the tape and
|
|
32
|
+
# the adjoint are the same bits either way (b3 TA), so this choice moves the time only
|
|
33
|
+
_EXT = {}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def load_ext(fmad=True, verbose=False, init=True, comdr=False):
|
|
37
|
+
"""build (once per flag set) and load the extension; init=False only builds (a CPU prebuild with CUDA hidden). comdr: the
|
|
38
|
+
deck-only COMDR build (-DD16_G1_COMDR: a per-world CoM offset of the anchor body, tools/g1_seconds/COMDR_DESIGN.md), set only by
|
|
39
|
+
this argument (no environment variable), its own library name and cache key"""
|
|
40
|
+
key = (bool(fmad), bool(comdr))
|
|
41
|
+
if key in _EXT:
|
|
42
|
+
return _EXT[key]
|
|
43
|
+
law = ROOT / "models" / "derived" / "unitree_g1_soft_law.json"
|
|
44
|
+
assert hashlib.sha256(law.read_bytes()).hexdigest()[:12] == MODEL_ID.split("_")[-1], "the law JSON is not the generated header's"
|
|
45
|
+
if soft_capi.LAW != law: # D16_G1_LAW: the same G1 with other contact pairs. The header (l1_gen.py) holds no pair or geom
|
|
46
|
+
# data and L2 reads the pair table at run time (np <= kV2NP), so this build serves it if everything but the pairs is equal
|
|
47
|
+
import json
|
|
48
|
+
alt, prod = json.loads(soft_capi.LAW.read_text()), json.loads(law.read_text())
|
|
49
|
+
strip = lambda d: {k: v for k, v in d.items() if k not in ("pairs", "derived")} # noqa: E731
|
|
50
|
+
assert strip(alt) == strip(prod), f"{soft_capi.LAW} differs from the production law beyond its pairs"
|
|
51
|
+
assert len(alt["pairs"]) <= len(prod["pairs"]), "more pairs than the compiled capacity"
|
|
52
|
+
# the #53 runner's engine cache (the review's rule 3, 11-11): D16_ENGINE_SRC_ROOT names ONE canonical tree per engine source hash, so the
|
|
53
|
+
# sources and include paths torch's JIT keys on are the same for every commit with this engine (built once, reused). Fail fast if its
|
|
54
|
+
# engine sources differ from this tree's (bindings/, core/, byte for byte)
|
|
55
|
+
src = pathlib.Path(os.environ["D16_ENGINE_SRC_ROOT"]).resolve() if os.environ.get("D16_ENGINE_SRC_ROOT") else ROOT
|
|
56
|
+
if src != ROOT:
|
|
57
|
+
for d in ("bindings", "core"):
|
|
58
|
+
mine = sorted(q.relative_to(ROOT) for q in (ROOT / d).rglob("*") if q.is_file())
|
|
59
|
+
theirs = sorted(q.relative_to(src) for q in (src / d).rglob("*") if q.is_file())
|
|
60
|
+
assert mine == theirs and all((ROOT / q).read_bytes() == (src / q).read_bytes() for q in mine), \
|
|
61
|
+
f"D16_ENGINE_SRC_ROOT={src}: its {d}/ differs from this tree's"
|
|
62
|
+
from torch.utils.cpp_extension import load
|
|
63
|
+
# the gate build (f64 correctness, -fmad=false) keeps the device asserts (JS_DEVICE_ASSERT, -DJS_DEVICE_ASSERTS); production drops them
|
|
64
|
+
flags = ["-O3", "-std=c++17", "-lineinfo"] + ([] if fmad else ["-fmad=false", "-DJS_DEVICE_ASSERTS"]) + \
|
|
65
|
+
os.environ.get("D16_ENGINE_EXTRA", "").split()
|
|
66
|
+
assert "-DD16_G1_COMDR" not in flags, "D16_G1_COMDR is set by load_ext(comdr=True) only"
|
|
67
|
+
if comdr:
|
|
68
|
+
flags.append("-DD16_G1_COMDR")
|
|
69
|
+
# the flags and every file the build reads (its include closure, every generated header): the flags alone reused a stale build
|
|
70
|
+
# after any source edit (ENGINE_UNIFY_PLAN.md item 3.0.5). Hashed over src, the tree the build reads (D16_ENGINE_SRC_ROOT's bindings/
|
|
71
|
+
# and core/ are asserted byte-identical to this tree's above, so the tag is the same either way)
|
|
72
|
+
import importlib.util
|
|
73
|
+
_s = importlib.util.spec_from_file_location("d16_build_tag", ROOT / "engine" / "build_tag.py") # (3b g1) was: ROOT / "tools" / "d16" / "build_tag.py"
|
|
74
|
+
BT = importlib.util.module_from_spec(_s)
|
|
75
|
+
_s.loader.exec_module(BT)
|
|
76
|
+
tag = BT.tag(src, [src / "bindings" / "soft_engine_ext.cu"], flags)
|
|
77
|
+
ext = load(name=f"soft_engine_{MODEL_ID}_{tag}", sources=[str(src / "bindings" / "soft_engine_ext.cu")],
|
|
78
|
+
extra_include_paths=[str(src / "core"), str(src / "core" / "include"), str(src / "bindings")],
|
|
79
|
+
extra_cuda_cflags=flags, extra_cflags=["-O2", "-std=c++17"] + (["-DD16_G1_COMDR"] if comdr else []), verbose=verbose)
|
|
80
|
+
assert hasattr(ext, "comdr") == bool(comdr), ("the loaded extension's COMDR build differs from the request", comdr)
|
|
81
|
+
if not init:
|
|
82
|
+
return ext, None
|
|
83
|
+
# the CPU law's handle is built by soft_capi.cpp INSIDE this extension (the same Model the kernels read)
|
|
84
|
+
soft_capi.LIB = pathlib.Path(ext.__file__)
|
|
85
|
+
soft_capi.build = lambda: None
|
|
86
|
+
s = soft_capi.Soft()
|
|
87
|
+
rb = torch.tensor([g["rbound"] for g in s.L["geoms"]], dtype=torch.float32)
|
|
88
|
+
ext.init(int(s.h.value), rb)
|
|
89
|
+
_EXT[key] = (ext, s)
|
|
90
|
+
return ext, s
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class SoftEngine:
|
|
94
|
+
def __init__(self, n, bodies=None, dtype=torch.float32, fmad=True, device="cuda", tape=False, dense=False, chunks=1):
|
|
95
|
+
self.ext, self.soft = load_ext(fmad)
|
|
96
|
+
# v8: the worlds' chunks per substep (k_pre .. tail run per chunk, so a chunk's hands stay in L2); 1 = one launch set
|
|
97
|
+
assert chunks == 1 or (hasattr(self.ext, "max_chunks") and 1 <= chunks <= self.ext.max_chunks()), chunks
|
|
98
|
+
self.chunks = int(chunks)
|
|
99
|
+
# the production dispatch for this engine: TA where it is defined, else the row order (the padded launch is f32-only and
|
|
100
|
+
# needs one chunk and more worlds than its K heavy slots); the row order on the ROWS_ARCHS devices
|
|
101
|
+
K = int(self.ext.tail()[0])
|
|
102
|
+
self.cc = tuple(torch.cuda.get_device_capability(torch.device(device)))
|
|
103
|
+
self.prod = TA if (dtype == torch.float32 and self.chunks == 1 and n > K and self.cc not in ROWS_ARCHS) else ROWS
|
|
104
|
+
self.n, self.dt = n, dtype
|
|
105
|
+
f = lambda *shape: torch.zeros(*shape, dtype=dtype, device=device) # noqa: E731
|
|
106
|
+
i = lambda *shape, dt=torch.int32: torch.zeros(*shape, dtype=dt, device=device) # noqa: E731
|
|
107
|
+
# the hand's size from the extension's compiled layout (soft_hand_layout's output length changed with min_nu, 31232470:
|
|
108
|
+
# an 18-int buffer read at [17] overflowed and read rowmeta, a segfault on the laptop GPU)
|
|
109
|
+
hw = int(self.ext.hand_words())
|
|
110
|
+
# and the named C ABI agrees (the 891f7639: hand_format.layout asserts the library's entry count and names, so a
|
|
111
|
+
# reorder of the same length fails too); its words at the decoder's capacities must equal the compiled layout's
|
|
112
|
+
h = hand_format.layout(self.soft.lib, NV)
|
|
113
|
+
assert h["words"] == hw, ("the C ABI's hand layout is not the one the kernels are compiled with", h["words"], hw)
|
|
114
|
+
self.b = dict(oq=f(n, NQ), ov=f(n, NV), ow=f(n, NV), sq=f(n, NQ), sv=f(n, NV), sw=f(n, NV), hand=f(n, hw), nefc=i(n),
|
|
115
|
+
a_adv=f(n, NV), qfrc_c=f(n, NV) if dense else f(0), LH=f(n, NV * (NV + 1) // 2) if dense else f(0),
|
|
116
|
+
LQ=f(n, NV * (NV + 1) // 2) if dense else f(0), zone=i(n, 6) if dense else i(0), niter=i(n),
|
|
117
|
+
kflags=i(n), nls=i(n), nfact=i(n), cycles=i(n, dt=torch.int64), flags=i(n), stats=i(n, NSUB, 6),
|
|
118
|
+
order=i(n), nbig=i(self.chunks))
|
|
119
|
+
# the tape (tape=True): [n, NSUB, words] per control step, written by the forward (k_post: every word but POSE; k_pre: POSE)
|
|
120
|
+
# and read by adjoint(); the words from the compiled layout, checked against the named ABI (count, names: 891f7639)
|
|
121
|
+
tw = int(self.ext.tape_words())
|
|
122
|
+
tl = tape_format.layout(self.soft.lib, NQ, NV, 64, 192, 32)
|
|
123
|
+
assert tl["words"] == tw, ("the C ABI's tape layout is not the one the kernels are compiled with", tl["words"], tw)
|
|
124
|
+
self.tape = f(n, NSUB, tw) if tape else f(0)
|
|
125
|
+
self.adj = dict(q_bar=f(n, NV), v_bar=f(n, NV), u_bar=f(n, NU), aflags=i(n), foot=torch.zeros(n, dtype=torch.float64, device=device),
|
|
126
|
+
cycles=i(n, dt=torch.int64)) if tape else None
|
|
127
|
+
self.empty = f(0)
|
|
128
|
+
self.bodies = torch.tensor([] if bodies is None else list(bodies), dtype=torch.int32, device=device)
|
|
129
|
+
nbt = len(self.bodies)
|
|
130
|
+
self.b.update(xpos=f(n, nbt, 3), xquat=f(n, nbt, 4), xvel=f(n, nbt, 3), xangvel=f(n, nbt, 3))
|
|
131
|
+
|
|
132
|
+
def control_step_batch(self, qpos, qvel, warm, ctrl, foot_friction, parts=None):
|
|
133
|
+
"""parts: 1 k_pre, 2 k_post, 4 the flag / stats tail, 8 the frames; 16 the row-count order with the big kernel for the
|
|
134
|
+
worlds over 128 rows (production), 32 every world on the big kernel (its positive control); neither: identity order,
|
|
135
|
+
all on the 128-row kernel (v0). A subset of 1-8 is for timing only. None: this engine's production dispatch (self.prod)."""
|
|
136
|
+
if parts is None:
|
|
137
|
+
parts = self.prod
|
|
138
|
+
fr = foot_friction if torch.is_tensor(foot_friction) else torch.full((self.n,), float(foot_friction), dtype=self.dt,
|
|
139
|
+
device=qpos.device)
|
|
140
|
+
b = self.b
|
|
141
|
+
self.ext.control_step(qpos, qvel, warm, ctrl, fr, b["oq"], b["ov"], b["ow"], b["sq"], b["sv"], b["sw"], b["hand"], b["nefc"],
|
|
142
|
+
b["a_adv"], b["qfrc_c"], b["LH"], b["LQ"], b["zone"], b["niter"], b["kflags"], b["nls"], b["nfact"],
|
|
143
|
+
b["cycles"], b["flags"], b["stats"], self.bodies, b["xpos"], b["xquat"], b["xvel"], b["xangvel"], b["order"], b["nbig"], self.tape, NSUB,
|
|
144
|
+
parts | (self.chunks << 8 if self.chunks > 1 else 0))
|
|
145
|
+
if self.adj is not None:
|
|
146
|
+
self.adj["foot"].copy_(fr) # the adjoint reads the forward's foot friction in f64 (B's RowsBFactory)
|
|
147
|
+
return dict(qpos=b["oq"], qvel=b["ov"], warm=b["ow"], stats=b["stats"], xpos=b["xpos"], xquat=b["xquat"], xvel=b["xvel"],
|
|
148
|
+
xangvel=b["xangvel"])
|
|
149
|
+
|
|
150
|
+
def adjoint(self, wq, wv, xpos_bar=None, xrot_bar=None, vb_bar=None, wb_bar=None, cycles=False):
|
|
151
|
+
"""the last control step's VJP from its tape: wq [n, 35] (the output q's cotangent in the tangent at the output q), wv
|
|
152
|
+
[n, 35], the output frames' cotangents [n, 32, 3] each (optional) -> dict(q_bar [n, 35] tangent at the input q, v_bar,
|
|
153
|
+
u_bar [n, 29], aflags [n]); launches only (graph-capturable)"""
|
|
154
|
+
assert self.adj is not None, "SoftEngine(tape=True) first"
|
|
155
|
+
a, e = self.adj, self.empty
|
|
156
|
+
self.ext.adjoint(self.tape, self.b["oq"], self.b["ov"], wq, wv, a["foot"], e if xpos_bar is None else xpos_bar,
|
|
157
|
+
e if xrot_bar is None else xrot_bar, e if vb_bar is None else vb_bar, e if wb_bar is None else wb_bar,
|
|
158
|
+
a["q_bar"], a["v_bar"], a["u_bar"], a["aflags"], a["cycles"] if cycles else e, NSUB)
|
|
159
|
+
return dict(q_bar=a["q_bar"], v_bar=a["v_bar"], u_bar=a["u_bar"], aflags=a["aflags"])
|
|
160
|
+
|
|
161
|
+
def zero_flags(self):
|
|
162
|
+
self.b["flags"].zero_()
|
|
163
|
+
|
|
164
|
+
def flags(self):
|
|
165
|
+
return int(np.bitwise_or.reduce(self.b["flags"].cpu().numpy()))
|