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,273 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// Phase 2: minimal-coordinate kinematic tree + forward kinematics.
|
|
3
|
+
//
|
|
4
|
+
// Codex-debated (discuss_20260621_1008): minimal/generalized coordinates (matches
|
|
5
|
+
// mujoco-son for parity, smallest solve). FK is a per-body assembly stage — the
|
|
6
|
+
// batch maps env x body in parallel (NOT one thread per env walking the whole
|
|
7
|
+
// tree, which is the mjwarp env-serial trap, postmortem). Bodies are stored in
|
|
8
|
+
// tree order (parent index < child), so a single forward sweep resolves poses.
|
|
9
|
+
//
|
|
10
|
+
// Pose = body->world (quat q, position p), matching mujoco xquat/xpos so the
|
|
11
|
+
// FK parity check is direct. Per body i:
|
|
12
|
+
// pose[i] = pose[parent] ∘ ( T_tree[i] · T_joint(q_i) )
|
|
13
|
+
// where T_tree is the fixed rest offset (parent frame -> joint frame) and
|
|
14
|
+
// T_joint is the joint displacement. Reuses so3 (quat mul/rotate/exp_map).
|
|
15
|
+
#include "diffneusim/macros.h"
|
|
16
|
+
#include "../math/so3.h"
|
|
17
|
+
|
|
18
|
+
namespace js::kin {
|
|
19
|
+
|
|
20
|
+
using so3::Vec3;
|
|
21
|
+
using so3::Quat;
|
|
22
|
+
|
|
23
|
+
enum class JointType { Fixed = 0, Revolute, Slide, Ball, Free };
|
|
24
|
+
|
|
25
|
+
// nq (q coords) / nv (dof) per joint type.
|
|
26
|
+
DN_HOST_DEVICE inline int joint_nq(JointType t) {
|
|
27
|
+
switch (t) {
|
|
28
|
+
case JointType::Fixed: return 0;
|
|
29
|
+
case JointType::Revolute: case JointType::Slide: return 1;
|
|
30
|
+
case JointType::Ball: return 4;
|
|
31
|
+
case JointType::Free: return 7;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
DN_HOST_DEVICE inline int joint_nv(JointType t) {
|
|
36
|
+
switch (t) {
|
|
37
|
+
case JointType::Fixed: return 0;
|
|
38
|
+
case JointType::Revolute: case JointType::Slide: return 1;
|
|
39
|
+
case JointType::Ball: return 3;
|
|
40
|
+
case JointType::Free: return 6;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Read-only model parameters (shared across envs; q is per-env state). Pointer
|
|
46
|
+
// view so the same struct is host- and device-usable.
|
|
47
|
+
//
|
|
48
|
+
// Compound joints (MuJoCo-style ordered scalar primitive stacks) are ADDITIVE:
|
|
49
|
+
// the four stack_* / jnt_* members default to nullptr, so every existing
|
|
50
|
+
// aggregate-initialized KinModel (Ant, myoLeg, all tests) is unchanged and
|
|
51
|
+
// single-joint behaviour is bit-identical. A body i is a compound stack iff
|
|
52
|
+
// m.jnt_num && m.jnt_num[i] > 1
|
|
53
|
+
// in which case its jnt_num[i] primitive scalar joints live at stack index
|
|
54
|
+
// jnt_adr[i] .. jnt_adr[i]+jnt_num[i]-1 (each a Revolute/Slide with one nq=nv=1
|
|
55
|
+
// scalar dof; q-offsets accumulate per primitive from qadr[i], v-offsets from
|
|
56
|
+
// vadr[i]). Otherwise the legacy jtype[i]/jaxis[i] path is used verbatim.
|
|
57
|
+
// Primitive k applies first (nearest the parent); the body frame is AFTER all
|
|
58
|
+
// primitives (see compound_joint_transform / compound_subspace_axis).
|
|
59
|
+
template <class S> struct KinModel {
|
|
60
|
+
int nbody;
|
|
61
|
+
const int* parent; // [nbody], <0 = attached to world
|
|
62
|
+
const JointType* jtype; // [nbody]
|
|
63
|
+
const Vec3<S>* jaxis; // [nbody] revolute/slide axis (joint frame, unit)
|
|
64
|
+
const Quat<S>* quat_tree; // [nbody] rest orientation: parent -> joint frame
|
|
65
|
+
const Vec3<S>* pos_tree; // [nbody] rest position: joint origin in parent frame
|
|
66
|
+
const int* qadr; // [nbody] start index of this joint's coords in q
|
|
67
|
+
// --- compound-joint stack (optional; nullptr => single-joint legacy path) ---
|
|
68
|
+
const int* jnt_num = nullptr; // [nbody] primitives in this body's stack (0 => use jtype[i])
|
|
69
|
+
const int* jnt_adr = nullptr; // [nbody] start index into stack_type/stack_axis
|
|
70
|
+
const JointType* stack_type = nullptr; // [n_stack] per-primitive type (Revolute|Slide)
|
|
71
|
+
const Vec3<S>* stack_axis = nullptr; // [n_stack] per-primitive axis (its own frame, unit)
|
|
72
|
+
// --- coupled ("mimic") joint (optional; nullptr => no coupling) ---
|
|
73
|
+
// A coupled body has ZERO own coords in q; its scalar joint (jtype[i]/jaxis[i], a hinge or slide)
|
|
74
|
+
// is DRIVEN by a master DOF: q_dep = Σ_k coef[5*i+k]·q[master]^k (a quartic, so it covers the
|
|
75
|
+
// source mjEQ_JOINT couplings — the same quartic-in-one-master form MuJoCo's mjEQ_JOINT uses;
|
|
76
|
+
// linear for the spine, quartic for the knee). This is the
|
|
77
|
+
// coordinate-reduction of the MuJoCo equality constraints the engine cannot solve; it REMOVES the
|
|
78
|
+
// dependent coord from nq/nv. coupled_master_qadr[i] < 0 => body i is not coupled (legacy path).
|
|
79
|
+
const int* coupled_master_qadr = nullptr; // [nbody] master coord index in q, or <0 if uncoupled
|
|
80
|
+
const int* coupled_master_vadr = nullptr; // [nbody] master velocity-dof index (dynamics reads qd/writes tau here)
|
|
81
|
+
const S* coupled_coef = nullptr; // [nbody*5] per-body quartic coef c0..c4
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
#if defined(DN_KIN_SIMPLE_JOINTS)
|
|
85
|
+
// A build for models without compound stacks or coupled joints (the rigid GPU ext, which refuses any other model at load):
|
|
86
|
+
// both tests are false at compile time, so the per-body null-pointer tests and their branches inside every FK / RNE / M loop
|
|
87
|
+
// disappear (forward item (c), 2026-11-01: about 10-17% of the forward kernel's stall samples on an RTX 3080 Ti laptop GPU). The same answers
|
|
88
|
+
// as the runtime tests give for such a model, so the arithmetic is unchanged.
|
|
89
|
+
template <class S>
|
|
90
|
+
DN_HOST_DEVICE inline constexpr bool is_compound(const KinModel<S>&, int) { return false; }
|
|
91
|
+
template <class S>
|
|
92
|
+
DN_HOST_DEVICE inline constexpr bool is_coupled(const KinModel<S>&, int) { return false; }
|
|
93
|
+
#else
|
|
94
|
+
// True iff body i owns a >1-primitive scalar stack (else the single-joint path).
|
|
95
|
+
template <class S>
|
|
96
|
+
DN_HOST_DEVICE inline bool is_compound(const KinModel<S>& m, int i) {
|
|
97
|
+
return m.jnt_num != nullptr && m.jnt_num[i] > 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// True iff body i's joint is DRIVEN by a master DOF (q_dep = poly(q_master), 0 own coords).
|
|
101
|
+
template <class S>
|
|
102
|
+
DN_HOST_DEVICE inline bool is_coupled(const KinModel<S>& m, int i) {
|
|
103
|
+
return m.coupled_master_qadr != nullptr && m.coupled_master_qadr[i] >= 0;
|
|
104
|
+
}
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
// Dependent joint coordinate q_dep = f(q_master) = Σ_k coef[k]·q_master^k (Horner), plus its first
|
|
108
|
+
// and second derivatives when the out-pointers are non-null.
|
|
109
|
+
//
|
|
110
|
+
// BOTH derivatives are load-bearing, and for a while only the first one existed anywhere and only its
|
|
111
|
+
// CONSTANT term was used (docs/logs/bug-grad-audits.md, 2026-08-27). The kinematic relations are
|
|
112
|
+
// q̇_dep = f'(q_m) q̇_m -- the coupling Jacobian G
|
|
113
|
+
// q̈_dep = f'(q_m) q̈_m + f''(q_m) q̇_m² -- the second term is the joint's Ṡq̇ bias
|
|
114
|
+
// so a non-linear coupling needs f' at every site that projects through G (velocity, force, the mass
|
|
115
|
+
// matrix) AND f'' wherever a velocity-product acceleration is formed. For a LINEAR coupling f' is the
|
|
116
|
+
// constant c1 and f'' is 0, which is why the spine worked while both were missing.
|
|
117
|
+
template <class S>
|
|
118
|
+
DN_HOST_DEVICE inline S coupled_q(const KinModel<S>& m, int i, const S* q, S* dcoef = nullptr,
|
|
119
|
+
S* d2coef = nullptr) {
|
|
120
|
+
const S qm = q[m.coupled_master_qadr[i]];
|
|
121
|
+
const S* c = m.coupled_coef + 5 * i;
|
|
122
|
+
if (dcoef) *dcoef = c[1] + qm * (S(2) * c[2] + qm * (S(3) * c[3] + qm * S(4) * c[4]));
|
|
123
|
+
if (d2coef) *d2coef = S(2) * c[2] + qm * (S(6) * c[3] + qm * S(12) * c[4]);
|
|
124
|
+
return c[0] + qm * (c[1] + qm * (c[2] + qm * (c[3] + qm * c[4])));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The coupling Jacobian f'(q_master) alone -- the value that must be used wherever the old code read
|
|
128
|
+
// `coupled_coef[5*i + 1]`. Identical to that read for a linear coupling.
|
|
129
|
+
template <class S>
|
|
130
|
+
DN_HOST_DEVICE inline S coupled_dcoef(const KinModel<S>& m, int i, const S* q) {
|
|
131
|
+
const S qm = q[m.coupled_master_qadr[i]];
|
|
132
|
+
const S* c = m.coupled_coef + 5 * i;
|
|
133
|
+
return c[1] + qm * (S(2) * c[2] + qm * (S(3) * c[3] + qm * S(4) * c[4]));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// THIRD derivative of f. Needed only by the ADJOINT: the acceleration carries an f''(q_m) qd_m^2
|
|
137
|
+
// term, and that term's own q-derivative brings in the third. Zero below a cubic coupling.
|
|
138
|
+
template <class S>
|
|
139
|
+
DN_HOST_DEVICE inline S coupled_d3coef(const KinModel<S>& m, int i, const S* q) {
|
|
140
|
+
const S qm = q[m.coupled_master_qadr[i]];
|
|
141
|
+
const S* c = m.coupled_coef + 5 * i;
|
|
142
|
+
return S(6) * c[3] + qm * S(24) * c[4];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// f''(q_master): the second-order term of q̈_dep. Zero for a linear coupling.
|
|
146
|
+
template <class S>
|
|
147
|
+
DN_HOST_DEVICE inline S coupled_d2coef(const KinModel<S>& m, int i, const S* q) {
|
|
148
|
+
const S qm = q[m.coupled_master_qadr[i]];
|
|
149
|
+
const S* c = m.coupled_coef + 5 * i;
|
|
150
|
+
return S(2) * c[2] + qm * (S(6) * c[3] + qm * S(12) * c[4]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
template <class S> struct Pose { Quat<S> q; Vec3<S> p; }; // body -> world
|
|
154
|
+
|
|
155
|
+
// Joint displacement transform (R_j, p_j) from this joint's q coords. A Ball / Free quaternion is normalized here,
|
|
156
|
+
// the one place every path reads a joint rotation from q (forward_kinematics, the spatial transforms of
|
|
157
|
+
// body_velocities / RNE / ABA, the contact and muscle chains, their adjoints). The GPU state stores q in f32, so its
|
|
158
|
+
// quaternions are unit only to ~1e-7; read raw, from_pose -> quat_to_mat built a non-orthogonal transform while the
|
|
159
|
+
// pose chains normalized, and the two paths disagreed by ~|q| - 1 (docs/logs/bug-grad-audits.md 2026-10-29). Every q
|
|
160
|
+
// cotangent is in the right-trivialized chart (q (x) exp(d) keeps |q|), where the normalization's Jacobian
|
|
161
|
+
// (I - qh qh^T) / |q| acts as the identity; a Dual-seeded VJP carries it through this quat_normalize. The lift to a raw
|
|
162
|
+
// 4-component cotangent (gpu_bridge._lift_quat) applies it explicitly.
|
|
163
|
+
template <class S>
|
|
164
|
+
DN_HOST_DEVICE void joint_transform(JointType t, Vec3<S> axis, const S* q,
|
|
165
|
+
Quat<S>& R_j, Vec3<S>& p_j) {
|
|
166
|
+
using namespace so3;
|
|
167
|
+
R_j = {S(1), S(0), S(0), S(0)};
|
|
168
|
+
p_j = {S(0), S(0), S(0)};
|
|
169
|
+
switch (t) {
|
|
170
|
+
case JointType::Fixed: break;
|
|
171
|
+
case JointType::Revolute: R_j = exp_map(scale(axis, q[0])); break;
|
|
172
|
+
case JointType::Slide: p_j = scale(axis, q[0]); break;
|
|
173
|
+
case JointType::Ball: R_j = quat_normalize(Quat<S>{q[0], q[1], q[2], q[3]}); break;
|
|
174
|
+
case JointType::Free:
|
|
175
|
+
p_j = {q[0], q[1], q[2]};
|
|
176
|
+
R_j = quat_normalize(Quat<S>{q[3], q[4], q[5], q[6]});
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Compound-joint displacement transform: the ordered composition of the body's
|
|
182
|
+
// primitive scalar joints T_J = T_0(q0)·T_1(q1)·…·T_{n-1}, with primitive 0
|
|
183
|
+
// applied first (nearest the parent) and the body frame AFTER the last primitive.
|
|
184
|
+
// q points at this body's first coord; primitive k consumes joint_nq(stack[k])
|
|
185
|
+
// (== 1 for Revolute/Slide) coords. (Used only when is_compound(m,i).)
|
|
186
|
+
template <class S>
|
|
187
|
+
DN_HOST_DEVICE void compound_joint_transform(const KinModel<S>& m, int i, const S* q,
|
|
188
|
+
Quat<S>& R_j, Vec3<S>& p_j) {
|
|
189
|
+
using namespace so3;
|
|
190
|
+
const int base = m.jnt_adr[i], n = m.jnt_num[i];
|
|
191
|
+
R_j = {S(1), S(0), S(0), S(0)};
|
|
192
|
+
p_j = {S(0), S(0), S(0)};
|
|
193
|
+
int qoff = 0;
|
|
194
|
+
for (int k = 0; k < n; ++k) {
|
|
195
|
+
Quat<S> R_k; Vec3<S> p_k;
|
|
196
|
+
joint_transform(m.stack_type[base + k], m.stack_axis[base + k], q + qoff, R_k, p_k);
|
|
197
|
+
// T_J <- T_J · T_k : p_J += R_J p_k ; R_J = R_J R_k.
|
|
198
|
+
p_j = add(p_j, quat_rotate(R_j, p_k));
|
|
199
|
+
R_j = quat_mul(R_j, R_k);
|
|
200
|
+
qoff += joint_nq(m.stack_type[base + k]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Body-frame screw AXIS of compound primitive k (local index 0..jnt_num[i]-1):
|
|
205
|
+
// axis_k^body = (R_{k+1}·…·R_{n-1})^T · axis_k
|
|
206
|
+
// where R_j is primitive j's joint rotation. The screw direction axis_k is
|
|
207
|
+
// invariant under its OWN rotation/translation T_k (a hinge rotation is about
|
|
208
|
+
// axis_k; a slide has identity rotation), so axis_k expressed in the frame just
|
|
209
|
+
// AFTER T_k equals axis_k; the remaining primitives k+1..n-1 rotate it into the
|
|
210
|
+
// body frame. The last primitive (k=n-1) has an empty product => its axis is the
|
|
211
|
+
// body-frame axis directly (today's single-joint convention). Caller forms the
|
|
212
|
+
// 6-column from this: hinge S_k=[axis_k^body;0], slide S_k=[0;axis_k^body].
|
|
213
|
+
template <class S>
|
|
214
|
+
DN_HOST_DEVICE so3::Vec3<S> compound_subspace_axis(const KinModel<S>& m, int i, int k, const S* q) {
|
|
215
|
+
using namespace so3;
|
|
216
|
+
const int base = m.jnt_adr[i], n = m.jnt_num[i];
|
|
217
|
+
// R_rest = R_{k+1}·…·R_{n-1} (product of the LATER primitives' joint rotations).
|
|
218
|
+
Quat<S> R_rest{S(1), S(0), S(0), S(0)};
|
|
219
|
+
int qoff = 0;
|
|
220
|
+
for (int j = 0; j < k; ++j) qoff += joint_nq(m.stack_type[base + j]); // skip to primitive k's coords
|
|
221
|
+
int qoff_j = qoff + joint_nq(m.stack_type[base + k]); // first coord of primitive k+1
|
|
222
|
+
for (int j = k + 1; j < n; ++j) {
|
|
223
|
+
Quat<S> R_jj; Vec3<S> p_jj;
|
|
224
|
+
joint_transform(m.stack_type[base + j], m.stack_axis[base + j], q + qoff_j, R_jj, p_jj);
|
|
225
|
+
R_rest = quat_mul(R_rest, R_jj);
|
|
226
|
+
qoff_j += joint_nq(m.stack_type[base + j]);
|
|
227
|
+
}
|
|
228
|
+
// (R_{k+1}…R_{n-1})^T · axis_k = quat_rotate(conj(R_rest), axis_k).
|
|
229
|
+
return quat_rotate(quat_conj(R_rest), m.stack_axis[base + k]);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Joint displacement (R_j, p_j) of body i read from the FULL coordinate vector q. A coupled body
|
|
233
|
+
// evaluates its driven q_dep = poly(q_master) (its own qadr is a phantom that aliases another body's
|
|
234
|
+
// coordinate), a compound body composes its stack, and a single joint reads its own coords. Every
|
|
235
|
+
// sweep that rebuilds a body transform from q goes through here, so none of them can read a coupled
|
|
236
|
+
// body through its phantom address (the contact velocity sweeps did, docs/logs/bug-grad-audits.md
|
|
237
|
+
// 2026-10-25).
|
|
238
|
+
template <class S>
|
|
239
|
+
DN_HOST_DEVICE void body_joint_transform(const KinModel<S>& m, int i, const S* q, Quat<S>& R_j,
|
|
240
|
+
Vec3<S>& p_j) {
|
|
241
|
+
if (is_coupled(m, i)) {
|
|
242
|
+
const S qc = coupled_q(m, i, q);
|
|
243
|
+
joint_transform(m.jtype[i], m.jaxis[i], &qc, R_j, p_j);
|
|
244
|
+
} else if (is_compound(m, i)) {
|
|
245
|
+
compound_joint_transform(m, i, q + m.qadr[i], R_j, p_j);
|
|
246
|
+
} else {
|
|
247
|
+
joint_transform(m.jtype[i], m.jaxis[i], q + m.qadr[i], R_j, p_j);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Forward kinematics: fill pose[i] (body->world) for all bodies. q = one env's
|
|
252
|
+
// generalized coords. Single forward sweep (bodies in tree order). Compound
|
|
253
|
+
// bodies compose their primitive stack; single-joint bodies use joint_transform.
|
|
254
|
+
template <class S>
|
|
255
|
+
DN_HOST_DEVICE void forward_kinematics(const KinModel<S>& m, const S* q, Pose<S>* pose) {
|
|
256
|
+
using namespace so3;
|
|
257
|
+
for (int i = 0; i < m.nbody; ++i) {
|
|
258
|
+
Quat<S> R_j; Vec3<S> p_j;
|
|
259
|
+
body_joint_transform(m, i, q, R_j, p_j);
|
|
260
|
+
// relative pose parent-frame -> body: T_tree · T_joint
|
|
261
|
+
Quat<S> R_rel = quat_mul(m.quat_tree[i], R_j);
|
|
262
|
+
Vec3<S> p_rel = add(quat_rotate(m.quat_tree[i], p_j), m.pos_tree[i]);
|
|
263
|
+
if (m.parent[i] < 0) {
|
|
264
|
+
pose[i] = {quat_normalize(R_rel), p_rel};
|
|
265
|
+
} else {
|
|
266
|
+
const Pose<S>& pp = pose[m.parent[i]];
|
|
267
|
+
pose[i] = {quat_normalize(quat_mul(pp.q, R_rel)),
|
|
268
|
+
add(quat_rotate(pp.q, p_rel), pp.p)};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
} // namespace js::kin
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// SO(3) / unit-quaternion tangent algebra (Phase 1).
|
|
3
|
+
//
|
|
4
|
+
// Conventions (pinned; everything downstream — FK, free-body integration, the
|
|
5
|
+
// IFT adjoint — builds on these, and they match the mujoco-son f64 oracle so
|
|
6
|
+
// parity is well-defined):
|
|
7
|
+
// * Quaternion: Hamilton convention, scalar-first layout [w, x, y, z], unit
|
|
8
|
+
// norm = rotation. (MuJoCo/mujoco-son use scalar-first Hamilton.)
|
|
9
|
+
// * Tangent: rotation-vector phi in R^3 (axis * angle). exp: R^3 -> quat,
|
|
10
|
+
// log: quat -> R^3.
|
|
11
|
+
// * Right Jacobian J_r(phi): exp(phi + d) ~= exp(phi) (x) exp(J_r(phi) d)
|
|
12
|
+
// for small d. Used by the adjoint (Phase 3) to map tangent perturbations.
|
|
13
|
+
//
|
|
14
|
+
// Pure precision-agnostic primitives templated on the scalar S: a component
|
|
15
|
+
// instantiates them at its PrecisionTraits<C>::Scalar (the precision *policy*
|
|
16
|
+
// stays in component_scalars.h; these are just math). Same source compiles for
|
|
17
|
+
// the CPU f64 oracle and CUDA (DN_HOST_DEVICE).
|
|
18
|
+
//
|
|
19
|
+
// Small-angle error budget (dev-rules §3): below kSmallAngle the 1/theta and
|
|
20
|
+
// 1/theta^2 forms are replaced by their leading Taylor terms. The threshold is
|
|
21
|
+
// set so the dropped O(theta^2) correction is below f32 round-off; truncation
|
|
22
|
+
// error at the switch is O(theta^2) ~ 1e-12 (f32) / negligible (f64).
|
|
23
|
+
#include <cmath>
|
|
24
|
+
|
|
25
|
+
#include "diffneusim/macros.h"
|
|
26
|
+
|
|
27
|
+
namespace js::so3 {
|
|
28
|
+
|
|
29
|
+
template <class S> struct Vec3 { S x, y, z; };
|
|
30
|
+
template <class S> struct Quat { S w, x, y, z; }; // scalar-first Hamilton
|
|
31
|
+
template <class S> struct Mat3 { S m[9]; }; // row-major
|
|
32
|
+
|
|
33
|
+
// theta below which small-angle Taylor forms are used (rotation-vector norm).
|
|
34
|
+
template <class S> DN_HOST_DEVICE constexpr S kSmallAngle() { return S(1e-7); } // default (f64-grade; e.g. Dual)
|
|
35
|
+
template <> DN_HOST_DEVICE constexpr float kSmallAngle<float>() { return 1e-4f; }
|
|
36
|
+
template <> DN_HOST_DEVICE constexpr double kSmallAngle<double>() { return 1e-7; }
|
|
37
|
+
|
|
38
|
+
// sqrt/sin/cos/atan2 that resolve to the right precision on host and device.
|
|
39
|
+
// Declared before the vec3/quat templates that use them (built-in scalar args
|
|
40
|
+
// give no ADL, so they must be visible at template definition).
|
|
41
|
+
DN_HOST_DEVICE inline float js_sqrt(float x) { return sqrtf(x); }
|
|
42
|
+
DN_HOST_DEVICE inline double js_sqrt(double x) { return sqrt(x); }
|
|
43
|
+
DN_HOST_DEVICE inline float js_sin(float x) { return sinf(x); }
|
|
44
|
+
DN_HOST_DEVICE inline double js_sin(double x) { return sin(x); }
|
|
45
|
+
DN_HOST_DEVICE inline float js_cos(float x) { return cosf(x); }
|
|
46
|
+
DN_HOST_DEVICE inline double js_cos(double x) { return cos(x); }
|
|
47
|
+
DN_HOST_DEVICE inline float js_atan2(float y, float x) { return atan2f(y, x); }
|
|
48
|
+
DN_HOST_DEVICE inline double js_atan2(double y, double x) { return atan2(y, x); }
|
|
49
|
+
DN_HOST_DEVICE inline float js_acos(float x) { return acosf(x); }
|
|
50
|
+
DN_HOST_DEVICE inline double js_acos(double x) { return acos(x); }
|
|
51
|
+
DN_HOST_DEVICE inline float js_exp(float x) { return expf(x); }
|
|
52
|
+
DN_HOST_DEVICE inline double js_exp(double x) { return exp(x); }
|
|
53
|
+
DN_HOST_DEVICE inline float js_log(float x) { return logf(x); }
|
|
54
|
+
DN_HOST_DEVICE inline double js_log(double x) { return log(x); }
|
|
55
|
+
|
|
56
|
+
// --- vec3 ---------------------------------------------------------------
|
|
57
|
+
template <class S> DN_HOST_DEVICE Vec3<S> add(Vec3<S> a, Vec3<S> b) { return {a.x+b.x, a.y+b.y, a.z+b.z}; }
|
|
58
|
+
template <class S> DN_HOST_DEVICE Vec3<S> sub(Vec3<S> a, Vec3<S> b) { return {a.x-b.x, a.y-b.y, a.z-b.z}; }
|
|
59
|
+
template <class S> DN_HOST_DEVICE Vec3<S> scale(Vec3<S> a, S s) { return {a.x*s, a.y*s, a.z*s}; }
|
|
60
|
+
template <class S> DN_HOST_DEVICE S dot(Vec3<S> a, Vec3<S> b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
|
|
61
|
+
template <class S> DN_HOST_DEVICE Vec3<S> cross(Vec3<S> a, Vec3<S> b) {
|
|
62
|
+
return {a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x};
|
|
63
|
+
}
|
|
64
|
+
template <class S> DN_HOST_DEVICE S norm(Vec3<S> a) { return js_sqrt(dot(a, a)); }
|
|
65
|
+
|
|
66
|
+
// --- quaternion ---------------------------------------------------------
|
|
67
|
+
template <class S> DN_HOST_DEVICE Quat<S> quat_mul(Quat<S> a, Quat<S> b) {
|
|
68
|
+
return {a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z,
|
|
69
|
+
a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y,
|
|
70
|
+
a.w*b.y - a.x*b.z + a.y*b.w + a.z*b.x,
|
|
71
|
+
a.w*b.z + a.x*b.y - a.y*b.x + a.z*b.w};
|
|
72
|
+
}
|
|
73
|
+
template <class S> DN_HOST_DEVICE Quat<S> quat_conj(Quat<S> q) { return {q.w, -q.x, -q.y, -q.z}; }
|
|
74
|
+
|
|
75
|
+
template <class S> DN_HOST_DEVICE Quat<S> quat_normalize(Quat<S> q) {
|
|
76
|
+
S n = js_sqrt(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
|
|
77
|
+
S inv = S(1) / n;
|
|
78
|
+
return {q.w*inv, q.x*inv, q.y*inv, q.z*inv};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Rotate v by q: v' = q (x) [0,v] (x) q* (Rodrigues form, no matrix).
|
|
82
|
+
template <class S> DN_HOST_DEVICE Vec3<S> quat_rotate(Quat<S> q, Vec3<S> v) {
|
|
83
|
+
Vec3<S> u{q.x, q.y, q.z};
|
|
84
|
+
Vec3<S> t = scale(cross(u, v), S(2));
|
|
85
|
+
return add(add(v, scale(t, q.w)), cross(u, t));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// --- exp / log ----------------------------------------------------------
|
|
89
|
+
// exp: rotation vector phi (axis*angle) -> unit quaternion.
|
|
90
|
+
template <class S> DN_HOST_DEVICE Quat<S> exp_map(Vec3<S> phi) {
|
|
91
|
+
S theta = norm(phi);
|
|
92
|
+
S half = theta * S(0.5);
|
|
93
|
+
S w = js_cos(half);
|
|
94
|
+
// sin(theta/2)/theta = (1/2) * sinc(theta/2); smooth at 0.
|
|
95
|
+
S k;
|
|
96
|
+
if (theta < kSmallAngle<S>()) {
|
|
97
|
+
// (1/2)(1 - (theta/2)^2/6 + ...) ; leading term dominates below threshold.
|
|
98
|
+
k = S(0.5) - theta*theta * S(1.0/48.0);
|
|
99
|
+
} else {
|
|
100
|
+
k = js_sin(half) / theta;
|
|
101
|
+
}
|
|
102
|
+
return {w, phi.x*k, phi.y*k, phi.z*k};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// log: unit quaternion -> rotation vector phi. Returns the shortest rotation
|
|
106
|
+
// (canonicalizes to w >= 0).
|
|
107
|
+
template <class S> DN_HOST_DEVICE Vec3<S> log_map(Quat<S> q) {
|
|
108
|
+
if (q.w < S(0)) { q.w = -q.w; q.x = -q.x; q.y = -q.y; q.z = -q.z; }
|
|
109
|
+
Vec3<S> v{q.x, q.y, q.z};
|
|
110
|
+
S nv = norm(v);
|
|
111
|
+
S theta = S(2) * js_atan2(nv, q.w);
|
|
112
|
+
S k; // phi = k * v, where k = theta / nv
|
|
113
|
+
if (nv < kSmallAngle<S>()) {
|
|
114
|
+
// theta/nv -> 2/w as nv->0 (atan2(nv,w) ~ nv/w); w ~ 1 here.
|
|
115
|
+
k = S(2) / q.w;
|
|
116
|
+
} else {
|
|
117
|
+
k = theta / nv;
|
|
118
|
+
}
|
|
119
|
+
return {v.x*k, v.y*k, v.z*k};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// --- right Jacobian -----------------------------------------------------
|
|
123
|
+
// J_r(phi) = I - a [phi]x + b [phi]x^2, a=(1-cos t)/t^2, b=(t-sin t)/t^3.
|
|
124
|
+
// Satisfies exp(phi + d) ~= exp(phi) (x) exp(J_r(phi) d) for small d.
|
|
125
|
+
template <class S> DN_HOST_DEVICE Mat3<S> right_jacobian(Vec3<S> phi) {
|
|
126
|
+
S t2 = dot(phi, phi);
|
|
127
|
+
S t = js_sqrt(t2);
|
|
128
|
+
S a, b;
|
|
129
|
+
if (t < kSmallAngle<S>()) {
|
|
130
|
+
a = S(0.5) - t2 * S(1.0/24.0); // (1-cos t)/t^2
|
|
131
|
+
b = S(1.0/6.0) - t2 * S(1.0/120.0); // (t-sin t)/t^3
|
|
132
|
+
} else {
|
|
133
|
+
a = (S(1) - js_cos(t)) / t2;
|
|
134
|
+
b = (t - js_sin(t)) / (t2 * t);
|
|
135
|
+
}
|
|
136
|
+
// [phi]x
|
|
137
|
+
const S x = phi.x, y = phi.y, z = phi.z;
|
|
138
|
+
// [phi]x^2 = phi phi^T - t2 I
|
|
139
|
+
Mat3<S> J;
|
|
140
|
+
// I
|
|
141
|
+
J.m[0]=1; J.m[1]=0; J.m[2]=0;
|
|
142
|
+
J.m[3]=0; J.m[4]=1; J.m[5]=0;
|
|
143
|
+
J.m[6]=0; J.m[7]=0; J.m[8]=1;
|
|
144
|
+
// - a [phi]x ([phi]x = [[0,-z,y],[z,0,-x],[-y,x,0]])
|
|
145
|
+
J.m[1] -= a*(-z); J.m[2] -= a*( y);
|
|
146
|
+
J.m[3] -= a*( z); J.m[5] -= a*(-x);
|
|
147
|
+
J.m[6] -= a*(-y); J.m[7] -= a*( x);
|
|
148
|
+
// + b [phi]x^2 = b (phi phi^T - t2 I)
|
|
149
|
+
J.m[0] += b*(x*x - t2); J.m[1] += b*(x*y); J.m[2] += b*(x*z);
|
|
150
|
+
J.m[3] += b*(y*x); J.m[4] += b*(y*y - t2); J.m[5] += b*(y*z);
|
|
151
|
+
J.m[6] += b*(z*x); J.m[7] += b*(z*y); J.m[8] += b*(z*z - t2);
|
|
152
|
+
return J;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// --- Mat3 (row-major) ops ----------------------------------------------
|
|
156
|
+
template <class S> DN_HOST_DEVICE Mat3<S> identity3() {
|
|
157
|
+
return {{S(1),0,0, 0,S(1),0, 0,0,S(1)}};
|
|
158
|
+
}
|
|
159
|
+
template <class S> DN_HOST_DEVICE Vec3<S> mat_vec(const Mat3<S>& A, Vec3<S> v) {
|
|
160
|
+
return {A.m[0]*v.x + A.m[1]*v.y + A.m[2]*v.z,
|
|
161
|
+
A.m[3]*v.x + A.m[4]*v.y + A.m[5]*v.z,
|
|
162
|
+
A.m[6]*v.x + A.m[7]*v.y + A.m[8]*v.z};
|
|
163
|
+
}
|
|
164
|
+
template <class S> DN_HOST_DEVICE Mat3<S> transpose(const Mat3<S>& A) {
|
|
165
|
+
return {{A.m[0],A.m[3],A.m[6], A.m[1],A.m[4],A.m[7], A.m[2],A.m[5],A.m[8]}};
|
|
166
|
+
}
|
|
167
|
+
template <class S> DN_HOST_DEVICE Mat3<S> mat_mul(const Mat3<S>& A, const Mat3<S>& B) {
|
|
168
|
+
Mat3<S> C;
|
|
169
|
+
for (int i = 0; i < 3; ++i)
|
|
170
|
+
for (int j = 0; j < 3; ++j)
|
|
171
|
+
C.m[3*i+j] = A.m[3*i]*B.m[j] + A.m[3*i+1]*B.m[3+j] + A.m[3*i+2]*B.m[6+j];
|
|
172
|
+
return C;
|
|
173
|
+
}
|
|
174
|
+
// Rotation matrix from a unit quaternion (body->world).
|
|
175
|
+
template <class S> DN_HOST_DEVICE Mat3<S> quat_to_mat(Quat<S> q) {
|
|
176
|
+
S w=q.w,x=q.x,y=q.y,z=q.z;
|
|
177
|
+
return {{ S(1)-2*(y*y+z*z), 2*(x*y-z*w), 2*(x*z+y*w),
|
|
178
|
+
2*(x*y+z*w), S(1)-2*(x*x+z*z), 2*(y*z-x*w),
|
|
179
|
+
2*(x*z-y*w), 2*(y*z+x*w), S(1)-2*(x*x+y*y) }};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
} // namespace js::so3
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
// D16 adjoint, the control step's OUTPUT pull-back (d5, 2026-11-02; tools/d16_adj_shell/PREREG.md, gate G-TW): the tracked bodies'
|
|
3
|
+
// world poses and twists at (q, v) = (q_{t+1}, v_{t+1}), the trainer's definition [v_b; w_b] = J_b(q) v (v_b the body origin's
|
|
4
|
+
// world velocity, w_b its world angular velocity), and their cotangents pulled back to the q tangent and to v:
|
|
5
|
+
// s = sum_b xpos_bar_b . xpos_b + xrot_bar_b . theta_b + vb_bar_b . v_b + wb_bar_b . w_b
|
|
6
|
+
// q_bar += ds/dq (tangent; through fk and through dJ/dq along v), v_bar += J' [vb_bar; wb_bar]
|
|
7
|
+
// One level sweep each way, lane = body, the same conventions and phases as rnea_adj.h (host-emulable, deterministic).
|
|
8
|
+
#include "rnea_adj.h"
|
|
9
|
+
|
|
10
|
+
namespace js::soft::adj {
|
|
11
|
+
|
|
12
|
+
constexpr int kSlotO = 16; // publish: xq 4, xp 3, w 3, vo 3 (+3 pad); message: xpb 3, tau 3, wbar 3, vobar 3
|
|
13
|
+
|
|
14
|
+
// cotangent arrays are nb x 3 (world frame), nullptr for none; PC (the gate's positive control, 0 in real builds): 1 drops the
|
|
15
|
+
// q terms through dJ/dq (the velocities' dependence on the frames)
|
|
16
|
+
template <class S, int PC = 0, class Tab>
|
|
17
|
+
DN_HOST_DEVICE void adj_out_pullback(const Tab& B, const S* q, const S* v, const S* xpos_bar, const S* xrot_bar,
|
|
18
|
+
const S* vb_bar, const S* wb_bar, S* q_bar, S* v_bar, S* scratch) {
|
|
19
|
+
S (*slot)[kSlotO] = reinterpret_cast<S (*)[kSlotO]>(scratch);
|
|
20
|
+
const int nb = B.nb();
|
|
21
|
+
LANEA(S, R, 9); LANEA(S, r, 3); LANEA(S, a, 3);
|
|
22
|
+
ADJ_LANES(lane) {
|
|
23
|
+
if (lane == 0) { S* s = slot[0]; s[0] = S(1); for (int k = 1; k < kSlotO; ++k) s[k] = S(0); }
|
|
24
|
+
}
|
|
25
|
+
for (int d = 1; d <= B.maxdepth(); ++d) {
|
|
26
|
+
ADJ_LANES(lane) {
|
|
27
|
+
if (lane < nb && B.depth(lane) == d) {
|
|
28
|
+
const int b = lane, jt = B.jnt(b);
|
|
29
|
+
const S* ps = slot[B.parent(b)];
|
|
30
|
+
S xq[4], xp[3], w[3], vo[3];
|
|
31
|
+
body_kin(B, b, q, ps, ps + 4, xq, xp, LV(R), LV(r), LV(a));
|
|
32
|
+
if (jt == kJntFree) {
|
|
33
|
+
const int dd = B.dadr(b);
|
|
34
|
+
const S wbody[3] = {v[dd + 3], v[dd + 4], v[dd + 5]};
|
|
35
|
+
mat_vec(LV(R), wbody, w);
|
|
36
|
+
for (int k = 0; k < 3; ++k) vo[k] = v[dd + k];
|
|
37
|
+
} else {
|
|
38
|
+
const S *wp = ps + 7, *vop = ps + 10;
|
|
39
|
+
S t[3];
|
|
40
|
+
cross3(wp, LV(r), t);
|
|
41
|
+
for (int k = 0; k < 3; ++k) vo[k] = vop[k] + t[k];
|
|
42
|
+
const S vb = jt == kJntHinge ? v[B.dadr(b)] : S(0);
|
|
43
|
+
for (int k = 0; k < 3; ++k) w[k] = wp[k] + LV(a)[k] * vb;
|
|
44
|
+
}
|
|
45
|
+
S* s = slot[b];
|
|
46
|
+
for (int k = 0; k < 4; ++k) s[k] = xq[k];
|
|
47
|
+
for (int k = 0; k < 3; ++k) { s[4 + k] = xp[k]; s[7 + k] = w[k]; s[10 + k] = vo[k]; }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (int d = B.maxdepth(); d >= 1; --d) {
|
|
52
|
+
ADJ_LANES(lane) {
|
|
53
|
+
if (lane < nb && B.depth(lane) == d) {
|
|
54
|
+
const int b = lane, jt = B.jnt(b);
|
|
55
|
+
S xpb[3], tau[3], wb[3], vob[3], t[3];
|
|
56
|
+
for (int k = 0; k < 3; ++k) {
|
|
57
|
+
xpb[k] = xpos_bar ? xpos_bar[3 * b + k] : S(0); tau[k] = xrot_bar ? xrot_bar[3 * b + k] : S(0);
|
|
58
|
+
wb[k] = wb_bar ? wb_bar[3 * b + k] : S(0); vob[k] = vb_bar ? vb_bar[3 * b + k] : S(0);
|
|
59
|
+
}
|
|
60
|
+
for (int ci = 0; ci < B.nchild(b); ++ci) { // the children, in increasing index
|
|
61
|
+
const S* mc = slot[B.child(b, ci)];
|
|
62
|
+
add3(xpb, mc); add3(tau, mc + 3); add3(wb, mc + 6); add3(vob, mc + 9);
|
|
63
|
+
}
|
|
64
|
+
const S* s = slot[b];
|
|
65
|
+
if (jt == kJntFree) {
|
|
66
|
+
const int dd = B.dadr(b);
|
|
67
|
+
const S* w = s + 7;
|
|
68
|
+
if (PC != 1) { cross3(w, wb, t); add3(tau, t); } // w = R w_body
|
|
69
|
+
mat_tvec(LV(R), wb, t);
|
|
70
|
+
for (int k = 0; k < 3; ++k) { v_bar[dd + 3 + k] = v_bar[dd + 3 + k] + t[k]; v_bar[dd + k] = v_bar[dd + k] + vob[k]; }
|
|
71
|
+
mat_tvec(LV(R), tau, t);
|
|
72
|
+
for (int k = 0; k < 3; ++k) { q_bar[dd + k] = q_bar[dd + k] + xpb[k]; q_bar[dd + 3 + k] = q_bar[dd + 3 + k] + t[k]; }
|
|
73
|
+
} else {
|
|
74
|
+
const S* ps = slot[B.parent(b)]; // the parent's forward values (overwritten only in the next phase)
|
|
75
|
+
const S* wp = ps + 7;
|
|
76
|
+
S rb[3] = {xpb[0], xpb[1], xpb[2]}, out[kSlotO];
|
|
77
|
+
for (int k = 0; k < kSlotO; ++k) out[k] = S(0);
|
|
78
|
+
// vo = vo_p + w_p x r
|
|
79
|
+
for (int k = 0; k < 3; ++k) out[9 + k] = vob[k];
|
|
80
|
+
cross3(LV(r), vob, t); for (int k = 0; k < 3; ++k) out[6 + k] = t[k];
|
|
81
|
+
if (PC != 1) { cross3(vob, wp, t); add3(rb, t); }
|
|
82
|
+
// w = w_p + a v_b
|
|
83
|
+
add3(out + 6, wb);
|
|
84
|
+
if (jt == kJntHinge) {
|
|
85
|
+
const int dd = B.dadr(b);
|
|
86
|
+
v_bar[dd] = v_bar[dd] + dot3(LV(a), wb);
|
|
87
|
+
S ab3[3];
|
|
88
|
+
for (int k = 0; k < 3; ++k) ab3[k] = v[dd] * wb[k];
|
|
89
|
+
if (PC != 1) { cross3(LV(a), ab3, t); add3(tau, t); } // a = R axis
|
|
90
|
+
q_bar[dd] = q_bar[dd] + dot3(LV(a), tau);
|
|
91
|
+
}
|
|
92
|
+
for (int k = 0; k < 3; ++k) out[k] = xpb[k];
|
|
93
|
+
cross3(LV(r), rb, t);
|
|
94
|
+
for (int k = 0; k < 3; ++k) out[3 + k] = tau[k] + t[k];
|
|
95
|
+
for (int k = 0; k < kSlotO; ++k) slot[b][k] = out[k]; // read by the parent in the next phase
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
} // namespace js::soft::adj
|