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,458 @@
1
+ """CPU-side geometry: unit primitive meshes (pos+normal) + matrix/quaternion math.
2
+
3
+ Meshes are generated once on the host as (vertices[N,3], normals[N,3],
4
+ indices[M]); the renderer uploads them and draws each geom with a per-frame
5
+ model matrix (geom local offset/quat composed with the body pose, scaled by
6
+ size). Matches the geom-type/size table in docs/engine/concepts/renderer.md.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import pathlib
11
+ import struct
12
+
13
+ import numpy as np
14
+
15
+
16
+ # ----------------------------------------------------------------------------
17
+ # Math: 4x4 column-major matrices (OpenGL convention), quaternion [w,x,y,z].
18
+ # ----------------------------------------------------------------------------
19
+ def quat_to_mat3(q: np.ndarray) -> np.ndarray:
20
+ w, x, y, z = q
21
+ return np.array([
22
+ [1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w)],
23
+ [2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w)],
24
+ [2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)],
25
+ ], dtype=np.float32)
26
+
27
+
28
+ def trs(pos: np.ndarray, quat: np.ndarray, scale: np.ndarray) -> np.ndarray:
29
+ """4x4 model matrix = Translate * Rotate * Scale (returned row-major for numpy;
30
+ transpose at upload time for column-major GLSL)."""
31
+ m = np.eye(4, dtype=np.float32)
32
+ R = quat_to_mat3(quat)
33
+ m[:3, :3] = R * scale[np.newaxis, :] # scale columns (per-axis)
34
+ m[:3, 3] = pos
35
+ return m
36
+
37
+
38
+ def quat_mul(a: np.ndarray, b: np.ndarray) -> np.ndarray:
39
+ aw, ax, ay, az = a
40
+ bw, bx, by, bz = b
41
+ return np.array([
42
+ aw * bw - ax * bx - ay * by - az * bz,
43
+ aw * bx + ax * bw + ay * bz - az * by,
44
+ aw * by - ax * bz + ay * bw + az * bx,
45
+ aw * bz + ax * by - ay * bx + az * bw,
46
+ ], dtype=np.float32)
47
+
48
+
49
+ def quat_rotate(q: np.ndarray, v: np.ndarray) -> np.ndarray:
50
+ return quat_to_mat3(q) @ v
51
+
52
+
53
+ def perspective(fovy_deg: float, aspect: float, near: float, far: float) -> np.ndarray:
54
+ f = 1.0 / np.tan(np.radians(fovy_deg) * 0.5)
55
+ m = np.zeros((4, 4), dtype=np.float32)
56
+ m[0, 0] = f / aspect
57
+ m[1, 1] = f
58
+ m[2, 2] = (far + near) / (near - far)
59
+ m[2, 3] = (2 * far * near) / (near - far)
60
+ m[3, 2] = -1.0
61
+ return m
62
+
63
+
64
+ def ortho(left, right, bottom, top, near, far) -> np.ndarray:
65
+ """Orthographic projection (OpenGL clip, row-major). Used for the directional
66
+ light's shadow-map camera (a parallel projection)."""
67
+ m = np.eye(4, dtype=np.float32)
68
+ m[0, 0] = 2.0 / (right - left)
69
+ m[1, 1] = 2.0 / (top - bottom)
70
+ m[2, 2] = -2.0 / (far - near)
71
+ m[0, 3] = -(right + left) / (right - left)
72
+ m[1, 3] = -(top + bottom) / (top - bottom)
73
+ m[2, 3] = -(far + near) / (far - near)
74
+ return m
75
+
76
+
77
+ def look_at(eye: np.ndarray, target: np.ndarray, up: np.ndarray) -> np.ndarray:
78
+ f = target - eye
79
+ f = f / (np.linalg.norm(f) + 1e-9)
80
+ s = np.cross(f, up)
81
+ s = s / (np.linalg.norm(s) + 1e-9)
82
+ u = np.cross(s, f)
83
+ m = np.eye(4, dtype=np.float32)
84
+ m[0, :3] = s
85
+ m[1, :3] = u
86
+ m[2, :3] = -f
87
+ m[0, 3] = -np.dot(s, eye)
88
+ m[1, 3] = -np.dot(u, eye)
89
+ m[2, 3] = np.dot(f, eye)
90
+ return m
91
+
92
+
93
+ # ----------------------------------------------------------------------------
94
+ # Primitive mesh generators -> (verts[N,3] float32, normals[N,3], idx[M] uint32)
95
+ # All are UNIT meshes; the renderer scales by `size` per geom.
96
+ # ----------------------------------------------------------------------------
97
+ def _finalize(verts, normals, faces):
98
+ return (np.asarray(verts, dtype=np.float32),
99
+ np.asarray(normals, dtype=np.float32),
100
+ np.asarray(faces, dtype=np.uint32).reshape(-1))
101
+
102
+
103
+ # ----------------------------------------------------------------------------
104
+ # STL bone-mesh loader (binary + ASCII) -> the same (verts, normals, idx) tuple
105
+ # the primitives return, so the renderer uploads it through the identical path.
106
+ # Flat-shaded: every triangle keeps its own 3 vertices with a shared face normal
107
+ # (matching unit_box), so no vertex welding / smoothing is needed and negative
108
+ # per-axis scales (left-side mirror meshes) stay correct — the renderer's
109
+ # inverse-transpose normal matrix flips the face normals for a mirrored geom.
110
+ # ----------------------------------------------------------------------------
111
+ _STL_CACHE: dict[str, tuple] = {}
112
+
113
+
114
+ def _tri_soup_to_mesh(tris: np.ndarray):
115
+ """tris[(T,3,3)] triangle vertex soup -> flat-shaded (verts[3T,3], normals[3T,3], idx[3T])."""
116
+ tris = np.asarray(tris, dtype=np.float64)
117
+ assert tris.ndim == 3 and tris.shape[1:] == (3, 3), tris.shape
118
+ e1 = tris[:, 1] - tris[:, 0]
119
+ e2 = tris[:, 2] - tris[:, 0]
120
+ fn = np.cross(e1, e2) # (T,3) face normals
121
+ ln = np.linalg.norm(fn, axis=1, keepdims=True)
122
+ fn = np.where(ln > 1e-12, fn / np.maximum(ln, 1e-12), np.array([0.0, 0.0, 1.0]))
123
+ verts = tris.reshape(-1, 3)
124
+ normals = np.repeat(fn, 3, axis=0)
125
+ faces = np.arange(verts.shape[0], dtype=np.uint32)
126
+ return _finalize(verts, normals, faces)
127
+
128
+
129
+ def _parse_binary_stl(data: bytes):
130
+ n_tri = struct.unpack_from("<I", data, 80)[0]
131
+ expected = 84 + n_tri * 50
132
+ assert len(data) == expected, f"binary STL size {len(data)} != 84 + 50*{n_tri} = {expected}"
133
+ rec = np.dtype([("n", "<3f4"), ("v", "<9f4"), ("attr", "<u2")])
134
+ arr = np.frombuffer(data, dtype=rec, count=n_tri, offset=84)
135
+ return _tri_soup_to_mesh(arr["v"].reshape(n_tri, 3, 3).astype(np.float64))
136
+
137
+
138
+ def _parse_ascii_stl(text: str):
139
+ verts = []
140
+ for line in text.splitlines():
141
+ s = line.strip()
142
+ if s.startswith("vertex"):
143
+ parts = s.split()
144
+ assert len(parts) == 4, f"malformed STL vertex line: {line!r}"
145
+ verts.append((float(parts[1]), float(parts[2]), float(parts[3])))
146
+ assert verts and len(verts) % 3 == 0, f"ASCII STL vertex count {len(verts)} not a multiple of 3"
147
+ return _tri_soup_to_mesh(np.asarray(verts, dtype=np.float64).reshape(-1, 3, 3))
148
+
149
+
150
+ def load_stl(path):
151
+ """Load a triangle mesh from a binary or ASCII STL file into the renderer's
152
+ (verts[N,3] f32, normals[N,3] f32, faces[M] uint32) convention. Result cached
153
+ by resolved absolute path (scale/pose are applied per-geom by the renderer, so
154
+ the raw mesh is shared across every geom that references the same file)."""
155
+ key = str(pathlib.Path(path).resolve())
156
+ cached = _STL_CACHE.get(key)
157
+ if cached is not None:
158
+ return cached
159
+ with open(key, "rb") as f:
160
+ data = f.read()
161
+ assert len(data) >= 84, f"STL too small ({len(data)} bytes): {key}"
162
+ # Discriminate by the binary size formula (an ASCII file starting with "solid"
163
+ # would not satisfy 84 + 50*n_tri): binary if it matches, ASCII otherwise.
164
+ n_tri = struct.unpack_from("<I", data, 80)[0]
165
+ if len(data) == 84 + n_tri * 50:
166
+ mesh = _parse_binary_stl(data)
167
+ else:
168
+ mesh = _parse_ascii_stl(data.decode("ascii", errors="strict"))
169
+ _STL_CACHE[key] = mesh
170
+ return mesh
171
+
172
+
173
+ def unit_box():
174
+ # half-extent 1 cube (renderer scales by size = half-extents -> +/- size).
175
+ v = []
176
+ n = []
177
+ faces = []
178
+ # 6 faces, each with its own normal (flat shading)
179
+ dirs = [
180
+ ((1, 0, 0), [(1, -1, -1), (1, 1, -1), (1, 1, 1), (1, -1, 1)]),
181
+ ((-1, 0, 0), [(-1, -1, 1), (-1, 1, 1), (-1, 1, -1), (-1, -1, -1)]),
182
+ ((0, 1, 0), [(-1, 1, -1), (-1, 1, 1), (1, 1, 1), (1, 1, -1)]),
183
+ ((0, -1, 0), [(1, -1, -1), (1, -1, 1), (-1, -1, 1), (-1, -1, -1)]),
184
+ ((0, 0, 1), [(-1, -1, 1), (1, -1, 1), (1, 1, 1), (-1, 1, 1)]),
185
+ ((0, 0, -1), [(-1, 1, -1), (1, 1, -1), (1, -1, -1), (-1, -1, -1)]),
186
+ ]
187
+ for normal, quad in dirs:
188
+ base = len(v)
189
+ for p in quad:
190
+ v.append(p)
191
+ n.append(normal)
192
+ faces += [base, base + 1, base + 2, base, base + 2, base + 3]
193
+ return _finalize(v, n, faces)
194
+
195
+
196
+ def _sphere_grid(scale_xyz, lat=20, lon=28):
197
+ """Sphere/ellipsoid via lat-lon grid. scale_xyz applied to a unit sphere; the
198
+ normal of an axis-scaled sphere is (n / scale) renormalized."""
199
+ sx, sy, sz = scale_xyz
200
+ verts, norms, faces = [], [], []
201
+ for i in range(lat + 1):
202
+ theta = np.pi * i / lat # 0..pi
203
+ st, ct = np.sin(theta), np.cos(theta)
204
+ for j in range(lon + 1):
205
+ phi = 2 * np.pi * j / lon
206
+ sp_, cp = np.sin(phi), np.cos(phi)
207
+ ux, uy, uz = st * cp, st * sp_, ct # unit sphere point/normal
208
+ verts.append((ux * sx, uy * sy, uz * sz))
209
+ nrm = np.array([ux / sx, uy / sy, uz / sz], dtype=np.float64)
210
+ nrm /= (np.linalg.norm(nrm) + 1e-12)
211
+ norms.append(nrm)
212
+ row = lon + 1
213
+ for i in range(lat):
214
+ for j in range(lon):
215
+ a = i * row + j
216
+ b = a + row
217
+ faces += [a, b, a + 1, a + 1, b, b + 1]
218
+ return _finalize(verts, norms, faces)
219
+
220
+
221
+ def unit_sphere():
222
+ return _sphere_grid((1.0, 1.0, 1.0))
223
+
224
+
225
+ def ellipsoid(ax, ay, az):
226
+ return _sphere_grid((ax, ay, az))
227
+
228
+
229
+ def capsule(radius, half_len, seg=24, hemi=8):
230
+ """Capsule along local z: cylinder of length 2*half_len + 2 hemispheres of
231
+ `radius`. Built at actual size (not unit) because radius != length scaling."""
232
+ verts, norms, faces = [], [], []
233
+ rings = [] # list of (start_index, z, is_pole)
234
+
235
+ def add_ring(z, r, nz_sign_for_cap=None):
236
+ base = len(verts)
237
+ for j in range(seg + 1):
238
+ phi = 2 * np.pi * j / seg
239
+ cx, cy = np.cos(phi), np.sin(phi)
240
+ verts.append((r * cx, r * cy, z))
241
+ if nz_sign_for_cap is None: # cylinder wall normal is radial
242
+ norms.append((cx, cy, 0.0))
243
+ else:
244
+ # hemisphere: normal points from sphere center
245
+ cz = nz_sign_for_cap * np.sqrt(max(0.0, radius * radius - r * r))
246
+ nrm = np.array([r * cx, r * cy, cz], dtype=np.float64)
247
+ nrm /= (np.linalg.norm(nrm) + 1e-12)
248
+ norms.append(nrm)
249
+ rings.append(base)
250
+
251
+ # bottom hemisphere: polar angle from south pole, pi/2 (equator) -> 0 (pole).
252
+ # z = -half_len - radius*cos(polar), r = radius*sin(polar).
253
+ for i in range(hemi + 1):
254
+ polar = np.pi * 0.5 * (1 - i / hemi) # pi/2 -> 0
255
+ z = -half_len - radius * np.cos(polar)
256
+ r = radius * np.sin(polar)
257
+ add_ring(z, r, nz_sign_for_cap=-1.0)
258
+ # cylinder wall
259
+ add_ring(-half_len, radius)
260
+ add_ring(half_len, radius)
261
+ # top hemisphere: polar 0 (equator) -> pi/2 (north pole).
262
+ # z = half_len + radius*sin(polar), r = radius*cos(polar).
263
+ for i in range(hemi + 1):
264
+ polar = np.pi * 0.5 * (i / hemi) # 0 -> pi/2
265
+ z = half_len + radius * np.sin(polar)
266
+ r = radius * np.cos(polar)
267
+ add_ring(z, r, nz_sign_for_cap=1.0)
268
+
269
+ row = seg + 1
270
+ for k in range(len(rings) - 1):
271
+ a0 = rings[k]
272
+ b0 = rings[k + 1]
273
+ for j in range(seg):
274
+ a = a0 + j
275
+ b = b0 + j
276
+ faces += [a, b, a + 1, a + 1, b, b + 1]
277
+ return _finalize(verts, norms, faces)
278
+
279
+
280
+ def unit_cylinder(seg=24):
281
+ """Cylinder of radius 1 along local z, spanning z in [-0.5, 0.5] (no caps).
282
+ Renderer scales [r, r, length] to span an arbitrary segment. No hemispheres,
283
+ so the drawn extent is exactly the requested length (used for the MTU line)."""
284
+ verts, norms, faces = [], [], []
285
+ for z in (-0.5, 0.5):
286
+ for j in range(seg + 1):
287
+ phi = 2 * np.pi * j / seg
288
+ cx, cy = np.cos(phi), np.sin(phi)
289
+ verts.append((cx, cy, z))
290
+ norms.append((cx, cy, 0.0))
291
+ row = seg + 1
292
+ for j in range(seg):
293
+ a = j
294
+ b = row + j
295
+ faces += [a, b, a + 1, a + 1, b, b + 1]
296
+ return _finalize(verts, norms, faces)
297
+
298
+
299
+ def parallel_frames(centerline):
300
+ """Per-point unit tangent T and a PARALLEL-TRANSPORTED cross-section normal Nrm along a polyline
301
+ (N,3), so the frame (T, Nrm, T x Nrm) slides down the curve without twisting. Shared by swept_tube
302
+ and the VIPER-style muscle bundle (which offsets sub-rods in this cross-section frame)."""
303
+ P = np.asarray(centerline, np.float64)
304
+ N = len(P)
305
+ T = np.zeros((N, 3))
306
+ T[1:-1] = P[2:] - P[:-2]
307
+ T[0] = P[1] - P[0]
308
+ T[-1] = P[-1] - P[-2]
309
+ T /= (np.linalg.norm(T, axis=1, keepdims=True) + 1e-12)
310
+ ref = np.array([0.0, 0.0, 1.0]) if abs(T[0, 2]) < 0.9 else np.array([1.0, 0.0, 0.0])
311
+ n = ref - T[0] * np.dot(ref, T[0])
312
+ n /= np.linalg.norm(n) + 1e-12
313
+ # Sequential parallel transport (each frame depends on the previous). Uses SCALAR component math --
314
+ # np.cross/np.linalg.norm on single 3-vectors carry huge per-call overhead and dominated the profile.
315
+ Nrm = np.empty((N, 3))
316
+ Nrm[0] = n
317
+ px, py, pz = float(n[0]), float(n[1]), float(n[2])
318
+ for i in range(1, N):
319
+ ax, ay, az = T[i - 1]
320
+ bx, by, bz = T[i]
321
+ vx, vy, vz = ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx # cross(T[i-1], T[i])
322
+ s = (vx * vx + vy * vy + vz * vz) ** 0.5
323
+ c = ax * bx + ay * by + az * bz
324
+ if s < 1e-9:
325
+ nx, ny, nz = px, py, pz
326
+ else:
327
+ vx, vy, vz = vx / s, vy / s, vz / s
328
+ kx, ky, kz = vy * pz - vz * py, vz * px - vx * pz, vx * py - vy * px # cross(v, p)
329
+ vdp = (vx * px + vy * py + vz * pz) * (1.0 - c) # Rodrigues rotate p
330
+ nx, ny, nz = px * c + kx * s + vx * vdp, py * c + ky * s + vy * vdp, pz * c + kz * s + vz * vdp
331
+ d = nx * bx + ny * by + nz * bz # re-orthogonalise vs T[i]
332
+ nx, ny, nz = nx - bx * d, ny - by * d, nz - bz * d
333
+ inv = 1.0 / ((nx * nx + ny * ny + nz * nz) ** 0.5 + 1e-12)
334
+ px, py, pz = nx * inv, ny * inv, nz * inv
335
+ Nrm[i] = (px, py, pz)
336
+ return T, Nrm
337
+
338
+
339
+ def swept_tube(centerline, radii, seg=14, caps=True, aspect=1.0, radial=None):
340
+ """Smooth generalized cylinder swept along a polyline `centerline` (N,3) with per-vertex `radii`
341
+ (N,). Returns (verts, normals, uv, tangents, faces) as float32/int32 arrays -- richer than the
342
+ (pos,normal,idx) primitives above because the muscle shader needs a fibre parametrisation:
343
+ uv = (around in [0,1], normalised arc-length in [0,1]), tangent = fibre (along-length) direction.
344
+ `aspect`>1 makes the cross-section an ELLIPSE (WIDE semi-axis r*sqrt(aspect), THIN r/sqrt(aspect);
345
+ area/volume preserved) -- an anatomical FLATTENED belly. Cross-section ORIENTATION: if `radial` (N,3,
346
+ a per-point outward direction) is given, the THIN axis aligns with it (projected perpendicular to the
347
+ tangent) and the WIDE axis is tangential -- so the muscle hugs the limb like a strap rather than
348
+ flattening in an arbitrary parallel-transport direction; else the frame is parallel-transported (no
349
+ twist). `caps` adds a flat triangle-fan at each end so a thin open tube end does not show a hole."""
350
+ P = np.asarray(centerline, np.float64)
351
+ R = np.asarray(radii, np.float64)
352
+ N = len(P)
353
+ assert N >= 2 and R.shape[0] == N, (P.shape, R.shape)
354
+ T, Nrm = parallel_frames(P) # tangent + non-twisting fallback normal
355
+ seglen = np.linalg.norm(P[1:] - P[:-1], axis=1)
356
+ s_phys = np.concatenate([[0.0], np.cumsum(seglen)]) # physical arc-length (m)
357
+ arc = s_phys / (s_phys[-1] + 1e-12) # normalised [0,1] for uv.y
358
+ dRds = np.gradient(R, s_phys + 1e-9) # radius slope along the axis
359
+ ka, kb = np.sqrt(aspect), 1.0 / np.sqrt(aspect) # WIDE / THIN ellipse semi-axis scales
360
+ if radial is not None:
361
+ rad = np.asarray(radial, np.float64)
362
+ thin = rad - T * np.einsum("ij,ij->i", rad, T)[:, None] # radial component perpendicular to tangent
363
+ tn = np.linalg.norm(thin, axis=1)
364
+ bad = tn < 1e-9
365
+ thin[bad], tn[bad] = Nrm[bad], 1.0 # degenerate (on-axis) -> transported normal
366
+ thin /= tn[:, None]
367
+ # wide = thin x T (NOT T x thin) so the ring keeps the same handedness as the default frame
368
+ # (thin == T x wide); the opposite sign flips the winding -> inward normals -> wrong shading.
369
+ wide = np.cross(thin, T)
370
+ wide /= (np.linalg.norm(wide, axis=1, keepdims=True) + 1e-12)
371
+ else:
372
+ wide, thin = Nrm, np.cross(T, Nrm) # arbitrary (non-twisting) orientation
373
+ row = seg + 1
374
+ ang = 2.0 * np.pi * np.arange(row) / seg # (S,)
375
+ ca, sa = np.cos(ang)[None, :], np.sin(ang)[None, :] # (1,S)
376
+ ax, ay = (R * ka)[:, None], (R * kb)[:, None] # WIDE / THIN radius (N,1)
377
+ # ring vertices (N,S,3): P + wide*(ax*cos) + thin*(ay*sin) -- fully vectorised (no python loops)
378
+ off = wide[:, None, :] * (ax * ca)[:, :, None] + thin[:, None, :] * (ay * sa)[:, :, None]
379
+ verts = (P[:, None, :] + off).reshape(-1, 3)
380
+ # EXACT outward normal of the (elliptical, radius-varying) generalized cylinder = dp/dtheta x dp/ds,
381
+ # so the belly<->tendon taper and the ellipse flats shade correctly (no approximation artifacts).
382
+ axp, ayp = (dRds * ka)[:, None], (dRds * kb)[:, None] # d(semi-axis)/ds
383
+ dpdth = wide[:, None, :] * (-ax * sa)[:, :, None] + thin[:, None, :] * (ay * ca)[:, :, None]
384
+ dpds = (T[:, None, :] + wide[:, None, :] * (axp * ca)[:, :, None]
385
+ + thin[:, None, :] * (ayp * sa)[:, :, None])
386
+ nrm = np.cross(dpdth, dpds) # outward (thin = T x wide)
387
+ nrm /= (np.linalg.norm(nrm, axis=2, keepdims=True) + 1e-12)
388
+ norms = nrm.reshape(-1, 3)
389
+ uv = np.stack([np.broadcast_to((np.arange(row) / seg)[None, :], (N, row)),
390
+ np.broadcast_to(arc[:, None], (N, row))], axis=2).reshape(-1, 2)
391
+ tang = np.broadcast_to(T[:, None, :], (N, row, 3)).reshape(-1, 3)
392
+ ii, jj = np.arange(N - 1)[:, None], np.arange(seg)[None, :]
393
+ a = ii * row + jj
394
+ bb = (ii + 1) * row + jj
395
+ faces = [np.stack([a, bb, a + 1, a + 1, bb, bb + 1], axis=2).reshape(-1)]
396
+ if caps:
397
+ base_n = N * row
398
+ verts = np.vstack([verts, P[[0, -1]]])
399
+ norms = np.vstack([norms, np.stack([-T[0], T[-1]])])
400
+ uv = np.vstack([uv, [[0.5, arc[0]], [0.5, arc[-1]]]])
401
+ tang = np.vstack([tang, np.stack([T[0], T[-1]])])
402
+ j = np.arange(seg)
403
+ faces.append(np.stack([np.full(seg, base_n), j + 1, j], axis=1).reshape(-1)) # start cap
404
+ e = (N - 1) * row
405
+ faces.append(np.stack([np.full(seg, base_n + 1), e + j, e + j + 1], axis=1).reshape(-1)) # end cap
406
+ return (verts.astype(np.float32), norms.astype(np.float32),
407
+ uv.astype(np.float32), tang.astype(np.float32), np.concatenate(faces).astype(np.int32))
408
+
409
+
410
+ def arrow(shaft_r=0.04, shaft_len=0.7, head_r=0.1, head_len=0.3, seg=20):
411
+ """Unit-ish arrow along +z: cylinder shaft + cone head. Total length ~1.
412
+ Renderer scales/orients it to a contact force vector."""
413
+ verts, norms, faces = [], [], []
414
+
415
+ def ring(z, r):
416
+ base = len(verts)
417
+ for j in range(seg + 1):
418
+ phi = 2 * np.pi * j / seg
419
+ cx, cy = np.cos(phi), np.sin(phi)
420
+ verts.append((r * cx, r * cy, z))
421
+ norms.append((cx, cy, 0.0))
422
+ return base
423
+
424
+ a0 = ring(0.0, shaft_r)
425
+ a1 = ring(shaft_len, shaft_r)
426
+ for j in range(seg):
427
+ faces += [a0 + j, a1 + j, a0 + j + 1, a0 + j + 1, a1 + j, a1 + j + 1]
428
+ # cone: base ring at shaft_len, apex at shaft_len+head_len
429
+ cb = ring(shaft_len, head_r)
430
+ apex = len(verts)
431
+ verts.append((0.0, 0.0, shaft_len + head_len))
432
+ norms.append((0.0, 0.0, 1.0))
433
+ for j in range(seg):
434
+ faces += [cb + j, apex, cb + j + 1]
435
+ return _finalize(verts, norms, faces)
436
+
437
+
438
+ def ground_quad(half: float):
439
+ """Large flat quad at z=0 (renderer translates to ground z). Two triangles."""
440
+ v = [(-half, -half, 0), (half, -half, 0), (half, half, 0), (-half, half, 0)]
441
+ n = [(0, 0, 1)] * 4
442
+ f = [0, 1, 2, 0, 2, 3]
443
+ return _finalize(v, n, f)
444
+
445
+
446
+ def build_geom_mesh(gtype: str, size):
447
+ """Dispatch a geom descriptor to a (verts, normals, idx) mesh + a scale vec
448
+ used by the renderer. Returns (mesh, scale[3]). For meshes already built at
449
+ real size (capsule), scale is ones."""
450
+ if gtype == "sphere":
451
+ return unit_sphere(), np.array([size[0]] * 3, dtype=np.float32)
452
+ if gtype == "box":
453
+ return unit_box(), np.array(size[:3], dtype=np.float32)
454
+ if gtype == "ellipsoid":
455
+ return ellipsoid(*size[:3]), np.ones(3, dtype=np.float32)
456
+ if gtype == "capsule":
457
+ return capsule(size[0], size[1]), np.ones(3, dtype=np.float32)
458
+ raise ValueError(f"unknown geom type {gtype!r}")
diffneusim/viz/play.py ADDED
@@ -0,0 +1,237 @@
1
+ """Interactive `.dnrec` player (moderngl-window).
2
+
3
+ Window playback of an engine-produced `.dnrec`: play/pause, scrub the timeline,
4
+ change playback speed, orbit/pan/zoom the camera, toggle overlays. Physics is
5
+ 100% the engine's (poses read from the dump); this only draws.
6
+
7
+ Run:
8
+ python tools/viz/play.py <in.dnrec>
9
+
10
+ Controls (printed at startup):
11
+ Space play / pause
12
+ Left/Right step one frame (paused) ; Home/End jump to start/end
13
+ [ / ] playback speed down / up
14
+ Drag LMB orbit ; Drag RMB (or Shift+LMB) pan ; Wheel zoom
15
+ F toggle contact force arrow / G cycle muscle render mode / T COM trail / H shadow
16
+ 0-9 toggle geom render group N
17
+ C toggle caption HUD
18
+ R reset camera
19
+ Esc / Q quit
20
+ A scrub bar at the bottom shows the timeline; click/drag it to seek.
21
+ """
22
+ from __future__ import annotations
23
+
24
+ import sys
25
+
26
+ import numpy as np
27
+ import moderngl
28
+ import moderngl_window as mglw
29
+ from moderngl_window import geometry # noqa: F401 (ensures GL bootstrap)
30
+
31
+ from diffneusim.viz.dnrec import DnRec
32
+ from diffneusim.viz.camera import OrbitCamera
33
+ from diffneusim.viz import renderer
34
+
35
+
36
+ class Player(mglw.WindowConfig):
37
+ gl_version = (3, 3)
38
+ title = "diffneusim .dnrec player"
39
+ window_size = (1280, 720)
40
+ aspect_ratio = None
41
+ resizable = True
42
+ # dnrec path injected via argv (mglw passes unknown args through to us).
43
+ clip_path: str | None = None
44
+
45
+ def __init__(self, **kwargs):
46
+ super().__init__(**kwargs)
47
+ path = self.clip_path or (self.argv.filename if hasattr(self, "argv") else None)
48
+ if path is None:
49
+ # moderngl-window stores leftover args in self.argv
50
+ extra = getattr(self, "argv", None)
51
+ path = getattr(extra, "dnrec", None)
52
+ assert path, "no .dnrec path (set Player.clip_path before run)"
53
+ self.clip = DnRec(path)
54
+ print(f"loaded {path}: scene={self.clip.header['scene']} "
55
+ f"frames={self.clip.n_frames} channels={list(self.clip.channels)}")
56
+ self._print_help()
57
+
58
+ # ONE renderer: identical Scene defaults + camera policy as to_mp4/snapshot (renderer.py),
59
+ # so the interactive view matches the offscreen output. G/0-9 still cycle modes/groups live.
60
+ self._opt = renderer.RenderOptions()
61
+ self.scene = renderer.make_scene(self.ctx, self.clip, self._opt)
62
+ self.cam = renderer.resolve_camera(self.clip, self._opt)
63
+ self._home = (self.cam.target.copy(), self.cam.distance,
64
+ self.cam.yaw, self.cam.pitch)
65
+
66
+ # playback state
67
+ self.frame = 0.0
68
+ self.playing = True
69
+ self.speed = 1.0 # 1.0 = realtime per the clip dt
70
+ self.fps_clip = 1.0 / self.clip.dt if self.clip.dt > 0 else 60.0
71
+
72
+ # input state
73
+ self._drag = None # 'orbit' | 'pan' | 'scrub'
74
+ self._last = (0, 0)
75
+ self._shift = False
76
+
77
+ # scrub-bar geometry (overlay, NDC-ish via flat shader)
78
+ self._bar_prog = self.ctx.program(
79
+ vertex_shader="""
80
+ #version 330
81
+ in vec2 in_pos; uniform vec4 u_rect; // x,y,w,h in [0,1]
82
+ void main(){
83
+ vec2 p = u_rect.xy + in_pos * u_rect.zw;
84
+ gl_Position = vec4(p*2.0-1.0, 0.0, 1.0);
85
+ }""",
86
+ fragment_shader="""
87
+ #version 330
88
+ uniform vec4 u_color; out vec4 f; void main(){ f = u_color; }""")
89
+ quad = np.array([0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1], dtype="f4")
90
+ self._bar_vbo = self.ctx.buffer(quad.tobytes())
91
+ self._bar_vao = self.ctx.vertex_array(
92
+ self._bar_prog, [(self._bar_vbo, "2f", "in_pos")])
93
+
94
+ def _print_help(self):
95
+ print(__doc__.split("Controls")[1] if "Controls" in __doc__ else "")
96
+
97
+ # --- per-frame --------------------------------------------------------
98
+ def on_render(self, t: float, dt: float):
99
+ if self.playing:
100
+ self.frame += dt * self.fps_clip * self.speed
101
+ if self.frame >= self.clip.n_frames:
102
+ self.frame = 0.0 # loop
103
+ fi = int(self.frame) % self.clip.n_frames
104
+
105
+ self.ctx.clear(0.10, 0.11, 0.13, 1.0)
106
+ w, h = self.wnd.buffer_size
107
+ proj = self.cam.proj(w / h)
108
+ view = self.cam.view()
109
+ self.scene.render(fi, view, proj, self.cam.eye())
110
+ self.scene.draw_hud(w, h, fi, view, proj)
111
+ self._draw_scrub(fi)
112
+
113
+ def _draw_scrub(self, fi):
114
+ self.ctx.disable(moderngl.DEPTH_TEST)
115
+ self.ctx.enable(moderngl.BLEND)
116
+ self.ctx.blend_func = moderngl.SRC_ALPHA, moderngl.ONE_MINUS_SRC_ALPHA
117
+ # track
118
+ self._bar_prog["u_rect"].value = (0.04, 0.03, 0.92, 0.018)
119
+ self._bar_prog["u_color"].value = (0.25, 0.25, 0.30, 0.8)
120
+ self._bar_vao.render(moderngl.TRIANGLES)
121
+ # progress
122
+ frac = fi / max(1, self.clip.n_frames - 1)
123
+ self._bar_prog["u_rect"].value = (0.04, 0.03, 0.92 * frac, 0.018)
124
+ col = (1.0, 0.7, 0.1, 0.95) if self.playing else (0.6, 0.6, 0.65, 0.95)
125
+ self._bar_prog["u_color"].value = col
126
+ self._bar_vao.render(moderngl.TRIANGLES)
127
+ self.ctx.disable(moderngl.BLEND)
128
+ self.ctx.enable(moderngl.DEPTH_TEST)
129
+
130
+ # --- input ------------------------------------------------------------
131
+ def on_key_event(self, key, action, modifiers):
132
+ keys = self.wnd.keys
133
+ self._shift = modifiers.shift
134
+ if action != keys.ACTION_PRESS:
135
+ return
136
+ digit = self._digit_key(key, keys)
137
+ if digit is not None:
138
+ groups = set(self.scene.enabled_geom_groups)
139
+ if digit in groups:
140
+ if len(groups) == 1:
141
+ print(f"geom groups: {sorted(groups)} (refusing to hide the last group)")
142
+ return
143
+ groups.remove(digit)
144
+ else:
145
+ groups.add(digit)
146
+ self.scene.set_enabled_geom_groups(groups)
147
+ print(f"geom groups: {sorted(groups)}")
148
+ return
149
+ if key in (keys.ESCAPE, keys.Q):
150
+ self.wnd.close()
151
+ elif key == keys.SPACE:
152
+ self.playing = not self.playing
153
+ elif key == keys.RIGHT:
154
+ self.playing = False; self.frame = min(self.clip.n_frames - 1, int(self.frame) + 1)
155
+ elif key == keys.LEFT:
156
+ self.playing = False; self.frame = max(0, int(self.frame) - 1)
157
+ elif key == keys.HOME:
158
+ self.frame = 0
159
+ elif key == keys.END:
160
+ self.frame = self.clip.n_frames - 1
161
+ elif key == keys.RIGHT_BRACKET:
162
+ self.speed = min(8.0, self.speed * 1.5); print(f"speed {self.speed:.2f}x")
163
+ elif key == keys.LEFT_BRACKET:
164
+ self.speed = max(0.05, self.speed / 1.5); print(f"speed {self.speed:.2f}x")
165
+ elif key == keys.F:
166
+ self.scene.show_contact = not self.scene.show_contact
167
+ print(f"contact arrow: {self.scene.show_contact}")
168
+ elif key == keys.G:
169
+ mode = self.scene.cycle_muscle_mode()
170
+ print(f"muscle render: {mode}")
171
+ elif key == keys.T:
172
+ self.scene.show_trail = not self.scene.show_trail
173
+ print(f"COM trail: {self.scene.show_trail}")
174
+ elif key == keys.H:
175
+ self.scene.show_shadow = not self.scene.show_shadow
176
+ print(f"shadow: {self.scene.show_shadow}")
177
+ elif key == keys.C:
178
+ self.scene.show_hud = not self.scene.show_hud
179
+ print(f"caption HUD: {self.scene.show_hud}")
180
+ elif key == keys.R:
181
+ c, d, yaw, pitch = self._home
182
+ self.cam = OrbitCamera(c.copy(), distance=d, yaw=yaw, pitch=pitch)
183
+
184
+ def on_mouse_press_event(self, x, y, button):
185
+ self._last = (x, y)
186
+ # bottom 8% of the window is the scrub bar
187
+ if y > self.wnd.size[1] * 0.92:
188
+ self._drag = "scrub"
189
+ self._scrub_to(x)
190
+ elif button == self.wnd.mouse.left and not self._shift:
191
+ self._drag = "orbit"
192
+ else:
193
+ self._drag = "pan"
194
+
195
+ def on_mouse_release_event(self, x, y, button):
196
+ self._drag = None
197
+
198
+ def on_mouse_drag_event(self, x, y, dx, dy):
199
+ if self._drag == "orbit":
200
+ self.cam.orbit(-dx * 0.01, dy * 0.01)
201
+ elif self._drag == "pan":
202
+ self.cam.pan(dx, dy)
203
+ elif self._drag == "scrub":
204
+ self._scrub_to(x)
205
+
206
+ def on_mouse_scroll_event(self, x_offset, y_offset):
207
+ self.cam.zoom(0.9 ** y_offset)
208
+
209
+ @staticmethod
210
+ def _digit_key(key, keys):
211
+ for n in range(10):
212
+ for name in (f"NUMBER_{n}", f"KEY_{n}", f"NUM_{n}", f"DIGIT_{n}"):
213
+ if getattr(keys, name, None) == key:
214
+ return n
215
+ if key == ord(str(n)):
216
+ return n
217
+ return None
218
+
219
+ def _scrub_to(self, x):
220
+ w = self.wnd.size[0]
221
+ frac = np.clip((x / w - 0.04) / 0.92, 0.0, 1.0)
222
+ self.frame = frac * (self.clip.n_frames - 1)
223
+ self.playing = False
224
+
225
+
226
+ def main():
227
+ if len(sys.argv) < 2:
228
+ print("usage: python tools/viz/play.py <in.dnrec>")
229
+ sys.exit(1)
230
+ Player.clip_path = sys.argv[1]
231
+ # hand the rest to moderngl-window (strip our positional arg)
232
+ sys.argv = [sys.argv[0]] + sys.argv[2:]
233
+ mglw.run_window_config(Player)
234
+
235
+
236
+ if __name__ == "__main__":
237
+ main()