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.
Files changed (682) hide show
  1. diffneusim/__init__.py +1 -0
  2. diffneusim/_cache.py +42 -0
  3. diffneusim/_paths.py +5 -0
  4. diffneusim/bindings/rew14_ext.cu +115 -0
  5. diffneusim/bindings/soft14_capi.cpp +443 -0
  6. diffneusim/bindings/soft14_engine_ext.cu +596 -0
  7. diffneusim/bindings/soft_capi.cpp +782 -0
  8. diffneusim/bindings/soft_engine_ext.cu +495 -0
  9. diffneusim/core/cpu_engine/build.sh +40 -0
  10. diffneusim/core/cpu_engine/fiber/cuda_runtime.h +445 -0
  11. diffneusim/core/cpu_engine/x14_cpu.cpp +283 -0
  12. diffneusim/core/diff/dual.h +126 -0
  13. diffneusim/core/include/diffneusim/macros.h +35 -0
  14. diffneusim/core/kin/kinematic_tree.h +273 -0
  15. diffneusim/core/math/so3.h +182 -0
  16. diffneusim/core/soft/adj/out_adj.h +102 -0
  17. diffneusim/core/soft/adj/rnea_adj.h +425 -0
  18. diffneusim/core/soft/adj/rows_adj.h +439 -0
  19. diffneusim/core/soft/adj/rows_functor.h +89 -0
  20. diffneusim/core/soft/adj/rows_lanes.h +443 -0
  21. diffneusim/core/soft/adj/shell_adj.h +243 -0
  22. diffneusim/core/soft/adj/tree_adj.h +356 -0
  23. diffneusim/core/soft/collide.h +183 -0
  24. diffneusim/core/soft/gpu/adj14.cuh +233 -0
  25. diffneusim/core/soft/gpu/adj14_mus.cuh +98 -0
  26. diffneusim/core/soft/gpu/adj_shell.cuh +50 -0
  27. diffneusim/core/soft/gpu/adj_tab.cuh +49 -0
  28. diffneusim/core/soft/gpu/body14.cuh +47 -0
  29. diffneusim/core/soft/gpu/chol_rn.cuh +458 -0
  30. diffneusim/core/soft/gpu/chol_small.cuh +123 -0
  31. diffneusim/core/soft/gpu/chol_split.cuh +193 -0
  32. diffneusim/core/soft/gpu/engine_launch.cuh +263 -0
  33. diffneusim/core/soft/gpu/fk_rn.cuh +109 -0
  34. diffneusim/core/soft/gpu/generated/body_019e20820f86_mmfloor.cuh +28 -0
  35. diffneusim/core/soft/gpu/generated/body_62f77a4bb16b_mmfloor.cuh +52 -0
  36. diffneusim/core/soft/gpu/generated/body_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +28 -0
  37. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +28 -0
  38. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +28 -0
  39. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +28 -0
  40. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +28 -0
  41. diffneusim/core/soft/gpu/generated/body_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +52 -0
  42. diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor.cuh +25 -0
  43. diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +25 -0
  44. diffneusim/core/soft/gpu/generated/g1_soft_5db44fd45286.cuh +74 -0
  45. diffneusim/core/soft/gpu/generated/split_62f77a4bb16b_mmfloor.cuh +18 -0
  46. diffneusim/core/soft/gpu/generated/split_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +18 -0
  47. diffneusim/core/soft/gpu/generated/x14_soft_019e20820f86_mmfloor.cuh +123 -0
  48. diffneusim/core/soft/gpu/generated/x14_soft_62f77a4bb16b_mmfloor.cuh +129 -0
  49. diffneusim/core/soft/gpu/generated/x14_soft_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +123 -0
  50. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +123 -0
  51. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +123 -0
  52. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +123 -0
  53. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +123 -0
  54. diffneusim/core/soft/gpu/generated/x14_soft_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +129 -0
  55. diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor.cuh +123 -0
  56. diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +123 -0
  57. diffneusim/core/soft/gpu/k_mus.cuh +1038 -0
  58. diffneusim/core/soft/gpu/k_mus_host.cuh +377 -0
  59. diffneusim/core/soft/gpu/k_pre.cuh +52 -0
  60. diffneusim/core/soft/gpu/kernel_p.cuh +490 -0
  61. diffneusim/core/soft/gpu/kp14.cuh +465 -0
  62. diffneusim/core/soft/gpu/l2v2.cuh +367 -0
  63. diffneusim/core/soft/gpu/l2x14.cuh +319 -0
  64. diffneusim/core/soft/gpu/l3.cuh +1483 -0
  65. diffneusim/core/soft/gpu/model_view.cuh +48 -0
  66. diffneusim/core/soft/gpu/mus_case_fits.h +15 -0
  67. diffneusim/core/soft/gpu/mus_classes.h +182 -0
  68. diffneusim/core/soft/gpu/mus_row_cf.h +44 -0
  69. diffneusim/core/soft/gpu/rew14.cuh +177 -0
  70. diffneusim/core/soft/gpu/rows_ctab.cuh +44 -0
  71. diffneusim/core/soft/gpu/tree_m.cuh +247 -0
  72. diffneusim/core/soft/gpu/x14_engine_kernels.cuh +260 -0
  73. diffneusim/core/soft/gpu/x14_rowcf.h +14 -0
  74. diffneusim/core/soft/hand.h +124 -0
  75. diffneusim/core/soft/impedance.h +115 -0
  76. diffneusim/core/soft/jvp.h +202 -0
  77. diffneusim/core/soft/kin.h +250 -0
  78. diffneusim/core/soft/muscle.h +1208 -0
  79. diffneusim/core/soft/newton.h +371 -0
  80. diffneusim/core/soft/rows.h +176 -0
  81. diffneusim/core/soft/step.h +188 -0
  82. diffneusim/core/soft/tape.h +313 -0
  83. diffneusim/core/soft/x14/collide14.h +69 -0
  84. diffneusim/core/soft/x14/jvp14.h +182 -0
  85. diffneusim/core/soft/x14/law14.h +453 -0
  86. diffneusim/core/soft/x14adj/collide14_adj.h +134 -0
  87. diffneusim/core/soft/x14adj/passive14_adj.h +162 -0
  88. diffneusim/core/soft/x14adj/reward14.h +484 -0
  89. diffneusim/core/soft/x14adj/rows14_adj.h +400 -0
  90. diffneusim/core/soft/x14adj/scan14.h +349 -0
  91. diffneusim/core/soft/x14adj/shell14_adj.h +122 -0
  92. diffneusim/core/soft/x14adj/sweep14.h +255 -0
  93. diffneusim/core/soft/x14adj/tree14_adj.h +500 -0
  94. diffneusim/core/soft/x14adj/x14adj_common.h +96 -0
  95. diffneusim/data/mirror/H1622v2k_geyer_hfdeq.npz +0 -0
  96. diffneusim/data/mirror/H1622v2k_hfd.npz +0 -0
  97. diffneusim/data/mirror/H1622v2k_millard_hfdeq.npz +0 -0
  98. diffneusim/data/mirror/fullbody_contact.npz +0 -0
  99. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard.npz +0 -0
  100. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str.npz +0 -0
  101. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str_rigid.npz +0 -0
  102. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.npz +0 -0
  103. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.npz +0 -0
  104. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq.npz +0 -0
  105. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin.npz +0 -0
  106. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_calf2_pe.npz +0 -0
  107. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  108. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfix.npz +0 -0
  109. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.npz +0 -0
  110. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01.npz +0 -0
  111. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01legs.npz +0 -0
  112. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01lumbar.npz +0 -0
  113. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfix.npz +0 -0
  114. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfixlegs01.npz +0 -0
  115. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
  116. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
  117. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
  118. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
  119. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair.npz +0 -0
  120. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  121. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_hinge.npz +0 -0
  122. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
  123. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
  124. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
  125. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
  126. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_lspine_girdle_osimeq.npz +0 -0
  127. diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_millard.npz +0 -0
  128. diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_osimeq.npz +0 -0
  129. diffneusim/data/mirror/myoleg26_3d_compound_g14eq.npz +0 -0
  130. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq.npz +0 -0
  131. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose.npz +0 -0
  132. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin.npz +0 -0
  133. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30.npz +0 -0
  134. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30.npz +0 -0
  135. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_luispe.npz +0 -0
  136. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_trunk0701.npz +0 -0
  137. diffneusim/data/muscle_fit/wang_mass_volume_14t.json +91 -0
  138. diffneusim/data/muscle_fit/wang_mass_volume_14t_axfix.json +91 -0
  139. diffneusim/data/muscle_fit/wang_mass_volume_14t_axfixlegs01.json +91 -0
  140. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01.json +91 -0
  141. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01legs.json +91 -0
  142. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01lumbar.json +91 -0
  143. diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfix.json +91 -0
  144. diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfixlegs01.json +91 -0
  145. diffneusim/data/muscle_fit/wang_mass_volume_14t_n1.json +91 -0
  146. diffneusim/data/muscle_fit/wang_mass_volume_14t_n1a.json +91 -0
  147. diffneusim/data/muscle_fit/wang_mass_volume_14t_n2.json +91 -0
  148. diffneusim/data/muscle_fit/wang_mass_volume_14t_rom23.json +91 -0
  149. diffneusim/data/reference/musclemimic/myofullbody_mimic_sites.json +261 -0
  150. diffneusim/data/reference/pose3/pose3_scone.json +305 -0
  151. diffneusim/data/reference/pose3/pose3_scone.txt +3 -0
  152. diffneusim/data/reference/pose3/pose3_scone_gait.npz +0 -0
  153. diffneusim/data/reference/pose3/pose3_scone_mirror.npz +0 -0
  154. diffneusim/data/reference/pose3/pose3_scone_stand.npz +0 -0
  155. diffneusim/data/reference/x016run/MD5SUMS +241 -0
  156. diffneusim/data/reference/x016run/x016run_states.txt +240 -0
  157. diffneusim/data/reference/x016run/x016run_v3p00_s0_l0.npz +0 -0
  158. diffneusim/data/reference/x016run/x016run_v3p00_s0_l1.npz +0 -0
  159. diffneusim/data/reference/x016run/x016run_v3p00_s0_l2.npz +0 -0
  160. diffneusim/data/reference/x016run/x016run_v3p00_s0_l3.npz +0 -0
  161. diffneusim/data/reference/x016run/x016run_v3p00_s0_r0.npz +0 -0
  162. diffneusim/data/reference/x016run/x016run_v3p00_s0_r1.npz +0 -0
  163. diffneusim/data/reference/x016run/x016run_v3p00_s0_r2.npz +0 -0
  164. diffneusim/data/reference/x016run/x016run_v3p00_s0_r3.npz +0 -0
  165. diffneusim/data/reference/x016run/x016run_v3p00_s1_l0.npz +0 -0
  166. diffneusim/data/reference/x016run/x016run_v3p00_s1_l1.npz +0 -0
  167. diffneusim/data/reference/x016run/x016run_v3p00_s1_l2.npz +0 -0
  168. diffneusim/data/reference/x016run/x016run_v3p00_s1_l3.npz +0 -0
  169. diffneusim/data/reference/x016run/x016run_v3p00_s1_r0.npz +0 -0
  170. diffneusim/data/reference/x016run/x016run_v3p00_s1_r1.npz +0 -0
  171. diffneusim/data/reference/x016run/x016run_v3p00_s1_r2.npz +0 -0
  172. diffneusim/data/reference/x016run/x016run_v3p00_s1_r3.npz +0 -0
  173. diffneusim/data/reference/x016run/x016run_v3p00_s2_l0.npz +0 -0
  174. diffneusim/data/reference/x016run/x016run_v3p00_s2_l1.npz +0 -0
  175. diffneusim/data/reference/x016run/x016run_v3p00_s2_l2.npz +0 -0
  176. diffneusim/data/reference/x016run/x016run_v3p00_s2_l3.npz +0 -0
  177. diffneusim/data/reference/x016run/x016run_v3p00_s2_r0.npz +0 -0
  178. diffneusim/data/reference/x016run/x016run_v3p00_s2_r1.npz +0 -0
  179. diffneusim/data/reference/x016run/x016run_v3p00_s2_r2.npz +0 -0
  180. diffneusim/data/reference/x016run/x016run_v3p00_s2_r3.npz +0 -0
  181. diffneusim/data/reference/x016run/x016run_v3p00_s3_l0.npz +0 -0
  182. diffneusim/data/reference/x016run/x016run_v3p00_s3_l1.npz +0 -0
  183. diffneusim/data/reference/x016run/x016run_v3p00_s3_l2.npz +0 -0
  184. diffneusim/data/reference/x016run/x016run_v3p00_s3_l3.npz +0 -0
  185. diffneusim/data/reference/x016run/x016run_v3p00_s3_r0.npz +0 -0
  186. diffneusim/data/reference/x016run/x016run_v3p00_s3_r1.npz +0 -0
  187. diffneusim/data/reference/x016run/x016run_v3p00_s3_r2.npz +0 -0
  188. diffneusim/data/reference/x016run/x016run_v3p00_s3_r3.npz +0 -0
  189. diffneusim/data/reference/x016run/x016run_v3p00_s4_l0.npz +0 -0
  190. diffneusim/data/reference/x016run/x016run_v3p00_s4_l1.npz +0 -0
  191. diffneusim/data/reference/x016run/x016run_v3p00_s4_l2.npz +0 -0
  192. diffneusim/data/reference/x016run/x016run_v3p00_s4_l3.npz +0 -0
  193. diffneusim/data/reference/x016run/x016run_v3p00_s4_r0.npz +0 -0
  194. diffneusim/data/reference/x016run/x016run_v3p00_s4_r1.npz +0 -0
  195. diffneusim/data/reference/x016run/x016run_v3p00_s4_r2.npz +0 -0
  196. diffneusim/data/reference/x016run/x016run_v3p00_s4_r3.npz +0 -0
  197. diffneusim/data/reference/x016run/x016run_v3p00_s5_l0.npz +0 -0
  198. diffneusim/data/reference/x016run/x016run_v3p00_s5_l1.npz +0 -0
  199. diffneusim/data/reference/x016run/x016run_v3p00_s5_l2.npz +0 -0
  200. diffneusim/data/reference/x016run/x016run_v3p00_s5_l3.npz +0 -0
  201. diffneusim/data/reference/x016run/x016run_v3p00_s5_r0.npz +0 -0
  202. diffneusim/data/reference/x016run/x016run_v3p00_s5_r1.npz +0 -0
  203. diffneusim/data/reference/x016run/x016run_v3p00_s5_r2.npz +0 -0
  204. diffneusim/data/reference/x016run/x016run_v3p00_s5_r3.npz +0 -0
  205. diffneusim/data/reference/x016run/x016run_v3p00_s6_l0.npz +0 -0
  206. diffneusim/data/reference/x016run/x016run_v3p00_s6_l1.npz +0 -0
  207. diffneusim/data/reference/x016run/x016run_v3p00_s6_l2.npz +0 -0
  208. diffneusim/data/reference/x016run/x016run_v3p00_s6_l3.npz +0 -0
  209. diffneusim/data/reference/x016run/x016run_v3p00_s6_r0.npz +0 -0
  210. diffneusim/data/reference/x016run/x016run_v3p00_s6_r1.npz +0 -0
  211. diffneusim/data/reference/x016run/x016run_v3p00_s6_r2.npz +0 -0
  212. diffneusim/data/reference/x016run/x016run_v3p00_s6_r3.npz +0 -0
  213. diffneusim/data/reference/x016run/x016run_v3p00_s7_l0.npz +0 -0
  214. diffneusim/data/reference/x016run/x016run_v3p00_s7_l1.npz +0 -0
  215. diffneusim/data/reference/x016run/x016run_v3p00_s7_l2.npz +0 -0
  216. diffneusim/data/reference/x016run/x016run_v3p00_s7_l3.npz +0 -0
  217. diffneusim/data/reference/x016run/x016run_v3p00_s7_r0.npz +0 -0
  218. diffneusim/data/reference/x016run/x016run_v3p00_s7_r1.npz +0 -0
  219. diffneusim/data/reference/x016run/x016run_v3p00_s7_r2.npz +0 -0
  220. diffneusim/data/reference/x016run/x016run_v3p00_s7_r3.npz +0 -0
  221. diffneusim/data/reference/x016run/x016run_v3p25_s0_l0.npz +0 -0
  222. diffneusim/data/reference/x016run/x016run_v3p25_s0_l1.npz +0 -0
  223. diffneusim/data/reference/x016run/x016run_v3p25_s0_l2.npz +0 -0
  224. diffneusim/data/reference/x016run/x016run_v3p25_s0_l3.npz +0 -0
  225. diffneusim/data/reference/x016run/x016run_v3p25_s0_r0.npz +0 -0
  226. diffneusim/data/reference/x016run/x016run_v3p25_s0_r1.npz +0 -0
  227. diffneusim/data/reference/x016run/x016run_v3p25_s0_r2.npz +0 -0
  228. diffneusim/data/reference/x016run/x016run_v3p25_s0_r3.npz +0 -0
  229. diffneusim/data/reference/x016run/x016run_v3p25_s1_l0.npz +0 -0
  230. diffneusim/data/reference/x016run/x016run_v3p25_s1_l1.npz +0 -0
  231. diffneusim/data/reference/x016run/x016run_v3p25_s1_l2.npz +0 -0
  232. diffneusim/data/reference/x016run/x016run_v3p25_s1_l3.npz +0 -0
  233. diffneusim/data/reference/x016run/x016run_v3p25_s1_r0.npz +0 -0
  234. diffneusim/data/reference/x016run/x016run_v3p25_s1_r1.npz +0 -0
  235. diffneusim/data/reference/x016run/x016run_v3p25_s1_r2.npz +0 -0
  236. diffneusim/data/reference/x016run/x016run_v3p25_s1_r3.npz +0 -0
  237. diffneusim/data/reference/x016run/x016run_v3p25_s2_l0.npz +0 -0
  238. diffneusim/data/reference/x016run/x016run_v3p25_s2_l1.npz +0 -0
  239. diffneusim/data/reference/x016run/x016run_v3p25_s2_l2.npz +0 -0
  240. diffneusim/data/reference/x016run/x016run_v3p25_s2_l3.npz +0 -0
  241. diffneusim/data/reference/x016run/x016run_v3p25_s2_r0.npz +0 -0
  242. diffneusim/data/reference/x016run/x016run_v3p25_s2_r1.npz +0 -0
  243. diffneusim/data/reference/x016run/x016run_v3p25_s2_r2.npz +0 -0
  244. diffneusim/data/reference/x016run/x016run_v3p25_s2_r3.npz +0 -0
  245. diffneusim/data/reference/x016run/x016run_v3p25_s3_l0.npz +0 -0
  246. diffneusim/data/reference/x016run/x016run_v3p25_s3_l1.npz +0 -0
  247. diffneusim/data/reference/x016run/x016run_v3p25_s3_l2.npz +0 -0
  248. diffneusim/data/reference/x016run/x016run_v3p25_s3_l3.npz +0 -0
  249. diffneusim/data/reference/x016run/x016run_v3p25_s3_r0.npz +0 -0
  250. diffneusim/data/reference/x016run/x016run_v3p25_s3_r1.npz +0 -0
  251. diffneusim/data/reference/x016run/x016run_v3p25_s3_r2.npz +0 -0
  252. diffneusim/data/reference/x016run/x016run_v3p25_s3_r3.npz +0 -0
  253. diffneusim/data/reference/x016run/x016run_v3p25_s4_l0.npz +0 -0
  254. diffneusim/data/reference/x016run/x016run_v3p25_s4_l1.npz +0 -0
  255. diffneusim/data/reference/x016run/x016run_v3p25_s4_l2.npz +0 -0
  256. diffneusim/data/reference/x016run/x016run_v3p25_s4_l3.npz +0 -0
  257. diffneusim/data/reference/x016run/x016run_v3p25_s4_r0.npz +0 -0
  258. diffneusim/data/reference/x016run/x016run_v3p25_s4_r1.npz +0 -0
  259. diffneusim/data/reference/x016run/x016run_v3p25_s4_r2.npz +0 -0
  260. diffneusim/data/reference/x016run/x016run_v3p25_s4_r3.npz +0 -0
  261. diffneusim/data/reference/x016run/x016run_v3p25_s5_l0.npz +0 -0
  262. diffneusim/data/reference/x016run/x016run_v3p25_s5_l1.npz +0 -0
  263. diffneusim/data/reference/x016run/x016run_v3p25_s5_l2.npz +0 -0
  264. diffneusim/data/reference/x016run/x016run_v3p25_s5_l3.npz +0 -0
  265. diffneusim/data/reference/x016run/x016run_v3p25_s5_r0.npz +0 -0
  266. diffneusim/data/reference/x016run/x016run_v3p25_s5_r1.npz +0 -0
  267. diffneusim/data/reference/x016run/x016run_v3p25_s5_r2.npz +0 -0
  268. diffneusim/data/reference/x016run/x016run_v3p25_s5_r3.npz +0 -0
  269. diffneusim/data/reference/x016run/x016run_v3p25_s6_l0.npz +0 -0
  270. diffneusim/data/reference/x016run/x016run_v3p25_s6_l1.npz +0 -0
  271. diffneusim/data/reference/x016run/x016run_v3p25_s6_l2.npz +0 -0
  272. diffneusim/data/reference/x016run/x016run_v3p25_s6_l3.npz +0 -0
  273. diffneusim/data/reference/x016run/x016run_v3p25_s6_r0.npz +0 -0
  274. diffneusim/data/reference/x016run/x016run_v3p25_s6_r1.npz +0 -0
  275. diffneusim/data/reference/x016run/x016run_v3p25_s6_r2.npz +0 -0
  276. diffneusim/data/reference/x016run/x016run_v3p25_s6_r3.npz +0 -0
  277. diffneusim/data/reference/x016run/x016run_v3p25_s7_l0.npz +0 -0
  278. diffneusim/data/reference/x016run/x016run_v3p25_s7_l1.npz +0 -0
  279. diffneusim/data/reference/x016run/x016run_v3p25_s7_l2.npz +0 -0
  280. diffneusim/data/reference/x016run/x016run_v3p25_s7_l3.npz +0 -0
  281. diffneusim/data/reference/x016run/x016run_v3p25_s7_r0.npz +0 -0
  282. diffneusim/data/reference/x016run/x016run_v3p25_s7_r1.npz +0 -0
  283. diffneusim/data/reference/x016run/x016run_v3p25_s7_r2.npz +0 -0
  284. diffneusim/data/reference/x016run/x016run_v3p25_s7_r3.npz +0 -0
  285. diffneusim/data/reference/x016run/x016run_v3p50_s0_l0.npz +0 -0
  286. diffneusim/data/reference/x016run/x016run_v3p50_s0_l1.npz +0 -0
  287. diffneusim/data/reference/x016run/x016run_v3p50_s0_l2.npz +0 -0
  288. diffneusim/data/reference/x016run/x016run_v3p50_s0_l3.npz +0 -0
  289. diffneusim/data/reference/x016run/x016run_v3p50_s0_r0.npz +0 -0
  290. diffneusim/data/reference/x016run/x016run_v3p50_s0_r1.npz +0 -0
  291. diffneusim/data/reference/x016run/x016run_v3p50_s0_r2.npz +0 -0
  292. diffneusim/data/reference/x016run/x016run_v3p50_s0_r3.npz +0 -0
  293. diffneusim/data/reference/x016run/x016run_v3p50_s1_l0.npz +0 -0
  294. diffneusim/data/reference/x016run/x016run_v3p50_s1_l1.npz +0 -0
  295. diffneusim/data/reference/x016run/x016run_v3p50_s1_l2.npz +0 -0
  296. diffneusim/data/reference/x016run/x016run_v3p50_s1_l3.npz +0 -0
  297. diffneusim/data/reference/x016run/x016run_v3p50_s1_r0.npz +0 -0
  298. diffneusim/data/reference/x016run/x016run_v3p50_s1_r1.npz +0 -0
  299. diffneusim/data/reference/x016run/x016run_v3p50_s1_r2.npz +0 -0
  300. diffneusim/data/reference/x016run/x016run_v3p50_s1_r3.npz +0 -0
  301. diffneusim/data/reference/x016run/x016run_v3p50_s2_l0.npz +0 -0
  302. diffneusim/data/reference/x016run/x016run_v3p50_s2_l1.npz +0 -0
  303. diffneusim/data/reference/x016run/x016run_v3p50_s2_l2.npz +0 -0
  304. diffneusim/data/reference/x016run/x016run_v3p50_s2_l3.npz +0 -0
  305. diffneusim/data/reference/x016run/x016run_v3p50_s2_r0.npz +0 -0
  306. diffneusim/data/reference/x016run/x016run_v3p50_s2_r1.npz +0 -0
  307. diffneusim/data/reference/x016run/x016run_v3p50_s2_r2.npz +0 -0
  308. diffneusim/data/reference/x016run/x016run_v3p50_s2_r3.npz +0 -0
  309. diffneusim/data/reference/x016run/x016run_v3p50_s3_l0.npz +0 -0
  310. diffneusim/data/reference/x016run/x016run_v3p50_s3_l1.npz +0 -0
  311. diffneusim/data/reference/x016run/x016run_v3p50_s3_l2.npz +0 -0
  312. diffneusim/data/reference/x016run/x016run_v3p50_s3_l3.npz +0 -0
  313. diffneusim/data/reference/x016run/x016run_v3p50_s3_r0.npz +0 -0
  314. diffneusim/data/reference/x016run/x016run_v3p50_s3_r1.npz +0 -0
  315. diffneusim/data/reference/x016run/x016run_v3p50_s3_r2.npz +0 -0
  316. diffneusim/data/reference/x016run/x016run_v3p50_s3_r3.npz +0 -0
  317. diffneusim/data/reference/x016run/x016run_v3p50_s5_l0.npz +0 -0
  318. diffneusim/data/reference/x016run/x016run_v3p50_s5_l1.npz +0 -0
  319. diffneusim/data/reference/x016run/x016run_v3p50_s5_l2.npz +0 -0
  320. diffneusim/data/reference/x016run/x016run_v3p50_s5_l3.npz +0 -0
  321. diffneusim/data/reference/x016run/x016run_v3p50_s5_r0.npz +0 -0
  322. diffneusim/data/reference/x016run/x016run_v3p50_s5_r1.npz +0 -0
  323. diffneusim/data/reference/x016run/x016run_v3p50_s5_r2.npz +0 -0
  324. diffneusim/data/reference/x016run/x016run_v3p50_s5_r3.npz +0 -0
  325. diffneusim/data/reference/x016run/x016run_v3p50_s6_l0.npz +0 -0
  326. diffneusim/data/reference/x016run/x016run_v3p50_s6_l1.npz +0 -0
  327. diffneusim/data/reference/x016run/x016run_v3p50_s6_l2.npz +0 -0
  328. diffneusim/data/reference/x016run/x016run_v3p50_s6_l3.npz +0 -0
  329. diffneusim/data/reference/x016run/x016run_v3p50_s6_r0.npz +0 -0
  330. diffneusim/data/reference/x016run/x016run_v3p50_s6_r1.npz +0 -0
  331. diffneusim/data/reference/x016run/x016run_v3p50_s6_r2.npz +0 -0
  332. diffneusim/data/reference/x016run/x016run_v3p50_s6_r3.npz +0 -0
  333. diffneusim/data/reference/x016run/x016run_v3p50_s7_l0.npz +0 -0
  334. diffneusim/data/reference/x016run/x016run_v3p50_s7_l1.npz +0 -0
  335. diffneusim/data/reference/x016run/x016run_v3p50_s7_l2.npz +0 -0
  336. diffneusim/data/reference/x016run/x016run_v3p50_s7_l3.npz +0 -0
  337. diffneusim/data/reference/x016run/x016run_v3p50_s7_r0.npz +0 -0
  338. diffneusim/data/reference/x016run/x016run_v3p50_s7_r1.npz +0 -0
  339. diffneusim/data/reference/x016run/x016run_v3p50_s7_r2.npz +0 -0
  340. diffneusim/data/reference/x016run/x016run_v3p50_s7_r3.npz +0 -0
  341. diffneusim/data/reference/x016run/x016run_v3p75_s0_l0.npz +0 -0
  342. diffneusim/data/reference/x016run/x016run_v3p75_s0_l1.npz +0 -0
  343. diffneusim/data/reference/x016run/x016run_v3p75_s0_l2.npz +0 -0
  344. diffneusim/data/reference/x016run/x016run_v3p75_s0_l3.npz +0 -0
  345. diffneusim/data/reference/x016run/x016run_v3p75_s0_r0.npz +0 -0
  346. diffneusim/data/reference/x016run/x016run_v3p75_s0_r1.npz +0 -0
  347. diffneusim/data/reference/x016run/x016run_v3p75_s0_r2.npz +0 -0
  348. diffneusim/data/reference/x016run/x016run_v3p75_s0_r3.npz +0 -0
  349. diffneusim/data/reference/x016run/x016run_v3p75_s1_l0.npz +0 -0
  350. diffneusim/data/reference/x016run/x016run_v3p75_s1_l1.npz +0 -0
  351. diffneusim/data/reference/x016run/x016run_v3p75_s1_l2.npz +0 -0
  352. diffneusim/data/reference/x016run/x016run_v3p75_s1_l3.npz +0 -0
  353. diffneusim/data/reference/x016run/x016run_v3p75_s1_r0.npz +0 -0
  354. diffneusim/data/reference/x016run/x016run_v3p75_s1_r1.npz +0 -0
  355. diffneusim/data/reference/x016run/x016run_v3p75_s1_r2.npz +0 -0
  356. diffneusim/data/reference/x016run/x016run_v3p75_s1_r3.npz +0 -0
  357. diffneusim/data/reference/x016run/x016run_v3p75_s2_l0.npz +0 -0
  358. diffneusim/data/reference/x016run/x016run_v3p75_s2_l1.npz +0 -0
  359. diffneusim/data/reference/x016run/x016run_v3p75_s2_l2.npz +0 -0
  360. diffneusim/data/reference/x016run/x016run_v3p75_s2_l3.npz +0 -0
  361. diffneusim/data/reference/x016run/x016run_v3p75_s2_r0.npz +0 -0
  362. diffneusim/data/reference/x016run/x016run_v3p75_s2_r1.npz +0 -0
  363. diffneusim/data/reference/x016run/x016run_v3p75_s2_r2.npz +0 -0
  364. diffneusim/data/reference/x016run/x016run_v3p75_s2_r3.npz +0 -0
  365. diffneusim/data/reference/x016run/x016run_v3p75_s3_l0.npz +0 -0
  366. diffneusim/data/reference/x016run/x016run_v3p75_s3_l1.npz +0 -0
  367. diffneusim/data/reference/x016run/x016run_v3p75_s3_l2.npz +0 -0
  368. diffneusim/data/reference/x016run/x016run_v3p75_s3_l3.npz +0 -0
  369. diffneusim/data/reference/x016run/x016run_v3p75_s3_r0.npz +0 -0
  370. diffneusim/data/reference/x016run/x016run_v3p75_s3_r1.npz +0 -0
  371. diffneusim/data/reference/x016run/x016run_v3p75_s3_r2.npz +0 -0
  372. diffneusim/data/reference/x016run/x016run_v3p75_s3_r3.npz +0 -0
  373. diffneusim/data/reference/x016run/x016run_v3p75_s5_l0.npz +0 -0
  374. diffneusim/data/reference/x016run/x016run_v3p75_s5_l1.npz +0 -0
  375. diffneusim/data/reference/x016run/x016run_v3p75_s5_l2.npz +0 -0
  376. diffneusim/data/reference/x016run/x016run_v3p75_s5_l3.npz +0 -0
  377. diffneusim/data/reference/x016run/x016run_v3p75_s5_r0.npz +0 -0
  378. diffneusim/data/reference/x016run/x016run_v3p75_s5_r1.npz +0 -0
  379. diffneusim/data/reference/x016run/x016run_v3p75_s5_r2.npz +0 -0
  380. diffneusim/data/reference/x016run/x016run_v3p75_s5_r3.npz +0 -0
  381. diffneusim/data/reference/x016run/x016run_v3p75_s6_l0.npz +0 -0
  382. diffneusim/data/reference/x016run/x016run_v3p75_s6_l1.npz +0 -0
  383. diffneusim/data/reference/x016run/x016run_v3p75_s6_l2.npz +0 -0
  384. diffneusim/data/reference/x016run/x016run_v3p75_s6_l3.npz +0 -0
  385. diffneusim/data/reference/x016run/x016run_v3p75_s6_r0.npz +0 -0
  386. diffneusim/data/reference/x016run/x016run_v3p75_s6_r1.npz +0 -0
  387. diffneusim/data/reference/x016run/x016run_v3p75_s6_r2.npz +0 -0
  388. diffneusim/data/reference/x016run/x016run_v3p75_s6_r3.npz +0 -0
  389. diffneusim/data/reference/x016run/x016run_v3p75_s7_l0.npz +0 -0
  390. diffneusim/data/reference/x016run/x016run_v3p75_s7_l1.npz +0 -0
  391. diffneusim/data/reference/x016run/x016run_v3p75_s7_l2.npz +0 -0
  392. diffneusim/data/reference/x016run/x016run_v3p75_s7_l3.npz +0 -0
  393. diffneusim/data/reference/x016run/x016run_v3p75_s7_r0.npz +0 -0
  394. diffneusim/data/reference/x016run/x016run_v3p75_s7_r1.npz +0 -0
  395. diffneusim/data/reference/x016run/x016run_v3p75_s7_r2.npz +0 -0
  396. diffneusim/data/reference/x016run/x016run_v3p75_s7_r3.npz +0 -0
  397. diffneusim/data/state_prior/lumbar_poly_fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  398. diffneusim/engine/__init__.py +0 -0
  399. diffneusim/engine/build_tag.py +52 -0
  400. diffneusim/engine/case_tables.py +46 -0
  401. diffneusim/engine/d16_body.py +80 -0
  402. diffneusim/engine/engine14.py +367 -0
  403. diffneusim/engine/gen_split.py +159 -0
  404. diffneusim/engine/hand_format.py +69 -0
  405. diffneusim/engine/live14.py +149 -0
  406. diffneusim/engine/phase_b_tree.py +137 -0
  407. diffneusim/engine/soft14.py +130 -0
  408. diffneusim/engine/soft_capi.py +373 -0
  409. diffneusim/engine/soft_engine.py +165 -0
  410. diffneusim/engine/step14.py +132 -0
  411. diffneusim/engine/tape_format.py +89 -0
  412. diffneusim/engine/x14cpu.py +163 -0
  413. diffneusim/env/__init__.py +0 -0
  414. diffneusim/env/absent.py +20 -0
  415. diffneusim/env/cpu14.py +105 -0
  416. diffneusim/env/e0loop14.py +224 -0
  417. diffneusim/env/env14.py +568 -0
  418. diffneusim/env/kin_contact14.py +193 -0
  419. diffneusim/env/mimic_sites_x14.json +366 -0
  420. diffneusim/env/old_count.py +78 -0
  421. diffneusim/env/rew14.py +114 -0
  422. diffneusim/env/rew14_hook.py +105 -0
  423. diffneusim/g1/__init__.py +1 -0
  424. diffneusim/g1/arm_a2.py +165 -0
  425. diffneusim/g1/arm_a3.py +576 -0
  426. diffneusim/g1/read_a3.py +79 -0
  427. diffneusim/g1/rg1_read.py +89 -0
  428. diffneusim/model/__init__.py +66 -0
  429. diffneusim/model/case.py +17 -0
  430. diffneusim/model/dnmodel.py +79 -0
  431. diffneusim/model/fuse_fixed.py +281 -0
  432. diffneusim/model/monitor.py +834 -0
  433. diffneusim/models/BODIES.toml +48 -0
  434. diffneusim/models/MANIFEST.toml +979 -0
  435. diffneusim/models/cases/G290/case.bin +0 -0
  436. diffneusim/models/cases/G290/case.json +1 -0
  437. diffneusim/models/cases/G356-SRC/case.bin +0 -0
  438. diffneusim/models/cases/G356-SRC/case.json +1 -0
  439. diffneusim/models/cases/G416/case.bin +0 -0
  440. diffneusim/models/cases/G416/case.json +1 -0
  441. diffneusim/models/cases/M290C-SRC/case.bin +0 -0
  442. diffneusim/models/cases/M290C-SRC/case.json +1 -0
  443. diffneusim/models/cases/M290R-SRC/case.bin +0 -0
  444. diffneusim/models/cases/M290R-SRC/case.json +1 -0
  445. diffneusim/models/cases/M356C-SRC/case.bin +0 -0
  446. diffneusim/models/cases/M356C-SRC/case.json +1 -0
  447. diffneusim/models/cases/M356R-SRC/case.bin +0 -0
  448. diffneusim/models/cases/M356R-SRC/case.json +1 -0
  449. diffneusim/models/cases/M416C-SRC/case.bin +0 -0
  450. diffneusim/models/cases/M416C-SRC/case.json +1 -0
  451. diffneusim/models/derived/d16_expanded_62f77a4bb16b1e67_mmfloor.xml +673 -0
  452. diffneusim/models/derived/d16_expanded_a1e8b196b2cd7b3c_mmfloor.xml +673 -0
  453. diffneusim/models/derived/d16_soft_law_019e20820f8633b9_mmfloor.json +7844 -0
  454. diffneusim/models/derived/d16_soft_law_62f77a4bb16b1e67_mmfloor.json +16855 -0
  455. diffneusim/models/derived/d16_soft_law_77dbb7213f26e821_mmfloor_rampsb3l_n6t12.json +7883 -0
  456. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rampsb3l_n6t12.json +7883 -0
  457. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsd05_n6t12.json +7868 -0
  458. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsdef_n6t12.json +7868 -0
  459. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsmjd_n6t12.json +7868 -0
  460. diffneusim/models/derived/d16_soft_law_a1e8b196b2cd7b3c_mmfloor_rampsb3l_n6t12.json +16894 -0
  461. diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor.json +12655 -0
  462. diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor_rampsb3l_n6t12.json +12700 -0
  463. diffneusim/models/derived/unitree_g1_soft_law.json +15580 -0
  464. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +28913 -0
  465. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  466. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +29202 -0
  467. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
  468. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.dnmodel +1 -0
  469. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  470. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  471. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +46970 -0
  472. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  473. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  474. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  475. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +38570 -0
  476. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  477. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +38923 -0
  478. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
  479. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  480. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  481. diffneusim/models/fullbody_meshes/1mc.stl +0 -0
  482. diffneusim/models/fullbody_meshes/2distph.stl +0 -0
  483. diffneusim/models/fullbody_meshes/2mc.stl +0 -0
  484. diffneusim/models/fullbody_meshes/2midph.stl +0 -0
  485. diffneusim/models/fullbody_meshes/2proxph.stl +0 -0
  486. diffneusim/models/fullbody_meshes/3distph.stl +0 -0
  487. diffneusim/models/fullbody_meshes/3mc.stl +0 -0
  488. diffneusim/models/fullbody_meshes/3midph.stl +0 -0
  489. diffneusim/models/fullbody_meshes/3proxph.stl +0 -0
  490. diffneusim/models/fullbody_meshes/4distph.stl +0 -0
  491. diffneusim/models/fullbody_meshes/4mc.stl +0 -0
  492. diffneusim/models/fullbody_meshes/4midph.stl +0 -0
  493. diffneusim/models/fullbody_meshes/4proxph.stl +0 -0
  494. diffneusim/models/fullbody_meshes/5distph.stl +0 -0
  495. diffneusim/models/fullbody_meshes/5mc.stl +0 -0
  496. diffneusim/models/fullbody_meshes/5midph.stl +0 -0
  497. diffneusim/models/fullbody_meshes/5proxph.stl +0 -0
  498. diffneusim/models/fullbody_meshes/NOTICE +2 -0
  499. diffneusim/models/fullbody_meshes/capitate.stl +0 -0
  500. diffneusim/models/fullbody_meshes/clavicle.stl +0 -0
  501. diffneusim/models/fullbody_meshes/hamate.stl +0 -0
  502. diffneusim/models/fullbody_meshes/hat_cervical.stl +0 -0
  503. diffneusim/models/fullbody_meshes/hat_jaw.stl +0 -0
  504. diffneusim/models/fullbody_meshes/hat_skull.stl +0 -0
  505. diffneusim/models/fullbody_meshes/humerus.stl +0 -0
  506. diffneusim/models/fullbody_meshes/l_bofoot.stl +0 -0
  507. diffneusim/models/fullbody_meshes/l_femur.stl +0 -0
  508. diffneusim/models/fullbody_meshes/l_fibula.stl +0 -0
  509. diffneusim/models/fullbody_meshes/l_foot.stl +0 -0
  510. diffneusim/models/fullbody_meshes/l_patella.stl +0 -0
  511. diffneusim/models/fullbody_meshes/l_pelvis.stl +0 -0
  512. diffneusim/models/fullbody_meshes/l_talus.stl +0 -0
  513. diffneusim/models/fullbody_meshes/l_tibia.stl +0 -0
  514. diffneusim/models/fullbody_meshes/lumbar1.stl +0 -0
  515. diffneusim/models/fullbody_meshes/lumbar2.stl +0 -0
  516. diffneusim/models/fullbody_meshes/lumbar3.stl +0 -0
  517. diffneusim/models/fullbody_meshes/lumbar4.stl +0 -0
  518. diffneusim/models/fullbody_meshes/lumbar5.stl +0 -0
  519. diffneusim/models/fullbody_meshes/lunate.stl +0 -0
  520. diffneusim/models/fullbody_meshes/pisiform.stl +0 -0
  521. diffneusim/models/fullbody_meshes/r_bofoot.stl +0 -0
  522. diffneusim/models/fullbody_meshes/r_femur.stl +0 -0
  523. diffneusim/models/fullbody_meshes/r_fibula.stl +0 -0
  524. diffneusim/models/fullbody_meshes/r_foot.stl +0 -0
  525. diffneusim/models/fullbody_meshes/r_patella.stl +0 -0
  526. diffneusim/models/fullbody_meshes/r_pelvis.stl +0 -0
  527. diffneusim/models/fullbody_meshes/r_talus.stl +0 -0
  528. diffneusim/models/fullbody_meshes/r_tibia.stl +0 -0
  529. diffneusim/models/fullbody_meshes/radius.stl +0 -0
  530. diffneusim/models/fullbody_meshes/sacrum.stl +0 -0
  531. diffneusim/models/fullbody_meshes/scaphoid.stl +0 -0
  532. diffneusim/models/fullbody_meshes/scapula.stl +0 -0
  533. diffneusim/models/fullbody_meshes/thoracic10_s.stl +0 -0
  534. diffneusim/models/fullbody_meshes/thoracic11_s.stl +0 -0
  535. diffneusim/models/fullbody_meshes/thoracic12_s.stl +0 -0
  536. diffneusim/models/fullbody_meshes/thoracic1_s.stl +0 -0
  537. diffneusim/models/fullbody_meshes/thoracic2_s.stl +0 -0
  538. diffneusim/models/fullbody_meshes/thoracic3_s.stl +0 -0
  539. diffneusim/models/fullbody_meshes/thoracic4_s.stl +0 -0
  540. diffneusim/models/fullbody_meshes/thoracic5_s.stl +0 -0
  541. diffneusim/models/fullbody_meshes/thoracic6_s.stl +0 -0
  542. diffneusim/models/fullbody_meshes/thoracic7_s.stl +0 -0
  543. diffneusim/models/fullbody_meshes/thoracic8_s.stl +0 -0
  544. diffneusim/models/fullbody_meshes/thoracic9_s.stl +0 -0
  545. diffneusim/models/fullbody_meshes/thorax.stl +0 -0
  546. diffneusim/models/fullbody_meshes/thumbdist.stl +0 -0
  547. diffneusim/models/fullbody_meshes/thumbprox.stl +0 -0
  548. diffneusim/models/fullbody_meshes/trapezium.stl +0 -0
  549. diffneusim/models/fullbody_meshes/trapezoid.stl +0 -0
  550. diffneusim/models/fullbody_meshes/triquetrum.stl +0 -0
  551. diffneusim/models/fullbody_meshes/ulna.stl +0 -0
  552. diffneusim/models/source/myo_fullbody/UPSTREAM.md +91 -0
  553. diffneusim/models/source/myoleg/UPSTREAM.md +52 -0
  554. diffneusim/models/source/unitree_g1/LICENSE.mjlab +202 -0
  555. diffneusim/models/source/unitree_g1/UPSTREAM.md +38 -0
  556. diffneusim/models/source/unitree_g1/assets/head_link.STL +0 -0
  557. diffneusim/models/source/unitree_g1/assets/left_ankle_pitch_link.STL +0 -0
  558. diffneusim/models/source/unitree_g1/assets/left_ankle_roll_link.STL +0 -0
  559. diffneusim/models/source/unitree_g1/assets/left_elbow_link.STL +0 -0
  560. diffneusim/models/source/unitree_g1/assets/left_hip_pitch_link.STL +0 -0
  561. diffneusim/models/source/unitree_g1/assets/left_hip_roll_link.STL +0 -0
  562. diffneusim/models/source/unitree_g1/assets/left_hip_yaw_link.STL +0 -0
  563. diffneusim/models/source/unitree_g1/assets/left_knee_link.STL +0 -0
  564. diffneusim/models/source/unitree_g1/assets/left_rubber_hand.STL +0 -0
  565. diffneusim/models/source/unitree_g1/assets/left_shoulder_pitch_link.STL +0 -0
  566. diffneusim/models/source/unitree_g1/assets/left_shoulder_roll_link.STL +0 -0
  567. diffneusim/models/source/unitree_g1/assets/left_shoulder_yaw_link.STL +0 -0
  568. diffneusim/models/source/unitree_g1/assets/left_wrist_pitch_link.STL +0 -0
  569. diffneusim/models/source/unitree_g1/assets/left_wrist_roll_link.STL +0 -0
  570. diffneusim/models/source/unitree_g1/assets/left_wrist_yaw_link.STL +0 -0
  571. diffneusim/models/source/unitree_g1/assets/logo_link.STL +0 -0
  572. diffneusim/models/source/unitree_g1/assets/pelvis.STL +0 -0
  573. diffneusim/models/source/unitree_g1/assets/pelvis_contour_link.STL +0 -0
  574. diffneusim/models/source/unitree_g1/assets/right_ankle_pitch_link.STL +0 -0
  575. diffneusim/models/source/unitree_g1/assets/right_ankle_roll_link.STL +0 -0
  576. diffneusim/models/source/unitree_g1/assets/right_elbow_link.STL +0 -0
  577. diffneusim/models/source/unitree_g1/assets/right_hip_pitch_link.STL +0 -0
  578. diffneusim/models/source/unitree_g1/assets/right_hip_roll_link.STL +0 -0
  579. diffneusim/models/source/unitree_g1/assets/right_hip_yaw_link.STL +0 -0
  580. diffneusim/models/source/unitree_g1/assets/right_knee_link.STL +0 -0
  581. diffneusim/models/source/unitree_g1/assets/right_rubber_hand.STL +0 -0
  582. diffneusim/models/source/unitree_g1/assets/right_shoulder_pitch_link.STL +0 -0
  583. diffneusim/models/source/unitree_g1/assets/right_shoulder_roll_link.STL +0 -0
  584. diffneusim/models/source/unitree_g1/assets/right_shoulder_yaw_link.STL +0 -0
  585. diffneusim/models/source/unitree_g1/assets/right_wrist_pitch_link.STL +0 -0
  586. diffneusim/models/source/unitree_g1/assets/right_wrist_roll_link.STL +0 -0
  587. diffneusim/models/source/unitree_g1/assets/right_wrist_yaw_link.STL +0 -0
  588. diffneusim/models/source/unitree_g1/assets/torso_link_rev_1_0.STL +0 -0
  589. diffneusim/models/source/unitree_g1/assets/waist_roll_link_rev_1_0.STL +0 -0
  590. diffneusim/models/source/unitree_g1/assets/waist_yaw_link_rev_1_0.STL +0 -0
  591. diffneusim/models/source/unitree_g1/dump_mjlab_reference.py +30 -0
  592. diffneusim/models/source/unitree_g1/g1.xml +308 -0
  593. diffneusim/models/source/unitree_g1/g1_constants.py +298 -0
  594. diffneusim/models/source/unitree_g1/mjlab_compiled_reference.json +857 -0
  595. diffneusim/models/unitree_g1.dnmodel +4393 -0
  596. diffneusim/models/unitree_g1_selfcol.dnmodel +20824 -0
  597. diffneusim/rl/__init__.py +2 -0
  598. diffneusim/rl/dynsyn_layer.py +146 -0
  599. diffneusim/rl/footstep_plan.py +337 -0
  600. diffneusim/rl/g1_bm_env.py +572 -0
  601. diffneusim/rl/g1_bm_eval.py +168 -0
  602. diffneusim/rl/g1_bm_fused.py +275 -0
  603. diffneusim/rl/g1_bm_ppo.py +622 -0
  604. diffneusim/rl/g1_bm_sapo.py +551 -0
  605. diffneusim/rl/g1_ppo.py +395 -0
  606. diffneusim/rl/g1_sapo_soft.py +240 -0
  607. diffneusim/rl/g1_soft_env.py +452 -0
  608. diffneusim/rl/g1_soft_grad.py +145 -0
  609. diffneusim/rl/geyer_curves_torch.py +108 -0
  610. diffneusim/rl/gpu_fullbody_vec_env.py +1241 -0
  611. diffneusim/rl/imitation.py +2027 -0
  612. diffneusim/rl/imitation_reward_v2.py +248 -0
  613. diffneusim/rl/imitation_reward_v3.py +349 -0
  614. diffneusim/rl/latent_task.py +175 -0
  615. diffneusim/rl/llc_reward.py +316 -0
  616. diffneusim/rl/millard_curves_torch.py +154 -0
  617. diffneusim/rl/mirror_symmetry.py +212 -0
  618. diffneusim/rl/model_path.py +35 -0
  619. diffneusim/rl/mvae_recon.py +123 -0
  620. diffneusim/rl/nets_shac.py +599 -0
  621. diffneusim/rl/reset_pool.py +154 -0
  622. diffneusim/rl/sapo_capture.py +873 -0
  623. diffneusim/rl/sapo_vec.py +1051 -0
  624. diffneusim/rl/shac_vec.py +346 -0
  625. diffneusim/rl/state_prior.py +151 -0
  626. diffneusim/rl/step_library.py +105 -0
  627. diffneusim/rl/task_walk_env.py +1793 -0
  628. diffneusim/rl/task_walk_reward.py +3300 -0
  629. diffneusim/run.py +23 -0
  630. diffneusim/run_env.py +46 -0
  631. diffneusim/tasks/__init__.py +147 -0
  632. diffneusim/tasks/legacy_names.py +63 -0
  633. diffneusim/tasks/paths.py +79 -0
  634. diffneusim/tasks/settings.py +202 -0
  635. diffneusim/third_party/instantmimic_947430ee/LICENSE +202 -0
  636. diffneusim/third_party/instantmimic_947430ee/NOTICE +19 -0
  637. diffneusim/third_party/instantmimic_947430ee/README.md +31 -0
  638. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/benchmark_protocol.py +106 -0
  639. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/metrics.py +214 -0
  640. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/reference.py +513 -0
  641. diffneusim/third_party/instantmimic_947430ee/instantmimic/motion/quaternion.py +193 -0
  642. diffneusim/train/__init__.py +0 -0
  643. diffneusim/train/eval_ckpt.py +239 -0
  644. diffneusim/train/eval_mimic.py +133 -0
  645. diffneusim/train/gait_report.py +203 -0
  646. diffneusim/train/gcot_chain.py +51 -0
  647. diffneusim/train/levers.py +135 -0
  648. diffneusim/train/masked_reset.py +314 -0
  649. diffneusim/train/rl_algorithm_suite.py +917 -0
  650. diffneusim/train/train14.py +240 -0
  651. diffneusim/train/train_tw14.py +674 -0
  652. diffneusim/viz/__init__.py +5 -0
  653. diffneusim/viz/__main__.py +41 -0
  654. diffneusim/viz/camera.py +115 -0
  655. diffneusim/viz/dnrec.py +118 -0
  656. diffneusim/viz/dnrec_io.py +686 -0
  657. diffneusim/viz/hud.py +565 -0
  658. diffneusim/viz/meshes.py +458 -0
  659. diffneusim/viz/play.py +237 -0
  660. diffneusim/viz/record.py +74 -0
  661. diffneusim/viz/render.py +1402 -0
  662. diffneusim/viz/renderer.py +268 -0
  663. diffneusim/viz/rl_env_render.py +635 -0
  664. diffneusim/viz/snapshot.py +54 -0
  665. diffneusim/viz/strobe.py +124 -0
  666. diffneusim/viz/to_mp4.py +58 -0
  667. diffneusim/viz/ui.py +481 -0
  668. diffneusim/viz/viewer.py +2086 -0
  669. diffneusim-1.0.0.dist-info/METADATA +226 -0
  670. diffneusim-1.0.0.dist-info/RECORD +682 -0
  671. diffneusim-1.0.0.dist-info/WHEEL +5 -0
  672. diffneusim-1.0.0.dist-info/licenses/LICENSE +201 -0
  673. diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-ARMS-hand-wrist-4.3.txt +20 -0
  674. diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-MoBL-ARMS.txt +25 -0
  675. diffneusim-1.0.0.dist-info/licenses/LICENSES/CC-BY-3.0-OpenSim-geometry.txt +25 -0
  676. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Christophy2012-lumbarspine.txt +10 -0
  677. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lai2017-model-high-flex.txt +10 -0
  678. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lee2015-hand_muscle.txt +11 -0
  679. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Rajagopal2016-full_body.txt +11 -0
  680. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Uhlrich2022-fbmodpassivecal.txt +10 -0
  681. diffneusim-1.0.0.dist-info/licenses/NOTICE +274 -0
  682. diffneusim-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,182 @@
1
+ #pragma once
2
+ // D16 14x C2 (2026-11-03; the request for the 14x adjoint): the 14x soft law's derivative, forward mode, in the
3
+ // design of core/soft/jvp.h (the G1's C2) on core/soft/x14/law14.h. One substep in Dual<double, K> (K input directions), the
4
+ // decisions held from the primal (double) substep: the contact list (pair, slot), the rows, the Newton solve's QUADRATIC set
5
+ // at the returned iterate a*.
6
+ // Smooth parts are evaluated in Dual: fk, M, qfrc_bias, qfrc_passive (damping, toe springs, the hips' ball_rom), the
7
+ // contacts (collide14: plane-ellipsoid and collide.h's colliders) and their rows (J, D, aref through the impedance), the
8
+ // limits in law14's form (J = +-coef e_master).
9
+ // The solve is differentiated through its optimality conditions at a* (the implicit function theorem):
10
+ // F(a, theta) = M a - qfrc_smooth + sum_QUADRATIC J' D (J a - aref) = 0, da* = -H^-1 dF/dtheta, H = M + sum D J'J,
11
+ // with H's factor from the primal solve (no rows: a* = M^-1 qfrc_smooth as a linear solve).
12
+ // Then law14's Euler (MuscleMimic's integrator): qvel' = qvel + h a*, positions from qvel' (the root and the balls by
13
+ // mju_quatIntegrate in their local frames). The warm start receives no derivative.
14
+ // The values of the outputs are the primal substep's (law14 substep), bitwise: the Dual carries only new tangents.
15
+ //
16
+ // Tangent coordinates (nv = 37 for the 14x), MuJoCo's: the free root's world translation then its body-frame rotation, each
17
+ // ball's body-frame rotation (quat <- quat (x) exp(delta / 2), mj_integratePos), each independent hinge or coupling master.
18
+ // qvel and tau_ext are in qvel's coordinates.
19
+ #include <cassert>
20
+ #include <cmath>
21
+ #include <vector>
22
+
23
+ #include "../../diff/dual.h"
24
+ #include "../jvp.h" // DualK, dual_solve, quat_integrate_t (the G1's C2 helpers)
25
+ #include "law14.h"
26
+
27
+ namespace js::diff {
28
+ // ADL entry points for law14.h's templates, which call these unqualified after `using std::...` (dual.h names them js_*)
29
+ template <class S, int N> Dual<S, N> sin(Dual<S, N> a) { return js_sin(a); }
30
+ template <class S, int N> Dual<S, N> cos(Dual<S, N> a) { return js_cos(a); }
31
+ template <class S, int N> Dual<S, N> exp(Dual<S, N> a) { return js_exp(a); }
32
+ template <class S, int N> Dual<S, N> sqrt(Dual<S, N> a) { return js_sqrt(a); }
33
+ template <class S, int N> Dual<S, N> atan2(Dual<S, N> y, Dual<S, N> x) { return js_atan2(y, x); }
34
+ // limexp compares two Duals with <= (dual.h has Dual <= S only); the branch is the value's, as every Dual comparison
35
+ template <class S, int N> bool operator<=(Dual<S, N> a, Dual<S, N> b) { return a.v <= b.v; }
36
+ } // namespace js::diff
37
+
38
+ namespace js::soft::x14 {
39
+
40
+ template <int K> using D14 = js::diff::Dual<double, K>;
41
+
42
+ struct JvpFlags14 { int contact_set_changed = 0, nquadratic = 0, ncon = 0, nefc = 0, niter = 0, nlim = 0; };
43
+
44
+ // q's Dual from the tangent t [nv] of direction k (in place on qd, whose values are q)
45
+ template <int K> void seed_q14(const Model14& m, const double* q, const double* t, int k, std::vector<D14<K>>& qd) {
46
+ for (size_t b = 1; b < m.bodies.size(); ++b) {
47
+ const Body14& bd = m.bodies[b];
48
+ if (bd.jtype == kFree || bd.jtype == kBall) {
49
+ const int qo = bd.jtype == kFree ? bd.qadr + 3 : bd.qadr, vo = bd.jtype == kFree ? bd.dadr + 3 : bd.dadr;
50
+ if (bd.jtype == kFree)
51
+ for (int j = 0; j < 3; ++j) qd[bd.qadr + j].d[k] = t[bd.dadr + j];
52
+ // d quat = 0.5 quat (x) (0, delta): the derivative of quat (x) exp(eps delta / 2) at eps = 0
53
+ const double qq[4] = {q[qo], q[qo + 1], q[qo + 2], q[qo + 3]}, dl[4] = {0, t[vo], t[vo + 1], t[vo + 2]};
54
+ double r[4];
55
+ quat_mul(qq, dl, r);
56
+ for (int j = 0; j < 4; ++j) qd[qo + j].d[k] = 0.5 * r[j];
57
+ } else if (bd.jtype == kHinge && bd.master_dadr < 0) {
58
+ qd[bd.qadr].d[k] = t[bd.dadr];
59
+ }
60
+ }
61
+ }
62
+
63
+ // the tangent [nv] of direction k from q's Dual (a unit quaternion's: delta = 2 Im(conj(quat) (x) d quat))
64
+ template <int K> void tangent_q14(const Model14& m, const std::vector<D14<K>>& qd, int k, double* t) {
65
+ for (size_t b = 1; b < m.bodies.size(); ++b) {
66
+ const Body14& bd = m.bodies[b];
67
+ if (bd.jtype == kFree || bd.jtype == kBall) {
68
+ const int qo = bd.jtype == kFree ? bd.qadr + 3 : bd.qadr, vo = bd.jtype == kFree ? bd.dadr + 3 : bd.dadr;
69
+ if (bd.jtype == kFree)
70
+ for (int j = 0; j < 3; ++j) t[bd.dadr + j] = qd[bd.qadr + j].d[k];
71
+ const double cq[4] = {qd[qo].v, -qd[qo + 1].v, -qd[qo + 2].v, -qd[qo + 3].v};
72
+ const double dq[4] = {qd[qo].d[k], qd[qo + 1].d[k], qd[qo + 2].d[k], qd[qo + 3].d[k]};
73
+ double r[4];
74
+ quat_mul(cq, dq, r);
75
+ for (int j = 0; j < 3; ++j) t[vo + j] = 2.0 * r[1 + j];
76
+ } else if (bd.jtype == kHinge && bd.master_dadr < 0) {
77
+ t[bd.dadr] = qd[bd.qadr].d[k];
78
+ }
79
+ }
80
+ }
81
+
82
+ // One substep: qpos, qvel (Dual, in / out), warm (double, in / out: a*), tau_ext (Dual), astar (out: a* with its tangent).
83
+ // foot_friction < 0: the exported values (law14's convention).
84
+ template <int K>
85
+ JvpFlags14 substep_jvp14(const Model14& m, std::vector<D14<K>>& qpos, std::vector<D14<K>>& qvel, double* warm,
86
+ const std::vector<D14<K>>& tau_ext, double foot_friction, std::vector<D14<K>>& astar) {
87
+ using D = D14<K>;
88
+ const int nv = m.nv, nq = m.nq;
89
+ JvpFlags14 fl;
90
+ // --- the primal substep (double): its decisions, and its outputs as the values
91
+ std::vector<double> q0(nq), v0(nv), t0(nv), q1(nq), v1(nv), w1(warm, warm + nv);
92
+ for (int i = 0; i < nq; ++i) q0[i] = qpos[i].v;
93
+ for (int i = 0; i < nv; ++i) { v0[i] = qvel[i].v; t0[i] = tau_ext[i].v; }
94
+ q1 = q0; v1 = v0;
95
+ Smooth14 sm;
96
+ Rows<double> rows0;
97
+ const Stats14 st = substep(m, q1.data(), v1.data(), w1.data(), t0.data(), foot_friction, &sm, &rows0);
98
+ std::vector<SoftContact<double>> con0;
99
+ collide_all14(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()), sm.X.data(),
100
+ foot_friction, con0);
101
+ // the solve again from the same warm start (substep() keeps no Result): the same inputs, so the same iterate, factor, zones
102
+ newton::Problem pr;
103
+ pr.nv = nv; pr.nefc = rows0.n; pr.M = sm.M.data(); pr.qfrc_smooth = sm.qfrc_smooth.data(); pr.qacc_smooth = sm.qacc_smooth.data();
104
+ pr.J = rows0.J.data(); pr.aref = rows0.aref.data(); pr.D = rows0.D.data();
105
+ pr.iterations = m.iterations; pr.ls_iterations = m.ls_iterations; pr.tolerance = m.tolerance; pr.ls_tolerance = m.ls_tolerance;
106
+ std::vector<double> wcopy(warm, warm + nv);
107
+ const newton::Result res = newton::solve(pr, wcopy.data());
108
+ for (int i = 0; i < nv; ++i) assert(res.qacc[i] == w1[i] && "substep_jvp14: the re-solve reproduces the substep's a*");
109
+ fl.ncon = st.ncon; fl.nefc = st.nefc; fl.niter = st.niter; fl.nlim = st.nlim;
110
+ // --- Dual: kinematics, M, bias, passive, contacts, rows
111
+ std::vector<BodyState<D>> X;
112
+ fk(m, qpos.data(), X);
113
+ std::vector<D> M, bD, pD;
114
+ mass(m, X, M);
115
+ bias(m, X, qvel.data(), bD);
116
+ passive(m, qpos.data(), qvel.data(), pD);
117
+ std::vector<D> fs(nv, D(0.0));
118
+ for (int i = 0; i < nv; ++i) fs[i] = pD[i] + tau_ext[i] - bD[i];
119
+ std::vector<SoftContact<D>> con;
120
+ collide_all14(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()), X.data(),
121
+ foot_friction, con);
122
+ if (con.size() != con0.size()) fl.contact_set_changed = 1;
123
+ else
124
+ for (size_t c = 0; c < con.size(); ++c)
125
+ if (con[c].pair != con0[c].pair || con[c].slot != con0[c].slot) fl.contact_set_changed = 1;
126
+ assert(!fl.contact_set_changed && "substep_jvp14: the Dual collision found another contact set (value branches differ)");
127
+ Rows<D> rows;
128
+ make_rows(m, X, con, qpos.data(), qvel.data(), rows);
129
+ assert(rows.n == rows0.n && "substep_jvp14: the Dual rows differ in number");
130
+ for (int r = 0; r < rows.n; ++r) assert(rows.type[r] == rows0.type[r] && rows.id[r] == rows0.id[r]);
131
+ // --- IFT: F(a*, theta) and da* = -H^-1 dF
132
+ std::vector<D> F(nv, D(0.0));
133
+ for (int i = 0; i < nv; ++i) {
134
+ D s = D(0.0);
135
+ for (int j = 0; j < nv; ++j) s = s + M[static_cast<size_t>(i) * nv + j] * D(res.qacc[j]);
136
+ F[i] = s - fs[i];
137
+ }
138
+ for (int r = 0; r < rows.n; ++r) {
139
+ if (res.state[r] != newton::kQuadratic) continue;
140
+ ++fl.nquadratic;
141
+ const D* Jr = rows.J.data() + static_cast<size_t>(r) * nv;
142
+ D ja = D(0.0);
143
+ for (int j = 0; j < nv; ++j) ja = ja + Jr[j] * D(res.qacc[j]);
144
+ const D g = rows.D[r] * (ja - rows.aref[r]);
145
+ for (int i = 0; i < nv; ++i) F[i] = F[i] + Jr[i] * g;
146
+ }
147
+ astar.assign(nv, D(0.0));
148
+ for (int i = 0; i < nv; ++i) astar[i].v = res.qacc[i];
149
+ if (rows.n > 0) {
150
+ std::vector<double> rhs(nv), da(nv);
151
+ for (int k = 0; k < K; ++k) {
152
+ for (int i = 0; i < nv; ++i) rhs[i] = -F[i].d[k];
153
+ newton::chol_solve(res.L.data(), da.data(), rhs.data(), nv);
154
+ for (int i = 0; i < nv; ++i) astar[i].d[k] = da[i];
155
+ }
156
+ } else { // no rows: a* = qacc_smooth = M^-1 qfrc_smooth, a linear solve
157
+ std::vector<D> x;
158
+ dual_solve<K>(M, fs, x, nv);
159
+ for (int i = 0; i < nv; ++i) for (int k = 0; k < K; ++k) astar[i].d[k] = x[i].d[k];
160
+ }
161
+ // --- law14's Euler in Dual
162
+ const double h = m.timestep;
163
+ for (int i = 0; i < nv; ++i) qvel[i] = qvel[i] + D(h) * astar[i];
164
+ for (size_t b = 1; b < m.bodies.size(); ++b) {
165
+ const Body14& bd = m.bodies[b];
166
+ if (bd.jtype == kFree) {
167
+ for (int k = 0; k < 3; ++k) qpos[bd.qadr + k] = qpos[bd.qadr + k] + D(h) * qvel[bd.dadr + k];
168
+ quat_integrate_t(qpos.data() + bd.qadr + 3, qvel.data() + bd.dadr + 3, h);
169
+ } else if (bd.jtype == kBall) {
170
+ quat_integrate_t(qpos.data() + bd.qadr, qvel.data() + bd.dadr, h);
171
+ } else if (bd.master_dadr < 0) {
172
+ qpos[bd.qadr] = qpos[bd.qadr] + D(h) * qvel[bd.dadr];
173
+ }
174
+ }
175
+ // the values: the primal substep's, bitwise
176
+ for (int i = 0; i < nq; ++i) qpos[i].v = q1[i];
177
+ for (int i = 0; i < nv; ++i) qvel[i].v = v1[i];
178
+ for (int i = 0; i < nv; ++i) warm[i] = w1[i];
179
+ return fl;
180
+ }
181
+
182
+ } // namespace js::soft::x14
@@ -0,0 +1,453 @@
1
+ #pragma once
2
+ // Portions of this file are translated from MuJoCo 3.16.0 (https://github.com/google-deepmind/mujoco), Copyright 2021
3
+ // DeepMind Technologies Limited, licensed under the Apache License, Version 2.0. Changed by this project: transcribed to
4
+ // templated C++, generalized from the G1's law (core/soft/kin.h, rows.h, step.h) to the 14x tree. See core/soft/NOTICE.md.
5
+ // D16 14x (2026-11-02; tools/d16_14x/X14_PREREG.md, CONTACT_PARAMS.md): the 14x soft law's CPU f64 reference.
6
+ // The tree: the dnmodel fused (66 bodies), a free root, 2 balls, independent hinges and COUPLED hinges whose angle is
7
+ // coef * q[master] (linear: the coupling Jacobian is constant). A dof's motion is its (body, coef) list: the dof's own joint
8
+ // and every joint it drives. MuJoCo's conventions: qpos [root pos, root quat wxyz, coordinates]; qvel [root v (world, of the
9
+ // root origin), root w (body), ...]; a ball's qvel is its child frame's angular velocity.
10
+ // fk mj_kinematics on the tree (every joint at its body origin)
11
+ // jac the point Jacobian (3 x nv) and the rotational one of a body, from the dof lists
12
+ // mass M = sum_b Jp(com)' m Jp + Jr' I_w Jr + diag(armature) (the world-frame form of kin.h)
13
+ // bias qfrc_bias = C qvel + g: Newton-Euler at qacc = 0 (gravity as the root's base acceleration)
14
+ // passive the old engine's passive terms the 14x keeps (decision 3): -D qvel, the toe springs, the hips' ball_rom
15
+ // rows MuJoCo's limits (every limited hinge, coupled ones on their master: J = +-coef e_m) then contacts
16
+ // substep the solve (core/soft/newton.h), then Euler with explicit damping (MuscleMimic's integrator, decision 4)
17
+ #include <cassert>
18
+ #include <cmath>
19
+ #include <vector>
20
+
21
+ #include "../step.h" // newton.h, rows.h (Rows, SoftGeom / SoftPair, geom_pose), kin.h helpers, quat_integrate
22
+ #include "collide14.h" // MuJoCo 3.16's plane-ellipsoid, dispatched beside collide.h's colliders
23
+
24
+ namespace js::soft::x14 {
25
+
26
+ constexpr int kWorld = -1, kFree = 0, kBall = 1, kHinge = 3;
27
+
28
+ struct Body14 {
29
+ int parent, jtype, qadr, dadr; // a coupled hinge: qadr = dadr = -1, master_* its master's
30
+ int master_qadr, master_dadr; // -1 unless coupled
31
+ double coef; // the coupling's linear coefficient (1 for an own joint)
32
+ double axis[3], pos[3], quat[4], ipos[3], iquat[4], inertia[3], mass, invweight0[2];
33
+ };
34
+ struct DofEnt { int body; double coef; };
35
+ struct Limit14 { int dof, qadr; double coef, range[2], solref[2], solimp[5], margin, diagA; };
36
+ struct Spring14 { int dof, qadr; double k, rest; };
37
+ struct BallRom14 { int qadr, dadr; double lo[3], hi[3], d_lim[3], exp_a, exp_w, beta; };
38
+
39
+ struct Model14 {
40
+ int nq = 0, nv = 0;
41
+ std::vector<Body14> bodies;
42
+ std::vector<std::vector<DofEnt>> dofs; // per dof: the joints it moves, with their coefficients
43
+ std::vector<double> armature, damping; // per dof
44
+ std::vector<SoftGeom> geoms;
45
+ std::vector<SoftPair> pairs;
46
+ std::vector<Limit14> limits;
47
+ std::vector<Spring14> springs;
48
+ std::vector<BallRom14> roms;
49
+ double gravity[3] = {0, 0, -9.81};
50
+ double timestep = 0.002, impratio = 1, tolerance = 1e-8, ls_tolerance = 0.01;
51
+ int iterations = 4, ls_iterations = 8, nsub = 5;
52
+ std::vector<std::vector<char>> anc; // anc[b][j]: body j is body b or an ancestor of it (built by finalize)
53
+ void finalize() {
54
+ const int nb = static_cast<int>(bodies.size());
55
+ anc.assign(nb, std::vector<char>(nb, 0));
56
+ for (int b = 0; b < nb; ++b)
57
+ for (int j = b; j >= 0; j = j ? bodies[j].parent : -1) { anc[b][j] = 1; if (j == 0) break; }
58
+ }
59
+ };
60
+
61
+ // a hinge's angle: its own coordinate, or coef * its master's
62
+ template <class S> inline S hinge_angle(const Body14& b, const S* qpos) {
63
+ return b.master_qadr >= 0 ? S(b.coef) * qpos[b.master_qadr] : qpos[b.qadr];
64
+ }
65
+
66
+ template <class S> void fk(const Model14& m, const S* qpos, std::vector<BodyState<S>>& X) {
67
+ const int nb = static_cast<int>(m.bodies.size());
68
+ X.assign(nb, BodyState<S>{});
69
+ for (int k = 0; k < 3; ++k) { X[0].xpos[k] = S(0); X[0].xipos[k] = S(0); }
70
+ X[0].xquat[0] = S(1); X[0].xquat[1] = X[0].xquat[2] = X[0].xquat[3] = S(0);
71
+ quat_to_mat(X[0].xquat, X[0].xmat);
72
+ for (int k = 0; k < 9; ++k) X[0].ximat[k] = X[0].xmat[k];
73
+ for (int b = 1; b < nb; ++b) {
74
+ const Body14& bd = m.bodies[b];
75
+ BodyState<S>& x = X[b];
76
+ if (bd.jtype == kFree) {
77
+ for (int k = 0; k < 3; ++k) x.xpos[k] = qpos[bd.qadr + k];
78
+ for (int k = 0; k < 4; ++k) x.xquat[k] = qpos[bd.qadr + 3 + k];
79
+ quat_normalize(x.xquat);
80
+ } else {
81
+ const BodyState<S>& p = X[bd.parent];
82
+ S t[3];
83
+ mat_vec(p.xmat, bd.pos, t);
84
+ for (int k = 0; k < 3; ++k) x.xpos[k] = p.xpos[k] + t[k];
85
+ S bq[4] = {S(bd.quat[0]), S(bd.quat[1]), S(bd.quat[2]), S(bd.quat[3])};
86
+ quat_mul(p.xquat, bq, x.xquat);
87
+ S ql[4], tmp[4];
88
+ if (bd.jtype == kHinge) {
89
+ using std::sin; using std::cos;
90
+ const S half = hinge_angle(bd, qpos) * S(0.5), sh = sin(half);
91
+ ql[0] = cos(half); ql[1] = S(bd.axis[0]) * sh; ql[2] = S(bd.axis[1]) * sh; ql[3] = S(bd.axis[2]) * sh;
92
+ } else {
93
+ assert(bd.jtype == kBall && "fk: free, ball or hinge");
94
+ for (int k = 0; k < 4; ++k) ql[k] = qpos[bd.qadr + k];
95
+ quat_normalize(ql);
96
+ }
97
+ quat_mul(x.xquat, ql, tmp);
98
+ for (int k = 0; k < 4; ++k) x.xquat[k] = tmp[k];
99
+ quat_normalize(x.xquat);
100
+ }
101
+ quat_to_mat(x.xquat, x.xmat);
102
+ S t[3];
103
+ mat_vec(x.xmat, bd.ipos, t);
104
+ for (int k = 0; k < 3; ++k) x.xipos[k] = x.xpos[k] + t[k];
105
+ S iq[4] = {S(bd.iquat[0]), S(bd.iquat[1]), S(bd.iquat[2]), S(bd.iquat[3])}, q2[4];
106
+ quat_mul(x.xquat, iq, q2);
107
+ quat_to_mat(q2, x.ximat);
108
+ }
109
+ }
110
+
111
+ // rows.h's collide_all with the 14x's dispatch (collide14: plane-ellipsoid beside collide.h's colliders); otherwise the same
112
+ // (pair order, then collider slot order; kept iff dist < margin; mjMINMU on the friction)
113
+ template <class S>
114
+ void collide_all14(const SoftGeom* geoms, int ng, const SoftPair* pairs, int np, const BodyState<S>* X, double foot_friction,
115
+ std::vector<SoftContact<S>>& out) {
116
+ std::vector<GeomPose<S>> gp(ng);
117
+ for (int g = 0; g < ng; ++g) gp[g] = geom_pose(X[geoms[g].body], geoms[g]);
118
+ out.clear();
119
+ for (int i = 0; i < np; ++i) {
120
+ const SoftPair& pr = pairs[i];
121
+ const SoftGeom &a = geoms[pr.g1], &b = geoms[pr.g2];
122
+ PreContact<S> pc[4];
123
+ const int n = collide14(pc, pr.margin + pr.gap, a.type, gp[pr.g1], a.size, b.type, gp[pr.g2], b.size);
124
+ for (int k = 0; k < n; ++k) {
125
+ if (!(pc[k].dist < pr.margin)) continue;
126
+ SoftContact<S> c;
127
+ c.pair = i; c.slot = pc[k].slot; c.condim = pr.condim; c.dist = pc[k].dist; c.pos = pc[k].pos;
128
+ make_frame(pc[k].normal, pc[k].tangent, c.frame);
129
+ const double f0 = (pr.foot >= 0 && foot_friction >= 0) ? foot_friction : pr.friction[0];
130
+ c.mu = smax(1e-5, f0);
131
+ for (int j = 0; j < 2; ++j) c.solref[j] = pr.solref[j];
132
+ for (int j = 0; j < 5; ++j) c.solimp[j] = pr.solimp[j];
133
+ c.includemargin = pr.margin;
134
+ out.push_back(c);
135
+ }
136
+ }
137
+ }
138
+
139
+ // one joint's world motion for dof entry e of dof d: angular w (3) and, when translational, the unit translation
140
+ template <class S> inline void dof_motion(const Model14& m, const std::vector<BodyState<S>>& X, int d, const DofEnt& e, S* w,
141
+ bool* trans) {
142
+ const Body14& bd = m.bodies[e.body];
143
+ const BodyState<S>& x = X[e.body];
144
+ *trans = false;
145
+ if (bd.jtype == kFree) {
146
+ const int k = d - bd.dadr;
147
+ if (k < 3) { *trans = true; for (int i = 0; i < 3; ++i) w[i] = S(i == k ? 1.0 : 0.0); return; } // world axis k
148
+ for (int i = 0; i < 3; ++i) w[i] = x.xmat[3 * i + (k - 3)]; // body axis k - 3
149
+ } else if (bd.jtype == kBall) {
150
+ const int k = d - bd.dadr;
151
+ for (int i = 0; i < 3; ++i) w[i] = x.xmat[3 * i + k];
152
+ } else {
153
+ S a[3];
154
+ mat_vec(x.xmat, bd.axis, a);
155
+ for (int i = 0; i < 3; ++i) w[i] = S(e.coef) * a[i];
156
+ }
157
+ }
158
+
159
+ // jp (3 x nv) of point p on body b, jr (3 x nv) of body b (null to skip)
160
+ template <class S> void jac(const Model14& m, const std::vector<BodyState<S>>& X, int b, const S* p, S* jp, S* jr) {
161
+ const int nv = m.nv;
162
+ for (int k = 0; k < 3 * nv; ++k) { jp[k] = S(0); if (jr) jr[k] = S(0); }
163
+ if (b <= 0) return;
164
+ for (int d = 0; d < nv; ++d)
165
+ for (const DofEnt& e : m.dofs[d]) {
166
+ if (!m.anc[b][e.body]) continue;
167
+ S w[3];
168
+ bool tr;
169
+ dof_motion(m, X, d, e, w, &tr);
170
+ if (tr) { for (int i = 0; i < 3; ++i) jp[i * nv + d] = jp[i * nv + d] + w[i]; continue; }
171
+ const S* o = X[e.body].xpos; // every joint sits at its body's origin
172
+ const S r[3] = {p[0] - o[0], p[1] - o[1], p[2] - o[2]};
173
+ S c[3];
174
+ cross3(w, r, c);
175
+ for (int i = 0; i < 3; ++i) {
176
+ jp[i * nv + d] = jp[i * nv + d] + c[i];
177
+ if (jr) jr[i * nv + d] = jr[i * nv + d] + w[i];
178
+ }
179
+ }
180
+ }
181
+
182
+ // the world inertia about the COM: ximat diag(inertia) ximat'
183
+ template <class S> inline void inertia_world(const Body14& bd, const BodyState<S>& x, S* I) {
184
+ for (int i = 0; i < 3; ++i)
185
+ for (int j = 0; j < 3; ++j) {
186
+ S s = S(0);
187
+ for (int k = 0; k < 3; ++k) s = s + x.ximat[3 * i + k] * S(bd.inertia[k]) * x.ximat[3 * j + k];
188
+ I[3 * i + j] = s;
189
+ }
190
+ }
191
+
192
+ template <class S> void mass(const Model14& m, const std::vector<BodyState<S>>& X, std::vector<S>& M) {
193
+ const int nb = static_cast<int>(m.bodies.size()), nv = m.nv;
194
+ M.assign(static_cast<size_t>(nv) * nv, S(0));
195
+ std::vector<S> jp(3 * nv), jr(3 * nv);
196
+ for (int b = 1; b < nb; ++b) {
197
+ const Body14& bd = m.bodies[b];
198
+ if (bd.mass == 0) continue;
199
+ jac(m, X, b, X[b].xipos, jp.data(), jr.data());
200
+ S I[9];
201
+ inertia_world(bd, X[b], I);
202
+ for (int i = 0; i < nv; ++i)
203
+ for (int j = 0; j < nv; ++j) {
204
+ S s = S(0);
205
+ for (int k = 0; k < 3; ++k) s = s + S(bd.mass) * jp[k * nv + i] * jp[k * nv + j];
206
+ for (int k = 0; k < 3; ++k)
207
+ for (int l = 0; l < 3; ++l) s = s + jr[k * nv + i] * I[3 * k + l] * jr[l * nv + j];
208
+ M[static_cast<size_t>(i) * nv + j] = M[static_cast<size_t>(i) * nv + j] + s;
209
+ }
210
+ }
211
+ for (int i = 0; i < nv; ++i) M[static_cast<size_t>(i) * nv + i] = M[static_cast<size_t>(i) * nv + i] + S(m.armature[i]);
212
+ }
213
+
214
+ // qfrc_bias: per body the angular velocity w, the origin's velocity, and at qacc = 0 the angular acceleration al and the origin's
215
+ // acceleration ao (the root's base acceleration -gravity), then f = m a_com, n = I al + w x I w, mapped by Jp(com)' f + Jr' n
216
+ template <class S> void bias(const Model14& m, const std::vector<BodyState<S>>& X, const S* qvel, std::vector<S>& out) {
217
+ const int nb = static_cast<int>(m.bodies.size()), nv = m.nv;
218
+ std::vector<S> w(3 * nb, S(0)), vo(3 * nb, S(0)), al(3 * nb, S(0)), ao(3 * nb, S(0));
219
+ for (int k = 0; k < 3; ++k) ao[k] = S(-m.gravity[k]);
220
+ for (int b = 1; b < nb; ++b) {
221
+ const Body14& bd = m.bodies[b];
222
+ const int p = bd.parent;
223
+ S s[3] = {S(0), S(0), S(0)}; // the joint's own angular velocity (world)
224
+ if (bd.jtype == kFree) {
225
+ S wl[3] = {qvel[bd.dadr + 3], qvel[bd.dadr + 4], qvel[bd.dadr + 5]};
226
+ mat_vec(X[b].xmat, wl, s);
227
+ } else if (bd.jtype == kBall) {
228
+ S wl[3] = {qvel[bd.dadr], qvel[bd.dadr + 1], qvel[bd.dadr + 2]};
229
+ mat_vec(X[b].xmat, wl, s);
230
+ } else {
231
+ S a[3];
232
+ mat_vec(X[b].xmat, bd.axis, a);
233
+ const S rate = bd.master_dadr >= 0 ? S(bd.coef) * qvel[bd.master_dadr] : qvel[bd.dadr];
234
+ for (int i = 0; i < 3; ++i) s[i] = a[i] * rate;
235
+ }
236
+ const S* wp = &w[3 * p];
237
+ S ws[3];
238
+ cross3(wp, s, ws);
239
+ for (int i = 0; i < 3; ++i) { w[3 * b + i] = wp[i] + s[i]; al[3 * b + i] = al[3 * p + i] + ws[i]; }
240
+ if (bd.jtype == kFree) {
241
+ for (int i = 0; i < 3; ++i) { vo[3 * b + i] = qvel[bd.dadr + i]; ao[3 * b + i] = ao[3 * p + i]; }
242
+ } else {
243
+ const S r[3] = {X[b].xpos[0] - X[p].xpos[0], X[b].xpos[1] - X[p].xpos[1], X[b].xpos[2] - X[p].xpos[2]};
244
+ S wr[3], wwr[3], alr[3];
245
+ cross3(wp, r, wr);
246
+ cross3(wp, wr, wwr);
247
+ cross3(&al[3 * p], r, alr);
248
+ for (int i = 0; i < 3; ++i) { vo[3 * b + i] = vo[3 * p + i] + wr[i]; ao[3 * b + i] = ao[3 * p + i] + alr[i] + wwr[i]; }
249
+ }
250
+ }
251
+ out.assign(nv, S(0));
252
+ std::vector<S> jp(3 * nv), jr(3 * nv);
253
+ for (int b = 1; b < nb; ++b) {
254
+ const Body14& bd = m.bodies[b];
255
+ if (bd.mass == 0) continue;
256
+ const S rc[3] = {X[b].xipos[0] - X[b].xpos[0], X[b].xipos[1] - X[b].xpos[1], X[b].xipos[2] - X[b].xpos[2]};
257
+ S wr[3], wwr[3], alr[3];
258
+ cross3(&w[3 * b], rc, wr);
259
+ cross3(&w[3 * b], wr, wwr);
260
+ cross3(&al[3 * b], rc, alr);
261
+ S f[3], I[9], Iw[3], Ia[3], wIw[3];
262
+ for (int i = 0; i < 3; ++i) f[i] = S(bd.mass) * (ao[3 * b + i] + alr[i] + wwr[i]);
263
+ inertia_world(bd, X[b], I);
264
+ mat_vec(I, &w[3 * b], Iw);
265
+ mat_vec(I, &al[3 * b], Ia);
266
+ cross3(&w[3 * b], Iw, wIw);
267
+ jac(m, X, b, X[b].xipos, jp.data(), jr.data());
268
+ for (int d = 0; d < nv; ++d) {
269
+ S s = S(0);
270
+ for (int i = 0; i < 3; ++i) s = s + jp[i * nv + d] * f[i] + jr[i * nv + d] * (Ia[i] + wIw[i]);
271
+ out[d] = out[d] + s;
272
+ }
273
+ }
274
+ }
275
+
276
+ // the old engine's ball_rom (core/dyn/ball_limit.h:101-132; passive.h:21-29, 81-89, 164-175): intrinsic Z-X'-Y'' angles of the
277
+ // ball's local rotation, an exponential spring past each bound, a damper gated by srelu', mapped back by E' (theta_dot = E w)
278
+ template <class S> inline S limexp(S x, double a, double w) {
279
+ const double xc = 12;
280
+ const S u = x / S(w);
281
+ using std::exp;
282
+ if (u <= S(xc)) return S(a) * exp(u);
283
+ return S(a) * S(std::exp(xc)) * (S(1) + (u - S(xc)));
284
+ }
285
+ template <class S> inline S srelu_d(S x, double b) { using std::sqrt; return S(0.5) * (S(1) + x / sqrt(x * x + S(b * b))); }
286
+
287
+ template <class S> void ball_rom_force(const BallRom14& r, const S* qpos, const S* qvel, S* tau) {
288
+ using std::atan2; using std::sqrt; using std::sin; using std::cos;
289
+ S q[4] = {qpos[r.qadr], qpos[r.qadr + 1], qpos[r.qadr + 2], qpos[r.qadr + 3]};
290
+ quat_normalize(q);
291
+ const S w = q[0], x = q[1], y = q[2], z = q[3];
292
+ const S R01 = S(2) * (x * y - w * z), R11 = S(1) - S(2) * (x * x + z * z), R20 = S(2) * (x * z - w * y);
293
+ const S R21 = S(2) * (y * z + w * x), R22 = S(1) - S(2) * (x * x + y * y);
294
+ const S th[3] = {atan2(-R01, R11), atan2(R21, sqrt(R01 * R01 + R11 * R11)), atan2(-R20, R22)}; // flexion, adduction, rotation
295
+ const S sa = sin(th[1]), ca = cos(th[1]), sr = sin(th[2]), cr = cos(th[2]);
296
+ const S E[9] = {-sr / ca, S(0), cr / ca, cr, S(0), sr, sa * sr / ca, S(1), -sa * cr / ca};
297
+ const S om[3] = {qvel[r.dadr], qvel[r.dadr + 1], qvel[r.dadr + 2]};
298
+ S sk[3];
299
+ for (int k = 0; k < 3; ++k) {
300
+ const S thd = E[3 * k] * om[0] + E[3 * k + 1] * om[1] + E[3 * k + 2] * om[2];
301
+ const S dlo = S(r.lo[k]) - th[k], dhi = th[k] - S(r.hi[k]);
302
+ const S spring = limexp(dlo, r.exp_a, r.exp_w) - limexp(dhi, r.exp_a, r.exp_w);
303
+ const S eng = srelu_d(dlo, r.beta) + srelu_d(dhi, r.beta);
304
+ sk[k] = spring - S(r.d_lim[k]) * thd * eng;
305
+ }
306
+ for (int i = 0; i < 3; ++i) tau[r.dadr + i] = tau[r.dadr + i] + E[i] * sk[0] + E[3 + i] * sk[1] + E[6 + i] * sk[2];
307
+ }
308
+
309
+ // qfrc_passive: -D qvel (explicit), the toe springs -k (q - rest), the hips' ball_rom
310
+ template <class S> void passive(const Model14& m, const S* qpos, const S* qvel, std::vector<S>& out) {
311
+ out.assign(m.nv, S(0));
312
+ for (int i = 0; i < m.nv; ++i) out[i] = -S(m.damping[i]) * qvel[i];
313
+ for (const Spring14& s : m.springs) out[s.dof] = out[s.dof] - S(s.k) * (qpos[s.qadr] - S(s.rest));
314
+ for (const BallRom14& r : m.roms) ball_rom_force(r, qpos, qvel, out.data());
315
+ }
316
+
317
+ // the rows (rows.h's make_rows with the 14x's limits and Jacobians; the same impedance, R, D and aref passes)
318
+ template <class S>
319
+ void make_rows(const Model14& m, const std::vector<BodyState<S>>& X, const std::vector<SoftContact<S>>& con, const S* qpos,
320
+ const S* qvel, Rows<S>& rows) {
321
+ const int nv = m.nv;
322
+ rows.clear(nv);
323
+ for (int j = 0; j < static_cast<int>(m.limits.size()); ++j) { // limits in joint order, the lower side then the upper
324
+ const Limit14& L = m.limits[j];
325
+ for (int side = -1; side <= 1; side += 2) {
326
+ const S q = S(L.coef) * qpos[L.qadr];
327
+ const S dist = side < 0 ? q - S(L.range[0]) : S(L.range[1]) - q;
328
+ if (!(dist < L.margin)) continue;
329
+ S* J = rows.add(kRowLimit, j, dist, L.margin, L.diagA);
330
+ J[L.dof] = S(side < 0 ? L.coef : -L.coef);
331
+ const SolParam sp = sol_param(L.solref, L.solimp, m.timestep);
332
+ const KB kb = stiffness_damping(sp, false);
333
+ rows.K[rows.n - 1] = kb.K; rows.B[rows.n - 1] = kb.B;
334
+ }
335
+ }
336
+ std::vector<S> jp1(3 * nv), jp2(3 * nv), jc(3 * nv);
337
+ for (size_t c = 0; c < con.size(); ++c) {
338
+ const SoftContact<S>& ct = con[c];
339
+ const SoftPair& pr = m.pairs[ct.pair];
340
+ const int b1 = m.geoms[pr.g1].body, b2 = m.geoms[pr.g2].body;
341
+ const S p[3] = {ct.pos.x, ct.pos.y, ct.pos.z};
342
+ jac(m, X, b2, p, jp2.data(), static_cast<S*>(nullptr));
343
+ jac(m, X, b1, p, jp1.data(), static_cast<S*>(nullptr));
344
+ for (int d = 0; d < 3; ++d)
345
+ for (int i = 0; i < nv; ++i) {
346
+ const S dx = jp2[i] - jp1[i], dy = jp2[nv + i] - jp1[nv + i], dz = jp2[2 * nv + i] - jp1[2 * nv + i];
347
+ jc[d * nv + i] = ct.frame[d].x * dx + ct.frame[d].y * dy + ct.frame[d].z * dz;
348
+ }
349
+ const double tran = m.bodies[b1].invweight0[0] + m.bodies[b2].invweight0[0];
350
+ const SolParam sp = sol_param(ct.solref, ct.solimp, m.timestep);
351
+ const KB kb = stiffness_damping(sp, false);
352
+ if (ct.condim == 1) {
353
+ S* J = rows.add(kRowFrictionless, static_cast<int>(c), ct.dist, ct.includemargin, tran);
354
+ for (int i = 0; i < nv; ++i) J[i] = jc[i];
355
+ rows.K[rows.n - 1] = kb.K; rows.B[rows.n - 1] = kb.B;
356
+ } else {
357
+ assert(ct.condim == 3 && "the 14x law: condim 1 or 3");
358
+ for (int k = 1; k < 3; ++k)
359
+ for (int s = 0; s < 2; ++s) {
360
+ S* J = rows.add(kRowPyramidal, static_cast<int>(c), ct.dist, ct.includemargin, tran + ct.mu * ct.mu * tran);
361
+ const S sg = S(s == 0 ? ct.mu : -ct.mu);
362
+ for (int i = 0; i < nv; ++i) J[i] = jc[i] + sg * jc[k * nv + i];
363
+ rows.K[rows.n - 1] = kb.K; rows.B[rows.n - 1] = kb.B;
364
+ }
365
+ }
366
+ }
367
+ for (int r = 0; r < rows.n; ++r) {
368
+ const bool lim = rows.type[r] == kRowLimit;
369
+ const SolParam sp = lim ? sol_param(m.limits[rows.id[r]].solref, m.limits[rows.id[r]].solimp, m.timestep)
370
+ : sol_param(con[rows.id[r]].solref, con[rows.id[r]].solimp, m.timestep);
371
+ rows.imp[r] = impedance(sp.imp, rows.pos[r], rows.margin[r]);
372
+ rows.R[r] = regularizer(rows.imp[r], rows.diagA[r]);
373
+ }
374
+ for (int r = 0; r < rows.n;) {
375
+ if (rows.type[r] == kRowPyramidal) {
376
+ const S Rpy = pyramid_regularizer(rows.R[r], con[rows.id[r]].mu, m.impratio);
377
+ for (int j = 0; j < 4; ++j) rows.R[r + j] = Rpy;
378
+ r += 4;
379
+ } else {
380
+ ++r;
381
+ }
382
+ }
383
+ for (int r = 0; r < rows.n; ++r) {
384
+ rows.D[r] = S(1) / rows.R[r];
385
+ S vel = S(0);
386
+ const S* J = rows.J.data() + static_cast<size_t>(r) * nv;
387
+ for (int i = 0; i < nv; ++i) vel = vel + J[i] * qvel[i];
388
+ rows.aref[r] = reference_accel(KB{rows.K[r], rows.B[r]}, rows.imp[r], vel, rows.pos[r], rows.margin[r]);
389
+ }
390
+ }
391
+
392
+ // the smooth half of a substep: frames, M, qfrc_bias, qfrc_passive, qfrc_smooth = passive + tau_ext - bias, qacc_smooth
393
+ struct Smooth14 {
394
+ std::vector<BodyState<double>> X;
395
+ std::vector<double> M, bias, passive, qfrc_smooth, qacc_smooth;
396
+ };
397
+ inline void smooth(const Model14& m, const double* qpos, const double* qvel, const double* tau_ext, Smooth14& o) {
398
+ fk(m, qpos, o.X);
399
+ mass(m, o.X, o.M);
400
+ bias(m, o.X, qvel, o.bias);
401
+ passive(m, qpos, qvel, o.passive);
402
+ const int nv = m.nv;
403
+ o.qfrc_smooth.assign(nv, 0.0);
404
+ for (int i = 0; i < nv; ++i) o.qfrc_smooth[i] = o.passive[i] + (tau_ext ? tau_ext[i] : 0.0) - o.bias[i];
405
+ std::vector<double> L(o.M);
406
+ o.qacc_smooth.assign(nv, 0.0);
407
+ newton::chol_factor(L.data(), nv, kMinVal);
408
+ newton::chol_solve(L.data(), o.qacc_smooth.data(), o.qfrc_smooth.data(), nv);
409
+ }
410
+
411
+ struct Stats14 { int ncon = 0, nefc = 0, nlim = 0, niter = 0; bool warm_used = false, ran_out = false; };
412
+
413
+ // one substep in place on (qpos, qvel, warm) with the external generalized force tau_ext [nv] (the muscle stage's; null: 0).
414
+ // foot_friction < 0: the exported values. Euler with explicit damping (mjDSBL_EULERDAMP): qvel += h qacc; positions from the
415
+ // new qvel (the root and the balls by mju_quatIntegrate in their local frames); warm = qacc.
416
+ inline Stats14 substep(const Model14& m, double* qpos, double* qvel, double* warm, const double* tau_ext, double foot_friction,
417
+ Smooth14* keep = nullptr, Rows<double>* keep_rows = nullptr) {
418
+ Smooth14 sm;
419
+ smooth(m, qpos, qvel, tau_ext, sm);
420
+ std::vector<SoftContact<double>> con;
421
+ collide_all14(m.geoms.data(), static_cast<int>(m.geoms.size()), m.pairs.data(), static_cast<int>(m.pairs.size()), sm.X.data(),
422
+ foot_friction, con);
423
+ Rows<double> rows;
424
+ make_rows(m, sm.X, con, qpos, qvel, rows);
425
+ newton::Problem pr;
426
+ pr.nv = m.nv; pr.nefc = rows.n; pr.M = sm.M.data(); pr.qfrc_smooth = sm.qfrc_smooth.data();
427
+ pr.qacc_smooth = sm.qacc_smooth.data(); pr.J = rows.J.data(); pr.aref = rows.aref.data(); pr.D = rows.D.data();
428
+ pr.iterations = m.iterations; pr.ls_iterations = m.ls_iterations; pr.tolerance = m.tolerance; pr.ls_tolerance = m.ls_tolerance;
429
+ const newton::Result res = newton::solve(pr, warm);
430
+ Stats14 st;
431
+ st.ncon = static_cast<int>(con.size()); st.nefc = rows.n; st.niter = res.niter; st.warm_used = res.warm_used;
432
+ st.ran_out = res.ran_out;
433
+ for (int r = 0; r < rows.n; ++r) st.nlim += rows.type[r] == kRowLimit;
434
+ const double h = m.timestep;
435
+ for (int i = 0; i < m.nv; ++i) qvel[i] += h * res.qacc[i];
436
+ for (size_t b = 1; b < m.bodies.size(); ++b) {
437
+ const Body14& bd = m.bodies[b];
438
+ if (bd.jtype == kFree) {
439
+ for (int k = 0; k < 3; ++k) qpos[bd.qadr + k] += h * qvel[bd.dadr + k];
440
+ quat_integrate(qpos + bd.qadr + 3, qvel + bd.dadr + 3, h);
441
+ } else if (bd.jtype == kBall) {
442
+ quat_integrate(qpos + bd.qadr, qvel + bd.dadr, h);
443
+ } else if (bd.master_dadr < 0) {
444
+ qpos[bd.qadr] += h * qvel[bd.dadr];
445
+ }
446
+ }
447
+ for (int i = 0; i < m.nv; ++i) warm[i] = res.qacc[i];
448
+ if (keep) *keep = std::move(sm);
449
+ if (keep_rows) *keep_rows = std::move(rows);
450
+ return st;
451
+ }
452
+
453
+ } // namespace js::soft::x14