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,346 @@
1
+ """DiffRL-style SHAC trainer (Xu et al. 2022) -- batched envs, stochastic actor, td-lambda critic
2
+ with a target network, obs normalization, grad-clip, linear lr decay. A faithful mirror of
3
+ physics-review/DiffRL/algorithms/shac.py adapted to our GpuAntVecEnv (no dflex/tensorboard/yaml).
4
+
5
+ This is the fix for the crippled single-env stand-still: num_envs >> 1 (gradient variance down =
6
+ the biggest lever) + exploration (stochastic actor) + a proper value bootstrap (td-lambda + target
7
+ critic) + obs_rms + enough budget. The reference recipe walks Ant/Humanoid AND the musculotendon
8
+ humanoid from scratch -- no imitation.
9
+ """
10
+ import copy
11
+
12
+ import numpy as np
13
+ import torch
14
+ from torch.nn.utils.clip_grad import clip_grad_norm_
15
+
16
+ from .nets_shac import ActorStochasticMLP, CriticMLP, RunningMeanStd
17
+
18
+
19
+ def _clip_grad_per_env(grad, factor):
20
+ """Clip each env's action-gradient vector to `factor` x the median env-norm. Scale-free:
21
+ uniform envs (Ant: all envs ~equal) pass through unchanged, while a few chaotic envs -- an
22
+ unstable 3D biped whose BPTT gradient blows up through the gimbal-expanded dynamics -- get
23
+ pulled back so they cannot dominate the norm-clipped actor step direction."""
24
+ grad = torch.nan_to_num(grad, 0.0, 0.0, 0.0) # a diverged env (hard-contact blow-up) -> 0; don't poison the batch
25
+ n = grad.norm(dim=-1, keepdim=True)
26
+ cap = (n.median() * factor).clamp_min(1e-12)
27
+ return grad * (cap / n.clamp_min(cap))
28
+
29
+
30
+ class ShacVec:
31
+ def __init__(self, env, steps_num=32, gamma=0.99, lam=0.95, actor_lr=2e-3, critic_lr=2e-3,
32
+ lr_schedule="linear", target_critic_alpha=0.2, critic_iterations=16, num_batch=4,
33
+ grad_norm=1.0, betas=(0.7, 0.95), max_epochs=2000, device="cuda", seed=0,
34
+ actor_units=(128, 64, 32), critic_units=(64, 64), actor_out_bias=None,
35
+ action_grad_clip=None, logstd_init=-1.0, synergy_path=None, synergy_bias=0.0,
36
+ synergy_anneal_frac=0.5, ivw_h=False, ivw_eta=1e-12, lattice=False, lattice_alpha=1.0,
37
+ ddcg=False, ddcg_c=0.3, ddcg_eps_v=0.0):
38
+ torch.manual_seed(seed)
39
+ np.random.seed(seed)
40
+ self.env = env
41
+ self.device = torch.device(device)
42
+ self.num_envs, self.num_obs, self.num_actions = env.num_envs, env.num_obs, env.num_actions
43
+ self.steps_num = steps_num
44
+ self.gamma, self.lam = gamma, lam
45
+ self.actor_lr, self.critic_lr, self.lr_schedule = actor_lr, critic_lr, lr_schedule
46
+ self.target_critic_alpha = target_critic_alpha
47
+ self.critic_iterations, self.num_batch = critic_iterations, num_batch
48
+ self.grad_norm, self.max_epochs = grad_norm, max_epochs
49
+ self.action_grad_clip = action_grad_clip # None = off; per-env action-grad cap (x median)
50
+ # Stepwise inverse-variance weighting (IVW-H): blend the pathwise (FoBG) action gradient with a
51
+ # score-function (ZoBG) action gradient built from the SAME stochastic batch, per-step per-dim by
52
+ # inverse variance. The principled replacement for action_grad_clip on stiff/chaotic muscle+contact
53
+ # dynamics where the pathwise gradient explodes. Default OFF = byte-identical. Suh et al. ICML 2022
54
+ # (arXiv:2202.00817) + the 2026 critique (arXiv:2604.18161). See docs/training/concepts/ivw-h-gradient.md.
55
+ self.ivw_h = bool(ivw_h)
56
+ self.ivw_eta = float(ivw_eta) # variance floor (degenerate-variance guard)
57
+ # DDCG (Onoda/Parmas 2604.18161 Eq.14-15): gate the IVW FoBG-trust by a smoothness test, per
58
+ # action-dim. Where the empirical FoBG variance is too small to be consistent with a smooth function
59
+ # (a DEAD/saturated FoBG whose variance ~0 while the return still varies), fall back to the ZoBG
60
+ # (alpha=0) instead of over-trusting the low-variance-but-biased FoBG (Suh's "empirical bias" trap).
61
+ # This is what catches the tanh-saturation self-lock IVW alone cannot see. Default OFF = plain IVW-H.
62
+ self.ddcg = bool(ddcg)
63
+ self.ddcg_c = float(ddcg_c) # smoothness relaxation (paper: 0.3, robust in [0.1,0.9])
64
+ self.ddcg_eps_v = float(ddcg_eps_v) # variance-reliability floor (paper: omittable)
65
+ # Opt-in moment-arm synergy exploration prior (tools/build_synergy_matrix.py): color the actor's
66
+ # exploration noise so agonist muscles explore together / antagonists oppose. Applied in
67
+ # _env_action to the deviation from the rest bias (rest preserved), as a FIXED downstream map, so
68
+ # the diagonal density over the raw action is unchanged -> RPO log_prob/ratio/KL/reuse need no
69
+ # change. A = chol((1-lam)*Gram + lam*I) is invertible => the action mean is unrestricted => full
70
+ # DOF preserved (a soft exploration prior, NOT an action-space reduction).
71
+ self.synergy_A = None
72
+ self.synergy_bias = float(synergy_bias)
73
+ self.synergy_anneal_steps = 0.0
74
+ if synergy_path:
75
+ _d = np.load(synergy_path)
76
+ self.synergy_A = torch.tensor(_d["A"], dtype=torch.float32, device=self.device)
77
+ assert self.synergy_A.shape == (self.num_actions, self.num_actions), self.synergy_A.shape
78
+ self._syn_I = torch.eye(self.num_actions, dtype=torch.float32, device=self.device)
79
+ # "init-only" anneal: A_eff = (1-beta)A + beta*I, beta = step_count/anneal_steps (0->1) over the
80
+ # first synergy_anneal_frac of training. Exploration STARTS synergy-colored (basin escape) then
81
+ # decays to independent -- A-free by beta=1 (A_eff=I => bit-identical to synergy-off). chol A has
82
+ # a positive diagonal so (1-beta)A+beta*I stays invertible => DOF preserved. frac=0 => fixed A.
83
+ self.synergy_anneal_steps = synergy_anneal_frac * self.max_epochs * self.num_envs * self.steps_num
84
+
85
+ self.actor = ActorStochasticMLP(self.num_obs, self.num_actions, units=actor_units, device=device,
86
+ out_bias=actor_out_bias, logstd_init=logstd_init,
87
+ lattice=lattice, lattice_alpha=lattice_alpha)
88
+ self.critic = CriticMLP(self.num_obs, units=critic_units, device=device)
89
+ self.target_critic = copy.deepcopy(self.critic)
90
+ self.obs_rms = RunningMeanStd((self.num_obs,), device=device)
91
+ # the env's one-hot phase-bin slots (TASKWALK_CYCLE_PHASE_BINS), passed through unnormalized as DeepLoco's are
92
+ _bins = getattr(env, "phase_gate_bins", None)
93
+ if _bins is not None:
94
+ fx = torch.zeros(self.num_obs, dtype=torch.bool, device=device)
95
+ fx[torch.as_tensor(list(_bins), dtype=torch.long, device=device)] = True
96
+ self.obs_rms.fixed = fx
97
+ self.actor_opt = torch.optim.Adam(self.actor.parameters(), betas=betas, lr=actor_lr)
98
+ self.critic_opt = torch.optim.Adam(self.critic.parameters(), betas=betas, lr=critic_lr)
99
+
100
+ self.batch_size = self.num_envs * self.steps_num // self.num_batch
101
+ self.obs_buf = torch.zeros((steps_num, self.num_envs, self.num_obs), device=device)
102
+ self.rew_buf = torch.zeros((steps_num, self.num_envs), device=device)
103
+ self.done_mask = torch.zeros((steps_num, self.num_envs), device=device)
104
+ self.next_values = torch.zeros((steps_num, self.num_envs), device=device)
105
+ self.target_values = torch.zeros((steps_num, self.num_envs), device=device)
106
+ self.val_buf = torch.zeros((steps_num, self.num_envs), device=device) # live-critic V(s_t) baseline (IVW-H ZoBG / RPO GAE)
107
+ if self.ivw_h: # IVW-H per-step stashes (mu + sampled action -> noise)
108
+ self._ivw_mu = torch.zeros((steps_num, self.num_envs, self.num_actions), device=device)
109
+ self._ivw_act = torch.zeros((steps_num, self.num_envs, self.num_actions), device=device)
110
+ self.step_count = 0
111
+ self.last_raw_action_grad_max = 0.0 # monitor: max per-env raw action-grad L2 (pre-clip)
112
+ self.last_raw_action_grad_nonfinite = False
113
+ # (a) GPU-side monitor accumulators: the per-step action-grad hook updates these on-device
114
+ # (no host sync); we .item() them ONCE per epoch. Removes ~2*steps_num CPU-GPU syncs/epoch
115
+ # that stalled the launch-bound rollout. Logging-only -> training is numerically identical.
116
+ self._rag_max_gpu = torch.zeros((), device=self.device)
117
+ self._rag_nonfinite_gpu = torch.zeros((), dtype=torch.bool, device=self.device)
118
+
119
+ def _env_action(self, actions):
120
+ """Raw actor output (n_env, num_actions) -> the env's pre-tanh input. With the synergy prior on,
121
+ color the exploration by A (agonists together) applied to the deviation from the rest bias, so rest
122
+ is preserved and A only mixes the deviation+noise. Default (A=None) is bit-identical: tanh(actions)."""
123
+ if self.synergy_A is None:
124
+ return torch.tanh(actions)
125
+ b = self.synergy_bias
126
+ A = self.synergy_A
127
+ if self.synergy_anneal_steps > 0: # init-only: anneal A_eff -> I over training
128
+ beta = min(1.0, self.step_count / self.synergy_anneal_steps)
129
+ A = (1.0 - beta) * A + beta * self._syn_I
130
+ return torch.tanh(b + (actions - b) @ A.t())
131
+
132
+ def compute_actor_loss(self):
133
+ self._rag_max_gpu.zero_() # reset raw action-grad monitor for this window (GPU accum)
134
+ self._rag_nonfinite_gpu.zero_()
135
+ rew_acc = torch.zeros((self.steps_num + 1, self.num_envs), device=self.device)
136
+ gamma = torch.ones(self.num_envs, device=self.device)
137
+ next_values = torch.zeros((self.steps_num + 1, self.num_envs), device=self.device)
138
+ actor_loss = torch.zeros((), device=self.device)
139
+
140
+ rms = copy.deepcopy(self.obs_rms) # frozen normalization for this window
141
+ obs = self.env.initialize_trajectory() # detach state at the window boundary
142
+ self.obs_rms.update(obs)
143
+ obs = rms.normalize(obs)
144
+ for i in range(self.steps_num):
145
+ self.obs_buf[i] = obs.detach()
146
+ if self.ivw_h:
147
+ # Same reparameterized draw as self.actor(obs), but we also stash mu + the sample so the
148
+ # IVW-H hook can rebuild the noise w=a-mu, and V(s_i) as the ZoBG advantage baseline.
149
+ dist = self.actor.distribution(obs)
150
+ actions = dist.rsample() # stochastic (exploration), differentiable
151
+ with torch.no_grad():
152
+ self._ivw_mu[i] = dist.loc
153
+ self._ivw_act[i] = actions
154
+ self.val_buf[i] = self.critic(obs).squeeze(-1)
155
+ actions.register_hook(lambda g, i=i: self._action_grad_hook(g, i)) # blend at step i
156
+ else:
157
+ actions = self.actor(obs) # stochastic (exploration)
158
+ actions.register_hook(self._action_grad_hook) # record raw per-env grad (+ optional per-env clip)
159
+ obs_raw, rew, done, extra = self.env.step(self._env_action(actions))
160
+ self.obs_rms.update(obs_raw)
161
+ obs = rms.normalize(obs_raw)
162
+ base_next = self.target_critic(obs).squeeze(-1) # bootstrap value if the env keeps going
163
+
164
+ # (b) vectorized terminal handling -- replaces the .nonzero()+python loop that did a per-env
165
+ # host sync every step (parity-verified vs the loop across all branches). Override done envs:
166
+ # non-finite obr -> 0 ; early-term (fell, not ep_end) -> 0 ; timeout (ep_end, finite) -> bootstrap.
167
+ # Sanitize obr BEFORE the critic so torch.where cannot poison the graph with NaNs (non-finite
168
+ # envs feed zeros to the critic and are masked out). Non-finite wins over ep_end (matches the loop).
169
+ obr, ep_end = extra["obs_before_reset"], extra["episode_end"]
170
+ obr_valid = torch.isfinite(obr).all(dim=1) & (obr.abs() <= 1e6).all(dim=1)
171
+ obr_safe = torch.where(obr_valid[:, None], obr, torch.zeros_like(obr))
172
+ timeout_next = self.target_critic(rms.normalize(obr_safe)).squeeze(-1)
173
+ boot = done & ep_end & obr_valid
174
+ next_values[i + 1] = torch.where(
175
+ done, torch.where(boot, timeout_next, torch.zeros_like(base_next)), base_next)
176
+
177
+ rew_acc[i + 1] = rew_acc[i] + gamma * rew
178
+ if i < self.steps_num - 1: # finalize returns for just-terminated envs (masked sum)
179
+ actor_loss = actor_loss + ((-rew_acc[i + 1] - self.gamma * gamma * next_values[i + 1]) * done.float()).sum()
180
+ else: # truncate-bootstrap all envs at window end
181
+ actor_loss = actor_loss + (-rew_acc[i + 1] - self.gamma * gamma * next_values[i + 1]).sum()
182
+ gamma = torch.where(done, torch.ones_like(gamma), gamma * self.gamma)
183
+ rew_acc[i + 1] = torch.where(done, torch.zeros_like(rew_acc[i + 1]), rew_acc[i + 1])
184
+
185
+ with torch.no_grad(): # data for the critic regression
186
+ self.rew_buf[i] = rew
187
+ self.done_mask[i] = done.float() if i < self.steps_num - 1 else torch.ones(self.num_envs, device=self.device)
188
+ self.next_values[i] = next_values[i + 1]
189
+
190
+ if self.ivw_h:
191
+ # ZoBG material for the hooks (which fire during the upcoming actor_loss.backward()). All
192
+ # rollout buffers are now populated; compute the advantage-to-go, noise, and 1/sigma^2 once.
193
+ with torch.no_grad():
194
+ self._ivw_adv = self._gae(self.done_mask) # (S,N) reward-units advantage
195
+ self._ivw_w = self._ivw_act - self._ivw_mu # (S,N,A) = a - mu = sigma*eps
196
+ self._ivw_inv_var = torch.exp(-2.0 * self.actor.logstd.detach()) # (A,) 1/sigma^2
197
+ actor_loss = actor_loss / (self.steps_num * self.num_envs)
198
+ self.step_count += self.steps_num * self.num_envs
199
+ return actor_loss
200
+
201
+ def _action_grad_hook(self, g, i=None):
202
+ """Record the raw per-env action-grad L2 (pre-clip) for monitoring, then apply either the IVW-H
203
+ blend (if enabled, i = the rollout step this hook fires for) or the optional per-env clip. With
204
+ both off (humanoid default) the grad is returned unchanged, so training is numerically identical
205
+ to registering no hook -- only the monitor side-effect runs."""
206
+ with torch.no_grad():
207
+ n = g.detach().norm(dim=-1) # per-env L2 of the action gradient
208
+ fin = torch.isfinite(n) # accumulate on-device (NO per-step host sync)
209
+ self._rag_nonfinite_gpu.logical_or_((~fin).any())
210
+ # max over finite entries (non-finite -> 0; norms are >=0 so 0 is a safe floor / matches "no finite -> skip")
211
+ # in place (P3 of CAPTURE_PLAN.md: a captured backward replays this hook, so the monitor must keep one address)
212
+ self._rag_max_gpu.copy_(torch.maximum(self._rag_max_gpu, torch.where(fin, n, torch.zeros_like(n)).max()))
213
+ if self.ivw_h and i is not None:
214
+ # IVW-H: blend the pathwise action-grad g with the score-function ZoBG for this step. g here
215
+ # is d(actor_loss)/d(a_i) and actor_loss is normalized by S*N, so scale the summed-objective
216
+ # ZoBG ((-adv)*w/sigma^2) by 1/(S*N) to match g's scale. Replaces action_grad_clip.
217
+ scale = self.steps_num * self.num_envs
218
+ g_zo = ((-self._ivw_adv[i])[:, None] * self._ivw_w[i] * self._ivw_inv_var[None, :]) / scale
219
+ return self._ivw_blend(g, g_zo, adv_i=self._ivw_adv[i], inv_var=self._ivw_inv_var, gate_scale=scale)
220
+ if self.action_grad_clip is not None: # tame per-env BPTT gradient blow-ups
221
+ return _clip_grad_per_env(g, self.action_grad_clip)
222
+ return None
223
+
224
+ @torch.no_grad()
225
+ def _gae(self, done):
226
+ """GAE(gamma, lam) advantage-to-go from the stored rollout buffers: V(s_t)=val_buf (live critic),
227
+ bootstrap=next_values (target critic, terminal-handled during the rollout), terminal mask=done.
228
+ RpoVec passes done_real_buf (actual done); SHAC's IVW-H passes done_mask. Reward units."""
229
+ adv = torch.zeros((self.steps_num, self.num_envs), device=self.device)
230
+ gae = torch.zeros(self.num_envs, device=self.device)
231
+ for t in reversed(range(self.steps_num)):
232
+ nonterm = 1.0 - done[t]
233
+ delta = self.rew_buf[t] + self.gamma * self.next_values[t] - self.val_buf[t]
234
+ gae = delta + self.gamma * self.lam * nonterm * gae
235
+ adv[t] = gae
236
+ return adv
237
+
238
+ def _ivw_blend(self, g_fo, g_zo, adv_i=None, inv_var=None, gate_scale=1.0):
239
+ """Stepwise inverse-variance blend of the pathwise (FoBG) and score-function (ZoBG) action
240
+ gradients, per action-dim over the env batch (dim 0) -- called once per rollout step, so the
241
+ weight adapts along the horizon (docs/training/concepts/ivw-h-gradient.md). Suh et al. ICML 2022
242
+ (arXiv:2202.00817) give the variance-optimal weight alpha = v_zo/(v_fo+v_zo); we apply it
243
+ per-step per-dim WITHOUT the fragile gamma/REINFORCE-CI bias detector, following the 2026
244
+ critique (arXiv:2604.18161) which shows stepwise IVW-H beats AoBG in high dim / on contact.
245
+ alpha -> 1 (keep the fast pathwise signal) where FoBG is well-conditioned; alpha -> 0 (fall back
246
+ to the bounded-variance ZoBG) where the pathwise gradient explodes. g_fo, g_zo must be on the
247
+ SAME scale (both estimate d(objective)/d(a) for this step). Not variance-optimal (FoBG/ZoBG share
248
+ the rollout so they are correlated) but empirically robust and strictly better than clipping.
249
+
250
+ DDCG (self.ddcg): before applying alpha, gate the FoBG-trust by the smoothness test of Onoda/Parmas
251
+ 2604.18161 Eq.14, per action-dim: trust the FoBG (keep alpha_opt) only where its empirical variance
252
+ is large enough to be consistent with a locally-smooth function; otherwise set alpha=0 (pure ZoBG).
253
+ `adv_i` (N,) = the per-env return-to-go whose gradient these estimate; `inv_var` (A,) = 1/sigma^2 of
254
+ the smoothing (behavior) policy; `gate_scale` rescales V[f] to the gradients' scale (both g_fo/g_zo
255
+ here are divided by gate_scale relative to the summed-objective, so f is too => V[f]/gate_scale^2)."""
256
+ eta = self.ivw_eta
257
+ g_fo = torch.nan_to_num(g_fo, 0.0, 0.0, 0.0)
258
+ g_zo = torch.nan_to_num(g_zo, 0.0, 0.0, 0.0)
259
+ v_fo = g_fo.var(dim=0, unbiased=False) # (A,) FoBG variance across envs, per action-dim
260
+ v_zo = g_zo.var(dim=0, unbiased=False) # (A,) ZoBG variance across envs, per action-dim
261
+ alpha = (v_zo + eta) / (v_fo + v_zo + 2.0 * eta) # (A,)
262
+ if self.ddcg and adv_i is not None and inv_var is not None:
263
+ v_f = adv_i.var(unbiased=False) / (gate_scale * gate_scale) # V[f]: return variance at grad scale (scalar)
264
+ mean_fo2 = g_fo.mean(dim=0) ** 2 # (A,) ||grad-bar f||^2 per dim
265
+ rhs = 2.0 * (1.0 - self.ddcg_c) * v_f * inv_var - 2.0 * mean_fo2 # (A,) Eq.14 RHS
266
+ trust_fo = (v_fo + self.ddcg_eps_v) >= rhs # (A,) Eq.14: FoBG variance big enough => smooth
267
+ alpha = torch.where(trust_fo, alpha, torch.zeros_like(alpha)) # fail => alpha=0 => pure ZoBG (Eq.15)
268
+ return alpha[None, :] * g_fo + (1.0 - alpha)[None, :] * g_zo
269
+
270
+ @torch.no_grad()
271
+ def compute_target_values(self): # td-lambda returns (DiffRL)
272
+ Ai = torch.zeros(self.num_envs, device=self.device)
273
+ Bi = torch.zeros(self.num_envs, device=self.device)
274
+ lam = torch.ones(self.num_envs, device=self.device)
275
+ for i in reversed(range(self.steps_num)):
276
+ lam = lam * self.lam * (1.0 - self.done_mask[i]) + self.done_mask[i]
277
+ Ai = (1.0 - self.done_mask[i]) * (self.lam * self.gamma * Ai + self.gamma * self.next_values[i]
278
+ + (1.0 - lam) / (1.0 - self.lam) * self.rew_buf[i])
279
+ Bi = self.gamma * (self.next_values[i] * self.done_mask[i] + Bi * (1.0 - self.done_mask[i])) + self.rew_buf[i]
280
+ self.target_values[i] = (1.0 - self.lam) * Ai + lam * Bi
281
+
282
+ def train_critic(self):
283
+ obs = self.obs_buf.reshape(-1, self.num_obs)
284
+ tgt = self.target_values.reshape(-1)
285
+ n = obs.shape[0]
286
+ value_loss = 0.0
287
+ for _ in range(self.critic_iterations):
288
+ perm = torch.randperm(n, device=self.device)
289
+ ep_loss, nb = 0.0, 0
290
+ for s in range(0, n, self.batch_size):
291
+ idx = perm[s:s + self.batch_size]
292
+ self.critic_opt.zero_grad()
293
+ loss = ((self.critic(obs[idx]).squeeze(-1) - tgt[idx]) ** 2).mean()
294
+ loss.backward()
295
+ for p in self.critic.parameters():
296
+ p.grad.nan_to_num_(0.0, 0.0, 0.0)
297
+ clip_grad_norm_(self.critic.parameters(), self.grad_norm)
298
+ self.critic_opt.step()
299
+ ep_loss += loss.item()
300
+ nb += 1
301
+ value_loss = ep_loss / nb
302
+ return value_loss
303
+
304
+ def train(self, log_every=1, callback=None):
305
+ """callback(epoch, step_count, return_proxy, value_loss, grad_norm) is called every epoch
306
+ (after the actor/critic update); the runner uses it for periodic logging + eval without
307
+ disturbing the continuous training rollout."""
308
+ curve = []
309
+ for epoch in range(self.max_epochs):
310
+ if self.lr_schedule == "linear":
311
+ _off = getattr(self, "epoch_offset", 0) # warm-start: continue the anneal, don't restart at peak lr
312
+ frac = (epoch + _off) / (self.max_epochs + _off)
313
+ for g in self.actor_opt.param_groups:
314
+ g["lr"] = (1e-5 - self.actor_lr) * frac + self.actor_lr
315
+ for g in self.critic_opt.param_groups:
316
+ g["lr"] = (1e-5 - self.critic_lr) * frac + self.critic_lr
317
+
318
+ self.actor_opt.zero_grad()
319
+ actor_loss = self.compute_actor_loss()
320
+ actor_loss.backward()
321
+ gn = clip_grad_norm_(self.actor.parameters(), self.grad_norm)
322
+ if not torch.isfinite(gn):
323
+ raise ValueError(f"non-finite actor grad norm at epoch {epoch}")
324
+ self.actor_opt.step()
325
+
326
+ self.compute_target_values()
327
+ value_loss = self.train_critic()
328
+
329
+ with torch.no_grad(): # target-critic Polyak update
330
+ a = self.target_critic_alpha
331
+ for p, pt in zip(self.critic.parameters(), self.target_critic.parameters()):
332
+ pt.data.mul_(a)
333
+ pt.data.add_((1.0 - a) * p.data)
334
+
335
+ self.last_raw_action_grad_max = float(self._rag_max_gpu) # (a) single host sync/epoch (was ~2*steps_num)
336
+ self.last_raw_action_grad_nonfinite = bool(self._rag_nonfinite_gpu)
337
+ ret = -float(actor_loss.detach())
338
+ if (epoch + 1) % log_every == 0 or epoch == 0:
339
+ curve.append((self.step_count, ret, value_loss))
340
+ if callback is not None:
341
+ callback(epoch, self.step_count, ret, value_loss, float(gn))
342
+ return curve
343
+
344
+ @torch.no_grad()
345
+ def act(self, obs_raw, deterministic=True):
346
+ return self.actor(self.obs_rms.normalize(obs_raw), deterministic=deterministic)
@@ -0,0 +1,151 @@
1
+ """A learned state prior over (q, qdot, GRF): the VAE of Gambietz et al. 2026 (arXiv:2610.08506), re-implemented.
2
+
3
+ The upstream repository (github.com/gambimar/BiomechPriorVAE @ e0e9d3e) carries no LICENSE, so nothing is copied from it; the
4
+ architecture and the loss below are written from its paper and read against its code (docs-dev/20261016_1707_state_prior_review/):
5
+
6
+ encoder LayerNorm(D) -> Linear(H) -> GELU -> Linear(H, H) -> GELU -> RMSNorm(H) -> Linear(H, H) -> (mu, logvar) in R^Z,
7
+ logvar clamped to [-10, 10]
8
+ decoder Linear(Z, H) -> GELU -> RMSNorm(H) -> Linear(H, H) -> GELU -> Linear(H, 2D) -> (mean, 8 tanh(.) = log variance)
9
+ loss 0.1 * sum_d GNLL + KL(q(z|x) || N(0, I)) (the paper's L = GNLL / beta + KL with beta = 10), z sampled
10
+ cost the per-dim MEAN Gaussian NLL of x under Dec(Enc_mean(x)) in the UNSCALED units of x -- a reconstruction
11
+ likelihood, not the ELBO; the authors' vaeReconstructionTerm, evaluated at every collocation node
12
+
13
+ Smooth activations (GELU, RMSNorm) because the cost is differentiated by the optimiser that uses it. Inputs are standardised with
14
+ the training split's mean and std, which travel with the weights.
15
+ """
16
+ import torch
17
+ import torch.nn as nn
18
+
19
+
20
+ class StatePriorVAE(nn.Module):
21
+ def __init__(self, dim, latent=24, hidden=512):
22
+ super().__init__()
23
+ self.dim, self.latent, self.hidden = dim, latent, hidden
24
+ self.encoder = nn.Sequential(nn.LayerNorm(dim), nn.Linear(dim, hidden), nn.GELU(), nn.Linear(hidden, hidden), nn.GELU(),
25
+ nn.RMSNorm(hidden), nn.Linear(hidden, hidden))
26
+ self.fc_mu = nn.Linear(hidden, latent)
27
+ self.fc_logvar = nn.Linear(hidden, latent)
28
+ self.decoder = nn.Sequential(nn.Linear(latent, hidden), nn.GELU(), nn.RMSNorm(hidden), nn.Linear(hidden, hidden), nn.GELU(),
29
+ nn.Linear(hidden, 2 * dim))
30
+ self.register_buffer("x_mean", torch.zeros(dim))
31
+ self.register_buffer("x_std", torch.ones(dim))
32
+
33
+ def encode(self, xs):
34
+ h = self.encoder(xs)
35
+ return self.fc_mu(h), self.fc_logvar(h).clamp(-10.0, 10.0)
36
+
37
+ def decode(self, z):
38
+ out = self.decoder(z)
39
+ return out[..., :self.dim], torch.tanh(out[..., self.dim:]) * 8.0
40
+
41
+ def loss(self, xs, beta=1.0):
42
+ """Training loss on STANDARDISED inputs: (total, recon, kl), each a batch mean. beta = 1 is the authors' objective;
43
+ beta < 1 only during a KL warm-up (tools/state_prior/train_prior.py --kl-warmup)."""
44
+ mu, logvar = self.encode(xs)
45
+ z = mu + torch.randn_like(mu) * torch.exp(0.5 * logvar)
46
+ m, lv = self.decode(z)
47
+ recon = (0.5 * (lv + (xs - m) ** 2 * torch.exp(-lv))).sum(-1).mean()
48
+ kl = (-0.5 * (1.0 + logvar - mu ** 2 - logvar.exp()).sum(-1)).mean()
49
+ return 0.1 * recon + beta * kl, recon, kl
50
+
51
+ def nll(self, x):
52
+ """The prior cost: per-dim mean Gaussian NLL of UNSCALED x (..., D) under Dec(Enc_mean(x)). Differentiable in x."""
53
+ xs = (x - self.x_mean) / self.x_std
54
+ mu, _ = self.encode(xs)
55
+ m, lv = self.decode(mu)
56
+ mean = m * self.x_std + self.x_mean
57
+ log_var = lv + 2.0 * torch.log(self.x_std)
58
+ return (0.5 * (log_var + (x - mean) ** 2 * torch.exp(-log_var))).mean(-1)
59
+
60
+ def save(self, path, **meta):
61
+ torch.save(dict(state=self.state_dict(), dim=self.dim, latent=self.latent, hidden=self.hidden, meta=meta), path)
62
+
63
+ @staticmethod
64
+ def load(path, device="cpu"):
65
+ d = torch.load(path, map_location=device, weights_only=False)
66
+ m = StatePriorVAE(d["dim"], d["latent"], d["hidden"]).to(device)
67
+ m.load_state_dict(d["state"])
68
+ m.eval()
69
+ return m, d["meta"]
70
+
71
+
72
+ def ball_zxy(qw, qx, qy, qz):
73
+ """ZXY intrinsic Euler angles (flexion, adduction, rotation) of a Ball quaternion: core/dyn/ball_limit.h ball_euler_zxy."""
74
+ R01, R11 = 2.0 * (qx * qy - qw * qz), 1.0 - 2.0 * (qx * qx + qz * qz)
75
+ R20, R21, R22 = 2.0 * (qx * qz - qw * qy), 2.0 * (qy * qz + qw * qx), 1.0 - 2.0 * (qx * qx + qy * qy)
76
+ return torch.atan2(-R01, R11), torch.atan2(R21, torch.sqrt(R01 * R01 + R11 * R11)), torch.atan2(-R20, R22)
77
+
78
+
79
+ def ball_zxy_rates(f, a, r, wx, wy, wz):
80
+ """theta_dot = E(theta) omega, omega the CHILD-frame angular velocity: core/dyn/ball_limit.h ball_euler_rate_map."""
81
+ sa, ca, sr, cr = torch.sin(a), torch.cos(a), torch.sin(r), torch.cos(r)
82
+ return (-sr / ca * wx + cr / ca * wz,
83
+ cr * wx + sr * wz,
84
+ sa * sr / ca * wx + wy - sa * cr / ca * wz)
85
+
86
+
87
+ class FullbodyPriorMap:
88
+ """The full-body lane's state -> the prior's 30 features, in the order and conventions of build_features.py `fullbody`:
89
+ 13 angles (hip flexion / adduction / rotation, knee, ankle per leg [r, l], lumbar extension / bending / rotation), their
90
+ 13 rates, and per foot [vertical, horizontal magnitude] ground reaction in body weights.
91
+
92
+ hips the engine's ZXY chart of the Ball quaternion, rates by its closed-form E(theta) on the child-frame omega. The
93
+ LEFT hip is composed from OpenSim's mirrored axes (+z, -x, -y; models/fullbody_contact.dnmodel, imitation.
94
+ adapt_reference), so Rajagopal's left adduction and rotation are the chart's NEGATED.
95
+ knee, ankle copied: the model's knee is Rajagopal's (flexion positive), the ankle shares Rajagopal's axis.
96
+ lumbar a degree-5 polynomial in the three spine masters (tools/state_prior/fit_lumbar_map.py; 0.024 deg max over the
97
+ model's lumbar ROM), rates as its analytic gradient times the master rates. No FK, no finite difference.
98
+ GRF grf_bw (..., 2, 3) per foot [right, left] in the world frame (x forward, y left, z up), in body weights;
99
+ horizontal magnitude with the authors' +1e-12 inside the root (the swing foot's zero force has no gradient).
100
+ Every input is differentiated through, so the prior's gradient reaches q, qd and the contact force's VJP.
101
+ """
102
+
103
+ def __init__(self, jm, lumbar_npz, device="cpu"):
104
+ import numpy as np
105
+ B = jm["bodies"]
106
+
107
+ def owned(name):
108
+ hits = [b for b in B if b.get("joint_name") == name and "coupled" not in b]
109
+ assert len(hits) == 1, (name, len(hits))
110
+ return hits[0]
111
+ self.hips = []
112
+ for s in "rl":
113
+ b = owned(f"hip_flexion_{s}")
114
+ assert b["joint"] == "ball", (s, b["joint"])
115
+ self.hips.append((int(b["qadr"]), int(b["vadr"])))
116
+ self.scalars = [(int(owned(n)["qadr"]), int(owned(n)["vadr"])) for n in
117
+ ("knee_angle_r", "ankle_angle_r", "knee_angle_l", "ankle_angle_l")]
118
+ L = np.load(lumbar_npz)
119
+ self.lumbar_qadr = [int(v) for v in L["qadr"]]
120
+ self.lumbar_vadr = [int(owned(n)["vadr"]) for n in ("flex_extension", "lat_bending", "axial_rotation")]
121
+ assert self.lumbar_qadr == [int(owned(n)["qadr"]) for n in ("flex_extension", "lat_bending", "axial_rotation")]
122
+ E = torch.tensor(L["exponents"], dtype=torch.float32, device=device)
123
+ self.E, self.Em1, self.Emask = E, (E - 1).clamp(min=0), E > 0
124
+ self.coef = torch.tensor(L["coef"], dtype=torch.float32, device=device)
125
+
126
+ def _lumbar(self, m, md):
127
+ P = m[..., None, :] ** self.E # (..., J, 3)
128
+ ang = P.prod(-1) @ self.coef
129
+ D = torch.where(self.Emask, self.E * m[..., None, :] ** self.Em1, torch.zeros_like(P))
130
+ rate = 0
131
+ for i in range(3):
132
+ Pi = torch.cat([P[..., :i], D[..., i:i + 1], P[..., i + 1:]], -1).prod(-1)
133
+ rate = rate + (Pi @ self.coef) * md[..., i:i + 1]
134
+ return ang, rate
135
+
136
+ def features(self, q, qd, grf_bw):
137
+ """q (..., nq), qd (..., nv), grf_bw (..., 2, 3) -> (..., 30)."""
138
+ ang, rate = [], []
139
+ for side, (qa, va) in enumerate(self.hips):
140
+ f, a, r = ball_zxy(q[..., qa], q[..., qa + 1], q[..., qa + 2], q[..., qa + 3])
141
+ fd, ad, rd = ball_zxy_rates(f, a, r, qd[..., va], qd[..., va + 1], qd[..., va + 2])
142
+ sgn = 1.0 if side == 0 else -1.0
143
+ (kq, kv), (aq, av) = self.scalars[2 * side], self.scalars[2 * side + 1]
144
+ ang += [f, sgn * a, sgn * r, q[..., kq], q[..., aq]]
145
+ rate += [fd, sgn * ad, sgn * rd, qd[..., kv], qd[..., av]]
146
+ la, lr = self._lumbar(q[..., self.lumbar_qadr], qd[..., self.lumbar_vadr])
147
+ F = grf_bw
148
+ Fv = F[..., 2]
149
+ Fh = torch.sqrt(F[..., 0] ** 2 + F[..., 1] ** 2 + 1e-12)
150
+ return torch.cat([torch.stack(ang, -1), la, torch.stack(rate, -1), lr,
151
+ torch.stack([Fv[..., 0], Fh[..., 0], Fv[..., 1], Fh[..., 1]], -1)], -1)
@@ -0,0 +1,105 @@
1
+ """DeepLoco's per-step reference (Peng et al. 2017, anim/MocapStepController.cpp) over a library of single steps, for the
2
+ footstep task's tracking arm (TASKWALK_TRACK_PHASE=steps, TASKWALK_STEP_LIBRARY = a tools/steer/build_step_library.py
3
+ library.json).
4
+
5
+ At every new plan step the env asks for the library entry nearest to the body's state (SelectNewMotion ->
6
+ BuildPoseMotionFeatures -> FindNearestMotion):
7
+ - the state, in the root's heading frame (NormalizePoseHeading: the root at the origin facing +x), MIRRORED when the plan's
8
+ stance is the left foot (ShouldMirrorPose -> MirrorPoseStance; the plan's p0 and heading direction get their lateral part
9
+ negated, as BuildPoseMotionFeatures does): the stance foot, the swing foot, the swing target p0, and the plan heading
10
+ relative to the root's;
11
+ - against each entry's (right foot start, left foot start, left foot end, end heading) with the library's weights
12
+ (CalcMotionFeatureDist: the squared weighted difference);
13
+ - the nearest entry k is played as clip k for a right stance and as its mirrored copy, clip k + n, for a left stance (DeepLoco
14
+ mirrors the pose it plays, CalcMotionPose; the library ships both copies).
15
+ The joints below the root are tracked by task_walk_reward.track_pose_error. DeepLoco's END-EFFECTOR term (CalcRewardStep: each end
16
+ effector's position relative to the root in the root's heading frame, against the clip's, x 2 / n_end_effs, inside exp(-5 err)
17
+ with the footstep error) is ee_ref() + the env's TASKWALK_STEP_EE: the feet (calcanei; the model is armless, DeepLoco's
18
+ IsEndEffector set is every leaf joint), horizontal by default. DeepLoco's vertical is each foot's height above the ground; the
19
+ turning retargets skip the loop pipeline's re-grounding, so their floor heights are not comparable, and TASKWALK_STEP_EE_H=1
20
+ compares each foot's height above the LOWER foot instead (ee_h_ref(), the definition llc_reward.root_height_above_feet uses).
21
+ Without it the swing foot's lift is priced by the knee and ankle angles alone, and llccold marched (a 103-mm lift against the
22
+ human clips' 58 at the same speed, docs-dev/deeploco/20261024_0930_llc_cold/marching). Because both sides are root-relative,
23
+ DeepLoco's re-anchoring of the clip's root to the character's (UpdateNewStep's
24
+ origin transform) is not needed. The joints alone cannot tell a pivoting step from one over a planted foot (2026-10-23, fslibw50:
25
+ the pose followed, the stance foot did not pivot); the root-relative feet can. The clip is played over
26
+ the plan's nominal step time L / v (the human's at the command), DeepLoco's fixed 0.5-s clock time warp in our speed-commanded
27
+ task, and held on its last frame until the step ends. The clips are OPEN (ImitationTask cyclic=False): before 2026-10-24 they were
28
+ indexed as closed loops, so the last 1/T of the step and the whole hold blended the last frame 90-96% into the step's FIRST frame.
29
+ """
30
+ import json
31
+ import math
32
+ import pathlib
33
+
34
+ import torch
35
+
36
+ from diffneusim.rl.imitation import ImitationTask
37
+
38
+
39
+ def _yaw(q):
40
+ w, x, y, z = q[3], q[4], q[5], q[6]
41
+ return torch.atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (y * y + z * z))
42
+
43
+
44
+ class StepLibrary:
45
+ def __init__(self, F, w, task=None, meta=None):
46
+ """F (n, 7) the entries' features, w (7,) the weights; task = the ImitationTask holding the 2n clips (load())."""
47
+ self.F, self.w, self.n = F, w, int(F.shape[0])
48
+ assert F.ndim == 2 and F.shape[1] == 7 and w.shape == (7,), (F.shape, w.shape)
49
+ if task is not None:
50
+ assert task.n_clips == 2 * self.n, (task.n_clips, self.n)
51
+ self.task, self.meta = task, meta
52
+
53
+ def build_ee(self, monitor, feet):
54
+ """The clips' feet relative to the root, (x ahead, y left) in each frame's root heading frame: (sum_T, 2 feet, 2); and each
55
+ foot's height above the lower of the two, ee_h (sum_T, 2 feet)."""
56
+ q = self.task.ref_q.t().contiguous() # (nq, sum_T), the training model's layout
57
+ with torch.no_grad():
58
+ pos, _, _ = monitor.body_poses_subset(q, list(feet), False)
59
+ yaw = _yaw(q)
60
+ c, s = torch.cos(yaw), torch.sin(yaw)
61
+ out = []
62
+ for b in feet:
63
+ d = pos[b][0:2] - q[0:2]
64
+ out.append(torch.stack([c * d[0] + s * d[1], -s * d[0] + c * d[1]], -1)) # (sum_T, 2)
65
+ self.ee = torch.stack(out, 1) # (sum_T, 2, 2)
66
+ z = torch.stack([pos[b][2] for b in feet], 1) # (sum_T, 2)
67
+ self.ee_h = z - z.min(1, keepdim=True).values
68
+
69
+ def ee_ref(self, phase):
70
+ """(2 feet, 2, n) the reference feet relative to the root at each env's clip and phase."""
71
+ i0, i1, wf = self.task.frame_idx(phase)
72
+ e = self.ee[i0] * (1.0 - wf)[:, None, None] + self.ee[i1] * wf[:, None, None] # (n, 2, 2)
73
+ return e.permute(1, 2, 0)
74
+
75
+ def ee_h_ref(self, phase):
76
+ """(2 feet, n) the reference feet's heights above the lower foot at each env's clip and phase."""
77
+ i0, i1, wf = self.task.frame_idx(phase)
78
+ return (self.ee_h[i0] * (1.0 - wf)[:, None] + self.ee_h[i1] * wf[:, None]).t()
79
+
80
+ @classmethod
81
+ def load(cls, path, morph, monitor, device, model_jm):
82
+ path = pathlib.Path(path)
83
+ meta = json.load(open(path))
84
+ assert int(meta["n"]) >= 1 and len(meta["entries"]) == int(meta["n"]), (path, meta["n"])
85
+ F = torch.tensor([e["feat"] for e in meta["entries"]], dtype=torch.float32, device=device)
86
+ w = torch.tensor(meta["weights"], dtype=torch.float32, device=device)
87
+ task = ImitationTask(morph, str(path.parent / "clips.txt"), monitor, device, model_jm=model_jm, cyclic=False) # single steps
88
+ return cls(F, w, task, meta)
89
+
90
+ def features(self, stance_left, stance_xy, swing_xy, p0, plan_heading, root_xy, root_yaw):
91
+ """(m, 7) BuildPoseMotionFeatures for m envs; every argument (2, m) or (m,) world, detached."""
92
+ c, s = torch.cos(root_yaw), torch.sin(root_yaw)
93
+ def loc(p): # world -> the root's heading frame
94
+ d = p - root_xy
95
+ return c * d[0] + s * d[1], -s * d[0] + c * d[1]
96
+ st, sw, tg = loc(stance_xy), loc(swing_xy), loc(p0)
97
+ h = torch.remainder(plan_heading - root_yaw + math.pi, 2.0 * math.pi) - math.pi
98
+ sg = torch.where(stance_left, -1.0, 1.0).to(h.dtype) # a left stance is read in the mirrored frame
99
+ return torch.stack([st[0], sg * st[1], sw[0], sg * sw[1], tg[0], sg * tg[1], sg * h], 1)
100
+
101
+ def select(self, feat, stance_left):
102
+ """FindNearestMotion: the clip id (k for a right stance, k + n for the mirrored copy) of the nearest entry, (m,)."""
103
+ d = (((feat[:, None, :] - self.F[None]) * self.w) ** 2).sum(-1) # (m, n)
104
+ k = d.argmin(1)
105
+ return k + torch.where(stance_left, self.n, 0)