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,115 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// Portions of this file are translated from MuJoCo 3.16.0 (https://github.com/google-deepmind/mujoco), Copyright 2021
|
|
3
|
+
// DeepMind Technologies Limited, licensed under the Apache License, Version 2.0. Changed by this project: transcribed to
|
|
4
|
+
// templated C++ (double, Dual, float), restructured for the G1 soft law and the GPU path. See core/soft/NOTICE.md.
|
|
5
|
+
// D16 C1 (2026-11-02): MuJoCo 3.16.0's soft-constraint impedance, regularizer and reference acceleration,
|
|
6
|
+
// the non-metric path (mj_isMetric(m) == 0, i.e. not the discrete integrator: the G1 scene is implicitfast). Transcribed
|
|
7
|
+
// from engine_core_constraint.c at tag 3.16.0; docs-dev/engine-model/20261102_d16_engine_redesign/LAW_SPEC_MUJOCO316.md
|
|
8
|
+
// cites the lines. Templated on the row scalar S: double for the law, js::diff::Dual for C2's forward-mode IFT JVP (the
|
|
9
|
+
// branches dispatch on the value, as MuJoCo's do). The model constants (solref, solimp, timestep, invweights) stay double.
|
|
10
|
+
#include <cassert>
|
|
11
|
+
|
|
12
|
+
#include "diffneusim/macros.h"
|
|
13
|
+
#include "../math/so3.h"
|
|
14
|
+
|
|
15
|
+
namespace js::soft {
|
|
16
|
+
|
|
17
|
+
constexpr double kMinVal = 1e-15; // mjMINVAL (mjtype.h, double build)
|
|
18
|
+
constexpr double kMinImp = 0.0001; // mjMINIMP (mdnmodel.h)
|
|
19
|
+
constexpr double kMaxImp = 0.9999; // mjMAXIMP
|
|
20
|
+
|
|
21
|
+
template <class T> DN_HOST_DEVICE T smax(T a, T b) { return a < b ? b : a; }
|
|
22
|
+
template <class T> DN_HOST_DEVICE T smin(T a, T b) { return a < b ? a : b; }
|
|
23
|
+
|
|
24
|
+
// The parameter type P of the functions below (D16 L2 v2.1, 2026-11-02): double by default (the CPU law and C2's Dual JVP,
|
|
25
|
+
// unchanged), float on the GPU's f32 path, whose parameters are precomputed in f32 so no FP64 instruction runs there.
|
|
26
|
+
// lit_t<S>: the type a literal is compared in where no P is at hand: float for S = float, else double (double, and Dual,
|
|
27
|
+
// which compares against double only).
|
|
28
|
+
template <class S> struct LitType { using type = double; };
|
|
29
|
+
template <> struct LitType<float> { using type = float; };
|
|
30
|
+
template <class S> using lit_t = typename LitType<S>::type;
|
|
31
|
+
|
|
32
|
+
// solref / solimp of one row after getsolparam's checks (:1726-1802), non-metric: refsafe imposes
|
|
33
|
+
// timeconst >= 2 timestep (standard format only), solimp clamped to its valid ranges.
|
|
34
|
+
struct SolParam {
|
|
35
|
+
double ref[2]; // (timeconst, dampratio) standard if both > 0; direct (-stiffness, -damping) if both <= 0
|
|
36
|
+
double imp[5]; // (d0, dwidth, width, midpoint, power)
|
|
37
|
+
};
|
|
38
|
+
DN_HOST_DEVICE inline SolParam sol_param(const double* solref, const double* solimp, double timestep,
|
|
39
|
+
bool refsafe = true) {
|
|
40
|
+
SolParam p;
|
|
41
|
+
p.ref[0] = solref[0];
|
|
42
|
+
p.ref[1] = solref[1];
|
|
43
|
+
// a mixed format is replaced by MuJoCo's default with a warning; the engine refuses it instead (fail fast)
|
|
44
|
+
assert(!((p.ref[0] > 0) ^ (p.ref[1] > 0)) && "mixed solref format");
|
|
45
|
+
if (refsafe && p.ref[0] > 0) p.ref[0] = smax(p.ref[0], 2 * timestep);
|
|
46
|
+
p.imp[0] = smin(kMaxImp, smax(kMinImp, solimp[0]));
|
|
47
|
+
p.imp[1] = smin(kMaxImp, smax(kMinImp, solimp[1]));
|
|
48
|
+
p.imp[2] = smax(0.0, solimp[2]);
|
|
49
|
+
p.imp[3] = smin(kMaxImp, smax(kMinImp, solimp[3]));
|
|
50
|
+
p.imp[4] = smax(1.0, solimp[4]);
|
|
51
|
+
return p;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// a^b with MuJoCo's quick returns for b = 1, 2 (power, :1840); S = Dual needs the general branch only for b not in {1, 2}
|
|
55
|
+
template <class S, class P = double> DN_HOST_DEVICE S power_(S a, P b) {
|
|
56
|
+
if (b == P(1)) return a;
|
|
57
|
+
if (b == P(2)) return a * a;
|
|
58
|
+
using so3::js_exp; using so3::js_log;
|
|
59
|
+
return js_exp(js_log(a) * S(b)); // a > 0 here (x in (0, 1))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// getimpedance (:1851-1900): imp(pos) for x = (pos - margin) / width, |x| saturated at 0 and 1. (impP, the derivative
|
|
63
|
+
// MuJoCo stores in KBIP[3], is not needed: S = Dual carries the derivative.)
|
|
64
|
+
template <class S, class P = double> DN_HOST_DEVICE S impedance(const P* solimp, S pos, P margin) {
|
|
65
|
+
if (solimp[0] == solimp[1] || solimp[2] <= P(kMinVal)) return S(P(0.5) * (solimp[0] + solimp[1]));
|
|
66
|
+
S x = (pos - S(margin)) / S(solimp[2]);
|
|
67
|
+
if (x < P(0)) x = S(0) - x; // comparisons against P: our Dual compares on the value (dual.h)
|
|
68
|
+
if (x >= P(1) || x <= P(0)) return S(x >= P(1) ? solimp[1] : solimp[0]);
|
|
69
|
+
S y;
|
|
70
|
+
if (solimp[4] == P(1)) {
|
|
71
|
+
y = x;
|
|
72
|
+
} else if (x <= solimp[3]) {
|
|
73
|
+
const P a = P(1) / power_(solimp[3], solimp[4] - P(1));
|
|
74
|
+
y = S(a) * power_(x, solimp[4]);
|
|
75
|
+
} else {
|
|
76
|
+
const P b = P(1) / power_(P(1) - solimp[3], solimp[4] - P(1));
|
|
77
|
+
y = S(1) - S(b) * power_(S(1) - x, solimp[4]);
|
|
78
|
+
}
|
|
79
|
+
return S(solimp[0]) + y * S(solimp[1] - solimp[0]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// KBIP's K and B (mj_makeImpedance :1940-1962): standard or direct format; dof / tendon friction rows have K = 0.
|
|
83
|
+
template <class P = double> struct KBT { P K, B; };
|
|
84
|
+
using KB = KBT<double>;
|
|
85
|
+
DN_HOST_DEVICE inline KB stiffness_damping(const SolParam& p, bool friction_row) {
|
|
86
|
+
KB r;
|
|
87
|
+
if (friction_row) r.K = 0;
|
|
88
|
+
else if (p.ref[0] > 0) r.K = 1 / smax(kMinVal, p.imp[1] * p.imp[1] * p.ref[0] * p.ref[0] * p.ref[1] * p.ref[1]);
|
|
89
|
+
else r.K = -p.ref[0] / smax(kMinVal, p.imp[1] * p.imp[1]);
|
|
90
|
+
if (p.ref[1] > 0) r.B = 2 / smax(kMinVal, p.imp[1] * p.ref[0]);
|
|
91
|
+
else r.B = -p.ref[1] / smax(kMinVal, p.imp[1]);
|
|
92
|
+
return r;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// One row's regularizer R = max(mjMINVAL, (1 - imp) diagA / imp) (:1932), before the pyramidal pass.
|
|
96
|
+
template <class S, class P = double> DN_HOST_DEVICE S regularizer(S imp, P diagA) {
|
|
97
|
+
return smax(S(kMinVal), (S(1) - imp) * S(diagA) / imp);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The reference acceleration, non-metric (mj_referenceConstraint :3180-3218): aref = -B vel - K I (pos - margin).
|
|
101
|
+
template <class S, class P = double> DN_HOST_DEVICE S reference_accel(const KBT<P>& kb, S imp, S vel, S pos, P margin) {
|
|
102
|
+
return S(0) - S(kb.B) * vel - S(kb.K) * imp * (pos - S(margin));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The pyramidal pass (mj_makeImpedance :2030-2049) for one condim-3 contact: from the first row's R0 (its own
|
|
106
|
+
// imp and diagA), R1 = R0 / impratio, the regularized cone's mu = friction0 sqrt(R1 / R0), and every one of the four
|
|
107
|
+
// pyramid rows gets Rpy = 2 mu^2 R0. Returns Rpy; D = 1 / Rpy for all four rows.
|
|
108
|
+
template <class S, class P = double> DN_HOST_DEVICE S pyramid_regularizer(S R0, P friction0, P impratio) {
|
|
109
|
+
using so3::js_sqrt;
|
|
110
|
+
const S R1 = R0 / S(smax(P(kMinVal), impratio));
|
|
111
|
+
const S mu = S(friction0) * js_sqrt(R1 / R0);
|
|
112
|
+
return S(2) * mu * mu * R0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
} // namespace js::soft
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// D16 C2 (2026-11-02): the soft law's derivative, forward mode, the design's FD-gated condition (10-31). One substep
|
|
3
|
+
// in Dual<double, K> (K input directions), the decisions held from the primal (double) substep:
|
|
4
|
+
// the contact list (pair, slot), the rows, the solver's active (QUADRATIC) set, the actuator clamps.
|
|
5
|
+
// Smooth parts are differentiated by evaluating them in Dual: kinematics, M, qfrc_bias, the unclamped PD forces, the contacts
|
|
6
|
+
// and their rows (J, D, aref through the impedance and the reference). The Newton solve is differentiated through its
|
|
7
|
+
// optimality conditions at the returned iterate a* (the implicit function theorem, ∇Mimic App. B eq. 8-9):
|
|
8
|
+
// F(a, theta) = M a - qfrc_smooth + sum_active J' D (J a - aref) = 0, da* = -H^-1 dF/dtheta, H = M + sum_active D J' J,
|
|
9
|
+
// with H's factor from the primal solve. Then implicitfast's linear solve and the position integration in Dual. The warm
|
|
10
|
+
// start receives no derivative (it selects the iterate, not the converged solution).
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
#include "../diff/dual.h"
|
|
14
|
+
#include "step.h"
|
|
15
|
+
|
|
16
|
+
namespace js::soft {
|
|
17
|
+
|
|
18
|
+
template <int K> using DualK = js::diff::Dual<double, K>;
|
|
19
|
+
|
|
20
|
+
// x = A^-1 b for Dual A (n x n, full) and b: x.v from the double factor of A.v; x.d[k] = A.v^-1 (b.d[k] - A.d[k] x.v)
|
|
21
|
+
template <int K>
|
|
22
|
+
void dual_solve(const std::vector<DualK<K>>& A, const std::vector<DualK<K>>& b, std::vector<DualK<K>>& x, int n,
|
|
23
|
+
const double* Lfactor = nullptr) {
|
|
24
|
+
std::vector<double> L, v(n), r(n), xv(n);
|
|
25
|
+
if (Lfactor) {
|
|
26
|
+
L.assign(Lfactor, Lfactor + static_cast<size_t>(n) * n);
|
|
27
|
+
} else {
|
|
28
|
+
L.resize(static_cast<size_t>(n) * n);
|
|
29
|
+
for (int i = 0; i < n * n; ++i) L[i] = A[i].v;
|
|
30
|
+
newton::chol_factor(L.data(), n, kMinVal);
|
|
31
|
+
}
|
|
32
|
+
for (int i = 0; i < n; ++i) v[i] = b[i].v;
|
|
33
|
+
newton::chol_solve(L.data(), xv.data(), v.data(), n);
|
|
34
|
+
x.assign(n, DualK<K>(0.0));
|
|
35
|
+
for (int i = 0; i < n; ++i) x[i].v = xv[i];
|
|
36
|
+
for (int k = 0; k < K; ++k) {
|
|
37
|
+
for (int i = 0; i < n; ++i) {
|
|
38
|
+
double s = b[i].d[k];
|
|
39
|
+
for (int j = 0; j < n; ++j) s -= A[static_cast<size_t>(i) * n + j].d[k] * xv[j];
|
|
40
|
+
v[i] = s;
|
|
41
|
+
}
|
|
42
|
+
newton::chol_solve(L.data(), r.data(), v.data(), n);
|
|
43
|
+
for (int i = 0; i < n; ++i) x[i].d[k] = r[i];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// mju_quatIntegrate in Dual (the same steps as step.h quat_integrate)
|
|
48
|
+
template <class S> void quat_integrate_t(S* quat, const S* vel, double h) {
|
|
49
|
+
V3<S> a{vel[0], vel[1], vel[2]};
|
|
50
|
+
const S n = normalize3(a);
|
|
51
|
+
const S angle = S(h) * n;
|
|
52
|
+
S qrot[4] = {S(1), S(0), S(0), S(0)};
|
|
53
|
+
if (angle < 0.0 || angle > 0.0) {
|
|
54
|
+
using so3::js_sin; using so3::js_cos;
|
|
55
|
+
const S s = js_sin(S(0.5) * angle);
|
|
56
|
+
qrot[0] = js_cos(S(0.5) * angle); qrot[1] = a.x * s; qrot[2] = a.y * s; qrot[3] = a.z * s;
|
|
57
|
+
}
|
|
58
|
+
quat_normalize(quat);
|
|
59
|
+
S r[4];
|
|
60
|
+
quat_mul(quat, qrot, r);
|
|
61
|
+
for (int k = 0; k < 4; ++k) quat[k] = r[k];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
struct JvpFlags { int contact_set_changed = 0, nquadratic = 0, nclamped = 0, niter = 0, ncon = 0; };
|
|
65
|
+
|
|
66
|
+
// one substep: (qpos, qvel) Dual in / out, warm double in / out, ctrl Dual; iterations / tolerance of the primal solve
|
|
67
|
+
template <int K>
|
|
68
|
+
JvpFlags substep_jvp(const SoftModel& m, std::vector<DualK<K>>& qpos, std::vector<DualK<K>>& qvel, double* warm,
|
|
69
|
+
const std::vector<DualK<K>>& ctrl, double foot_friction) {
|
|
70
|
+
using D = DualK<K>;
|
|
71
|
+
const int nb = static_cast<int>(m.bodies.size()), nv = m.nv, nq = m.nq;
|
|
72
|
+
JvpFlags fl;
|
|
73
|
+
// --- the primal substep's decisions (double): rerun its pieces up to the solve
|
|
74
|
+
std::vector<double> q0(nq), v0(nv), c0(ctrl.size());
|
|
75
|
+
for (int i = 0; i < nq; ++i) q0[i] = qpos[i].v;
|
|
76
|
+
for (int i = 0; i < nv; ++i) v0[i] = qvel[i].v;
|
|
77
|
+
for (size_t u = 0; u < ctrl.size(); ++u) c0[u] = ctrl[u].v;
|
|
78
|
+
std::vector<BodyState<double>> X0(nb);
|
|
79
|
+
fk(m.bodies.data(), nb, q0.data(), X0.data());
|
|
80
|
+
std::vector<double> M0(static_cast<size_t>(nv) * nv), b0(nv), jp(3 * nv), jr(3 * nv), w(3 * nb), al(3 * nb), vo(3 * nb),
|
|
81
|
+
ao(3 * nb);
|
|
82
|
+
mass_matrix(m.bodies.data(), nb, X0.data(), nv, m.armature.data(), M0.data(), jp.data(), jr.data());
|
|
83
|
+
bias(m.bodies.data(), nb, X0.data(), nv, v0.data(), m.gravity, b0.data(), jp.data(), jr.data(), w.data(), al.data(),
|
|
84
|
+
vo.data(), ao.data());
|
|
85
|
+
std::vector<double> fact(nv, 0.0);
|
|
86
|
+
std::vector<char> clamped(nv, 0);
|
|
87
|
+
std::vector<double> fclamp(m.actuators.size(), 0.0);
|
|
88
|
+
for (size_t u = 0; u < m.actuators.size(); ++u) {
|
|
89
|
+
const SoftActuator& a = m.actuators[u];
|
|
90
|
+
double f = a.kp * c0[u] + (0 + (-a.kp) * q0[a.qadr] + (-a.kd) * v0[a.dof]);
|
|
91
|
+
if (a.forcelimited) {
|
|
92
|
+
f = f < a.lo ? a.lo : (f > a.hi ? a.hi : f);
|
|
93
|
+
if (f <= a.lo || f >= a.hi) { clamped[a.dof] = 1; ++fl.nclamped; }
|
|
94
|
+
}
|
|
95
|
+
fclamp[u] = f;
|
|
96
|
+
fact[a.dof] += f;
|
|
97
|
+
}
|
|
98
|
+
std::vector<double> fs0(nv), as0(nv), LM(M0);
|
|
99
|
+
for (int i = 0; i < nv; ++i) fs0[i] = fact[i] - b0[i];
|
|
100
|
+
newton::chol_factor(LM.data(), nv, kMinVal);
|
|
101
|
+
newton::chol_solve(LM.data(), as0.data(), fs0.data(), nv);
|
|
102
|
+
std::vector<SoftContact<double>> con0;
|
|
103
|
+
collide_all(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()),
|
|
104
|
+
X0.data(), foot_friction, con0);
|
|
105
|
+
Rows<double> rows0;
|
|
106
|
+
make_rows(m.bodies.data(), X0.data(), nv, m.dof_invweight0.data(), m.joints.data(), static_cast<int>(m.joints.size()),
|
|
107
|
+
m.geoms.data(), m.pairs.data(), con0, q0.data(), v0.data(), m.timestep, m.impratio, rows0);
|
|
108
|
+
newton::Problem pr;
|
|
109
|
+
pr.nv = nv; pr.nefc = rows0.n; pr.M = M0.data(); pr.qfrc_smooth = fs0.data(); pr.qacc_smooth = as0.data();
|
|
110
|
+
pr.J = rows0.J.data(); pr.aref = rows0.aref.data(); pr.D = rows0.D.data();
|
|
111
|
+
pr.iterations = m.iterations; pr.ls_iterations = m.ls_iterations; pr.tolerance = m.tolerance;
|
|
112
|
+
pr.ls_tolerance = m.ls_tolerance;
|
|
113
|
+
const newton::Result res = newton::solve(pr, warm);
|
|
114
|
+
fl.niter = res.niter; fl.ncon = static_cast<int>(con0.size());
|
|
115
|
+
// --- Dual: kinematics, M, bias, actuators, contacts, rows
|
|
116
|
+
std::vector<BodyState<D>> X(nb);
|
|
117
|
+
fk(m.bodies.data(), nb, qpos.data(), X.data());
|
|
118
|
+
std::vector<D> M(static_cast<size_t>(nv) * nv), bD(nv), jpD(3 * nv), jrD(3 * nv), wD(3 * nb), alD(3 * nb), voD(3 * nb),
|
|
119
|
+
aoD(3 * nb);
|
|
120
|
+
mass_matrix(m.bodies.data(), nb, X.data(), nv, m.armature.data(), M.data(), jpD.data(), jrD.data());
|
|
121
|
+
bias(m.bodies.data(), nb, X.data(), nv, qvel.data(), m.gravity, bD.data(), jpD.data(), jrD.data(), wD.data(), alD.data(),
|
|
122
|
+
voD.data(), aoD.data());
|
|
123
|
+
std::vector<D> fs(nv, D(0.0));
|
|
124
|
+
for (size_t u = 0; u < m.actuators.size(); ++u) {
|
|
125
|
+
const SoftActuator& a = m.actuators[u];
|
|
126
|
+
const D f = clamped[a.dof] ? D(fclamp[u]) // a clamped force is the bound (exact derivative: 0, MuJoCo's clamp_kv 1)
|
|
127
|
+
: D(a.kp) * ctrl[u] + (D(0.0) + D(-a.kp) * qpos[a.qadr] + D(-a.kd) * qvel[a.dof]);
|
|
128
|
+
fs[a.dof] = fs[a.dof] + f;
|
|
129
|
+
}
|
|
130
|
+
for (int i = 0; i < nv; ++i) fs[i] = fs[i] - bD[i];
|
|
131
|
+
std::vector<SoftContact<D>> con;
|
|
132
|
+
collide_all(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()), X.data(),
|
|
133
|
+
foot_friction, con);
|
|
134
|
+
if (con.size() != con0.size()) fl.contact_set_changed = 1;
|
|
135
|
+
else
|
|
136
|
+
for (size_t c = 0; c < con.size(); ++c)
|
|
137
|
+
if (con[c].pair != con0[c].pair || con[c].slot != con0[c].slot) fl.contact_set_changed = 1;
|
|
138
|
+
assert(!fl.contact_set_changed && "substep_jvp: the Dual collision found another contact set (value branches differ)");
|
|
139
|
+
Rows<D> rows;
|
|
140
|
+
make_rows(m.bodies.data(), X.data(), nv, m.dof_invweight0.data(), m.joints.data(), static_cast<int>(m.joints.size()),
|
|
141
|
+
m.geoms.data(), m.pairs.data(), con, qpos.data(), qvel.data(), m.timestep, m.impratio, rows);
|
|
142
|
+
assert(rows.n == rows0.n && "substep_jvp: the Dual rows differ in number");
|
|
143
|
+
// --- IFT: F(a*, theta) and da* = -H^-1 dF
|
|
144
|
+
std::vector<D> F(nv, D(0.0));
|
|
145
|
+
for (int i = 0; i < nv; ++i) {
|
|
146
|
+
D s = D(0.0);
|
|
147
|
+
for (int j = 0; j < nv; ++j) s = s + M[static_cast<size_t>(i) * nv + j] * D(res.qacc[j]);
|
|
148
|
+
F[i] = s - fs[i];
|
|
149
|
+
}
|
|
150
|
+
for (int r = 0; r < rows.n; ++r) {
|
|
151
|
+
if (res.state[r] != newton::kQuadratic) continue;
|
|
152
|
+
++fl.nquadratic;
|
|
153
|
+
const D* Jr = rows.J.data() + static_cast<size_t>(r) * nv;
|
|
154
|
+
D ja = D(0.0);
|
|
155
|
+
for (int j = 0; j < nv; ++j) ja = ja + Jr[j] * D(res.qacc[j]);
|
|
156
|
+
const D g = rows.D[r] * (ja - rows.aref[r]);
|
|
157
|
+
for (int i = 0; i < nv; ++i) F[i] = F[i] + Jr[i] * g;
|
|
158
|
+
}
|
|
159
|
+
std::vector<D> astar(nv, D(0.0));
|
|
160
|
+
for (int i = 0; i < nv; ++i) astar[i].v = res.qacc[i];
|
|
161
|
+
if (rows.n > 0) {
|
|
162
|
+
std::vector<double> rhs(nv), da(nv);
|
|
163
|
+
for (int k = 0; k < K; ++k) {
|
|
164
|
+
for (int i = 0; i < nv; ++i) rhs[i] = -F[i].d[k];
|
|
165
|
+
newton::chol_solve(res.L.data(), da.data(), rhs.data(), nv);
|
|
166
|
+
for (int i = 0; i < nv; ++i) astar[i].d[k] = da[i];
|
|
167
|
+
}
|
|
168
|
+
} else { // no rows: a* = qacc_smooth = M^-1 qfrc_smooth, differentiated as a linear solve
|
|
169
|
+
dual_solve<K>(M, fs, astar, nv);
|
|
170
|
+
}
|
|
171
|
+
// qfrc_constraint = sum_active J' (-D (J a* - aref)), in Dual with a*'s derivative
|
|
172
|
+
std::vector<D> qc(nv, D(0.0));
|
|
173
|
+
for (int r = 0; r < rows.n; ++r) {
|
|
174
|
+
if (res.state[r] != newton::kQuadratic) continue;
|
|
175
|
+
const D* Jr = rows.J.data() + static_cast<size_t>(r) * nv;
|
|
176
|
+
D ja = D(0.0);
|
|
177
|
+
for (int j = 0; j < nv; ++j) ja = ja + Jr[j] * astar[j];
|
|
178
|
+
const D force = D(0.0) - rows.D[r] * (ja - rows.aref[r]);
|
|
179
|
+
for (int i = 0; i < nv; ++i) qc[i] = qc[i] + Jr[i] * force;
|
|
180
|
+
}
|
|
181
|
+
// --- implicitfast and the integration, in Dual
|
|
182
|
+
const double h = m.timestep;
|
|
183
|
+
std::vector<D> qH(M), rhsD(nv), qacc_imp;
|
|
184
|
+
for (const SoftActuator& a : m.actuators)
|
|
185
|
+
if (!clamped[a.dof]) qH[static_cast<size_t>(a.dof) * nv + a.dof] = qH[static_cast<size_t>(a.dof) * nv + a.dof] + D(h * a.kd);
|
|
186
|
+
for (int i = 0; i < nv; ++i) rhsD[i] = fs[i] + qc[i];
|
|
187
|
+
dual_solve<K>(qH, rhsD, qacc_imp, nv);
|
|
188
|
+
for (int i = 0; i < nv; ++i) qvel[i] = qvel[i] + D(h) * qacc_imp[i];
|
|
189
|
+
for (int b = 1; b < nb; ++b) {
|
|
190
|
+
const SoftBody& bd = m.bodies[b];
|
|
191
|
+
if (bd.jnt_type == kJntFree) {
|
|
192
|
+
for (int k = 0; k < 3; ++k) qpos[bd.qadr + k] = qpos[bd.qadr + k] + D(h) * qvel[bd.dadr + k];
|
|
193
|
+
quat_integrate_t(qpos.data() + bd.qadr + 3, qvel.data() + bd.dadr + 3, h);
|
|
194
|
+
} else if (bd.jnt_type == kJntHinge) {
|
|
195
|
+
qpos[bd.qadr] = qpos[bd.qadr] + D(h) * qvel[bd.dadr];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
for (int i = 0; i < nv; ++i) warm[i] = res.qacc[i];
|
|
199
|
+
return fl;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
} // namespace js::soft
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// D16 C1 (2026-11-02): the soft law's own kinematics and smooth dynamics, in MuJoCo's coordinates (qpos = [root
|
|
3
|
+
// pos, root quat wxyz, hinges in MuJoCo's joint order]; qvel = [v_world of the root origin, w_body, hinges]), from the model
|
|
4
|
+
// data tools/d16/export_soft_law.py exports. The CPU f64 reference of the law and of its derivative (C2, S = Dual); the
|
|
5
|
+
// GPU path (L1) computes the same quantities lane-parallel and is gated against this.
|
|
6
|
+
// fk mj_kinematics for a free root and hinges at body origins (jnt_pos 0): xpos, xquat, xmat, xipos, ximat
|
|
7
|
+
// point_jacobian the translational Jacobian of a point on a body: the free dofs [I | (R e_k) x (p - x_root)], a hinge
|
|
8
|
+
// a_world x (p - x_anchor) for every hinge on the body's chain, 0 elsewhere (mj_jac's columns)
|
|
9
|
+
// mass_matrix M = sum_b Jp_b(com)' m_b Jp_b(com) + Jr_b' I_b Jr_b, plus the dof armature on the diagonal (MuJoCo's qM)
|
|
10
|
+
// bias qfrc_bias = C(q, qvel) qvel + g(q): Newton-Euler at qacc = 0 in the world frame, gravity as the root's
|
|
11
|
+
// base acceleration, mapped to dofs by the same Jacobians (sum_b Jp_b' f_b + Jr_b' n_b)
|
|
12
|
+
// The formulation is the plain world-frame one, not MuJoCo's com-based cdof / cinert; the two agree to roundoff, which the
|
|
13
|
+
// reference corpus gates (M and qfrc_bias per state).
|
|
14
|
+
#include <cassert>
|
|
15
|
+
|
|
16
|
+
#include "diffneusim/macros.h"
|
|
17
|
+
#include "../math/so3.h"
|
|
18
|
+
#include "impedance.h"
|
|
19
|
+
|
|
20
|
+
namespace js::soft {
|
|
21
|
+
|
|
22
|
+
constexpr int kJntFree = 0, kJntHinge = 3; // mjtJoint
|
|
23
|
+
|
|
24
|
+
struct SoftBody {
|
|
25
|
+
int parent, jnt_type, qadr, dadr; // jnt_type -1: no joint (world, static bodies)
|
|
26
|
+
double pos[3], quat[4], ipos[3], iquat[4], mass, inertia[3], axis[3], invweight0[2];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <class S> struct BodyState {
|
|
30
|
+
S xpos[3], xquat[4], xmat[9], xipos[3], ximat[9];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// --- small fixed-size helpers (MuJoCo's mju_* order of operations where it matters to roundoff only) ---
|
|
34
|
+
template <class S> DN_HOST_DEVICE void quat_mul(const S* a, const S* b, S* r) { // mju_mulQuat
|
|
35
|
+
const S r0 = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
|
|
36
|
+
const S r1 = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
|
|
37
|
+
const S r2 = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
|
|
38
|
+
const S r3 = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
|
|
39
|
+
r[0] = r0; r[1] = r1; r[2] = r2; r[3] = r3;
|
|
40
|
+
}
|
|
41
|
+
template <class S> DN_HOST_DEVICE void quat_normalize(S* q) { // mju_normalize4: rescale only if |norm - 1| > MINVAL
|
|
42
|
+
using so3::js_sqrt;
|
|
43
|
+
using L = lit_t<S>; // float on the f32 path (no FP64 compare there, the 2026-11-02 count in k_post); double otherwise, unchanged
|
|
44
|
+
const S n = js_sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
|
|
45
|
+
if (n < L(kMinVal)) { q[0] = S(1); q[1] = q[2] = q[3] = S(0); return; }
|
|
46
|
+
const S d = n - S(1);
|
|
47
|
+
if (d > L(kMinVal) || d < -L(kMinVal)) { const S inv = S(1) / n; for (int k = 0; k < 4; ++k) q[k] = q[k] * inv; }
|
|
48
|
+
}
|
|
49
|
+
template <class S> DN_HOST_DEVICE void quat_to_mat(const S* q, S* R) { // mju_quat2Mat, row-major
|
|
50
|
+
const S q00 = q[0] * q[0], q01 = q[0] * q[1], q02 = q[0] * q[2], q03 = q[0] * q[3];
|
|
51
|
+
const S q11 = q[1] * q[1], q12 = q[1] * q[2], q13 = q[1] * q[3], q22 = q[2] * q[2], q23 = q[2] * q[3], q33 = q[3] * q[3];
|
|
52
|
+
R[0] = q00 + q11 - q22 - q33; R[4] = q00 - q11 + q22 - q33; R[8] = q00 - q11 - q22 + q33;
|
|
53
|
+
R[1] = S(2) * (q12 - q03); R[2] = S(2) * (q13 + q02);
|
|
54
|
+
R[3] = S(2) * (q12 + q03); R[5] = S(2) * (q23 - q01);
|
|
55
|
+
R[6] = S(2) * (q13 - q02); R[7] = S(2) * (q23 + q01);
|
|
56
|
+
}
|
|
57
|
+
template <class S, class T> DN_HOST_DEVICE void mat_vec(const S* R, const T* v, S* r) { // r = R v
|
|
58
|
+
for (int i = 0; i < 3; ++i) r[i] = R[3 * i] * S(v[0]) + R[3 * i + 1] * S(v[1]) + R[3 * i + 2] * S(v[2]);
|
|
59
|
+
}
|
|
60
|
+
// x == 0 on the value (our Dual has no ==; it compares on the value, dual.h)
|
|
61
|
+
template <class S> DN_HOST_DEVICE bool is_zero(S x) { return !(x < 0.0) && !(x > 0.0); }
|
|
62
|
+
template <class S> DN_HOST_DEVICE void cross3(const S* a, const S* b, S* r) {
|
|
63
|
+
const S r0 = a[1] * b[2] - a[2] * b[1], r1 = a[2] * b[0] - a[0] * b[2], r2 = a[0] * b[1] - a[1] * b[0];
|
|
64
|
+
r[0] = r0; r[1] = r1; r[2] = r2;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// mj_kinematics for the law's tree: bodies in topological order (parent < body), body 0 the world
|
|
68
|
+
template <class S>
|
|
69
|
+
DN_HOST_DEVICE void fk(const SoftBody* B, int nb, const S* qpos, BodyState<S>* X) {
|
|
70
|
+
for (int k = 0; k < 3; ++k) { X[0].xpos[k] = S(0); X[0].xipos[k] = S(0); }
|
|
71
|
+
X[0].xquat[0] = S(1); X[0].xquat[1] = X[0].xquat[2] = X[0].xquat[3] = S(0);
|
|
72
|
+
quat_to_mat(X[0].xquat, X[0].xmat);
|
|
73
|
+
for (int k = 0; k < 9; ++k) X[0].ximat[k] = X[0].xmat[k];
|
|
74
|
+
for (int b = 1; b < nb; ++b) {
|
|
75
|
+
const SoftBody& bd = B[b];
|
|
76
|
+
BodyState<S>& x = X[b];
|
|
77
|
+
if (bd.jnt_type == kJntFree) { // the free joint sets the frame from qpos (the body's pos / quat are ignored)
|
|
78
|
+
for (int k = 0; k < 3; ++k) x.xpos[k] = qpos[bd.qadr + k];
|
|
79
|
+
for (int k = 0; k < 4; ++k) x.xquat[k] = qpos[bd.qadr + 3 + k];
|
|
80
|
+
quat_normalize(x.xquat);
|
|
81
|
+
} else {
|
|
82
|
+
const BodyState<S>& p = X[bd.parent];
|
|
83
|
+
S t[3];
|
|
84
|
+
mat_vec(p.xmat, bd.pos, t);
|
|
85
|
+
for (int k = 0; k < 3; ++k) x.xpos[k] = p.xpos[k] + t[k];
|
|
86
|
+
S bq[4] = {S(bd.quat[0]), S(bd.quat[1]), S(bd.quat[2]), S(bd.quat[3])};
|
|
87
|
+
quat_mul(p.xquat, bq, x.xquat);
|
|
88
|
+
if (bd.jnt_type == kJntHinge) { // quat = quat * axisangle(axis, q): the hinge at the body origin
|
|
89
|
+
using so3::js_sin; using so3::js_cos;
|
|
90
|
+
const S half = qpos[bd.qadr] * S(0.5);
|
|
91
|
+
const S sh = js_sin(half);
|
|
92
|
+
S ql[4] = {js_cos(half), S(bd.axis[0]) * sh, S(bd.axis[1]) * sh, S(bd.axis[2]) * sh};
|
|
93
|
+
S tmp[4];
|
|
94
|
+
quat_mul(x.xquat, ql, tmp);
|
|
95
|
+
for (int k = 0; k < 4; ++k) x.xquat[k] = tmp[k];
|
|
96
|
+
} else {
|
|
97
|
+
assert(bd.jnt_type == -1 && "fk: free, hinge or no joint");
|
|
98
|
+
}
|
|
99
|
+
quat_normalize(x.xquat);
|
|
100
|
+
}
|
|
101
|
+
quat_to_mat(x.xquat, x.xmat);
|
|
102
|
+
S t[3];
|
|
103
|
+
mat_vec(x.xmat, bd.ipos, t);
|
|
104
|
+
for (int k = 0; k < 3; ++k) x.xipos[k] = x.xpos[k] + t[k];
|
|
105
|
+
S iq[4] = {S(bd.iquat[0]), S(bd.iquat[1]), S(bd.iquat[2]), S(bd.iquat[3])}, q2[4];
|
|
106
|
+
quat_mul(x.xquat, iq, q2);
|
|
107
|
+
quat_to_mat(q2, x.ximat);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// the world axis of dof d's motion and the anchor it rotates about: hinge (axis_world, xpos of its body); the free root's
|
|
112
|
+
// rotation dofs (R_root e_k, xpos root); the free root's translation dofs return translational = true
|
|
113
|
+
template <class S> struct DofMotion { bool translational; S w[3]; const S* anchor; };
|
|
114
|
+
|
|
115
|
+
// the dofs on body b's chain to the root, nearest first, written to chain[] (n returned)
|
|
116
|
+
DN_HOST_DEVICE inline int body_chain_dofs(const SoftBody* B, int b, int* chain) {
|
|
117
|
+
int n = 0;
|
|
118
|
+
for (; b > 0; b = B[b].parent) {
|
|
119
|
+
if (B[b].jnt_type == kJntHinge) chain[n++] = B[b].dadr;
|
|
120
|
+
else if (B[b].jnt_type == kJntFree)
|
|
121
|
+
for (int k = 5; k >= 0; --k) chain[n++] = B[b].dadr + k;
|
|
122
|
+
}
|
|
123
|
+
return n;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// translational (jp, 3 x nv row-major) and rotational (jr) Jacobians of point p on body b, zeroed then filled on b's chain
|
|
127
|
+
template <class S>
|
|
128
|
+
DN_HOST_DEVICE void point_jacobian(const SoftBody* B, const BodyState<S>* X, int nv, int b, const S* p, S* jp,
|
|
129
|
+
S* jr) {
|
|
130
|
+
for (int k = 0; k < 3 * nv; ++k) { jp[k] = S(0); if (jr) jr[k] = S(0); }
|
|
131
|
+
for (; b > 0; b = B[b].parent) {
|
|
132
|
+
const SoftBody& bd = B[b];
|
|
133
|
+
const BodyState<S>& x = X[b];
|
|
134
|
+
if (bd.jnt_type == kJntHinge) {
|
|
135
|
+
S a[3], r[3], c[3];
|
|
136
|
+
mat_vec(x.xmat, bd.axis, a); // the hinge's world axis (the joint sits at the body origin)
|
|
137
|
+
for (int k = 0; k < 3; ++k) r[k] = p[k] - x.xpos[k];
|
|
138
|
+
cross3(a, r, c);
|
|
139
|
+
for (int k = 0; k < 3; ++k) { jp[k * nv + bd.dadr] = c[k]; if (jr) jr[k * nv + bd.dadr] = a[k]; }
|
|
140
|
+
} else if (bd.jnt_type == kJntFree) {
|
|
141
|
+
S r[3];
|
|
142
|
+
for (int k = 0; k < 3; ++k) r[k] = p[k] - x.xpos[k];
|
|
143
|
+
for (int k = 0; k < 3; ++k) jp[k * nv + bd.dadr + k] = S(1); // v_world
|
|
144
|
+
for (int e = 0; e < 3; ++e) { // w_body: the world axis R e_e
|
|
145
|
+
S a[3] = {x.xmat[e], x.xmat[3 + e], x.xmat[6 + e]}, c[3];
|
|
146
|
+
cross3(a, r, c);
|
|
147
|
+
for (int k = 0; k < 3; ++k) { jp[k * nv + bd.dadr + 3 + e] = c[k]; if (jr) jr[k * nv + bd.dadr + 3 + e] = a[k]; }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// MuJoCo's qM (dense, nv x nv row-major): sum over bodies of the COM Jacobians against mass and world inertia, + armature
|
|
154
|
+
template <class S>
|
|
155
|
+
DN_HOST_DEVICE void mass_matrix(const SoftBody* B, int nb, const BodyState<S>* X, int nv, const double* armature,
|
|
156
|
+
S* M, S* jp, S* jr) {
|
|
157
|
+
for (int k = 0; k < nv * nv; ++k) M[k] = S(0);
|
|
158
|
+
for (int b = 1; b < nb; ++b) {
|
|
159
|
+
if (B[b].mass == 0 && B[b].inertia[0] == 0 && B[b].inertia[1] == 0 && B[b].inertia[2] == 0) continue;
|
|
160
|
+
point_jacobian(B, X, nv, b, X[b].xipos, jp, jr);
|
|
161
|
+
// world inertia I = ximat diag(inertia) ximat'
|
|
162
|
+
S I[9];
|
|
163
|
+
for (int i = 0; i < 3; ++i)
|
|
164
|
+
for (int j = 0; j < 3; ++j) {
|
|
165
|
+
S s = S(0);
|
|
166
|
+
for (int k = 0; k < 3; ++k) s = s + X[b].ximat[3 * i + k] * S(B[b].inertia[k]) * X[b].ximat[3 * j + k];
|
|
167
|
+
I[3 * i + j] = s;
|
|
168
|
+
}
|
|
169
|
+
for (int i = 0; i < nv; ++i) {
|
|
170
|
+
S ji[3] = {jp[i], jp[nv + i], jp[2 * nv + i]}, ri[3] = {jr[i], jr[nv + i], jr[2 * nv + i]};
|
|
171
|
+
if (is_zero(ji[0]) && is_zero(ji[1]) && is_zero(ji[2]) && is_zero(ri[0]) && is_zero(ri[1]) && is_zero(ri[2])) continue;
|
|
172
|
+
S Iri[3];
|
|
173
|
+
mat_vec(I, ri, Iri);
|
|
174
|
+
for (int j = 0; j < nv; ++j) {
|
|
175
|
+
const S lin = S(B[b].mass) * (ji[0] * jp[j] + ji[1] * jp[nv + j] + ji[2] * jp[2 * nv + j]);
|
|
176
|
+
const S rot = Iri[0] * jr[j] + Iri[1] * jr[nv + j] + Iri[2] * jr[2 * nv + j];
|
|
177
|
+
M[i * nv + j] = M[i * nv + j] + lin + rot;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (int i = 0; i < nv; ++i) M[i * nv + i] = M[i * nv + i] + S(armature[i]);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// qfrc_bias = C(q, qvel) qvel + g(q) (MuJoCo's sign: M qacc + qfrc_bias = applied forces). Newton-Euler at qacc = 0, world
|
|
185
|
+
// frame: per body its angular velocity w, angular acceleration al, origin velocity / acceleration, COM acceleration with
|
|
186
|
+
// the base acceleration -gravity; then f_b = m a_com, n_b = I al + w x (I w), mapped by the COM Jacobians.
|
|
187
|
+
template <class S>
|
|
188
|
+
DN_HOST_DEVICE void bias(const SoftBody* B, int nb, const BodyState<S>* X, int nv, const S* qvel,
|
|
189
|
+
const double* gravity, S* qfrc_bias, S* jp, S* jr, S* w, S* al, S* vo, S* ao) {
|
|
190
|
+
// w, al, vo, ao: 3 nb each (scratch); body 0 at rest with the base acceleration -gravity
|
|
191
|
+
for (int k = 0; k < 3; ++k) { w[k] = S(0); al[k] = S(0); vo[k] = S(0); ao[k] = S(0) - S(gravity[k]); }
|
|
192
|
+
for (int i = 0; i < nv; ++i) qfrc_bias[i] = S(0);
|
|
193
|
+
for (int b = 1; b < nb; ++b) {
|
|
194
|
+
const SoftBody& bd = B[b];
|
|
195
|
+
const BodyState<S>& x = X[b];
|
|
196
|
+
const int p = bd.parent;
|
|
197
|
+
S* wb = w + 3 * b; S* alb = al + 3 * b; S* vb = vo + 3 * b; S* ab = ao + 3 * b;
|
|
198
|
+
const S* wp = w + 3 * p; const S* alp = al + 3 * p; const S* vp = vo + 3 * p; const S* ap = ao + 3 * p;
|
|
199
|
+
if (bd.jnt_type == kJntFree) { // root: w = R w_body, v_origin = v_world, accelerations 0 at qacc = 0 (+ base)
|
|
200
|
+
S wbody[3] = {qvel[bd.dadr + 3], qvel[bd.dadr + 4], qvel[bd.dadr + 5]};
|
|
201
|
+
mat_vec(x.xmat, wbody, wb);
|
|
202
|
+
for (int k = 0; k < 3; ++k) { alb[k] = alp[k]; vb[k] = qvel[bd.dadr + k]; ab[k] = ap[k]; }
|
|
203
|
+
} else {
|
|
204
|
+
// the origin moves with the parent: r = x_b - x_p
|
|
205
|
+
S r[3], t1[3], t2[3], t3[3];
|
|
206
|
+
for (int k = 0; k < 3; ++k) r[k] = x.xpos[k] - X[p].xpos[k];
|
|
207
|
+
cross3(wp, r, t1);
|
|
208
|
+
for (int k = 0; k < 3; ++k) vb[k] = vp[k] + t1[k];
|
|
209
|
+
cross3(alp, r, t2);
|
|
210
|
+
cross3(wp, t1, t3);
|
|
211
|
+
for (int k = 0; k < 3; ++k) ab[k] = ap[k] + t2[k] + t3[k];
|
|
212
|
+
if (bd.jnt_type == kJntHinge) {
|
|
213
|
+
S a[3], sq[3], c[3];
|
|
214
|
+
mat_vec(x.xmat, bd.axis, a);
|
|
215
|
+
for (int k = 0; k < 3; ++k) sq[k] = a[k] * qvel[bd.dadr];
|
|
216
|
+
cross3(wp, sq, c);
|
|
217
|
+
for (int k = 0; k < 3; ++k) { wb[k] = wp[k] + sq[k]; alb[k] = alp[k] + c[k]; }
|
|
218
|
+
} else {
|
|
219
|
+
for (int k = 0; k < 3; ++k) { wb[k] = wp[k]; alb[k] = alp[k]; }
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (bd.mass == 0 && bd.inertia[0] == 0 && bd.inertia[1] == 0 && bd.inertia[2] == 0) continue;
|
|
223
|
+
// COM acceleration a_c = a_o + al x rc + w x (w x rc), rc = xipos - xpos
|
|
224
|
+
S rc[3], u1[3], u2[3], u3[3], ac[3];
|
|
225
|
+
for (int k = 0; k < 3; ++k) rc[k] = x.xipos[k] - x.xpos[k];
|
|
226
|
+
cross3(alb, rc, u1);
|
|
227
|
+
cross3(wb, rc, u2);
|
|
228
|
+
cross3(wb, u2, u3);
|
|
229
|
+
for (int k = 0; k < 3; ++k) ac[k] = ab[k] + u1[k] + u3[k];
|
|
230
|
+
S I[9];
|
|
231
|
+
for (int i = 0; i < 3; ++i)
|
|
232
|
+
for (int j = 0; j < 3; ++j) {
|
|
233
|
+
S s = S(0);
|
|
234
|
+
for (int k = 0; k < 3; ++k) s = s + x.ximat[3 * i + k] * S(bd.inertia[k]) * x.ximat[3 * j + k];
|
|
235
|
+
I[3 * i + j] = s;
|
|
236
|
+
}
|
|
237
|
+
S f[3], n[3], Iw[3], Ial[3], wIw[3];
|
|
238
|
+
for (int k = 0; k < 3; ++k) f[k] = S(bd.mass) * ac[k];
|
|
239
|
+
mat_vec(I, wb, Iw);
|
|
240
|
+
mat_vec(I, alb, Ial);
|
|
241
|
+
cross3(wb, Iw, wIw);
|
|
242
|
+
for (int k = 0; k < 3; ++k) n[k] = Ial[k] + wIw[k];
|
|
243
|
+
point_jacobian(B, X, nv, b, x.xipos, jp, jr);
|
|
244
|
+
for (int i = 0; i < nv; ++i)
|
|
245
|
+
qfrc_bias[i] = qfrc_bias[i] + jp[i] * f[0] + jp[nv + i] * f[1] + jp[2 * nv + i] * f[2] + jr[i] * n[0] +
|
|
246
|
+
jr[nv + i] * n[1] + jr[2 * nv + i] * n[2];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
} // namespace js::soft
|