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,69 @@
1
+ """D16 hand (core/soft/hand.h) from Python: the layout through the C ABI (soft_hand_layout), decode() into fields, and
2
+ expand() into the CPU law's dense rows, so a hand from k_pre (GPU) or from soft_hand (the CPU reference) can be compared with
3
+ rows.h. Integer words are stored bitwise (tape_format.words_u32)."""
4
+ import ctypes
5
+
6
+ import numpy as np
7
+
8
+ from diffneusim.engine.tape_format import tri_unpack, words_u32
9
+
10
+ KEYS = ("nv", "ntri", "nc", "nr", "kdof", "M", "qfrc", "qacc", "clamp", "counts", "min_nu", "conJ", "condof", "conmeta", "conmu",
11
+ "aref", "efcD", "rowmeta", "words")
12
+ NC, NR, KDOF = 64, 192, 16 # the G1's hand capacities, NablaEngine's MAXCON / NEFC for the mjlab G1 (k_post's shared fast path
13
+ # is 32 / 128 inside them); the corpora's largest world has 33 contacts and 118 rows
14
+ ROW_LIMIT, ROW_FRICTIONLESS, ROW_PYRAMIDAL = 1, 2, 3
15
+
16
+
17
+ def layout(lib, nv, nc=NC, nr=NR, kdof=KDOF):
18
+ # the library's own count and names must equal KEYS (an entry inserted in the C array would otherwise shift every later
19
+ # index silently; the request after d5's crash, 2026-11-02)
20
+ getattr(lib, "soft_hand_layout_keys").restype = ctypes.c_char_p
21
+ n_lib, k_lib = int(getattr(lib, "soft_hand_layout_count")()), getattr(lib, "soft_hand_layout_keys")().decode()
22
+ assert n_lib == len(KEYS) and k_lib == ",".join(KEYS), (n_lib, len(KEYS), k_lib, ",".join(KEYS))
23
+ out = np.zeros(len(KEYS), np.int32)
24
+ lib.soft_hand_layout(nv, nc, nr, kdof, out.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
25
+ return dict(zip(KEYS, (int(x) for x in out)))
26
+
27
+
28
+ def decode(rec, h):
29
+ """one record [words] -> dict of fields (the contact and row tables cut at ncon / nefc)"""
30
+ a = np.ascontiguousarray(rec)
31
+ assert a.shape == (h["words"],), (a.shape, h["words"])
32
+ u = words_u32(a).astype(np.int64)
33
+ nv, nc, nr, kd = h["nv"], h["nc"], h["nr"], h["kdof"]
34
+ ncon, nefc, nlim, ovf = (int(u[h["counts"] + k]) for k in range(4))
35
+ out = dict(M=tri_unpack(a[h["M"]:h["M"] + h["ntri"]], nv), qfrc_smooth=a[h["qfrc"]:h["qfrc"] + nv],
36
+ qacc_smooth=a[h["qacc"]:h["qacc"] + nv], ncon=ncon, nefc=nefc, nlim=nlim, overflow=ovf,
37
+ min_nu=a[h["min_nu"]])
38
+ cl = u[h["clamp"]] | (u[h["clamp"] + 1] << 32)
39
+ out["clamp"] = ((cl >> np.arange(nv)) & 1).astype(bool)
40
+ out["conJ"] = a[h["conJ"]:h["conJ"] + nc * 3 * kd].reshape(nc, 3, kd)[:ncon]
41
+ dw = u[h["condof"]:h["condof"] + (nc * kd + 3) // 4]
42
+ out["condof"] = ((dw[:, None] >> (8 * np.arange(4))) & 255).reshape(-1)[:nc * kd].reshape(nc, kd)[:ncon]
43
+ m = u[h["conmeta"]:h["conmeta"] + nc][:ncon]
44
+ out.update(con_pair=m & 511, con_slot=(m >> 9) & 7, con_condim=(m >> 12) & 3, con_row0=(m >> 16) & 255,
45
+ con_nd=(m >> 24) & 31, con_mu=a[h["conmu"]:h["conmu"] + ncon])
46
+ rm = u[h["rowmeta"]:h["rowmeta"] + nr][:nefc]
47
+ out.update(aref=a[h["aref"]:h["aref"] + nefc], D=a[h["efcD"]:h["efcD"] + nefc], row_type=rm & 3,
48
+ row_index=(rm >> 2) & 255, row_k=(rm >> 10) & 3, row_neg=((rm >> 12) & 1).astype(bool))
49
+ return out
50
+
51
+
52
+ def expand(d, nv):
53
+ """the dense J [nefc, nv] of a decoded hand (limits +-e_dof; contact rows Jn + s mu Jt(t), s = (+,-,+,-), t = (1,1,2,2))"""
54
+ J = np.zeros((d["nefc"], nv), d["conJ"].dtype if d["ncon"] else np.float64)
55
+ for r in range(d["nefc"]):
56
+ t, i = int(d["row_type"][r]), int(d["row_index"][r])
57
+ if t == ROW_LIMIT:
58
+ J[r, i] = -1.0 if d["row_neg"][r] else 1.0
59
+ continue
60
+ nd = int(d["con_nd"][i])
61
+ dofs = d["condof"][i, :nd]
62
+ cj = d["conJ"][i]
63
+ if t == ROW_FRICTIONLESS:
64
+ J[r, dofs] = cj[0, :nd]
65
+ else:
66
+ k = int(d["row_k"][r])
67
+ tt, s = (1 if k < 2 else 2), (1.0 if k % 2 == 0 else -1.0)
68
+ J[r, dofs] = cj[0, :nd] + (s * d["con_mu"][i]) * cj[tt, :nd]
69
+ return J
@@ -0,0 +1,149 @@
1
+ """The viewer's live simulation on the shipped CPU engine (core/cpu_engine: the GPU engine's own kernels through the fiber shim), labelled.
2
+ LiveSim14 has the interface the viewer drives (reset, set_pin, step, finite, q_np, act_np, contact_np and the attributes it reads) and runs a
3
+ shipped muscle body (models/BODIES.toml) on its paper build (the body's tag) and its muscle case, one 2 ms substep per step, u held between
4
+ steps.
5
+ - The start state is the viewer's pose, v = 0, warm 0, a = A0, and the fibres at k_mus_equil's equilibrium (8 rounds, as the training
6
+ env's reset).
7
+ - Precision: f32 (the production engine's) unless DN_VIEW_CPU_F64=1.
8
+ - Not wired: the contact-force arrows (ncon = 0 here) and PD actuators (the muscle bodies have none).
9
+ - The CPU engine library is built once per source or compiler change into $XDG_CACHE_HOME/diffneusim/cpu_engine (default
10
+ ~/.cache/diffneusim; needs a C++ compiler, CXX)."""
11
+ import os
12
+ import re
13
+ import pathlib
14
+ import shutil
15
+ import subprocess
16
+
17
+ import numpy as np
18
+
19
+ from diffneusim._paths import ROOT
20
+ from diffneusim.model import body_info, body_of
21
+ from diffneusim.model.case import read_case
22
+
23
+ LABEL = "D16 engine on the CPU (the GPU kernels through the fiber shim)"
24
+
25
+
26
+ def _body(dnmodel_path):
27
+ """the shipped muscle body at this path, as (name, its BODIES.toml entry), or None"""
28
+ name = body_of(dnmodel_path) if dnmodel_path else None
29
+ if name is None:
30
+ return None
31
+ b = body_info(name)
32
+ return (name, b) if "tag" in b else None
33
+
34
+
35
+ class LiveSim14:
36
+ A0 = 0.05 # the training env's baseline activation (GpuFullBodyVecEnv.A0)
37
+ fixed_dt = 0.002 # the law's substep: the viewer sets its sim dt to this
38
+ backend = "cpu-d16"
39
+ pd = None
40
+
41
+ @staticmethod
42
+ def accepts(dnmodel_path):
43
+ """a shipped muscle body (models/BODIES.toml)"""
44
+ return _body(dnmodel_path) is not None
45
+
46
+ @staticmethod
47
+ def available(dnmodel_path):
48
+ b = _body(dnmodel_path)
49
+ return b is not None and (b[1]["case"] / "case.bin").exists() and shutil.which(os.environ.get("CXX", "c++")) is not None
50
+
51
+ def __init__(self, dnmodel_path, jm, q0_np):
52
+ hit = _body(dnmodel_path)
53
+ assert hit is not None, f"live14: {dnmodel_path} is not a shipped muscle body (models/BODIES.toml)"
54
+ name, b = hit
55
+ from diffneusim.engine import x14cpu
56
+ from diffneusim.engine import build_tag as BT
57
+ tag, case = b["tag"], b["case"]
58
+ header = ROOT / "core" / "soft" / "gpu" / "generated" / f"body_{tag}.cuh"
59
+ V = {k: int(v) for k, v in re.findall(r"^#define D16_BODY_(\w+) (\d+)\s*$", header.read_text(), re.M)}
60
+ self._quats = (3, V["BQ0"], V["BQ1"]) # the root's and the two balls' quaternion addresses (d16_body.QUATS)
61
+ flags = ["-DD16_X14_MILLARD"] if "law" in read_case(case) else []
62
+ CE = ROOT / "core" / "cpu_engine"
63
+ src = [CE / "x14_cpu.cpp", CE / "fiber" / "cuda_runtime.h", CE / "build.sh", header]
64
+ from diffneusim import _cache # the user's build cache (XDG_CACHE_HOME), never the package
65
+ out = _cache.root() / "cpu_engine" / BT.tag(ROOT, src, [tag] + flags + _cache.compiler(os.environ.get("CXX", "c++")))
66
+ lib = out / f"libx14cpu_{tag}.so"
67
+ if not lib.exists():
68
+ print(f"live14: building the CPU engine for {name} into {out} (once per source change)", flush=True)
69
+ subprocess.run(["bash", str(CE / "build.sh"), tag, str(out)] + flags, check=True, capture_output=True)
70
+ assert lib.exists(), lib
71
+ self.prec = 1 if os.environ.get("DN_VIEW_CPU_F64", "0") == "1" else 0
72
+ self.E = x14cpu.X14Cpu(lib, case, self.prec)
73
+ self.ft = self.E.ft
74
+ self.nq, self.nv, self.nm, self.ncon = self.E.nq, self.E.nv, self.E.nm, 0
75
+ assert (self.nq, self.nv) == (V["NQ"], V["NV"]), ((self.nq, self.nv), V["NQ"], V["NV"])
76
+ self.has_muscle = True
77
+ self.label = f"{LABEL}, {name}" + (" f64" if self.prec else " f32")
78
+ self.jm = jm
79
+ self.dt = self.fixed_dt
80
+ lo_case = np.asarray(self.E.keep[1], np.float64) # TABLE[1] = lopt, in the case's muscle order
81
+ from diffneusim.viz.dnrec_io import muscle_l_opts
82
+ lo_model = np.asarray(muscle_l_opts(jm), np.float64)
83
+ assert lo_model.shape == lo_case.shape and float(np.abs(lo_model - lo_case).max()) < 1e-6, "live14: the case's l_opt is not the model's (env14.install_equil14's check)"
84
+ self.l_opt = lo_case.astype(self.ft)
85
+ self.q0_np = np.array(q0_np, dtype=np.float64)
86
+ assert self.q0_np.shape == (self.nq,), f"live14: q0 has {self.q0_np.shape}, the engine nq {self.nq}"
87
+ self.excitation, self.excitation_vec, self.pin, self.n_steps = 0.0, None, None, 0
88
+ self.reset()
89
+
90
+ def _law_q(self, q):
91
+ """env14.old_to_law's q: the root and the two ball quaternions normalized"""
92
+ q = np.array(q, dtype=np.float64)
93
+ for k in self._quats:
94
+ q[k:k + 4] = q[k:k + 4] / np.linalg.norm(q[k:k + 4])
95
+ return q
96
+
97
+ def reset(self):
98
+ self.n_steps = 0
99
+ self.q = self._law_q(self.q0_np).astype(self.ft).reshape(1, -1)
100
+ self.v = np.zeros((1, self.nv), self.ft)
101
+ self.w = np.zeros((1, self.nv), self.ft)
102
+ self.a = np.full((1, self.nm), self.A0, self.ft)
103
+ self._apply_pin()
104
+ n = int(os.environ.get("DN_VIEW_FIBER_INIT_ITERS", "8"))
105
+ seed = self.l_opt.reshape(1, -1).copy()
106
+ self.lce = self.E.equil(self.q, seed, self.a, outer=n) if n > 0 else seed
107
+
108
+ def set_pin(self, q_idx=None, q_val=None, v_idx=None):
109
+ """as LiveSim.set_pin: hold coordinates kinematically and zero their velocity dofs (here in the law's chart; zero is zero in both)"""
110
+ if q_idx is None:
111
+ self.pin = None
112
+ return
113
+ qi, qv = np.asarray(q_idx, np.int64), np.asarray(q_val, np.float64)
114
+ vi = np.asarray(v_idx if v_idx is not None else [], np.int64)
115
+ assert qi.shape == qv.shape and (qi.size == 0 or (qi.min() >= 0 and qi.max() < self.nq)) and (vi.size == 0 or (vi.min() >= 0 and vi.max() < self.nv))
116
+ self.pin = dict(q_idx=qi, v_idx=vi, q_val=qv)
117
+ self._apply_pin()
118
+
119
+ def set_pd_targets(self, q_np):
120
+ raise AssertionError("live14: the muscle bodies have no PD actuators")
121
+
122
+ def _apply_pin(self):
123
+ p = self.pin
124
+ if p is None:
125
+ return
126
+ self.q[0, p["q_idx"]] = p["q_val"]
127
+ self.v[0, p["v_idx"]] = 0.0
128
+
129
+ def step(self, dt):
130
+ assert abs(dt - self.fixed_dt) < 1e-12, f"live14: the engine steps the law's {self.fixed_dt} s substep, the viewer asked {dt}"
131
+ if self.excitation_vec is not None:
132
+ u = np.clip(np.asarray(self.excitation_vec, np.float64).reshape(1, self.nm), 0.0, 1.0).astype(self.ft)
133
+ else:
134
+ u = np.full((1, self.nm), float(self.excitation), self.ft)
135
+ (self.q, self.v, self.w, self.lce, self.a), _, _ = self.E.run(self.q, self.v, self.w, self.lce, self.a, u, steps=1, nsub=1)
136
+ self._apply_pin()
137
+ self.n_steps += 1
138
+
139
+ def finite(self):
140
+ return bool(np.isfinite(self.q).all())
141
+
142
+ def q_np(self):
143
+ return np.asarray(self.q, np.float64).reshape(-1)
144
+
145
+ def act_np(self):
146
+ return np.asarray(self.a, np.float64).reshape(-1)
147
+
148
+ def contact_np(self):
149
+ return None
@@ -0,0 +1,137 @@
1
+ """Phase B's measured basis (2026-11-06; PHASE_B.md): the sparsity of M and of the Newton matrix H on a body's dof tree, and what eliminating the finger dofs onto a dense core costs.
2
+ From the law JSON only (no engine). M[i][j] != 0 exactly when dofs i and j both move one body (one is an ancestor of the other, coupled masters included), so a floor contact, whose Jacobian support is one body's chain, adds
3
+ nothing outside M's pattern; a self pair couples its two bodies' chains. The split: E = the dofs of the bodies below a wrist (a hand's bones and fingers), the core = the rest. The elimination is exact when no E dof is coupled
4
+ to an E dof of another chain and every E dof's off-chain coupling lands on its own core ancestors; then the core's Schur complement is dense of order |core| and E's factor has no fill.
5
+ What else enters a matrix the engine factors (core/soft/gpu/kp14.cuh, l3.cuh): kernel P's M is the tree's CRBA plus armature on the diagonal; k_post's H adds each active limit row's D
6
+ on its own dof's diagonal and each contact's J'DJ over its support; implicitfast's L_Q adds h kd on the diagonal. Muscles act as explicit torques (k_mus) and enter no factored matrix.
7
+ So the checks below also cover the review's three (11-06): equality couplings (expanded as master-driven joints: none may sit below a wrist or have a master in a finger chain), MuJoCo
8
+ tendons or equalities left in the expanded model (none may exist), and limit rows on finger dofs (each one dof, not coupled).
9
+ python tools/d16_bodies/phase_b_tree.py LAW.json [LAW.json ...]"""
10
+ import json
11
+ import sys
12
+
13
+ import numpy as np
14
+
15
+ NDOF = {"free": 6, "ball": 3, "hinge": 1, "slide": 1}
16
+ WRIST = ("lunate_r", "lunate_l")
17
+
18
+
19
+ def chains_of(L):
20
+ B = L["bodies"]
21
+ own = {}
22
+ for i, b in enumerate(B):
23
+ if b.get("dadr", -1) >= 0:
24
+ for k in range(NDOF[b["jtype"]]):
25
+ own.setdefault(b["dadr"] + k, i)
26
+ assert len(own) == L["nv"], (len(own), L["nv"])
27
+
28
+ def chain(i):
29
+ out = set()
30
+ while i > 0:
31
+ b = B[i]
32
+ if b.get("dadr", -1) >= 0:
33
+ out |= set(range(b["dadr"], b["dadr"] + NDOF[b["jtype"]]))
34
+ if b.get("master_dadr", -1) >= 0:
35
+ out.add(b["master_dadr"])
36
+ i = b["parent"]
37
+ return out
38
+
39
+ return B, own, [chain(i) for i in range(len(B))]
40
+
41
+
42
+ def below_wrist(B, i):
43
+ """a hand bone or finger: a body below a wrist that is not itself a wrist body (the wrist's two hinges are two bodies named lunate)"""
44
+ if B[i]["name"] in WRIST:
45
+ return False
46
+ i = B[i]["parent"]
47
+ while i > 0:
48
+ if B[i]["name"] in WRIST:
49
+ return True
50
+ i = B[i]["parent"]
51
+ return False
52
+
53
+
54
+ def symbolic(P, order):
55
+ A = P[np.ix_(order, order)].copy()
56
+ madds = 0
57
+ for k in range(len(order)):
58
+ rows = np.nonzero(A[k + 1:, k])[0] + k + 1
59
+ madds += len(rows) * (len(rows) + 1) // 2 + len(rows)
60
+ A[np.ix_(rows, rows)] = True
61
+ return int(np.tril(A).sum()), int(madds)
62
+
63
+
64
+ def main():
65
+ for path in sys.argv[1:]:
66
+ L = json.load(open(path))
67
+ nv = L["nv"]
68
+ B, own, ch = chains_of(L)
69
+ G = L["geoms"]
70
+ P = np.zeros((nv, nv), bool)
71
+ for c in ch:
72
+ c = sorted(c)
73
+ P[np.ix_(c, c)] = True
74
+ H = P.copy() # every pair active at once: the widest pattern the Newton matrix can take
75
+ for pr in L["pairs"]:
76
+ c = sorted(ch[G[pr["g1"]]["body"]] | ch[G[pr["g2"]]["body"]])
77
+ H[np.ix_(c, c)] = True
78
+ E = sorted(d for d in range(nv) if below_wrist(B, own[d]))
79
+ core = [d for d in range(nv) if d not in set(E)]
80
+ dense = nv * (nv + 1) // 2
81
+ print(f"== {path.split('/')[-1]}: nv {nv}, bodies {len(B)}, limits {len(L['limits'])}, pairs {len(L['pairs'])}")
82
+ print(f" M: {int(np.tril(P).sum())} of {dense} entries ({100 * np.tril(P).sum() / dense:.0f}%); H with every pair: {int(np.tril(H).sum())}")
83
+ for nm, X in (("M", P), ("H", H)):
84
+ d = symbolic(X, list(range(nv)))
85
+ r = symbolic(X, list(range(nv))[::-1])
86
+ print(f" {nm} factor, multiply-adds: dense order {d[1]} (nnz {d[0]}); leaves first {r[1]} (nnz {r[0]}, fill {r[0] - int(np.tril(X).sum())})")
87
+ if not E:
88
+ continue
89
+ # the split: E's rows and its coupling to the core
90
+ EE = H[np.ix_(E, E)]
91
+ groups = {}
92
+ for d in E: # E's chains: the bodies below each wrist's children (one per finger or thumb)
93
+ i = own[d]
94
+ while B[B[i]["parent"]]["name"] not in WRIST:
95
+ i = B[i]["parent"]
96
+ groups.setdefault(B[i]["name"], []).append(d)
97
+ cross = sum(int(H[np.ix_(a, b)].any()) for ga, a in groups.items() for gb, b in groups.items() if ga < gb)
98
+ anc = {g: sorted(set().union(*(set(core) & ch[own[d]] for d in ds))) for g, ds in groups.items()}
99
+ offchain = sum(int(H[d, c]) for g, ds in groups.items() for d in ds for c in core if c not in set(anc[g]))
100
+ ec = int(H[np.ix_(E, core)].sum())
101
+ # elimination of E onto the core, leaves first within each chain: E's own fill, and the Schur update of each chain's core ancestors
102
+ order = E[::-1] + core
103
+ n_e = len(E)
104
+ A = H[np.ix_(order, order)].copy()
105
+ madds_e = 0
106
+ for k in range(n_e):
107
+ rows = np.nonzero(A[k + 1:, k])[0] + k + 1
108
+ madds_e += len(rows) * (len(rows) + 1) // 2 + len(rows)
109
+ A[np.ix_(rows, rows)] = True
110
+ fill_e = int(np.tril(A[:n_e, :n_e]).sum()) - int(np.tril(EE).sum())
111
+ S = A[n_e:, n_e:]
112
+ nc = len(core)
113
+ core_dense = nc ** 3 // 6 + nc * nc // 2
114
+ store = int(np.tril(A[:n_e, :n_e]).sum()) + int(A[n_e:, :n_e].sum()) + nc * (nc + 1) // 2
115
+ print(f" split: E {n_e} dofs in {len(groups)} chains ({', '.join(f'{g} {len(v)}' for g, v in sorted(groups.items()))}), core {nc}")
116
+ print(f" exact: E-E coupling across chains {cross} (0 needed); E coupled off its chain's core ancestors {offchain} (0 needed); E's fill {fill_e}; core ancestors per chain {sorted({len(v) for v in anc.values()})}")
117
+ print(f" cost: E elimination {madds_e} multiply-adds, then the core's dense factor {core_dense} (order {nc}); total {madds_e + core_dense}; Schur complement dense: {bool(np.tril(S).all())}")
118
+ cb = [(i, b["master_dadr"]) for i, b in enumerate(B) if b.get("master_dadr", -1) >= 0]
119
+ cb_below = sum(1 for i, m in cb if below_wrist(B, i))
120
+ cb_master = sum(1 for i, m in cb if m in set(E))
121
+ fl = [l for l in L["limits"] if l["dof"] in set(E)]
122
+ fl_bad = sum(1 for l in fl if l["coupled"] or not isinstance(l["dof"], int))
123
+ import pathlib
124
+ import re
125
+ xml = pathlib.Path(path).parent / L["source"]["expanded_xml"]
126
+ X = xml.read_text()
127
+ n_eq = len(re.findall(r"<equality\b", X))
128
+ n_ten = len(re.findall(r"<tendon\b", X))
129
+ print(f" other terms: couplings {len(cb)}, below a wrist {cb_below}, master in a finger chain {cb_master} (0 needed); limits on finger dofs {len(fl)}, coupled or multi-dof {fl_bad} (0 needed); "
130
+ f"the expanded model's equality sections {n_eq}, tendon sections {n_ten} (0 needed)")
131
+ ok = cross == 0 and offchain == 0 and fill_e == 0 and cb_below == 0 and cb_master == 0 and fl_bad == 0 and n_eq == 0 and n_ten == 0
132
+ print(f" SPLIT {'EXACT' if ok else 'NOT EXACT'}")
133
+ print(f" storage: {store} words (E's rows {int(np.tril(A[:n_e, :n_e]).sum())}, E-core {int(A[n_e:, :n_e].sum())}, core {nc * (nc + 1) // 2}) against {dense} dense")
134
+
135
+
136
+ if __name__ == "__main__":
137
+ main()
@@ -0,0 +1,130 @@
1
+ """ctypes loader of bindings/soft14_capi.cpp (the 14x soft law's CPU f64 reference, core/soft/x14/law14.h) from the law JSON
2
+ tools/d16_14x/export_14x_law.py writes. Builds the library on first use when it is older than its sources."""
3
+ import ctypes
4
+ import json
5
+ import os
6
+
7
+ import numpy as np
8
+
9
+ from diffneusim._paths import ROOT as ROOT # (3a) the repo root
10
+ SRC = [ROOT / "bindings" / "soft14_capi.cpp"] + sorted((ROOT / "core" / "soft" / "x14").glob("*.h")) + sorted((ROOT / "core" / "soft").glob("*.h"))
11
+ EXTRA = os.environ.get("SOFT14_EXTRA", "").split()
12
+ LIB = None # set by build(): the library in the user's build cache (diffneusim._cache), never inside the package
13
+ # the contact set: X14_VARIANT=mm (the default since 2026-11-03: MuscleMimic's floor contacts, FLOOR_CONTACT_TABLE.md, gates in
14
+ # COMPOSED14.md) or e0 (the 10 foot spheres, CONTACT_PARAMS.md decision 1)
15
+ VARIANT = os.environ.get("X14_VARIANT", "mm")
16
+ assert VARIANT in ("mm", "e0"), f"X14_VARIANT={VARIANT!r}: mm or e0"
17
+ # (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16_bodies"))
18
+ from diffneusim.engine import d16_body as BODY # noqa: E402
19
+ LAW = BODY.LAW if BODY.TAG else ROOT / "models" / "derived" / ("e0_14x_soft_law_f1c2243ae6be449e" + ("_mmfloor" if VARIANT == "mm" else "") + ".json")
20
+ D = ctypes.POINTER(ctypes.c_double)
21
+ I = ctypes.POINTER(ctypes.c_int)
22
+ JT = {"world": -1, "free": 0, "ball": 1, "hinge": 3}
23
+
24
+
25
+ def build():
26
+ """the library, built once per content tag (sources + flags + compiler) into the build cache"""
27
+ global LIB
28
+ if LIB is None:
29
+ from diffneusim import _cache
30
+ LIB = _cache.build_lib("build-soft", "libsoft14.so", SRC, ["c++", "-std=c++17", "-O2", "-fPIC", "-shared", "-pthread"] + EXTRA
31
+ + ["-I", str(ROOT / "core"), "-I", str(ROOT / "core" / "include"), str(SRC[0])])
32
+ return LIB
33
+
34
+
35
+ def p(a):
36
+ return a.ctypes.data_as(D if a.dtype == np.float64 else I)
37
+
38
+
39
+ class Soft14:
40
+ def __init__(self, law_path=LAW, iterations=None):
41
+ """iterations: override the law's Newton cap (the truth setting for the cap study); None keeps the law's (4)"""
42
+ build()
43
+ self.lib = ctypes.CDLL(str(LIB))
44
+ self.lib.s14_new.restype = ctypes.c_void_p
45
+ self.L = L = json.load(open(law_path))
46
+ if iterations is not None:
47
+ L["opt"]["iterations"] = int(iterations)
48
+ B = L["bodies"]
49
+ self.nb, self.nq, self.nv = len(B), L["nq"], L["nv"]
50
+ bint = np.zeros((self.nb, 6), np.int32); bdbl = np.zeros((self.nb, 24))
51
+ for i, b in enumerate(B):
52
+ bint[i] = [b["parent"], JT[b["jtype"]], b["qadr"], b["dadr"], b.get("master_qadr", -1), b.get("master_dadr", -1)]
53
+ if i == 0:
54
+ bdbl[i, 7] = bdbl[i, 14] = 1.0
55
+ continue
56
+ bdbl[i] = [b.get("coef", 1.0), *b["axis"], *b["pos"], *b["quat"], *b["ipos"], *b["iquat"], *b["inertia_principal"], b["mass"],
57
+ *L["body_invweight0"][i]]
58
+ ent = [(d, e[0], e[1]) for d, lst in enumerate(L["dofs"]) for e in lst]
59
+ ei = np.array([[d, b] for d, b, _ in ent], np.int32); ec = np.array([c for _, _, c in ent])
60
+ arm = np.array(L["armature"]); damp = np.array(L["passive"]["damping"])
61
+ self.h = ctypes.c_void_p(self.lib.s14_new(self.nb, self.nq, self.nv, p(bint), p(bdbl), len(ent), p(ei), p(ec), p(arm), p(damp)))
62
+ G = L["geoms"]; gi = np.array([[g["body"], g["type"]] for g in G], np.int32); gd = np.array([[*g["size"], *g["pos"], *g["quat"]] for g in G])
63
+ P = L["pairs"]; pi_ = np.array([[x["g1"], x["g2"], x["condim"], -1] for x in P], np.int32)
64
+ pd = np.array([[*x["friction"][:3], *x["solref"], *x["solimp"], x["margin"], x["gap"]] for x in P])
65
+ Li = L["limits"]; li = np.array([[x["dof"], x["qadr"]] for x in Li], np.int32)
66
+ ld = np.array([[x["coef"], *x["range"], *x["solref"], *x["solimp"], x["margin"], x["diagA"], 0.0] for x in Li])
67
+ S = L["passive"]["coord_springs"]; si = np.array([[x["dof"], x["qadr"]] for x in S], np.int32); sd = np.array([[x["k"], x["rest"]] for x in S])
68
+ R = L["passive"]["ball_rom"]; ri = np.array([[x["qadr"], x["dadr"]] for x in R], np.int32)
69
+ rd = np.array([[*[r[0] for r in x["range"]], *[r[1] for r in x["range"]], *x["d_lim"], x["exp_a"], x["exp_w"], x["beta"]] for x in R])
70
+ o = L["opt"]; od = np.array([*o["gravity"], o["timestep"], o["impratio"], o["tolerance"], o["ls_tolerance"]])
71
+ oi = np.array([o["iterations"], o["ls_iterations"], o["nsub"]], np.int32)
72
+ self._keep = [bint, bdbl, ei, ec, arm, damp, gi, gd, pi_, pd, li, ld, si, sd, ri, rd, od, oi]
73
+ self.lib.s14_law(self.h, len(G), p(gi), p(gd), len(P), p(pi_), p(pd), len(Li), p(li), p(ld), len(S), p(si), p(sd), len(R), p(ri), p(rd), p(od), p(oi))
74
+
75
+ def smooth(self, q, v, tau=None):
76
+ nb, nv = self.nb, self.nv
77
+ out = dict(xpos=np.zeros((nb, 3)), xquat=np.zeros((nb, 4)), xipos=np.zeros((nb, 3)), M=np.zeros((nv, nv)), bias=np.zeros(nv),
78
+ passive=np.zeros(nv), qfrc_smooth=np.zeros(nv), qacc_smooth=np.zeros(nv))
79
+ q, v = np.ascontiguousarray(q, np.float64), np.ascontiguousarray(v, np.float64)
80
+ t = None if tau is None else p(np.ascontiguousarray(tau, np.float64))
81
+ self.lib.s14_smooth(self.h, p(q), p(v), t, *[p(out[k]) for k in ("xpos", "xquat", "xipos", "M", "bias", "passive", "qfrc_smooth", "qacc_smooth")])
82
+ return out
83
+
84
+ def rows(self, q, v, cap=512):
85
+ nv = self.nv
86
+ a = dict(type=np.zeros(cap, np.int32), id=np.zeros(cap, np.int32), J=np.zeros((cap, nv)), pos=np.zeros(cap), margin=np.zeros(cap),
87
+ diagA=np.zeros(cap), aref=np.zeros(cap), R=np.zeros(cap), D=np.zeros(cap))
88
+ nc = np.zeros(1, np.int32); ci = np.zeros((cap, 3), np.int32); cd = np.zeros((cap, 13))
89
+ q, v = np.ascontiguousarray(q, np.float64), np.ascontiguousarray(v, np.float64)
90
+ n = self.lib.s14_rows(self.h, p(q), p(v), ctypes.c_double(-1.0), cap, p(a["type"]), p(a["id"]), p(a["J"]), p(a["pos"]), p(a["margin"]),
91
+ p(a["diagA"]), p(a["aref"]), p(a["R"]), p(a["D"]), p(nc), p(ci), p(cd))
92
+ assert n >= 0, "over cap"
93
+ r = {k: x[:n] for k, x in a.items()}
94
+ k = int(nc[0])
95
+ r["con"] = dict(pair=ci[:k, 0], slot=ci[:k, 1], condim=ci[:k, 2], dist=cd[:k, 0], pos=cd[:k, 1:4], frame=cd[:k, 4:13].reshape(k, 3, 3))
96
+ return r
97
+
98
+ def hand_words(self, nc=64, nr=255, kdof=16):
99
+ return int(self.lib.s14_hand_words(self.nv, nc, nr, kdof))
100
+
101
+ def hand_batch(self, q, v, tau=None, fric=None, nc=64, nr=255, kdof=16, nthreads=8):
102
+ """the CPU 14x hand records [n, words] (f64) of n states (law convention)"""
103
+ q, v = np.ascontiguousarray(q, np.float64), np.ascontiguousarray(v, np.float64)
104
+ n = len(q)
105
+ fr = np.full(n, -1.0) if fric is None else np.ascontiguousarray(fric, np.float64)
106
+ out = np.zeros((n, self.hand_words(nc, nr, kdof)))
107
+ t = None if tau is None else p(np.ascontiguousarray(tau, np.float64))
108
+ self.lib.s14_hand_batch(self.h, n, p(q), p(v), t, p(fr), nc, nr, kdof, p(out), nthreads)
109
+ return out
110
+
111
+ def substep(self, q, v, w, tau=None, fric=-1.0):
112
+ q1, v1, w1, st = np.zeros(self.nq), np.zeros(self.nv), np.zeros(self.nv), np.zeros(6, np.int32)
113
+ q, v, w = (np.ascontiguousarray(x, np.float64) for x in (q, v, w))
114
+ t = None if tau is None else p(np.ascontiguousarray(tau, np.float64))
115
+ self.lib.soft_substep(self.h, p(q), p(v), p(w), t, ctypes.c_double(fric), p(q1), p(v1), p(w1), p(st))
116
+ return q1, v1, w1, st
117
+
118
+
119
+ def from_old_engine(q, qd):
120
+ """the old engine's 14x state (core/dyn/articulated.h:70-81: qd[0:3] = root w, qd[3:6] = root v, both in the body frame) to the
121
+ law's MuJoCo convention (qvel[0:3] = root v in the world frame, qvel[3:6] = root w in the body frame). q is the same layout
122
+ (root position, quaternion wxyz, coordinates); ball qd is the child frame's w in both."""
123
+ q = np.asarray(q, np.float64).copy(); qd = np.asarray(qd, np.float64)
124
+ w, x, y, z = q[3:7] / np.linalg.norm(q[3:7])
125
+ R = np.array([[1 - 2 * (y * y + z * z), 2 * (x * y - w * z), 2 * (x * z + w * y)], [2 * (x * y + w * z), 1 - 2 * (x * x + z * z), 2 * (y * z - w * x)],
126
+ [2 * (x * z - w * y), 2 * (y * z + w * x), 1 - 2 * (x * x + y * y)]])
127
+ v = qd.copy()
128
+ v[0:3] = R @ qd[3:6]
129
+ v[3:6] = qd[0:3]
130
+ return q, v