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,782 @@
|
|
|
1
|
+
// D16 C1 / C2 test binding (2026-11-02): a plain C ABI over the soft law's CPU f64 headers (core/soft/), loaded
|
|
2
|
+
// by tools/d16/*.py with ctypes, so the law and its derivative are gated against the MuJoCo reference corpus without the
|
|
3
|
+
// CMake build of the CPU oracle. Not the engine's binding: the dnmodel switch (contact.law) and the GPU path come later.
|
|
4
|
+
// Build (Mac or Linux, no CUDA):
|
|
5
|
+
// c++ -std=c++17 -O2 -fPIC -shared -I core -I core/include bindings/soft_capi.cpp -o build-soft/libsoftcapi.so
|
|
6
|
+
#include <cstdio>
|
|
7
|
+
#include <cstdlib>
|
|
8
|
+
#include <thread>
|
|
9
|
+
#include <type_traits>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
#include "soft/kin.h"
|
|
13
|
+
#include "soft/rows.h"
|
|
14
|
+
#include "soft/step.h"
|
|
15
|
+
#include "soft/jvp.h"
|
|
16
|
+
#include "soft/tape.h"
|
|
17
|
+
#include "soft/hand.h"
|
|
18
|
+
|
|
19
|
+
namespace {
|
|
20
|
+
|
|
21
|
+
struct Model {
|
|
22
|
+
std::vector<js::soft::SoftBody> bodies;
|
|
23
|
+
std::vector<js::soft::SoftGeom> geoms;
|
|
24
|
+
std::vector<js::soft::SoftPair> pairs;
|
|
25
|
+
std::vector<js::soft::SoftJoint> joints;
|
|
26
|
+
std::vector<double> dof_invweight0;
|
|
27
|
+
double timestep = 0, impratio = 1;
|
|
28
|
+
js::soft::SoftModel sm; // the whole law (soft_model_act)
|
|
29
|
+
std::vector<double> armature;
|
|
30
|
+
double gravity[3];
|
|
31
|
+
int nb = 0, nq = 0, nv = 0;
|
|
32
|
+
bool law_ready = false, act_ready = false; // soft_model_law / soft_model_act ran (fail-fast: never a silent empty law)
|
|
33
|
+
#if !defined(__CUDACC__) || defined(D16_G1_COMDR)
|
|
34
|
+
// COMDR (tools/g1_seconds/COMDR_DESIGN.md): a per-world offset [anc_n, 3] added to body anc_body's ipos, set once
|
|
35
|
+
// (soft_set_anchor_ipos_offset); read only by the *_anc batch entry points. Compiled in the CPU library (no __CUDACC__) and in a
|
|
36
|
+
// CUDA unit only under -DD16_G1_COMDR, so the default CUDA builds' tokens are unchanged (tools/d16_bodies/token_check.py)
|
|
37
|
+
int anc_body = -1, anc_n = 0;
|
|
38
|
+
std::vector<double> anc_off;
|
|
39
|
+
#endif
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// fail fast whatever NDEBUG says: a model used before its law or actuators were pushed stops with this message
|
|
43
|
+
inline void require(bool ok, const char* what) {
|
|
44
|
+
if (!ok) { std::fprintf(stderr, "soft_capi: %s\n", what); std::abort(); }
|
|
45
|
+
}
|
|
46
|
+
inline const Model& law_model(void* h) {
|
|
47
|
+
const Model& m = *static_cast<Model*>(h);
|
|
48
|
+
require(m.law_ready, "the law (geoms, pairs, joints) was not pushed: call soft_model_law first");
|
|
49
|
+
return m;
|
|
50
|
+
}
|
|
51
|
+
inline const Model& act_model(void* h) {
|
|
52
|
+
const Model& m = law_model(h);
|
|
53
|
+
require(m.act_ready, "the actuators and solver options were not pushed: call soft_model_act first (a step without "
|
|
54
|
+
"them has no actuator term)");
|
|
55
|
+
return m;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
} // namespace
|
|
59
|
+
|
|
60
|
+
extern "C" {
|
|
61
|
+
|
|
62
|
+
// Model from flat arrays (the JSON's bodies in MuJoCo order); returns an opaque handle
|
|
63
|
+
void* soft_model_new(int nb, int nq, int nv, const int* parent, const int* jnt_type, const int* qadr, const int* dadr,
|
|
64
|
+
const double* pos, const double* quat, const double* ipos, const double* iquat, const double* mass,
|
|
65
|
+
const double* inertia, const double* axis, const double* invweight0, const double* armature,
|
|
66
|
+
const double* gravity) {
|
|
67
|
+
auto* m = new Model;
|
|
68
|
+
m->nb = nb; m->nq = nq; m->nv = nv;
|
|
69
|
+
m->bodies.resize(nb);
|
|
70
|
+
for (int b = 0; b < nb; ++b) {
|
|
71
|
+
js::soft::SoftBody& d = m->bodies[b];
|
|
72
|
+
d.parent = parent[b]; d.jnt_type = jnt_type[b]; d.qadr = qadr[b]; d.dadr = dadr[b];
|
|
73
|
+
for (int k = 0; k < 3; ++k) { d.pos[k] = pos[3 * b + k]; d.ipos[k] = ipos[3 * b + k]; d.inertia[k] = inertia[3 * b + k];
|
|
74
|
+
d.axis[k] = axis[3 * b + k]; }
|
|
75
|
+
for (int k = 0; k < 4; ++k) { d.quat[k] = quat[4 * b + k]; d.iquat[k] = iquat[4 * b + k]; }
|
|
76
|
+
d.mass = mass[b];
|
|
77
|
+
d.invweight0[0] = invweight0[2 * b]; d.invweight0[1] = invweight0[2 * b + 1];
|
|
78
|
+
}
|
|
79
|
+
m->armature.assign(armature, armature + nv);
|
|
80
|
+
for (int k = 0; k < 3; ++k) m->gravity[k] = gravity[k];
|
|
81
|
+
return m;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void soft_model_free(void* h) { delete static_cast<Model*>(h); }
|
|
85
|
+
|
|
86
|
+
// The smooth quantities of one state: xpos [nb, 3], xquat [nb, 4], M [nv, nv], qfrc_bias [nv]
|
|
87
|
+
void soft_smooth(void* h, const double* qpos, const double* qvel, double* xpos, double* xquat, double* M, double* bias) {
|
|
88
|
+
const Model& m = *static_cast<Model*>(h);
|
|
89
|
+
std::vector<js::soft::BodyState<double>> X(m.nb);
|
|
90
|
+
std::vector<double> jp(3 * m.nv), jr(3 * m.nv), w(3 * m.nb), al(3 * m.nb), vo(3 * m.nb), ao(3 * m.nb);
|
|
91
|
+
js::soft::fk(m.bodies.data(), m.nb, qpos, X.data());
|
|
92
|
+
for (int b = 0; b < m.nb; ++b) {
|
|
93
|
+
for (int k = 0; k < 3; ++k) xpos[3 * b + k] = X[b].xpos[k];
|
|
94
|
+
for (int k = 0; k < 4; ++k) xquat[4 * b + k] = X[b].xquat[k];
|
|
95
|
+
}
|
|
96
|
+
js::soft::mass_matrix(m.bodies.data(), m.nb, X.data(), m.nv, m.armature.data(), M, jp.data(), jr.data());
|
|
97
|
+
js::soft::bias(m.bodies.data(), m.nb, X.data(), m.nv, qvel, m.gravity, bias, jp.data(), jr.data(), w.data(), al.data(),
|
|
98
|
+
vo.data(), ao.data());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// the law's data: geoms [ng] (body, type, size 3, pos 3, quat 4), pairs [np] (g1, g2, condim, foot; friction 3, solref 2,
|
|
102
|
+
// solimp 5, margin, gap), hinge joints [nj] (dof, qadr, limited; range 2, solref 2, solimp 5, margin), dof_invweight0 [nv]
|
|
103
|
+
void soft_model_law(void* h, int ng, const int* g_int, const double* g_dbl, int np, const int* p_int, const double* p_dbl,
|
|
104
|
+
int nj, const int* j_int, const double* j_dbl, const double* dof_invweight0, double timestep,
|
|
105
|
+
double impratio) {
|
|
106
|
+
Model& m = *static_cast<Model*>(h);
|
|
107
|
+
m.geoms.resize(ng);
|
|
108
|
+
for (int g = 0; g < ng; ++g) {
|
|
109
|
+
js::soft::SoftGeom& x = m.geoms[g];
|
|
110
|
+
x.body = g_int[2 * g]; x.type = g_int[2 * g + 1];
|
|
111
|
+
const double* d = g_dbl + 10 * g;
|
|
112
|
+
for (int k = 0; k < 3; ++k) { x.size[k] = d[k]; x.pos[k] = d[3 + k]; }
|
|
113
|
+
for (int k = 0; k < 4; ++k) x.quat[k] = d[6 + k];
|
|
114
|
+
}
|
|
115
|
+
m.pairs.resize(np);
|
|
116
|
+
for (int i = 0; i < np; ++i) {
|
|
117
|
+
js::soft::SoftPair& x = m.pairs[i];
|
|
118
|
+
x.g1 = p_int[4 * i]; x.g2 = p_int[4 * i + 1]; x.condim = p_int[4 * i + 2]; x.foot = p_int[4 * i + 3];
|
|
119
|
+
const double* d = p_dbl + 12 * i;
|
|
120
|
+
for (int k = 0; k < 3; ++k) x.friction[k] = d[k];
|
|
121
|
+
for (int k = 0; k < 2; ++k) x.solref[k] = d[3 + k];
|
|
122
|
+
for (int k = 0; k < 5; ++k) x.solimp[k] = d[5 + k];
|
|
123
|
+
x.margin = d[10]; x.gap = d[11];
|
|
124
|
+
}
|
|
125
|
+
m.joints.resize(nj);
|
|
126
|
+
for (int j = 0; j < nj; ++j) {
|
|
127
|
+
js::soft::SoftJoint& x = m.joints[j];
|
|
128
|
+
x.dof = j_int[3 * j]; x.qadr = j_int[3 * j + 1]; x.limited = j_int[3 * j + 2] != 0;
|
|
129
|
+
const double* d = j_dbl + 10 * j;
|
|
130
|
+
for (int k = 0; k < 2; ++k) { x.range[k] = d[k]; x.solref[k] = d[2 + k]; }
|
|
131
|
+
for (int k = 0; k < 5; ++k) x.solimp[k] = d[4 + k];
|
|
132
|
+
x.margin = d[9];
|
|
133
|
+
}
|
|
134
|
+
m.dof_invweight0.assign(dof_invweight0, dof_invweight0 + m.nv);
|
|
135
|
+
m.timestep = timestep; m.impratio = impratio;
|
|
136
|
+
m.law_ready = true;
|
|
137
|
+
m.act_ready = false; // soft_model_act copies the law into the step model: a new law needs the actuators pushed again
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// the rows of one state (up to cap): returns nefc (-1 if over cap); type, id, J [nefc, nv], pos, aref, D, R; and the
|
|
141
|
+
// contacts (up to ccap): pair, slot, dist, pos 3, frame 9 -> ncon in *ncon_out
|
|
142
|
+
int soft_rows(void* h, const double* qpos, const double* qvel, double foot_friction, int cap, int* type, int* id, double* J,
|
|
143
|
+
double* pos, double* aref, double* D, double* R, int ccap, int* cpair, int* cslot, double* cdist,
|
|
144
|
+
double* cpos, double* cframe, int* ncon_out) {
|
|
145
|
+
const Model& m = law_model(h);
|
|
146
|
+
std::vector<js::soft::BodyState<double>> X(m.nb);
|
|
147
|
+
js::soft::fk(m.bodies.data(), m.nb, qpos, X.data());
|
|
148
|
+
std::vector<js::soft::SoftContact<double>> con;
|
|
149
|
+
js::soft::collide_all(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()),
|
|
150
|
+
X.data(), foot_friction, con);
|
|
151
|
+
js::soft::Rows<double> rows;
|
|
152
|
+
js::soft::make_rows(m.bodies.data(), X.data(), m.nv, m.dof_invweight0.data(), m.joints.data(),
|
|
153
|
+
static_cast<int>(m.joints.size()), m.geoms.data(), m.pairs.data(), con, qpos, qvel, m.timestep,
|
|
154
|
+
m.impratio, rows);
|
|
155
|
+
*ncon_out = static_cast<int>(con.size());
|
|
156
|
+
for (int c = 0; c < static_cast<int>(con.size()) && c < ccap; ++c) {
|
|
157
|
+
cpair[c] = con[c].pair; cslot[c] = con[c].slot; cdist[c] = con[c].dist;
|
|
158
|
+
cpos[3 * c] = con[c].pos.x; cpos[3 * c + 1] = con[c].pos.y; cpos[3 * c + 2] = con[c].pos.z;
|
|
159
|
+
for (int d = 0; d < 3; ++d) { cframe[9 * c + 3 * d] = con[c].frame[d].x; cframe[9 * c + 3 * d + 1] = con[c].frame[d].y;
|
|
160
|
+
cframe[9 * c + 3 * d + 2] = con[c].frame[d].z; }
|
|
161
|
+
}
|
|
162
|
+
if (rows.n > cap) return -1;
|
|
163
|
+
for (int r = 0; r < rows.n; ++r) {
|
|
164
|
+
type[r] = rows.type[r]; id[r] = rows.id[r]; pos[r] = rows.pos[r]; aref[r] = rows.aref[r]; D[r] = rows.D[r];
|
|
165
|
+
R[r] = rows.R[r];
|
|
166
|
+
for (int i = 0; i < m.nv; ++i) J[r * m.nv + i] = rows.J[static_cast<size_t>(r) * m.nv + i];
|
|
167
|
+
}
|
|
168
|
+
return rows.n;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// actuators [nu] (dof, qadr, forcelimited; kp, kd, lo, hi) and the solver options; armature / gravity / timestep come from
|
|
172
|
+
// soft_model_new / soft_model_law
|
|
173
|
+
void soft_model_act(void* h, int nu, const int* a_int, const double* a_dbl, int iterations, int ls_iterations,
|
|
174
|
+
double tolerance, double ls_tolerance) {
|
|
175
|
+
Model& m = *static_cast<Model*>(h);
|
|
176
|
+
require(m.law_ready, "soft_model_act before soft_model_law");
|
|
177
|
+
require(nu > 0, "soft_model_act with no actuators");
|
|
178
|
+
js::soft::SoftModel& sm = m.sm;
|
|
179
|
+
sm.bodies = m.bodies; sm.geoms = m.geoms; sm.pairs = m.pairs; sm.joints = m.joints;
|
|
180
|
+
sm.armature = m.armature; sm.dof_invweight0 = m.dof_invweight0;
|
|
181
|
+
for (int k = 0; k < 3; ++k) sm.gravity[k] = m.gravity[k];
|
|
182
|
+
sm.timestep = m.timestep; sm.impratio = m.impratio; sm.nq = m.nq; sm.nv = m.nv;
|
|
183
|
+
sm.iterations = iterations; sm.ls_iterations = ls_iterations; sm.tolerance = tolerance; sm.ls_tolerance = ls_tolerance;
|
|
184
|
+
sm.actuators.resize(nu);
|
|
185
|
+
for (int u = 0; u < nu; ++u) {
|
|
186
|
+
js::soft::SoftActuator& a = sm.actuators[u];
|
|
187
|
+
a.dof = a_int[3 * u]; a.qadr = a_int[3 * u + 1]; a.forcelimited = a_int[3 * u + 2] != 0;
|
|
188
|
+
a.kp = a_dbl[4 * u]; a.kd = a_dbl[4 * u + 1]; a.lo = a_dbl[4 * u + 2]; a.hi = a_dbl[4 * u + 3];
|
|
189
|
+
}
|
|
190
|
+
m.act_ready = true;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
} // extern "C"
|
|
194
|
+
|
|
195
|
+
namespace {
|
|
196
|
+
|
|
197
|
+
js::soft::SoftModel step_model(void* h, int iterations, double tolerance) {
|
|
198
|
+
js::soft::SoftModel sm = act_model(h).sm;
|
|
199
|
+
if (iterations > 0) sm.iterations = iterations;
|
|
200
|
+
if (tolerance > 0) sm.tolerance = tolerance;
|
|
201
|
+
return sm;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// the tracked bodies' frames of qpos (the law's own fk, as the step's): xpos [nbt, 3], xquat [nbt, 4]; with qvel and xvel
|
|
205
|
+
// (the A2, 2026-11-02) also their world velocities as the trainer defines them (dnmodel_monitor.body_twists_from_poses): the
|
|
206
|
+
// body origin's linear velocity xvel = Jp(b, xpos_b) qvel and the angular velocity xangvel = Jr(b) qvel, [nbt, 3] each
|
|
207
|
+
template <class S>
|
|
208
|
+
void tracked_poses(const js::soft::SoftModel& sm, const S* qpos, int nbt, const int* body_ids, S* xpos, S* xquat,
|
|
209
|
+
const S* qvel = nullptr, S* xvel = nullptr, S* xangvel = nullptr) {
|
|
210
|
+
const int nb = static_cast<int>(sm.bodies.size()), nv = sm.nv;
|
|
211
|
+
std::vector<js::soft::BodyState<S>> X(nb);
|
|
212
|
+
js::soft::fk(sm.bodies.data(), nb, qpos, X.data());
|
|
213
|
+
std::vector<S> jp(xvel ? 3 * nv : 0), jr(xvel ? 3 * nv : 0);
|
|
214
|
+
for (int j = 0; j < nbt; ++j) {
|
|
215
|
+
const int b = body_ids[j];
|
|
216
|
+
for (int k = 0; k < 3; ++k) xpos[3 * j + k] = X[b].xpos[k];
|
|
217
|
+
for (int k = 0; k < 4; ++k) xquat[4 * j + k] = X[b].xquat[k];
|
|
218
|
+
if (!xvel) continue;
|
|
219
|
+
js::soft::point_jacobian(sm.bodies.data(), X.data(), nv, b, X[b].xpos, jp.data(), jr.data());
|
|
220
|
+
for (int k = 0; k < 3; ++k) {
|
|
221
|
+
S a(0.0), w(0.0);
|
|
222
|
+
for (int i = 0; i < nv; ++i) { a = a + jp[k * nv + i] * qvel[i]; w = w + jr[k * nv + i] * qvel[i]; }
|
|
223
|
+
xvel[3 * j + k] = a; xangvel[3 * j + k] = w;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
void check_bodies(const js::soft::SoftModel& sm, int nbt, const int* body_ids, const void* xpos, const void* xquat) {
|
|
229
|
+
if (nbt == 0) return;
|
|
230
|
+
require(nbt > 0 && body_ids && xpos && xquat, "tracked poses: nbt > 0 needs body_ids, xpos and xquat");
|
|
231
|
+
for (int j = 0; j < nbt; ++j)
|
|
232
|
+
require(body_ids[j] >= 0 && body_ids[j] < static_cast<int>(sm.bodies.size()), "tracked poses: body id out of range");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// one env's control step: nsub substeps in place, stats [nsub, 6] (or null), then the tracked poses at the output state
|
|
236
|
+
void step_one(const js::soft::SoftModel& sm, double* qpos, double* qvel, double* warm, const double* ctrl, double foot_friction,
|
|
237
|
+
int nsub, int* stats, int nbt, const int* body_ids, double* xpos, double* xquat, double* xvel = nullptr,
|
|
238
|
+
double* xangvel = nullptr) {
|
|
239
|
+
for (int k = 0; k < nsub; ++k) {
|
|
240
|
+
const js::soft::SubstepStats st = js::soft::substep(sm, qpos, qvel, warm, ctrl, foot_friction);
|
|
241
|
+
if (!stats) continue;
|
|
242
|
+
stats[6 * k] = st.ncon; stats[6 * k + 1] = st.nefc; stats[6 * k + 2] = st.niter; stats[6 * k + 3] = st.warm_used;
|
|
243
|
+
stats[6 * k + 4] = static_cast<int>(st.dec_hash & 0xffffffffULL); stats[6 * k + 5] = static_cast<int>(st.dec_hash >> 32);
|
|
244
|
+
}
|
|
245
|
+
if (nbt) tracked_poses(sm, qpos, nbt, body_ids, xpos, xquat, static_cast<const double*>(qvel), xvel, xangvel);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// envs 0..n-1, each on one thread of nthreads (env i on thread i % T): envs are independent, so the results do not depend
|
|
249
|
+
// on nthreads
|
|
250
|
+
template <class F> void for_envs(int n, int nthreads, F f) {
|
|
251
|
+
const int T = std::max(1, std::min(nthreads, n));
|
|
252
|
+
if (T == 1) { for (int i = 0; i < n; ++i) f(i); return; }
|
|
253
|
+
std::vector<std::thread> th;
|
|
254
|
+
for (int t = 0; t < T; ++t) th.emplace_back([&f, n, T, t] { for (int i = t; i < n; i += T) f(i); });
|
|
255
|
+
for (std::thread& x : th) x.join();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
} // namespace
|
|
259
|
+
|
|
260
|
+
extern "C" {
|
|
261
|
+
|
|
262
|
+
// nsub substeps in place on (qpos, qvel, warm) with ctrl held; iterations / tolerance override the model's when > 0;
|
|
263
|
+
// per substep stats [nsub, 6]: ncon, nefc, niter, warm_used, and the decisions' fingerprint as two 32-bit halves
|
|
264
|
+
void soft_control_step(void* h, double* qpos, double* qvel, double* warm, const double* ctrl, double foot_friction,
|
|
265
|
+
int nsub, int iterations, double tolerance, int* stats) {
|
|
266
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
267
|
+
step_one(sm, qpos, qvel, warm, ctrl, foot_friction, nsub, stats, 0, nullptr, nullptr, nullptr);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// d5's API (A) +, 2026-11-02: n envs, one control step each, MuJoCo's native layout, in place: qpos [n, nq], qvel [n, nv],
|
|
271
|
+
// warm [n, nv]; ctrl [n, nu]; fric [n] (null: foot_friction for every env); stats [n, nsub, 6] as soft_control_step (null:
|
|
272
|
+
// none); the tracked bodies' frames at the output state (the law's fk): body_ids [nbt] -> xpos [n, nbt, 3], xquat [n, nbt, 4]
|
|
273
|
+
// (nbt 0: none). nthreads: CPU threads over envs (the results do not depend on it).
|
|
274
|
+
void soft_control_step_batch(void* h, int n, double* qpos, double* qvel, double* warm, const double* ctrl, const double* fric,
|
|
275
|
+
double foot_friction, int nsub, int iterations, double tolerance, int nthreads, int* stats,
|
|
276
|
+
int nbt, const int* body_ids, double* xpos, double* xquat, double* xvel, double* xangvel) {
|
|
277
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
278
|
+
check_bodies(sm, nbt, body_ids, xpos, xquat);
|
|
279
|
+
const size_t nq = sm.nq, nv = sm.nv, nu = sm.actuators.size();
|
|
280
|
+
for_envs(n, nthreads, [&](int i) {
|
|
281
|
+
step_one(sm, qpos + i * nq, qvel + i * nv, warm + i * nv, ctrl + i * nu, fric ? fric[i] : foot_friction, nsub,
|
|
282
|
+
stats ? stats + static_cast<size_t>(i) * nsub * 6 : nullptr, nbt, body_ids,
|
|
283
|
+
nbt ? xpos + static_cast<size_t>(i) * nbt * 3 : nullptr, nbt ? xquat + static_cast<size_t>(i) * nbt * 4 : nullptr,
|
|
284
|
+
nbt && xvel ? xvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
285
|
+
nbt && xangvel ? xangvel + static_cast<size_t>(i) * nbt * 3 : nullptr);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// the tracked bodies' frames and world velocities at given states (no step): qpos [n, nq], qvel [n, nv] -> xpos [n, nbt, 3],
|
|
290
|
+
// xquat [n, nbt, 4], xvel / xangvel [n, nbt, 3] (null: frames only)
|
|
291
|
+
void soft_body_frames(void* h, int n, const double* qpos, const double* qvel, int nbt, const int* body_ids, double* xpos,
|
|
292
|
+
double* xquat, double* xvel, double* xangvel) {
|
|
293
|
+
const js::soft::SoftModel& sm = act_model(h).sm;
|
|
294
|
+
check_bodies(sm, nbt, body_ids, xpos, xquat);
|
|
295
|
+
require(!xvel == !xangvel && (!xvel || qvel), "body frames: xvel and xangvel together, with qvel");
|
|
296
|
+
const size_t nq = sm.nq, nv = sm.nv;
|
|
297
|
+
for (int i = 0; i < n; ++i)
|
|
298
|
+
tracked_poses(sm, qpos + i * nq, nbt, body_ids, xpos + static_cast<size_t>(i) * nbt * 3, xquat + static_cast<size_t>(i) * nbt * 4,
|
|
299
|
+
xvel ? qvel + i * nv : nullptr, xvel ? xvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
300
|
+
xvel ? xangvel + static_cast<size_t>(i) * nbt * 3 : nullptr);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
} // extern "C"
|
|
304
|
+
|
|
305
|
+
namespace {
|
|
306
|
+
|
|
307
|
+
// one env's control step and its JVP along ndir (<= 4) input directions (see soft_control_step_jvp), then the tracked poses
|
|
308
|
+
// at the output state and their JVP (the same fk on the output state's duals): dxpos [ndir, nbt, 3], dxquat [ndir, nbt, 4]
|
|
309
|
+
void jvp_one(const js::soft::SoftModel& sm, double* qpos, double* qvel, double* warm, const double* ctrl, double foot_friction,
|
|
310
|
+
int nsub, int ndir, const double* vq, const double* vv, const double* vu, double* dq, double* dv, int* flags,
|
|
311
|
+
int nbt, const int* body_ids, double* xpos, double* xquat, double* dxpos, double* dxquat,
|
|
312
|
+
double* xvel = nullptr, double* xangvel = nullptr, double* dxvel = nullptr, double* dxangvel = nullptr) {
|
|
313
|
+
constexpr int K = 4;
|
|
314
|
+
using D = js::soft::DualK<K>;
|
|
315
|
+
require(ndir >= 1 && ndir <= K, "jvp: 1 <= ndir <= 4");
|
|
316
|
+
const int nq = sm.nq, nv = sm.nv, nu = static_cast<int>(sm.actuators.size());
|
|
317
|
+
std::vector<D> q(nq, D(0.0)), v(nv, D(0.0)), u(nu, D(0.0));
|
|
318
|
+
for (int i = 0; i < nq; ++i) q[i].v = qpos[i];
|
|
319
|
+
for (int i = 0; i < nv; ++i) v[i].v = qvel[i];
|
|
320
|
+
for (int i = 0; i < nu; ++i) u[i].v = ctrl[i];
|
|
321
|
+
for (int k = 0; k < ndir; ++k) {
|
|
322
|
+
const double* tq = vq + static_cast<size_t>(k) * nv;
|
|
323
|
+
for (const js::soft::SoftBody& bd : sm.bodies) {
|
|
324
|
+
if (bd.jnt_type == js::soft::kJntFree) {
|
|
325
|
+
for (int j = 0; j < 3; ++j) q[bd.qadr + j].d[k] = tq[bd.dadr + j];
|
|
326
|
+
// d quat = 0.5 quat (0, delta_body): the derivative of quat * exp(eps delta / 2) at eps = 0
|
|
327
|
+
const double qq[4] = {qpos[bd.qadr + 3], qpos[bd.qadr + 4], qpos[bd.qadr + 5], qpos[bd.qadr + 6]};
|
|
328
|
+
const double dl[4] = {0, tq[bd.dadr + 3], tq[bd.dadr + 4], tq[bd.dadr + 5]};
|
|
329
|
+
double r[4];
|
|
330
|
+
js::soft::quat_mul(qq, dl, r);
|
|
331
|
+
for (int j = 0; j < 4; ++j) q[bd.qadr + 3 + j].d[k] = 0.5 * r[j];
|
|
332
|
+
} else if (bd.jnt_type == js::soft::kJntHinge) {
|
|
333
|
+
q[bd.qadr].d[k] = tq[bd.dadr];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
for (int i = 0; i < nv; ++i) v[i].d[k] = vv[static_cast<size_t>(k) * nv + i];
|
|
337
|
+
for (int i = 0; i < nu; ++i) u[i].d[k] = vu[static_cast<size_t>(k) * nu + i];
|
|
338
|
+
}
|
|
339
|
+
for (int s = 0; s < nsub; ++s) {
|
|
340
|
+
const js::soft::JvpFlags fl = js::soft::substep_jvp<K>(sm, q, v, warm, u, foot_friction);
|
|
341
|
+
if (!flags) continue;
|
|
342
|
+
flags[5 * s] = fl.contact_set_changed; flags[5 * s + 1] = fl.nquadratic; flags[5 * s + 2] = fl.nclamped;
|
|
343
|
+
flags[5 * s + 3] = fl.niter; flags[5 * s + 4] = fl.ncon;
|
|
344
|
+
}
|
|
345
|
+
for (int i = 0; i < nq; ++i) qpos[i] = q[i].v;
|
|
346
|
+
for (int i = 0; i < nv; ++i) qvel[i] = v[i].v;
|
|
347
|
+
for (int k = 0; k < ndir; ++k) {
|
|
348
|
+
for (int i = 0; i < nq; ++i) dq[static_cast<size_t>(k) * nq + i] = q[i].d[k];
|
|
349
|
+
for (int i = 0; i < nv; ++i) dv[static_cast<size_t>(k) * nv + i] = v[i].d[k];
|
|
350
|
+
}
|
|
351
|
+
if (!nbt) return;
|
|
352
|
+
std::vector<D> px(3 * nbt), pq(4 * nbt), pv(xvel ? 3 * nbt : 0), pw(xvel ? 3 * nbt : 0);
|
|
353
|
+
tracked_poses(sm, q.data(), nbt, body_ids, px.data(), pq.data(), xvel ? static_cast<const D*>(v.data()) : nullptr,
|
|
354
|
+
xvel ? pv.data() : nullptr, xvel ? pw.data() : nullptr);
|
|
355
|
+
for (int j = 0; j < 3 * nbt; ++j) xpos[j] = px[j].v;
|
|
356
|
+
for (int j = 0; j < 4 * nbt; ++j) xquat[j] = pq[j].v;
|
|
357
|
+
if (xvel) for (int j = 0; j < 3 * nbt; ++j) { xvel[j] = pv[j].v; xangvel[j] = pw[j].v; }
|
|
358
|
+
for (int k = 0; k < ndir; ++k) {
|
|
359
|
+
if (dxpos) {
|
|
360
|
+
for (int j = 0; j < 3 * nbt; ++j) dxpos[static_cast<size_t>(k) * 3 * nbt + j] = px[j].d[k];
|
|
361
|
+
for (int j = 0; j < 4 * nbt; ++j) dxquat[static_cast<size_t>(k) * 4 * nbt + j] = pq[j].d[k];
|
|
362
|
+
}
|
|
363
|
+
if (xvel && dxvel)
|
|
364
|
+
for (int j = 0; j < 3 * nbt; ++j) {
|
|
365
|
+
dxvel[static_cast<size_t>(k) * 3 * nbt + j] = pv[j].d[k];
|
|
366
|
+
dxangvel[static_cast<size_t>(k) * 3 * nbt + j] = pw[j].d[k];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
} // namespace
|
|
372
|
+
|
|
373
|
+
extern "C" {
|
|
374
|
+
|
|
375
|
+
// C2: one control step and its JVP along ndir (<= 4) input directions. Inputs per direction: the qpos tangent vq [ndir, nv]
|
|
376
|
+
// (the free root: world translation, then body-frame rotation; hinges), vv [ndir, nv], vu [ndir, nu]. Outputs: qpos, qvel,
|
|
377
|
+
// warm after the step (in place), dq [ndir, nq] and dv [ndir, nv]; per substep flags [nsub, 5]: contact_set_changed,
|
|
378
|
+
// nquadratic, nclamped, niter, ncon.
|
|
379
|
+
void soft_control_step_jvp(void* h, double* qpos, double* qvel, double* warm, const double* ctrl, double foot_friction,
|
|
380
|
+
int nsub, int iterations, double tolerance, int ndir, const double* vq, const double* vv,
|
|
381
|
+
const double* vu, double* dq, double* dv, int* flags) {
|
|
382
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
383
|
+
jvp_one(sm, qpos, qvel, warm, ctrl, foot_friction, nsub, ndir, vq, vv, vu, dq, dv, flags, 0, nullptr, nullptr, nullptr,
|
|
384
|
+
nullptr, nullptr);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// the batched JVP (d5's small-n gradient path; the GPU adjoint replaces it): n envs as soft_control_step_batch, per env
|
|
388
|
+
// vq / vv [n, ndir, nv], vu [n, ndir, nu] -> dq [n, ndir, nq] (raw qpos), dv [n, ndir, nv], flags [n, nsub, 5] (or null); the
|
|
389
|
+
// tracked poses xpos [n, nbt, 3], xquat [n, nbt, 4] at the output state and their JVP dxpos [n, ndir, nbt, 3], dxquat
|
|
390
|
+
// [n, ndir, nbt, 4] (raw quaternion; dxpos null: values only)
|
|
391
|
+
void soft_control_step_jvp_batch(void* h, int n, double* qpos, double* qvel, double* warm, const double* ctrl,
|
|
392
|
+
const double* fric, double foot_friction, int nsub, int iterations, double tolerance,
|
|
393
|
+
int nthreads, int ndir, const double* vq, const double* vv, const double* vu, double* dq,
|
|
394
|
+
double* dv, int* flags, int nbt, const int* body_ids, double* xpos, double* xquat,
|
|
395
|
+
double* dxpos, double* dxquat, double* xvel, double* xangvel, double* dxvel,
|
|
396
|
+
double* dxangvel) {
|
|
397
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
398
|
+
check_bodies(sm, nbt, body_ids, xpos, xquat);
|
|
399
|
+
require(!dxpos == !dxquat, "jvp batch: dxpos and dxquat together");
|
|
400
|
+
require(!xvel == !xangvel && !dxvel == !dxangvel && (xvel || !dxvel), "jvp batch: velocities and their JVP together");
|
|
401
|
+
const size_t nq = sm.nq, nv = sm.nv, nu = sm.actuators.size(), nd = ndir;
|
|
402
|
+
for_envs(n, nthreads, [&](int i) {
|
|
403
|
+
jvp_one(sm, qpos + i * nq, qvel + i * nv, warm + i * nv, ctrl + i * nu, fric ? fric[i] : foot_friction, nsub, ndir,
|
|
404
|
+
vq + i * nd * nv, vv + i * nd * nv, vu + i * nd * nu, dq + i * nd * nq, dv + i * nd * nv,
|
|
405
|
+
flags ? flags + static_cast<size_t>(i) * nsub * 5 : nullptr, nbt, body_ids,
|
|
406
|
+
nbt ? xpos + static_cast<size_t>(i) * nbt * 3 : nullptr, nbt ? xquat + static_cast<size_t>(i) * nbt * 4 : nullptr,
|
|
407
|
+
nbt && dxpos ? dxpos + i * nd * nbt * 3 : nullptr, nbt && dxquat ? dxquat + i * nd * nbt * 4 : nullptr,
|
|
408
|
+
nbt && xvel ? xvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
409
|
+
nbt && xangvel ? xangvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
410
|
+
nbt && dxvel ? dxvel + i * nd * nbt * 3 : nullptr, nbt && dxangvel ? dxangvel + i * nd * nbt * 3 : nullptr);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// one substep with its tape record (CPU reference for engine B's adjoint): advances (qpos, qvel, warm) in place; writes
|
|
415
|
+
// a_star [nv], a_adv [nv], L_H [nv*nv], L_Q [nv*nv] (lower triangles, full storage), zone [cap] (row order), clamp [nv],
|
|
416
|
+
// con_pair / con_slot [ccap]; ints out [6]: ncon, nefc, nlim, niter, -1 if over cap; min_nu out
|
|
417
|
+
void soft_substep_tape(void* h, double* qpos, double* qvel, double* warm, const double* ctrl, double foot_friction,
|
|
418
|
+
int iterations, double tolerance, double* a_star, double* a_adv, double* L_H, double* L_Q, int cap,
|
|
419
|
+
int* zone, int* clamp, int ccap, int* con_pair, int* con_slot, int* ints, double* min_nu,
|
|
420
|
+
double* M, double* qfrc_smooth, double* qacc_smooth) {
|
|
421
|
+
const Model& m0 = act_model(h);
|
|
422
|
+
js::soft::SoftModel sm = m0.sm;
|
|
423
|
+
if (iterations > 0) sm.iterations = iterations;
|
|
424
|
+
if (tolerance > 0) sm.tolerance = tolerance;
|
|
425
|
+
js::soft::SubstepTape t;
|
|
426
|
+
js::soft::substep(sm, qpos, qvel, warm, ctrl, foot_friction, &t);
|
|
427
|
+
const int nv = sm.nv;
|
|
428
|
+
for (int i = 0; i < nv; ++i) { a_star[i] = t.a_star[i]; a_adv[i] = t.a_adv[i]; clamp[i] = t.clamp[i]; }
|
|
429
|
+
for (int i = 0; i < nv * nv; ++i) { L_H[i] = t.L_H.empty() ? 0.0 : t.L_H[i]; L_Q[i] = t.L_Q[i]; M[i] = t.M[i]; }
|
|
430
|
+
for (int i = 0; i < nv; ++i) { qfrc_smooth[i] = t.qfrc_smooth[i]; qacc_smooth[i] = t.qacc_smooth[i]; }
|
|
431
|
+
ints[0] = t.ncon; ints[1] = t.nefc; ints[2] = t.nlim; ints[3] = t.niter;
|
|
432
|
+
ints[4] = (t.nefc > cap || t.ncon > ccap) ? -1 : 0;
|
|
433
|
+
for (int r = 0; r < t.nefc && r < cap; ++r) zone[r] = t.zone[r];
|
|
434
|
+
for (int c = 0; c < t.ncon && c < ccap; ++c) { con_pair[c] = t.con_pair[c]; con_slot[c] = t.con_slot[c]; }
|
|
435
|
+
*min_nu = t.min_nu;
|
|
436
|
+
ints[5] = static_cast<int>(js::soft::tape_flags(false, t.ran_out, t.warm_used, t.stalled, t.min_nu));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// D16 L4: the tape record's layout (core/soft/tape.h) for (nq, nv, maxcon, maxrows, npose): out[24] = nq, nv, ntri, maxcon,
|
|
440
|
+
// maxrows, hdr, flags, min_nu, reserved, clamp, zone, con, qpos, qvel, qacc, qadv, LH, LQ, words, n_clamp, n_zone, n_con,
|
|
441
|
+
// npose, pose
|
|
442
|
+
// The layout arrays' entry counts and names (the request after d5's crash, 2026-11-02): a caller asserts both against its
|
|
443
|
+
// own key list, so an entry added to these arrays can never be read silently at the wrong index. New entries go at the END.
|
|
444
|
+
static const char* const kTapeLayoutKeys = "nq,nv,ntri,maxcon,maxrows,hdr,flags,min_nu,reserved,clamp,zone,con,qpos,qvel,qacc,"
|
|
445
|
+
"qadv,LH,LQ,words,n_clamp,n_zone,n_con,npose,pose";
|
|
446
|
+
constexpr int kTapeLayoutN = 24;
|
|
447
|
+
int soft_tape_layout_count() { return kTapeLayoutN; }
|
|
448
|
+
const char* soft_tape_layout_keys() { return kTapeLayoutKeys; }
|
|
449
|
+
void soft_tape_layout(int nq, int nv, int maxcon, int maxrows, int npose, int* out) {
|
|
450
|
+
const js::soft::TapeLayout t = js::soft::tape_layout(nq, nv, maxcon, maxrows, npose);
|
|
451
|
+
const int v[kTapeLayoutN] = {t.nq, t.nv, t.ntri, t.maxcon, t.maxrows, t.hdr, t.flags, t.min_nu, t.reserved, t.clamp, t.zone,
|
|
452
|
+
t.con, t.qpos, t.qvel, t.qacc, t.qadv, t.LH, t.LQ, t.words, t.n_clamp, t.n_zone, t.n_con, t.npose,
|
|
453
|
+
t.pose};
|
|
454
|
+
for (int k = 0; k < kTapeLayoutN; ++k) out[k] = v[k];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// D16 L4: one record packed on the CPU (lane 0 of 1) from the tape's fields as soft_substep_tape returns them (ints: ncon,
|
|
458
|
+
// nefc, nlim, niter, -, flags; L_H, L_Q full nv x nv, lower read), into an f64 record and an f32 record (either may be null)
|
|
459
|
+
void soft_tape_pack(int nq, int nv, int maxcon, int maxrows, int npose, int npair, const int* ints, double min_nu,
|
|
460
|
+
const int* clamp, const int* zone, const int* con_pair, const int* con_slot, const double* q,
|
|
461
|
+
const double* v, const double* a_star, const double* a_adv, const double* L_H, const double* L_Q,
|
|
462
|
+
const double* xpos, const double* xquat, double* rec64, float* rec32) {
|
|
463
|
+
const js::soft::TapeLayout t = js::soft::tape_layout(nq, nv, maxcon, maxrows, npose);
|
|
464
|
+
require(npose == 0 || (xpos && xquat), "tape pack: the POSE block needs xpos and xquat");
|
|
465
|
+
assert(js::soft::tape_layout_ok(t, npair) && ints[0] <= maxcon && ints[1] <= maxrows && ints[3] <= 255);
|
|
466
|
+
js::soft::TapeIn<double> in;
|
|
467
|
+
in.ncon = ints[0]; in.nefc = ints[1]; in.nlim = ints[2]; in.niter = ints[3]; in.flags = static_cast<uint32_t>(ints[5]);
|
|
468
|
+
in.min_nu = min_nu; in.clamp = clamp; in.zone = zone; in.con_pair = con_pair; in.con_slot = con_slot;
|
|
469
|
+
in.q = q; in.v = v; in.a_star = a_star; in.a_adv = a_adv; in.L_H = L_H; in.L_Q = L_Q; in.ld_H = nv; in.ld_Q = nv;
|
|
470
|
+
in.xpos = xpos; in.xquat = xquat;
|
|
471
|
+
for (int c = 0; c < in.ncon; ++c) assert(con_pair[c] >= 0 && con_pair[c] < 512 && con_slot[c] >= 0 && con_slot[c] < 128);
|
|
472
|
+
if (rec64) js::soft::tape_pack(rec64, t, in, 0, 1);
|
|
473
|
+
if (rec32) js::soft::tape_pack(rec32, t, in, 0, 1);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
} // extern "C"
|
|
477
|
+
|
|
478
|
+
extern "C" {
|
|
479
|
+
|
|
480
|
+
// D16 L4 (the v3c request): the same record through tape_pack_range in k_post's order ([LH, LQ), then the rest without
|
|
481
|
+
// POSE, then POSE as k_pre writes it), from the bit-word and hand-conmeta sources, for the gate's equality with soft_tape_pack
|
|
482
|
+
void soft_tape_pack_alt(int nq, int nv, int maxcon, int maxrows, int npose, int npair, const int* ints, double min_nu,
|
|
483
|
+
const int* clamp, const int* zone, const int* con_pair, const int* con_slot, const double* q,
|
|
484
|
+
const double* v, const double* a_star, const double* a_adv, const double* L_H, const double* L_Q,
|
|
485
|
+
const double* xpos, const double* xquat, double* rec64, float* rec32) {
|
|
486
|
+
const js::soft::TapeLayout t = js::soft::tape_layout(nq, nv, maxcon, maxrows, npose);
|
|
487
|
+
require(js::soft::tape_layout_ok(t, npair) && ints[0] <= maxcon && ints[1] <= maxrows, "tape pack alt: capacities");
|
|
488
|
+
std::vector<uint32_t> cb(t.n_clamp, 0u), zb(t.n_zone, 0xFFFFFFFFu); // zone: garbage past nefc, which the packer masks
|
|
489
|
+
for (int i = 0; i < nv; ++i) if (clamp[i]) cb[i / 32] |= 1u << (i % 32);
|
|
490
|
+
for (int r = 0; r < ints[1]; ++r) { const uint32_t b = 1u << (r % 32); if (zone[r]) zb[r / 32] |= b; else zb[r / 32] &= ~b; }
|
|
491
|
+
std::vector<double> meta64(maxcon, 0.0);
|
|
492
|
+
std::vector<float> meta32(maxcon, 0.0f);
|
|
493
|
+
for (int c = 0; c < ints[0]; ++c) {
|
|
494
|
+
const uint32_t m = js::soft::hand_conmeta(con_pair[c], con_slot[c], 3, 7, 5); // condim / row0 / nd: high bits the packer drops
|
|
495
|
+
js::soft::tape_put_u(meta64.data(), c, m);
|
|
496
|
+
js::soft::tape_put_u(meta32.data(), c, m);
|
|
497
|
+
}
|
|
498
|
+
auto run = [&](auto* rec, auto* meta) {
|
|
499
|
+
using S = std::remove_pointer_t<decltype(meta)>;
|
|
500
|
+
js::soft::TapeIn<double> in;
|
|
501
|
+
in.ncon = ints[0]; in.nefc = ints[1]; in.nlim = ints[2]; in.niter = ints[3]; in.flags = static_cast<uint32_t>(ints[5]);
|
|
502
|
+
in.min_nu = min_nu; in.q = q; in.v = v; in.a_star = a_star; in.a_adv = a_adv; in.L_H = L_H; in.L_Q = L_Q;
|
|
503
|
+
in.ld_H = nv; in.ld_Q = nv; in.xpos = xpos; in.xquat = xquat; in.clamp_bits = cb.data(); in.zone_bits = zb.data();
|
|
504
|
+
// con_meta is read as words of the record's scalar: the double pack reads meta64, the float pack meta32, through a
|
|
505
|
+
// TapeIn of that scalar for the entries only
|
|
506
|
+
js::soft::TapeIn<S> e;
|
|
507
|
+
e.ncon = in.ncon; e.con_meta = meta;
|
|
508
|
+
const int end = t.npose > 0 ? t.pose : t.words;
|
|
509
|
+
js::soft::tape_pack_range(rec, t, in, t.LH, t.LQ, 0, 1);
|
|
510
|
+
// the rest: everything but [LH, LQ) and POSE; the contact words come from the conmeta source
|
|
511
|
+
js::soft::tape_pack_range(rec, t, in, 0, t.con, 0, 1);
|
|
512
|
+
js::soft::tape_pack_range(rec, t, e, t.con, t.qpos, 0, 1);
|
|
513
|
+
js::soft::tape_pack_range(rec, t, in, t.qpos, t.LH, 0, 1);
|
|
514
|
+
js::soft::tape_pack_range(rec, t, in, t.LQ, end, 0, 1);
|
|
515
|
+
if (t.npose > 0) js::soft::tape_pack_range(rec, t, in, t.pose, t.words, 0, 1);
|
|
516
|
+
};
|
|
517
|
+
if (rec64) run(rec64, meta64.data());
|
|
518
|
+
if (rec32) run(rec32, meta32.data());
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// D16 hand (core/soft/hand.h): the layout for (nv, nc, nr, kdof): out[19] = nv, ntri, nc, nr, kdof, M, qfrc, qacc, clamp,
|
|
522
|
+
// counts, min_nu, conJ, condof, conmeta, conmu, aref, efcD, rowmeta, words
|
|
523
|
+
// The tape layout with the MUS block (2026-11-02): the 24 entries above, then nmus, mus (appended); its own count and names
|
|
524
|
+
static const char* const kTapeLayout2Keys = "nq,nv,ntri,maxcon,maxrows,hdr,flags,min_nu,reserved,clamp,zone,con,qpos,qvel,qacc,"
|
|
525
|
+
"qadv,LH,LQ,words,n_clamp,n_zone,n_con,npose,pose,nmus,mus";
|
|
526
|
+
constexpr int kTapeLayout2N = 26;
|
|
527
|
+
int soft_tape_layout2_count() { return kTapeLayout2N; }
|
|
528
|
+
const char* soft_tape_layout2_keys() { return kTapeLayout2Keys; }
|
|
529
|
+
void soft_tape_layout2(int nq, int nv, int maxcon, int maxrows, int npose, int nmus, int* out) {
|
|
530
|
+
const js::soft::TapeLayout t = js::soft::tape_layout(nq, nv, maxcon, maxrows, npose, nmus);
|
|
531
|
+
const int v[kTapeLayout2N] = {t.nq, t.nv, t.ntri, t.maxcon, t.maxrows, t.hdr, t.flags, t.min_nu, t.reserved, t.clamp, t.zone,
|
|
532
|
+
t.con, t.qpos, t.qvel, t.qacc, t.qadv, t.LH, t.LQ, t.words, t.n_clamp, t.n_zone, t.n_con, t.npose,
|
|
533
|
+
t.pose, t.nmus, t.mus};
|
|
534
|
+
for (int k = 0; k < kTapeLayout2N; ++k) out[k] = v[k];
|
|
535
|
+
}
|
|
536
|
+
// the muscles' per-control-step record: words, then a CPU pack of a_0 and u (the gate's round trip)
|
|
537
|
+
int soft_tape_ctl_words(int nmus) { return js::soft::tape_ctl_layout(nmus).words; }
|
|
538
|
+
void soft_tape_ctl_pack(int nmus, const double* a0, const double* u, double* rec64, float* rec32) {
|
|
539
|
+
const js::soft::TapeCtlLayout c = js::soft::tape_ctl_layout(nmus);
|
|
540
|
+
if (rec64) js::soft::tape_ctl_pack(rec64, c, a0, u, 0, 1);
|
|
541
|
+
if (rec32) js::soft::tape_ctl_pack(rec32, c, a0, u, 0, 1);
|
|
542
|
+
}
|
|
543
|
+
// one record with the MUS block (the gate's round trip): soft_tape_pack's arguments plus nmus and lce_prev [nmus]
|
|
544
|
+
void soft_tape_pack_mus(int nq, int nv, int maxcon, int maxrows, int npose, int nmus, int npair, const int* ints, double min_nu,
|
|
545
|
+
const int* clamp, const int* zone, const int* con_pair, const int* con_slot, const double* q,
|
|
546
|
+
const double* v, const double* a_star, const double* a_adv, const double* L_H, const double* L_Q,
|
|
547
|
+
const double* xpos, const double* xquat, const double* lce_prev, double* rec64, float* rec32) {
|
|
548
|
+
const js::soft::TapeLayout t = js::soft::tape_layout(nq, nv, maxcon, maxrows, npose, nmus);
|
|
549
|
+
require(js::soft::tape_layout_ok(t, npair) && (npose == 0 || (xpos && xquat)) && (nmus == 0 || lce_prev), "tape pack mus: inputs");
|
|
550
|
+
js::soft::TapeIn<double> in;
|
|
551
|
+
in.ncon = ints[0]; in.nefc = ints[1]; in.nlim = ints[2]; in.niter = ints[3]; in.flags = static_cast<uint32_t>(ints[5]);
|
|
552
|
+
in.min_nu = min_nu; in.clamp = clamp; in.zone = zone; in.con_pair = con_pair; in.con_slot = con_slot;
|
|
553
|
+
in.q = q; in.v = v; in.a_star = a_star; in.a_adv = a_adv; in.L_H = L_H; in.L_Q = L_Q; in.ld_H = nv; in.ld_Q = nv;
|
|
554
|
+
in.xpos = xpos; in.xquat = xquat; in.lce_prev = lce_prev;
|
|
555
|
+
if (rec64) js::soft::tape_pack(rec64, t, in, 0, 1);
|
|
556
|
+
if (rec32) js::soft::tape_pack(rec32, t, in, 0, 1);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// (the count and names as for the tape's; min_nu sits at index 10 since 31232470, before the rule "new entries at the END")
|
|
560
|
+
static const char* const kHandLayoutKeys = "nv,ntri,nc,nr,kdof,M,qfrc,qacc,clamp,counts,min_nu,conJ,condof,conmeta,conmu,aref,efcD,"
|
|
561
|
+
"rowmeta,words";
|
|
562
|
+
constexpr int kHandLayoutN = 19;
|
|
563
|
+
int soft_hand_layout_count() { return kHandLayoutN; }
|
|
564
|
+
const char* soft_hand_layout_keys() { return kHandLayoutKeys; }
|
|
565
|
+
void soft_hand_layout(int nv, int nc, int nr, int kdof, int* out) {
|
|
566
|
+
const js::soft::HandLayout h = js::soft::hand_layout(nv, nc, nr, kdof);
|
|
567
|
+
const int v[kHandLayoutN] = {h.nv, h.ntri, h.nc, h.nr, h.kdof, h.M, h.qfrc, h.qacc, h.clamp, h.counts, h.min_nu, h.conJ,
|
|
568
|
+
h.condof, h.conmeta, h.conmu, h.aref, h.efcD, h.rowmeta, h.words};
|
|
569
|
+
for (int k = 0; k < kHandLayoutN; ++k) out[k] = v[k];
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// D16 hand: the CPU reference record of one state (what k_pre writes), from the f64 law: the smooth terms (step.h
|
|
573
|
+
// smooth_terms), the contacts and rows (rows.h), the contact-frame Jacobian on each contact's support dofs. rec64 / rec32
|
|
574
|
+
// [words] (either may be null). Over a capacity (nc contacts, nr rows) the counts carry overflow 1 and the tables stop there.
|
|
575
|
+
void soft_hand(void* h, const double* qpos, const double* qvel, const double* ctrl, double foot_friction, int nc, int nr,
|
|
576
|
+
int kdof, double* rec64, float* rec32) {
|
|
577
|
+
const Model& m = act_model(h);
|
|
578
|
+
const js::soft::SoftModel& sm = m.sm;
|
|
579
|
+
const int nv = sm.nv, nb = static_cast<int>(sm.bodies.size());
|
|
580
|
+
const js::soft::HandLayout L = js::soft::hand_layout(nv, nc, nr, kdof);
|
|
581
|
+
require(js::soft::hand_layout_ok(L, static_cast<int>(sm.pairs.size())), "hand: field widths");
|
|
582
|
+
js::soft::SmoothTerms st;
|
|
583
|
+
js::soft::smooth_terms(sm, qpos, qvel, ctrl, st);
|
|
584
|
+
std::vector<js::soft::SoftContact<double>> con;
|
|
585
|
+
js::soft::collide_all(sm.geoms.data(), static_cast<int>(sm.geoms.size()), sm.pairs.data(), static_cast<int>(sm.pairs.size()),
|
|
586
|
+
st.X.data(), foot_friction, con);
|
|
587
|
+
js::soft::Rows<double> rows;
|
|
588
|
+
js::soft::make_rows(sm.bodies.data(), st.X.data(), nv, sm.dof_invweight0.data(), sm.joints.data(),
|
|
589
|
+
static_cast<int>(sm.joints.size()), sm.geoms.data(), sm.pairs.data(), con, qpos, qvel, sm.timestep,
|
|
590
|
+
sm.impratio, rows);
|
|
591
|
+
// each body's chain of dofs
|
|
592
|
+
std::vector<unsigned long long> mask(nb, 0ULL);
|
|
593
|
+
for (int b = 1; b < nb; ++b) {
|
|
594
|
+
const js::soft::SoftBody& bd = sm.bodies[b];
|
|
595
|
+
unsigned long long mk = bd.parent >= 0 ? mask[bd.parent] : 0ULL;
|
|
596
|
+
if (bd.jnt_type == js::soft::kJntFree) for (int k = 0; k < 6; ++k) mk |= 1ULL << (bd.dadr + k);
|
|
597
|
+
else if (bd.jnt_type == js::soft::kJntHinge) mk |= 1ULL << bd.dadr;
|
|
598
|
+
mask[b] = mk;
|
|
599
|
+
}
|
|
600
|
+
std::vector<double> V(L.words, 0.0); // values
|
|
601
|
+
std::vector<uint32_t> U(L.words, 0u); // integer words
|
|
602
|
+
std::vector<char> isint(L.words, 0);
|
|
603
|
+
auto put_u = [&](int w, uint32_t x) { U[w] = x; isint[w] = 1; };
|
|
604
|
+
for (int i = 0; i < nv; ++i)
|
|
605
|
+
for (int j = 0; j <= i; ++j) V[L.M + i * (i + 1) / 2 + j] = st.M[static_cast<size_t>(i) * nv + j];
|
|
606
|
+
for (int i = 0; i < nv; ++i) { V[L.qfrc + i] = st.qfrc_smooth[i]; V[L.qacc + i] = st.qacc_smooth[i]; }
|
|
607
|
+
uint32_t cl[2] = {0u, 0u};
|
|
608
|
+
for (int i = 0; i < nv; ++i) if (st.clamped[i]) cl[i / 32] |= 1u << (i % 32);
|
|
609
|
+
put_u(L.clamp, cl[0]); put_u(L.clamp + 1, cl[1]);
|
|
610
|
+
const int ncon = static_cast<int>(con.size());
|
|
611
|
+
int nlim = 0;
|
|
612
|
+
for (int r = 0; r < rows.n; ++r) nlim += rows.type[r] == js::soft::kRowLimit;
|
|
613
|
+
const bool ovf = ncon > nc || rows.n > nr;
|
|
614
|
+
const int nc_w = ncon < nc ? ncon : nc;
|
|
615
|
+
int nr_w = rows.n < nr ? rows.n : nr; // the rows stop with the contacts: none of a contact past the capacity
|
|
616
|
+
for (int r = 0; r < nr_w; ++r) if (rows.type[r] != js::soft::kRowLimit && rows.id[r] >= nc_w) { nr_w = r; break; }
|
|
617
|
+
put_u(L.counts, static_cast<uint32_t>(nc_w)); put_u(L.counts + 1, static_cast<uint32_t>(nr_w));
|
|
618
|
+
put_u(L.counts + 2, static_cast<uint32_t>(nlim)); put_u(L.counts + 3, ovf ? 1u : 0u);
|
|
619
|
+
{ // min_nu (step.h's SubstepTape.min_nu): the smallest dist + both radii over the contacts of two non-plane geoms
|
|
620
|
+
double mn = 1e300;
|
|
621
|
+
for (int c = 0; c < nc_w; ++c) {
|
|
622
|
+
const js::soft::SoftPair& pr = sm.pairs[con[c].pair];
|
|
623
|
+
const js::soft::SoftGeom &g1 = sm.geoms[pr.g1], &g2 = sm.geoms[pr.g2];
|
|
624
|
+
if (g1.type != 0 && g2.type != 0) mn = std::min(mn, con[c].dist + g1.size[0] + g2.size[0]);
|
|
625
|
+
}
|
|
626
|
+
V[L.min_nu] = mn >= 1e30 ? INFINITY : mn;
|
|
627
|
+
}
|
|
628
|
+
// the contacts: first row, support dofs, contact-frame Jacobian
|
|
629
|
+
std::vector<int> row0(ncon, -1);
|
|
630
|
+
for (int r = 0; r < rows.n; ++r)
|
|
631
|
+
if (rows.type[r] != js::soft::kRowLimit && row0[rows.id[r]] < 0) row0[rows.id[r]] = r;
|
|
632
|
+
std::vector<double> jp1(3 * nv), jp2(3 * nv);
|
|
633
|
+
std::vector<uint8_t> dofs(static_cast<size_t>(nc) * kdof, 0xFF);
|
|
634
|
+
for (int c = 0; c < nc_w; ++c) {
|
|
635
|
+
const js::soft::SoftContact<double>& ct = con[c];
|
|
636
|
+
const js::soft::SoftPair& pr = sm.pairs[ct.pair];
|
|
637
|
+
const int b1 = sm.geoms[pr.g1].body, b2 = sm.geoms[pr.g2].body;
|
|
638
|
+
const unsigned long long plus = mask[b2] & ~mask[b1], minus = mask[b1] & ~mask[b2], sup = plus | minus;
|
|
639
|
+
const double p[3] = {ct.pos.x, ct.pos.y, ct.pos.z};
|
|
640
|
+
js::soft::point_jacobian(sm.bodies.data(), st.X.data(), nv, b2, p, jp2.data(), static_cast<double*>(nullptr));
|
|
641
|
+
js::soft::point_jacobian(sm.bodies.data(), st.X.data(), nv, b1, p, jp1.data(), static_cast<double*>(nullptr));
|
|
642
|
+
int nd = 0;
|
|
643
|
+
for (int i = 0; i < nv; ++i) {
|
|
644
|
+
if (!((sup >> i) & 1ULL)) continue;
|
|
645
|
+
require(nd < kdof, "hand: a contact's support exceeds kdof");
|
|
646
|
+
const double dx = jp2[i] - jp1[i], dy = jp2[nv + i] - jp1[nv + i], dz = jp2[2 * nv + i] - jp1[2 * nv + i];
|
|
647
|
+
for (int k = 0; k < 3; ++k)
|
|
648
|
+
V[L.conJ + (c * 3 + k) * kdof + nd] = ct.frame[k].x * dx + ct.frame[k].y * dy + ct.frame[k].z * dz;
|
|
649
|
+
dofs[static_cast<size_t>(c) * kdof + nd] = static_cast<uint8_t>(i);
|
|
650
|
+
++nd;
|
|
651
|
+
}
|
|
652
|
+
require(row0[c] >= 0 && row0[c] < 256, "hand: contact row0");
|
|
653
|
+
put_u(L.conmeta + c, js::soft::hand_conmeta(ct.pair, ct.slot, ct.condim, row0[c], nd));
|
|
654
|
+
V[L.conmu + c] = ct.mu;
|
|
655
|
+
}
|
|
656
|
+
for (int w4 = 0; w4 < js::soft::tape_ceil(nc * kdof, 4); ++w4) {
|
|
657
|
+
uint32_t x = 0;
|
|
658
|
+
for (int b = 0; b < 4; ++b) x |= static_cast<uint32_t>(dofs[4 * w4 + b]) << (8 * b);
|
|
659
|
+
put_u(L.condof + w4, x);
|
|
660
|
+
}
|
|
661
|
+
for (int w = L.condof; w < L.conmeta; ++w) if (!isint[w]) put_u(w, 0u);
|
|
662
|
+
// the rows
|
|
663
|
+
for (int r = 0; r < nr_w; ++r) {
|
|
664
|
+
V[L.aref + r] = rows.aref[r];
|
|
665
|
+
V[L.efcD + r] = rows.D[r];
|
|
666
|
+
uint32_t meta;
|
|
667
|
+
if (rows.type[r] == js::soft::kRowLimit) {
|
|
668
|
+
const int dof = sm.joints[rows.id[r]].dof;
|
|
669
|
+
meta = js::soft::hand_rowmeta(js::soft::kHandRowLimit, dof, 0, rows.J[static_cast<size_t>(r) * nv + dof] < 0);
|
|
670
|
+
} else {
|
|
671
|
+
const int c = rows.id[r];
|
|
672
|
+
const uint32_t t = rows.type[r] == js::soft::kRowFrictionless ? js::soft::kHandRowFrictionless : js::soft::kHandRowPyramidal;
|
|
673
|
+
meta = js::soft::hand_rowmeta(t, c, r - row0[c], false);
|
|
674
|
+
}
|
|
675
|
+
put_u(L.rowmeta + r, meta);
|
|
676
|
+
}
|
|
677
|
+
for (int w = L.rowmeta; w < L.words; ++w) if (!isint[w]) put_u(w, 0u);
|
|
678
|
+
for (int w = L.counts; w < L.conJ; ++w) if (!isint[w] && w > L.min_nu) put_u(w, 0u);
|
|
679
|
+
for (int w = 0; w < L.words; ++w) {
|
|
680
|
+
if (isint[w]) {
|
|
681
|
+
if (rec64) js::soft::tape_put_u(rec64, w, U[w]);
|
|
682
|
+
if (rec32) js::soft::tape_put_u(rec32, w, U[w]);
|
|
683
|
+
} else {
|
|
684
|
+
if (rec64) rec64[w] = V[w];
|
|
685
|
+
if (rec32) rec32[w] = static_cast<float>(V[w]);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
} // extern "C"
|
|
691
|
+
|
|
692
|
+
#if !defined(__CUDACC__) || defined(D16_G1_COMDR)
|
|
693
|
+
// ---- COMDR (tools/g1_seconds/COMDR_DESIGN.md): a per-world CoM offset of one body (the G1's anchor, torso_link) ----
|
|
694
|
+
namespace {
|
|
695
|
+
// world i's model: a copy of the shared one with the anchor body's ipos shifted by world i's offset
|
|
696
|
+
const js::soft::SoftModel& anc_world_model(const Model& m, const js::soft::SoftModel& sm, int i, js::soft::SoftModel& local) {
|
|
697
|
+
require(!m.anc_off.empty(), "an *_anc entry point without an anchor offset (soft_set_anchor_ipos_offset first)");
|
|
698
|
+
local = sm;
|
|
699
|
+
for (int k = 0; k < 3; ++k) local.bodies[m.anc_body].ipos[k] += m.anc_off[3 * static_cast<size_t>(i) + k];
|
|
700
|
+
return local;
|
|
701
|
+
}
|
|
702
|
+
} // namespace
|
|
703
|
+
|
|
704
|
+
extern "C" {
|
|
705
|
+
|
|
706
|
+
// body `body`'s ipos += off[i] for world i of the *_anc batch calls; n = 0 or off null: cleared. Mass, inertia, iquat and every
|
|
707
|
+
// invweight0-derived constant stay nominal (a stated difference, the design note). The other entry points ignore it.
|
|
708
|
+
void soft_set_anchor_ipos_offset(void* h, int body, int n, const double* off) {
|
|
709
|
+
Model& m = *static_cast<Model*>(h);
|
|
710
|
+
if (n == 0 || !off) { m.anc_body = -1; m.anc_n = 0; m.anc_off.clear(); return; }
|
|
711
|
+
require(body >= 1 && body < m.nb, "anchor offset: body out of range (the world cannot move)");
|
|
712
|
+
m.anc_body = body; m.anc_n = n;
|
|
713
|
+
m.anc_off.assign(off, off + 3 * static_cast<size_t>(n));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// soft_control_step_batch with world i on a model whose anchor ipos is shifted by world i's offset (n must be the offset's)
|
|
717
|
+
void soft_control_step_batch_anc(void* h, int n, double* qpos, double* qvel, double* warm, const double* ctrl, const double* fric,
|
|
718
|
+
double foot_friction, int nsub, int iterations, double tolerance, int nthreads, int* stats,
|
|
719
|
+
int nbt, const int* body_ids, double* xpos, double* xquat, double* xvel, double* xangvel) {
|
|
720
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
721
|
+
check_bodies(sm, nbt, body_ids, xpos, xquat);
|
|
722
|
+
const Model& mh = *static_cast<Model*>(h);
|
|
723
|
+
require(mh.anc_n == n, "control step batch (anc): the anchor offset was set for another number of worlds");
|
|
724
|
+
const size_t nq = sm.nq, nv = sm.nv, nu = sm.actuators.size();
|
|
725
|
+
for_envs(n, nthreads, [&](int i) {
|
|
726
|
+
js::soft::SoftModel local;
|
|
727
|
+
step_one(anc_world_model(mh, sm, i, local), qpos + i * nq, qvel + i * nv, warm + i * nv, ctrl + i * nu,
|
|
728
|
+
fric ? fric[i] : foot_friction, nsub, stats ? stats + static_cast<size_t>(i) * nsub * 6 : nullptr, nbt, body_ids,
|
|
729
|
+
nbt ? xpos + static_cast<size_t>(i) * nbt * 3 : nullptr, nbt ? xquat + static_cast<size_t>(i) * nbt * 4 : nullptr,
|
|
730
|
+
nbt && xvel ? xvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
731
|
+
nbt && xangvel ? xangvel + static_cast<size_t>(i) * nbt * 3 : nullptr);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// soft_control_step_jvp_batch, the same per-world model
|
|
736
|
+
void soft_control_step_jvp_batch_anc(void* h, int n, double* qpos, double* qvel, double* warm, const double* ctrl,
|
|
737
|
+
const double* fric, double foot_friction, int nsub, int iterations, double tolerance,
|
|
738
|
+
int nthreads, int ndir, const double* vq, const double* vv, const double* vu, double* dq,
|
|
739
|
+
double* dv, int* flags, int nbt, const int* body_ids, double* xpos, double* xquat,
|
|
740
|
+
double* dxpos, double* dxquat, double* xvel, double* xangvel, double* dxvel,
|
|
741
|
+
double* dxangvel) {
|
|
742
|
+
const js::soft::SoftModel sm = step_model(h, iterations, tolerance);
|
|
743
|
+
check_bodies(sm, nbt, body_ids, xpos, xquat);
|
|
744
|
+
require(!dxpos == !dxquat, "jvp batch: dxpos and dxquat together");
|
|
745
|
+
require(!xvel == !xangvel && !dxvel == !dxangvel && (xvel || !dxvel), "jvp batch: velocities and their JVP together");
|
|
746
|
+
const Model& mh = *static_cast<Model*>(h);
|
|
747
|
+
require(mh.anc_n == n, "jvp batch (anc): the anchor offset was set for another number of worlds");
|
|
748
|
+
const size_t nq = sm.nq, nv = sm.nv, nu = sm.actuators.size(), nd = ndir;
|
|
749
|
+
for_envs(n, nthreads, [&](int i) {
|
|
750
|
+
js::soft::SoftModel local;
|
|
751
|
+
jvp_one(anc_world_model(mh, sm, i, local), qpos + i * nq, qvel + i * nv, warm + i * nv, ctrl + i * nu,
|
|
752
|
+
fric ? fric[i] : foot_friction, nsub, ndir, vq + i * nd * nv, vv + i * nd * nv, vu + i * nd * nu, dq + i * nd * nq,
|
|
753
|
+
dv + i * nd * nv, flags ? flags + static_cast<size_t>(i) * nsub * 5 : nullptr, nbt, body_ids,
|
|
754
|
+
nbt ? xpos + static_cast<size_t>(i) * nbt * 3 : nullptr, nbt ? xquat + static_cast<size_t>(i) * nbt * 4 : nullptr,
|
|
755
|
+
nbt && dxpos ? dxpos + i * nd * nbt * 3 : nullptr, nbt && dxquat ? dxquat + i * nd * nbt * 4 : nullptr,
|
|
756
|
+
nbt && xvel ? xvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
757
|
+
nbt && xangvel ? xangvel + static_cast<size_t>(i) * nbt * 3 : nullptr,
|
|
758
|
+
nbt && dxvel ? dxvel + i * nd * nbt * 3 : nullptr, nbt && dxangvel ? dxangvel + i * nd * nbt * 3 : nullptr);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// soft_smooth with body `body`'s ipos shifted by off [3] (one state; line 23's MuJoCo parity of M and qfrc_bias)
|
|
763
|
+
void soft_smooth_anchor(void* h, int body, const double* off, const double* qpos, const double* qvel, double* xpos,
|
|
764
|
+
double* xquat, double* M, double* bias) {
|
|
765
|
+
const Model& m = *static_cast<Model*>(h);
|
|
766
|
+
require(body >= 1 && body < m.nb, "smooth anchor: body out of range");
|
|
767
|
+
std::vector<js::soft::SoftBody> B(m.bodies);
|
|
768
|
+
for (int k = 0; k < 3; ++k) B[body].ipos[k] += off[k];
|
|
769
|
+
std::vector<js::soft::BodyState<double>> X(m.nb);
|
|
770
|
+
std::vector<double> jp(3 * m.nv), jr(3 * m.nv), w(3 * m.nb), al(3 * m.nb), vo(3 * m.nb), ao(3 * m.nb);
|
|
771
|
+
js::soft::fk(B.data(), m.nb, qpos, X.data());
|
|
772
|
+
for (int b = 0; b < m.nb; ++b) {
|
|
773
|
+
for (int k = 0; k < 3; ++k) xpos[3 * b + k] = X[b].xpos[k];
|
|
774
|
+
for (int k = 0; k < 4; ++k) xquat[4 * b + k] = X[b].xquat[k];
|
|
775
|
+
}
|
|
776
|
+
js::soft::mass_matrix(B.data(), m.nb, X.data(), m.nv, m.armature.data(), M, jp.data(), jr.data());
|
|
777
|
+
js::soft::bias(B.data(), m.nb, X.data(), m.nv, qvel, m.gravity, bias, jp.data(), jr.data(), w.data(), al.data(),
|
|
778
|
+
vo.data(), ao.data());
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
} // extern "C"
|
|
782
|
+
#endif
|