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,371 @@
|
|
|
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 primal Newton solver for the soft constraints, dense, as the G1 scene runs
|
|
6
|
+
// it (one island holding every dof and row; pyramidal cone; no friction rows; not metric). Transcribed from engine_forward.c
|
|
7
|
+
// (fwdConstraint, warmstart) and engine_solver.c (mj_solPrimal, PrimalUpdateConstraint, MakeHessian, FactorizeHessian,
|
|
8
|
+
// HessianIncremental, PrimalPrepare, PrimalEval, PrimalSearch, updateBracket) at tag 3.16.0; the line search was read
|
|
9
|
+
// against the C directly (LAW_SPEC_MUJOCO316.md, "The Newton solve"). double only: C2 differentiates the converged solution
|
|
10
|
+
// through the optimality conditions (IFT), never the iterations.
|
|
11
|
+
#include <cmath>
|
|
12
|
+
#include <vector>
|
|
13
|
+
|
|
14
|
+
#include "impedance.h"
|
|
15
|
+
|
|
16
|
+
namespace js::soft::newton {
|
|
17
|
+
|
|
18
|
+
constexpr int kQuadratic = 1, kSatisfied = 0; // mjCNSTRSTATE_QUADRATIC / _SATISFIED (only the two the G1's rows reach)
|
|
19
|
+
|
|
20
|
+
// mju_dot (engine_util_blas.c:477-510): four accumulators over blocks of 4, (r0 + r2) + (r1 + r3), then the 1-3 remaining
|
|
21
|
+
inline double dot(const double* a, const double* b, int n) {
|
|
22
|
+
double r0 = 0, r1 = 0, r2 = 0, r3 = 0;
|
|
23
|
+
int i = 0;
|
|
24
|
+
for (; i + 4 <= n; i += 4) { r0 += a[i] * b[i]; r1 += a[i + 1] * b[i + 1]; r2 += a[i + 2] * b[i + 2]; r3 += a[i + 3] * b[i + 3]; }
|
|
25
|
+
double res = (r0 + r2) + (r1 + r3);
|
|
26
|
+
const int rem = n - i;
|
|
27
|
+
if (rem == 1) res += a[i] * b[i];
|
|
28
|
+
else if (rem == 2) res += a[i] * b[i] + a[i + 1] * b[i + 1];
|
|
29
|
+
else if (rem == 3) res += a[i] * b[i] + a[i + 1] * b[i + 1] + a[i + 2] * b[i + 2];
|
|
30
|
+
return res;
|
|
31
|
+
}
|
|
32
|
+
inline double norm(const double* a, int n) { return std::sqrt(dot(a, a, n)); }
|
|
33
|
+
|
|
34
|
+
// res = M v, M dense symmetric (full storage)
|
|
35
|
+
inline void mul_sym(const double* M, const double* v, double* res, int n) {
|
|
36
|
+
for (int i = 0; i < n; ++i) res[i] = dot(M + static_cast<size_t>(i) * n, v, n);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// mju_cholFactor (engine_util_solve.c:33-70) on the lower triangle of L (n x n row-major), mindiag mjMINVAL; returns rank.
|
|
40
|
+
// One difference: at a pivot under mindiag the pivot becomes mindiag as in MuJoCo, but its column below is zeroed, where
|
|
41
|
+
// mju_cholFactor keeps it scaled by 1 / sqrt(mindiag) (MuJoCo 3.10.0, engine_util_solve.c:33-62). The device factor
|
|
42
|
+
// (gpu/chol_rn.cuh) does the same as this. Equal to MuJoCo's while the returned rank is n.
|
|
43
|
+
inline int chol_factor(double* L, int n, double mindiag) {
|
|
44
|
+
int rank = n;
|
|
45
|
+
for (int j = 0; j < n; ++j) {
|
|
46
|
+
double tmp = L[j * n + j] - dot(L + j * n, L + j * n, j);
|
|
47
|
+
if (tmp < mindiag) {
|
|
48
|
+
tmp = mindiag;
|
|
49
|
+
--rank;
|
|
50
|
+
for (int i = j + 1; i < n; ++i) L[i * n + j] = 0;
|
|
51
|
+
L[j * n + j] = std::sqrt(tmp);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
L[j * n + j] = std::sqrt(tmp);
|
|
55
|
+
const double inv = 1 / L[j * n + j];
|
|
56
|
+
for (int i = j + 1; i < n; ++i) L[i * n + j] = (L[i * n + j] - dot(L + i * n, L + j * n, j)) * inv;
|
|
57
|
+
}
|
|
58
|
+
return rank;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// mju_cholSolve (:74-100): res = (L L')^-1 vec
|
|
62
|
+
inline void chol_solve(const double* L, double* res, const double* vec, int n) {
|
|
63
|
+
if (res != vec) for (int i = 0; i < n; ++i) res[i] = vec[i];
|
|
64
|
+
for (int i = 0; i < n; ++i) res[i] = (res[i] - dot(L + i * n, res, i)) / L[i * n + i];
|
|
65
|
+
for (int i = n - 1; i >= 0; --i) {
|
|
66
|
+
for (int j = i + 1; j < n; ++j) res[i] -= L[j * n + i] * res[j];
|
|
67
|
+
res[i] /= L[i * n + i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// mju_cholUpdate (:104-144): L L' +- x x', x overwritten; returns rank
|
|
72
|
+
inline int chol_update(double* L, double* x, int n, bool plus) {
|
|
73
|
+
int rank = n;
|
|
74
|
+
for (int k = 0; k < n; ++k) {
|
|
75
|
+
if (x[k] == 0) continue;
|
|
76
|
+
const double Lkk = L[k * n + k];
|
|
77
|
+
double tmp = plus ? Lkk * Lkk + x[k] * x[k] : Lkk * Lkk - x[k] * x[k];
|
|
78
|
+
if (tmp < kMinVal) { tmp = kMinVal; --rank; }
|
|
79
|
+
const double r = std::sqrt(tmp), c = r / Lkk, cinv = 1 / c, s = x[k] / Lkk;
|
|
80
|
+
L[k * n + k] = r;
|
|
81
|
+
for (int i = k + 1; i < n; ++i) {
|
|
82
|
+
L[i * n + k] = plus ? (L[i * n + k] + s * x[i]) * cinv : (L[i * n + k] - s * x[i]) * cinv;
|
|
83
|
+
x[i] = c * x[i] - s * L[i * n + k];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return rank;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
struct Problem { // one substep's solve, MuJoCo's arrays (dense)
|
|
90
|
+
int nv = 0, nefc = 0;
|
|
91
|
+
const double* M = nullptr; // nv x nv, full symmetric
|
|
92
|
+
const double* qfrc_smooth = nullptr; // nv
|
|
93
|
+
const double* qacc_smooth = nullptr; // nv
|
|
94
|
+
const double* J = nullptr; // nefc x nv
|
|
95
|
+
const double* aref = nullptr; // nefc
|
|
96
|
+
const double* D = nullptr; // nefc
|
|
97
|
+
int iterations = 10, ls_iterations = 20;
|
|
98
|
+
double tolerance = 1e-8, ls_tolerance = 0.01;
|
|
99
|
+
};
|
|
100
|
+
struct Result {
|
|
101
|
+
std::vector<double> qacc, force, qfrc_constraint, L; // L: H's Cholesky factor at the last state (lower), for the tape
|
|
102
|
+
std::vector<int> state;
|
|
103
|
+
int niter = 0;
|
|
104
|
+
bool warm_used = false;
|
|
105
|
+
bool ran_out = false; // the iterations ran out before a stopping test held (the tape's NONCONV flag)
|
|
106
|
+
bool stalled = false; // the line search returned alpha 0 (the loop's other exit; MuJoCo's too)
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
namespace detail {
|
|
110
|
+
|
|
111
|
+
struct Ctx {
|
|
112
|
+
const Problem* p;
|
|
113
|
+
int nv, nefc;
|
|
114
|
+
double scale;
|
|
115
|
+
std::vector<double> qacc, Ma, Jaref, force, qfrc_c, grad, Mgrad, search, Mv, Jv, L, quad, quadGauss;
|
|
116
|
+
std::vector<int> state;
|
|
117
|
+
double cost = 0;
|
|
118
|
+
int LSiter = 0;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// mj_constraintUpdate_impl for limit / contact rows: force = -D jar where jar < 0 (QUADRATIC), else 0 (SATISFIED; jar == 0
|
|
122
|
+
// is SATISFIED); cost = sum 0.5 D jar^2 over the quadratic rows
|
|
123
|
+
inline double constraint_update(const Problem& p, const double* jar, double* force, int* state) {
|
|
124
|
+
double cost = 0;
|
|
125
|
+
for (int i = 0; i < p.nefc; ++i) {
|
|
126
|
+
force[i] = -p.D[i] * jar[i];
|
|
127
|
+
if (jar[i] >= 0) { force[i] = 0; state[i] = kSatisfied; }
|
|
128
|
+
else { state[i] = kQuadratic; cost += 0.5 * p.D[i] * jar[i] * jar[i]; }
|
|
129
|
+
}
|
|
130
|
+
return cost;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// res = J' f over the rows with f != 0 (mju_mulMatTVec: zero res, add each row's J[r,:] f[r])
|
|
134
|
+
inline void mul_JT(const Problem& p, const double* f, double* res) {
|
|
135
|
+
for (int i = 0; i < p.nv; ++i) res[i] = 0;
|
|
136
|
+
for (int r = 0; r < p.nefc; ++r) {
|
|
137
|
+
if (f[r] == 0) continue;
|
|
138
|
+
const double* Jr = p.J + static_cast<size_t>(r) * p.nv;
|
|
139
|
+
for (int i = 0; i < p.nv; ++i) res[i] += Jr[i] * f[r];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// PrimalUpdateConstraint (:1536-1569): states, forces, qfrc_constraint, cost = constraint cost + Gauss
|
|
144
|
+
inline void update_constraint(Ctx& c) {
|
|
145
|
+
const Problem& p = *c.p;
|
|
146
|
+
c.cost = constraint_update(p, c.Jaref.data(), c.force.data(), c.state.data());
|
|
147
|
+
mul_JT(p, c.force.data(), c.qfrc_c.data());
|
|
148
|
+
double gauss = 0;
|
|
149
|
+
for (int i = 0; i < c.nv; ++i) gauss += 0.5 * (c.Ma[i] - p.qfrc_smooth[i]) * (c.qacc[i] - p.qacc_smooth[i]);
|
|
150
|
+
c.cost += gauss;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
inline void update_grad(Ctx& c) { // grad = Ma - qfrc_smooth - qfrc_constraint
|
|
154
|
+
for (int i = 0; i < c.nv; ++i) c.grad[i] = c.Ma[i] - c.p->qfrc_smooth[i] - c.qfrc_c[i];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// MakeHessian + FactorizeHessian: L = chol(M + J' D_active J) (lower), rows entering only when QUADRATIC
|
|
158
|
+
inline void factorize_hessian(Ctx& c) {
|
|
159
|
+
const Problem& p = *c.p;
|
|
160
|
+
const int n = c.nv;
|
|
161
|
+
for (int k = 0; k < n * n; ++k) c.L[k] = 0;
|
|
162
|
+
for (int r = 0; r < p.nefc; ++r) { // mju_sqrMatTD_impl, lower: L[i, 0..i] += J[r, 0..i] (J[r,i] D)
|
|
163
|
+
if (c.state[r] != kQuadratic) continue;
|
|
164
|
+
const double* Jr = p.J + static_cast<size_t>(r) * n;
|
|
165
|
+
for (int i = 0; i < n; ++i) {
|
|
166
|
+
if (Jr[i] == 0) continue;
|
|
167
|
+
const double s = Jr[i] * p.D[r];
|
|
168
|
+
for (int j = 0; j <= i; ++j) c.L[i * n + j] += Jr[j] * s;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
for (int i = 0; i < n; ++i)
|
|
172
|
+
for (int j = 0; j <= i; ++j) c.L[i * n + j] += p.M[i * n + j];
|
|
173
|
+
chol_factor(c.L.data(), n, kMinVal);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// HessianIncremental (:2789-2849): a rank-1 update / downdate per row whose QUADRATIC status changed; a rank-deficient
|
|
177
|
+
// update triggers the full refactorization at the current states
|
|
178
|
+
inline void hessian_incremental(Ctx& c, const std::vector<int>& oldstate) {
|
|
179
|
+
const Problem& p = *c.p;
|
|
180
|
+
std::vector<double> x(c.nv);
|
|
181
|
+
for (int r = 0; r < p.nefc; ++r) {
|
|
182
|
+
const bool was = oldstate[r] == kQuadratic, is = c.state[r] == kQuadratic;
|
|
183
|
+
if (was == is) continue;
|
|
184
|
+
const double sq = std::sqrt(p.D[r]);
|
|
185
|
+
const double* Jr = p.J + static_cast<size_t>(r) * c.nv;
|
|
186
|
+
for (int i = 0; i < c.nv; ++i) x[i] = Jr[i] * sq;
|
|
187
|
+
if (chol_update(c.L.data(), x.data(), c.nv, is) < c.nv) { factorize_hessian(c); return; }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
struct Pnt { double alpha = 0, cost = 0, d0 = 0, d1 = 0; };
|
|
192
|
+
|
|
193
|
+
// PrimalPrepare (:1628-1700)
|
|
194
|
+
inline void prepare(Ctx& c) {
|
|
195
|
+
const Problem& p = *c.p;
|
|
196
|
+
c.quadGauss.assign(3, 0);
|
|
197
|
+
c.quadGauss[1] = dot(c.search.data(), c.Ma.data(), c.nv) - dot(p.qfrc_smooth, c.search.data(), c.nv);
|
|
198
|
+
c.quadGauss[2] = 0.5 * dot(c.search.data(), c.Mv.data(), c.nv);
|
|
199
|
+
c.quad.assign(3 * static_cast<size_t>(p.nefc), 0);
|
|
200
|
+
for (int r = 0; r < p.nefc; ++r) {
|
|
201
|
+
const double DJ0 = p.D[r] * c.Jaref[r];
|
|
202
|
+
c.quad[3 * r] = c.Jaref[r] * DJ0;
|
|
203
|
+
c.quad[3 * r + 1] = c.Jv[r] * DJ0;
|
|
204
|
+
c.quad[3 * r + 2] = c.Jv[r] * p.D[r] * c.Jv[r];
|
|
205
|
+
c.quad[3 * r] *= 0.5;
|
|
206
|
+
c.quad[3 * r + 2] *= 0.5;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// PrimalEval (:1852-1999): cost(alpha) - cost(0) and its first two alpha derivatives
|
|
211
|
+
inline void eval(Ctx& c, Pnt& pt) {
|
|
212
|
+
double Q0 = 0, Q1 = c.quadGauss[1], Q2 = c.quadGauss[2], cost = 0;
|
|
213
|
+
for (int r = 0; r < c.nefc; ++r) {
|
|
214
|
+
const double x = c.Jaref[r] + pt.alpha * c.Jv[r];
|
|
215
|
+
const double cost0 = c.Jaref[r] < 0 ? c.quad[3 * r] : 0.0;
|
|
216
|
+
if (x < 0) { Q0 += c.quad[3 * r] - cost0; Q1 += c.quad[3 * r + 1]; Q2 += c.quad[3 * r + 2]; }
|
|
217
|
+
else cost -= cost0;
|
|
218
|
+
}
|
|
219
|
+
cost += pt.alpha * pt.alpha * Q2 + pt.alpha * Q1 + Q0;
|
|
220
|
+
pt.cost = cost;
|
|
221
|
+
pt.d0 = 2 * pt.alpha * Q2 + Q1;
|
|
222
|
+
pt.d1 = 2 * Q2;
|
|
223
|
+
if (pt.d1 <= 0) pt.d1 = kMinVal;
|
|
224
|
+
++c.LSiter;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
inline bool update_bracket(Ctx& c, Pnt& p, const Pnt cand[3], Pnt& pnext) {
|
|
228
|
+
int flag = 0;
|
|
229
|
+
for (int i = 0; i < 3; ++i) {
|
|
230
|
+
if (p.d0 < 0 && cand[i].d0 < 0 && p.d0 < cand[i].d0) { p = cand[i]; flag = 1; }
|
|
231
|
+
else if (p.d0 > 0 && cand[i].d0 > 0 && p.d0 > cand[i].d0) { p = cand[i]; flag = 2; }
|
|
232
|
+
}
|
|
233
|
+
if (flag) { pnext.alpha = p.alpha - p.d0 / p.d1; eval(c, pnext); }
|
|
234
|
+
return flag != 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// PrimalSearch (:2033-2233), read against the C
|
|
238
|
+
inline double search(Ctx& c, double tolerance, double ls_iterations, double* improvement) {
|
|
239
|
+
const Problem& p = *c.p;
|
|
240
|
+
c.LSiter = 0;
|
|
241
|
+
*improvement = 0;
|
|
242
|
+
const double snorm = norm(c.search.data(), c.nv);
|
|
243
|
+
if (snorm < kMinVal) return 0;
|
|
244
|
+
const double gtol = tolerance * snorm / c.scale;
|
|
245
|
+
mul_sym(p.M, c.search.data(), c.Mv.data(), c.nv);
|
|
246
|
+
for (int r = 0; r < c.nefc; ++r) c.Jv[r] = dot(p.J + static_cast<size_t>(r) * c.nv, c.search.data(), c.nv);
|
|
247
|
+
prepare(c);
|
|
248
|
+
Pnt p0, p1, p2, pmid, p1next, p2next;
|
|
249
|
+
p0.alpha = 0;
|
|
250
|
+
eval(c, p0);
|
|
251
|
+
p1.alpha = p0.alpha - p0.d0 / p0.d1;
|
|
252
|
+
eval(c, p1);
|
|
253
|
+
if (std::fabs(p1.d0) < gtol && (p1.alpha == 0 || p1.cost < 0)) { *improvement = -p1.cost; return p1.alpha; }
|
|
254
|
+
const int dir = p1.d0 < 0 ? +1 : -1;
|
|
255
|
+
p2 = p0;
|
|
256
|
+
while (p1.d0 * dir <= -gtol && c.LSiter < ls_iterations) {
|
|
257
|
+
p2 = p1;
|
|
258
|
+
p1.alpha -= p1.d0 / p1.d1;
|
|
259
|
+
eval(c, p1);
|
|
260
|
+
if (std::fabs(p1.d0) < gtol && p1.cost < 0) { *improvement = -p1.cost; return p1.alpha; }
|
|
261
|
+
}
|
|
262
|
+
if (c.LSiter >= ls_iterations) { *improvement = -p1.cost; return p1.alpha; }
|
|
263
|
+
p2next = p1;
|
|
264
|
+
p1next.alpha = p1.alpha - p1.d0 / p1.d1;
|
|
265
|
+
eval(c, p1next);
|
|
266
|
+
while (c.LSiter < ls_iterations) {
|
|
267
|
+
pmid.alpha = 0.5 * (p1.alpha + p2.alpha);
|
|
268
|
+
eval(c, pmid);
|
|
269
|
+
const Pnt cand[3] = {p1next, p2next, pmid};
|
|
270
|
+
double bestcost = 0;
|
|
271
|
+
int best = -1;
|
|
272
|
+
for (int i = 0; i < 3; ++i)
|
|
273
|
+
if (std::fabs(cand[i].d0) < gtol && (best == -1 || cand[i].cost < bestcost)) { bestcost = cand[i].cost; best = i; }
|
|
274
|
+
if (best >= 0) { *improvement = -cand[best].cost; return cand[best].alpha; }
|
|
275
|
+
const bool b1 = update_bracket(c, p1, cand, p1next);
|
|
276
|
+
const bool b2 = update_bracket(c, p2, cand, p2next);
|
|
277
|
+
if (!b1 && !b2) { *improvement = -pmid.cost; return pmid.alpha; }
|
|
278
|
+
}
|
|
279
|
+
if (p1.cost <= p2.cost && p1.cost < 0) { *improvement = -p1.cost; return p1.alpha; }
|
|
280
|
+
if (p2.cost <= p1.cost && p2.cost < 0) { *improvement = -p2.cost; return p2.alpha; }
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
} // namespace detail
|
|
285
|
+
|
|
286
|
+
// The solve (fwdConstraint's island Newton with its warm start): returns qacc and the rows' forces / states.
|
|
287
|
+
// warm: qacc_warmstart (nullptr: DSBL_WARMSTART, start at qacc_smooth). Island scale: 1 / trace M (the G1's one island).
|
|
288
|
+
inline Result solve(const Problem& p, const double* warm) {
|
|
289
|
+
using namespace detail;
|
|
290
|
+
const int nv = p.nv, ne = p.nefc;
|
|
291
|
+
Result res;
|
|
292
|
+
res.qacc.assign(p.qacc_smooth, p.qacc_smooth + nv);
|
|
293
|
+
res.force.assign(ne, 0);
|
|
294
|
+
res.state.assign(ne, kSatisfied);
|
|
295
|
+
res.qfrc_constraint.assign(nv, 0);
|
|
296
|
+
if (ne == 0) { // qacc = qacc_smooth, niter 0; H = M, so the tape's L_H is chol(M) (it was left empty: a zero factor)
|
|
297
|
+
res.L.assign(p.M, p.M + static_cast<size_t>(nv) * nv);
|
|
298
|
+
chol_factor(res.L.data(), nv, kMinVal);
|
|
299
|
+
return res;
|
|
300
|
+
}
|
|
301
|
+
// warm start (engine_forward.c:1071-1150): keep the warm start unless its total cost exceeds qacc_smooth's
|
|
302
|
+
std::vector<double> jar(ne), f(ne), Mv(nv), da(nv);
|
|
303
|
+
std::vector<int> st(ne);
|
|
304
|
+
if (warm) {
|
|
305
|
+
for (int r = 0; r < ne; ++r) jar[r] = dot(p.J + static_cast<size_t>(r) * nv, warm, nv) - p.aref[r];
|
|
306
|
+
double cost_warm = constraint_update(p, jar.data(), f.data(), st.data());
|
|
307
|
+
for (int i = 0; i < nv; ++i) da[i] = warm[i] - p.qacc_smooth[i];
|
|
308
|
+
mul_sym(p.M, da.data(), Mv.data(), nv);
|
|
309
|
+
cost_warm += 0.5 * dot(da.data(), Mv.data(), nv);
|
|
310
|
+
for (int r = 0; r < ne; ++r) jar[r] = dot(p.J + static_cast<size_t>(r) * nv, p.qacc_smooth, nv) - p.aref[r];
|
|
311
|
+
const double cost_smooth = constraint_update(p, jar.data(), f.data(), st.data());
|
|
312
|
+
if (!(cost_warm > cost_smooth)) { res.qacc.assign(warm, warm + nv); res.warm_used = true; }
|
|
313
|
+
}
|
|
314
|
+
Ctx c;
|
|
315
|
+
c.p = &p; c.nv = nv; c.nefc = ne;
|
|
316
|
+
double tr = 0;
|
|
317
|
+
for (int i = 0; i < nv; ++i) tr += p.M[i * nv + i];
|
|
318
|
+
c.scale = 1 / tr;
|
|
319
|
+
c.qacc = res.qacc;
|
|
320
|
+
c.Ma.assign(nv, 0); c.Jaref.assign(ne, 0); c.force.assign(ne, 0); c.qfrc_c.assign(nv, 0); c.grad.assign(nv, 0);
|
|
321
|
+
c.Mgrad.assign(nv, 0); c.search.assign(nv, 0); c.Mv.assign(nv, 0); c.Jv.assign(ne, 0); c.L.assign(nv * nv, 0);
|
|
322
|
+
c.state.assign(ne, kSatisfied);
|
|
323
|
+
mul_sym(p.M, c.qacc.data(), c.Ma.data(), nv);
|
|
324
|
+
for (int r = 0; r < ne; ++r) c.Jaref[r] = dot(p.J + static_cast<size_t>(r) * nv, c.qacc.data(), nv) - p.aref[r];
|
|
325
|
+
update_constraint(c);
|
|
326
|
+
update_grad(c);
|
|
327
|
+
// zero-iteration exits (:2914-2945): Mgrad = M^-1 grad (MuJoCo: qLD; here a dense Cholesky of M, roundoff only)
|
|
328
|
+
std::vector<double> LM(p.M, p.M + static_cast<size_t>(nv) * nv);
|
|
329
|
+
chol_factor(LM.data(), nv, kMinVal);
|
|
330
|
+
chol_solve(LM.data(), c.Mgrad.data(), c.grad.data(), nv);
|
|
331
|
+
const bool flg_gap = std::max(0.0, 0.5 * c.scale * dot(c.grad.data(), c.Mgrad.data(), nv)) < p.tolerance;
|
|
332
|
+
const bool flg_gradient = c.scale * norm(c.grad.data(), nv) < p.tolerance;
|
|
333
|
+
bool done = flg_gap && flg_gradient;
|
|
334
|
+
if (!done) {
|
|
335
|
+
factorize_hessian(c);
|
|
336
|
+
chol_solve(c.L.data(), c.Mgrad.data(), c.grad.data(), nv);
|
|
337
|
+
done = flg_gradient && std::max(0.0, 0.5 * c.scale * dot(c.grad.data(), c.Mgrad.data(), nv)) < p.tolerance;
|
|
338
|
+
}
|
|
339
|
+
for (int i = 0; i < nv; ++i) c.search[i] = -c.Mgrad[i];
|
|
340
|
+
int iter = 0;
|
|
341
|
+
while (!done && iter < p.iterations) {
|
|
342
|
+
double ls_improvement = 0;
|
|
343
|
+
const double alpha = search(c, p.tolerance * p.ls_tolerance, p.ls_iterations, &ls_improvement);
|
|
344
|
+
if (alpha == 0) { res.stalled = true; break; }
|
|
345
|
+
for (int i = 0; i < nv; ++i) { c.qacc[i] += alpha * c.search[i]; c.Ma[i] += alpha * c.Mv[i]; }
|
|
346
|
+
for (int r = 0; r < ne; ++r) c.Jaref[r] += alpha * c.Jv[r];
|
|
347
|
+
const std::vector<int> oldstate = c.state;
|
|
348
|
+
update_constraint(c);
|
|
349
|
+
hessian_incremental(c, oldstate);
|
|
350
|
+
update_grad(c);
|
|
351
|
+
chol_solve(c.L.data(), c.Mgrad.data(), c.grad.data(), nv);
|
|
352
|
+
const double improvement = c.scale * ls_improvement;
|
|
353
|
+
const double gradient = c.scale * norm(c.grad.data(), nv);
|
|
354
|
+
const double decrement = std::max(0.0, 0.5 * c.scale * dot(c.grad.data(), c.Mgrad.data(), nv));
|
|
355
|
+
++iter;
|
|
356
|
+
if ((improvement > 0 && improvement < p.tolerance) || gradient < p.tolerance || decrement < p.tolerance) { done = true; break; }
|
|
357
|
+
for (int i = 0; i < nv; ++i) c.search[i] = -c.Mgrad[i];
|
|
358
|
+
}
|
|
359
|
+
res.ran_out = !done && !res.stalled;
|
|
360
|
+
// the factor at the final states (the tape's L_H): refactorize if the last incremental update left it stale
|
|
361
|
+
res.qacc = c.qacc;
|
|
362
|
+
res.force = c.force;
|
|
363
|
+
res.state = c.state;
|
|
364
|
+
res.qfrc_constraint = c.qfrc_c;
|
|
365
|
+
res.niter = iter;
|
|
366
|
+
factorize_hessian(c);
|
|
367
|
+
res.L = c.L;
|
|
368
|
+
return res;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
} // namespace js::soft::newton
|
|
@@ -0,0 +1,176 @@
|
|
|
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): the soft law's constraint rows for one state, MuJoCo 3.16.0's mj_makeConstraint for the
|
|
6
|
+
// G1 scene (LAW_SPEC_MUJOCO316.md: row order, joint limits, contacts, diagApprox, impedance, reference): geom poses, the
|
|
7
|
+
// colliders over the exported candidate pairs, then the rows in MuJoCo's order (limits by joint, lower side first; then the
|
|
8
|
+
// contacts in contact order: condim 1 one frictionless row, condim 3 four pyramid edges), each with J (dense, nv), pos,
|
|
9
|
+
// margin, diagA, imp, R, D, K, B and aref. Templated on the scalar (C2's Dual evaluates the rows at a fixed contact set:
|
|
10
|
+
// `fixed` replays a recorded contact list instead of colliding).
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
#include "collide.h"
|
|
14
|
+
#include "kin.h"
|
|
15
|
+
|
|
16
|
+
namespace js::soft {
|
|
17
|
+
|
|
18
|
+
struct SoftGeom { int body, type; double size[3], pos[3], quat[4]; };
|
|
19
|
+
struct SoftPair {
|
|
20
|
+
int g1, g2, condim, foot; // foot: a foot geom whose per-world friction overrides the pair's (-1: none)
|
|
21
|
+
double friction[3], solref[2], solimp[5], margin, gap;
|
|
22
|
+
};
|
|
23
|
+
struct SoftJoint { int dof, qadr; bool limited; double range[2], solref[2], solimp[5], margin; };
|
|
24
|
+
|
|
25
|
+
enum RowType { kRowLimit = 3, kRowFrictionless = 5, kRowPyramidal = 6 }; // mjtConstraint (mjtype.h:538-548, 3.16.0)
|
|
26
|
+
|
|
27
|
+
// one contact (the rows' source), MuJoCo's mjContact fields the law reads
|
|
28
|
+
template <class S> struct SoftContact {
|
|
29
|
+
int pair, slot, condim;
|
|
30
|
+
S dist;
|
|
31
|
+
V3<S> pos, frame[3];
|
|
32
|
+
double mu; // friction[0] after the foot override and mjMINMU (pyramid edges use it for both tangents)
|
|
33
|
+
double solref[2], solimp[5], includemargin;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
template <class S> struct Rows {
|
|
37
|
+
int nv = 0, n = 0;
|
|
38
|
+
std::vector<int> type, id; // id: joint index (limit) or contact index
|
|
39
|
+
std::vector<S> J, pos, aref, R, D, imp; // J row-major n x nv
|
|
40
|
+
std::vector<double> margin, diagA, K, B;
|
|
41
|
+
void clear(int nv_) { nv = nv_; n = 0; type.clear(); id.clear(); J.clear(); pos.clear(); aref.clear(); R.clear(); D.clear();
|
|
42
|
+
imp.clear(); margin.clear(); diagA.clear(); K.clear(); B.clear(); }
|
|
43
|
+
S* add(int t, int i, S p, double mg, double dA) {
|
|
44
|
+
type.push_back(t); id.push_back(i); pos.push_back(p); margin.push_back(mg); diagA.push_back(dA);
|
|
45
|
+
aref.push_back(S(0)); R.push_back(S(0)); D.push_back(S(0)); imp.push_back(S(0)); K.push_back(0); B.push_back(0);
|
|
46
|
+
J.resize(static_cast<size_t>(n + 1) * nv, S(0));
|
|
47
|
+
return J.data() + static_cast<size_t>(n++) * nv;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// the geom's world pose: xpos = xpos_b + xmat_b pos; R = quat2mat(xquat_b * quat) (mj_kinematics' geom loop)
|
|
52
|
+
template <class S> DN_HOST_DEVICE GeomPose<S> geom_pose(const BodyState<S>& x, const SoftGeom& g) {
|
|
53
|
+
GeomPose<S> gp;
|
|
54
|
+
S t[3];
|
|
55
|
+
mat_vec(x.xmat, g.pos, t);
|
|
56
|
+
gp.p = V3<S>{x.xpos[0] + t[0], x.xpos[1] + t[1], x.xpos[2] + t[2]};
|
|
57
|
+
S gq[4] = {S(g.quat[0]), S(g.quat[1]), S(g.quat[2]), S(g.quat[3])}, q[4];
|
|
58
|
+
quat_mul(x.xquat, gq, q);
|
|
59
|
+
quat_to_mat(q, gp.R);
|
|
60
|
+
return gp;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// the contacts of one state over every candidate pair, in pair order then collider order; a contact is kept (and makes
|
|
64
|
+
// rows) iff dist < includemargin (mj_collision's exclude test, :1865). foot_friction < 0: the exported value.
|
|
65
|
+
template <class S>
|
|
66
|
+
void collide_all(const SoftGeom* geoms, int ng, const SoftPair* pairs, int np, const BodyState<S>* X, double foot_friction,
|
|
67
|
+
std::vector<SoftContact<S>>& out) {
|
|
68
|
+
std::vector<GeomPose<S>> gp(ng);
|
|
69
|
+
for (int g = 0; g < ng; ++g) gp[g] = geom_pose(X[geoms[g].body], geoms[g]);
|
|
70
|
+
out.clear();
|
|
71
|
+
for (int i = 0; i < np; ++i) {
|
|
72
|
+
const SoftPair& pr = pairs[i];
|
|
73
|
+
const SoftGeom &a = geoms[pr.g1], &b = geoms[pr.g2];
|
|
74
|
+
PreContact<S> pc[4];
|
|
75
|
+
const int n = collide(pc, pr.margin + pr.gap, a.type, gp[pr.g1], a.size, b.type, gp[pr.g2], b.size);
|
|
76
|
+
for (int k = 0; k < n; ++k) {
|
|
77
|
+
if (!(pc[k].dist < pr.margin)) continue;
|
|
78
|
+
SoftContact<S> c;
|
|
79
|
+
c.pair = i; c.slot = pc[k].slot; c.condim = pr.condim; c.dist = pc[k].dist; c.pos = pc[k].pos;
|
|
80
|
+
make_frame(pc[k].normal, pc[k].tangent, c.frame);
|
|
81
|
+
const double f0 = (pr.foot >= 0 && foot_friction >= 0) ? foot_friction : pr.friction[0];
|
|
82
|
+
c.mu = smax(1e-5, f0); // mj_assignFriction's mjMINMU
|
|
83
|
+
for (int j = 0; j < 2; ++j) c.solref[j] = pr.solref[j];
|
|
84
|
+
for (int j = 0; j < 5; ++j) c.solimp[j] = pr.solimp[j];
|
|
85
|
+
c.includemargin = pr.margin;
|
|
86
|
+
out.push_back(c);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// geom index -> its row in the geom table, for the bodies: the contact's two bodies are the pair's geoms' bodies
|
|
92
|
+
// the rows of one state (mj_instantiateLimit, mj_instantiateContact, mj_diagApprox, mj_makeImpedance,
|
|
93
|
+
// mj_referenceConstraint). ref: the scene's timestep (refsafe) and impratio.
|
|
94
|
+
template <class S>
|
|
95
|
+
void make_rows(const SoftBody* B, const BodyState<S>* X, int nv, const double* dof_invweight0, const SoftJoint* joints,
|
|
96
|
+
int nj, const SoftGeom* geoms, const SoftPair* pairs, const std::vector<SoftContact<S>>& con,
|
|
97
|
+
const S* qpos, const S* qvel, double timestep, double impratio, Rows<S>& rows) {
|
|
98
|
+
assert(nv <= 64 && "make_rows: the contact Jacobian scratch holds 64 dofs");
|
|
99
|
+
rows.clear(nv);
|
|
100
|
+
// limits: joints in order, the lower side then the upper; a row iff dist < margin (strict)
|
|
101
|
+
for (int j = 0; j < nj; ++j) {
|
|
102
|
+
const SoftJoint& jt = joints[j];
|
|
103
|
+
if (!jt.limited) continue;
|
|
104
|
+
for (int side = -1; side <= 1; side += 2) {
|
|
105
|
+
const S q = qpos[jt.qadr];
|
|
106
|
+
const S dist = side < 0 ? q - S(jt.range[0]) : S(jt.range[1]) - q;
|
|
107
|
+
if (!(dist < jt.margin)) continue;
|
|
108
|
+
S* J = rows.add(kRowLimit, j, dist, jt.margin, dof_invweight0[jt.dof]);
|
|
109
|
+
J[jt.dof] = S(side < 0 ? 1.0 : -1.0);
|
|
110
|
+
const int r = rows.n - 1;
|
|
111
|
+
const SolParam sp = sol_param(jt.solref, jt.solimp, timestep);
|
|
112
|
+
const KB kb = stiffness_damping(sp, false);
|
|
113
|
+
rows.K[r] = kb.K; rows.B[r] = kb.B;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// contacts
|
|
117
|
+
std::vector<S> jp1(3 * nv), jp2(3 * nv);
|
|
118
|
+
for (size_t c = 0; c < con.size(); ++c) {
|
|
119
|
+
const SoftContact<S>& ct = con[c];
|
|
120
|
+
const SoftPair& pr = pairs[ct.pair];
|
|
121
|
+
const int b1 = geoms[pr.g1].body, b2 = geoms[pr.g2].body;
|
|
122
|
+
const S p[3] = {ct.pos.x, ct.pos.y, ct.pos.z};
|
|
123
|
+
point_jacobian(B, X, nv, b2, p, jp2.data(), static_cast<S*>(nullptr));
|
|
124
|
+
point_jacobian(B, X, nv, b1, p, jp1.data(), static_cast<S*>(nullptr));
|
|
125
|
+
// frame rows of (J2 - J1): normal, t1, t2
|
|
126
|
+
S jc[3][64];
|
|
127
|
+
for (int d = 0; d < 3; ++d)
|
|
128
|
+
for (int i = 0; i < nv; ++i) {
|
|
129
|
+
const S dx = jp2[i] - jp1[i], dy = jp2[nv + i] - jp1[nv + i], dz = jp2[2 * nv + i] - jp1[2 * nv + i];
|
|
130
|
+
jc[d][i] = ct.frame[d].x * dx + ct.frame[d].y * dy + ct.frame[d].z * dz;
|
|
131
|
+
}
|
|
132
|
+
const double tran = B[b1].invweight0[0] + B[b2].invweight0[0];
|
|
133
|
+
const SolParam sp = sol_param(ct.solref, ct.solimp, timestep);
|
|
134
|
+
const KB kb = stiffness_damping(sp, false);
|
|
135
|
+
if (ct.condim == 1) {
|
|
136
|
+
S* J = rows.add(kRowFrictionless, static_cast<int>(c), ct.dist, ct.includemargin, tran);
|
|
137
|
+
for (int i = 0; i < nv; ++i) J[i] = jc[0][i];
|
|
138
|
+
rows.K[rows.n - 1] = kb.K; rows.B[rows.n - 1] = kb.B;
|
|
139
|
+
} else {
|
|
140
|
+
assert(ct.condim == 3 && "the G1 law: condim 1 or 3");
|
|
141
|
+
for (int k = 1; k < 3; ++k)
|
|
142
|
+
for (int s = 0; s < 2; ++s) { // J_n + mu J_tk, then J_n - mu J_tk; diagA = tran + mu^2 tran
|
|
143
|
+
S* J = rows.add(kRowPyramidal, static_cast<int>(c), ct.dist, ct.includemargin, tran + ct.mu * ct.mu * tran);
|
|
144
|
+
const S sg = S(s == 0 ? ct.mu : -ct.mu);
|
|
145
|
+
for (int i = 0; i < nv; ++i) J[i] = jc[0][i] + sg * jc[k][i];
|
|
146
|
+
rows.K[rows.n - 1] = kb.K; rows.B[rows.n - 1] = kb.B;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// impedance, R (the pyramid pass), D, aref
|
|
151
|
+
for (int r = 0; r < rows.n; ++r) {
|
|
152
|
+
const double* solimp = rows.type[r] == kRowLimit ? joints[rows.id[r]].solimp : con[rows.id[r]].solimp;
|
|
153
|
+
const SolParam sp = rows.type[r] == kRowLimit ? sol_param(joints[rows.id[r]].solref, solimp, timestep)
|
|
154
|
+
: sol_param(con[rows.id[r]].solref, solimp, timestep);
|
|
155
|
+
rows.imp[r] = impedance(sp.imp, rows.pos[r], rows.margin[r]);
|
|
156
|
+
rows.R[r] = regularizer(rows.imp[r], rows.diagA[r]);
|
|
157
|
+
}
|
|
158
|
+
for (int r = 0; r < rows.n;) {
|
|
159
|
+
if (rows.type[r] == kRowPyramidal) { // the four rows of one contact share Rpy = 2 mu^2 R[first]
|
|
160
|
+
const S Rpy = pyramid_regularizer(rows.R[r], con[rows.id[r]].mu, impratio);
|
|
161
|
+
for (int j = 0; j < 4; ++j) rows.R[r + j] = Rpy;
|
|
162
|
+
r += 4;
|
|
163
|
+
} else {
|
|
164
|
+
++r;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (int r = 0; r < rows.n; ++r) {
|
|
168
|
+
rows.D[r] = S(1) / rows.R[r];
|
|
169
|
+
S vel = S(0);
|
|
170
|
+
const S* J = rows.J.data() + static_cast<size_t>(r) * nv;
|
|
171
|
+
for (int i = 0; i < nv; ++i) vel = vel + J[i] * qvel[i];
|
|
172
|
+
rows.aref[r] = reference_accel(KB{rows.K[r], rows.B[r]}, rows.imp[r], vel, rows.pos[r], rows.margin[r]);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
} // namespace js::soft
|