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,484 @@
1
+ #pragma once
2
+ // D16 fused env side, Fwd14r's math (engine C, 2026-11-03; tools/d16_fused_env/DESIGN.md): the MuscleMimic MimicReward, its
3
+ // deviation measures and the 708-wide observation at the post-step state, from Step14's law-chart outputs. The host build here
4
+ // is the reference the device kernel will share (groundwork 2); the formulas transcribe 4fd262cd's imitation.py
5
+ // (_ref_at_frames, frame_idx, _mimic_core, _mm_sites, mimic_goal_obs) and gpu_fullbody_vec_env.py's _obs, op for op where it
6
+ // matters for the discrete outputs (the frame indices: floor / rint as torch's floor / round, half to even).
7
+ // Charts: the law chart's q is the old chart's; the law's v[0:3] is the root's linear velocity in the world and v[3:6] its
8
+ // angular velocity in the body frame; the old chart's root qd is [w body, v body] (env14.law_to_old).
9
+ #include <cmath>
10
+
11
+ #include "x14adj_common.h"
12
+ #include "tree14_adj.h"
13
+
14
+ // REW14_PLANT (default off; gates E1 / E2's planted bugs only): 1 lin's R_0 -> R_0', 2 the reference's wf -> 1 - wf, 3 site 2's (head: the only nonzero) offset
15
+ // rotation dropped
16
+ #ifndef REW14_PLANT
17
+ #define REW14_PLANT 0
18
+ #endif
19
+ // REW14_RV_ANG (default undefined = MuscleMimic's root_vel, and these lines compile out): the root's angular-velocity coefficient in
20
+ // root_vel, per (rad/s)^2 (tools/e0speed/KT_REWARD_PROPOSAL.md, KT-width: BeyondMimic's 1 / sigma_w^2 with sigma_w = 3.14). MuscleMimic's
21
+ // root_vel is w exp(-k mean_6(e^2)), so each component's coefficient is k / 6 (10 / 6). The knob scales the angular sum inside e[3] by
22
+ // 6 REW14_RV_ANG / k, so k e[3] = (k / 6) |dv body|^2 + REW14_RV_ANG |dw body|^2; the linear part and every other term are unchanged.
23
+ // Forward and reverse. Set by tools/d16_fused_env/rew14.py from E0_REW14_RV_ANG. (Ported from 62e0bd288 onto the E0 tree, 11-16.)
24
+
25
+ namespace d16::x14adj {
26
+
27
+ constexpr int kRS = 17, kRT = 8, kGoal = 277, kObs = 708, kNM14 = 356;
28
+
29
+ // the site map (tools/d16_fused_env/mimic_sites_x14.json) and MM_TERMS: qpos, qvel, root_pos, root_vel, rpos, rquat, rvel_rot,
30
+ // rvel_lin
31
+ template <class T> struct Rew14Model {
32
+ int site_b[kRS];
33
+ T site_p[kRS][3], site_q[kRS][4];
34
+ T w[kRT], k[kRT];
35
+ int root_b; // the 14x body of the reward's root (1)
36
+ };
37
+ // the reference tables, as _mimic_build lays them out (Ttot frames over the concatenated corpus)
38
+ template <class T> struct Rew14Ref {
39
+ const T* rpos; const T* rrot; const T* ang; const T* lin; // [(kRS - 1) * 3][Ttot]
40
+ const T* root_p; const T* root_q; const T* root_vw; // [3 | 4 | 3][Ttot]
41
+ const T* ref_q; const T* ref_qd; // [Ttot][NQ], [Ttot][NV] (the old chart)
42
+ const T* goal_rpos; const T* goal_root_p; const T* goal_root_qvel; // [Ttot][48], [Ttot][3], [Ttot][6]
43
+ long ttot;
44
+ };
45
+ // per world: its clip (start, T, loop) and phase
46
+ template <class T> struct Rew14World {
47
+ long start, clipT;
48
+ bool loop;
49
+ T phase;
50
+ };
51
+ template <class T> struct Rew14Out {
52
+ T r, e[kRT], dev[3]; // dev: mean |d_rpos| over the sites, |root p - ref|, the root's angle to its reference
53
+ T height, upright, maxqd; // the env's fall gates' inputs: q[2], R[2][2] of the root, max |qd| in the old chart
54
+ int finite; // q, v, lce all finite
55
+ long i0, i1;
56
+ T wf;
57
+ T obs[kObs];
58
+ };
59
+
60
+ template <class T> DN_HOST_DEVICE inline void r14_quat_rot(const T* q, const T* v, T* o) { // R(q) v (q unit, wxyz)
61
+ T R[9];
62
+ qmat(q, R);
63
+ mv(R, v, o);
64
+ }
65
+ template <class T> DN_HOST_DEVICE inline T r14_angle(const T* a, const T* b) { // imitation._tq_angle
66
+ using std::sqrt; using std::atan2; using std::abs;
67
+ const T w = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
68
+ const T c0 = a[0] * b[1] - a[1] * b[0] - a[2] * b[3] + a[3] * b[2];
69
+ const T c1 = a[0] * b[2] + a[1] * b[3] - a[2] * b[0] - a[3] * b[1];
70
+ const T c2 = a[0] * b[3] - a[1] * b[2] + a[2] * b[1] - a[3] * b[0];
71
+ T s = c0 * c0 + c1 * c1 + c2 * c2;
72
+ if (s < T(1e-24)) s = T(1e-24);
73
+ return T(2) * atan2(sqrt(s), abs(w));
74
+ }
75
+ template <class T> DN_HOST_DEVICE inline void r14_log(const T* qin, T* o) { // imitation._tq_log
76
+ using std::sqrt; using std::atan2;
77
+ const T sg = qin[0] < T(0) ? T(-1) : T(1);
78
+ const T q[4] = {sg * qin[0], sg * qin[1], sg * qin[2], sg * qin[3]};
79
+ T s = q[1] * q[1] + q[2] * q[2] + q[3] * q[3];
80
+ if (s < T(1e-24)) s = T(1e-24);
81
+ const T nv = sqrt(s), f = T(2) * atan2(nv, q[0]) / nv;
82
+ for (int k = 0; k < 3; ++k) o[k] = q[k + 1] * f;
83
+ }
84
+
85
+ // frame_idx for one world (the any_nonloop branch: a loop clip wraps, a whole clip clamps at its last frame)
86
+ template <class T> DN_HOST_DEVICE inline void r14_frames(const Rew14World<T>& wd, long* i0, long* i1, T* wf) {
87
+ using std::floor; using std::fmod;
88
+ const T Tc = static_cast<T>(wd.clipT);
89
+ const T f = (wd.loop ? wd.phase - floor(wd.phase) : wd.phase) * Tc; // torch's phase % 1.0 for phase >= 0
90
+ const long k = static_cast<long>(floor(f));
91
+ const long last = wd.clipT - 1;
92
+ *i0 = wd.start + (wd.loop ? ((k % wd.clipT) + wd.clipT) % wd.clipT : (k < last ? k : last));
93
+ *i1 = wd.start + (wd.loop ? (((k + 1) % wd.clipT) + wd.clipT) % wd.clipT : (k + 1 < last ? k + 1 : last));
94
+ *wf = f - floor(f);
95
+ }
96
+
97
+ // the host forward for one world: q, v (law chart), lce; s.t is tree14's state (the frames by tree14_pose, the w / vo chains)
98
+ // the core (one thread): the reference, the 8 terms, r, the deviation measures and the fall gates' inputs, from the frames and
99
+ // the w / vo chains already in s
100
+ template <class T>
101
+ DN_HOST_DEVICE inline void reward14_core(const Tree14<T>& s, const Rew14Model<T>& M, const Rew14Ref<T>& R,
102
+ const Rew14World<T>& wd, const T* q, const T* v, const T* lce, Rew14Out<T>& o) {
103
+ using std::sqrt; using std::exp;
104
+ const long Tt = R.ttot;
105
+ r14_frames(wd, &o.i0, &o.i1, &o.wf);
106
+ const long i0 = o.i0, i1 = o.i1;
107
+ const T wf = REW14_PLANT == 2 ? T(1) - o.wf : o.wf, w0 = T(1) - wf;
108
+ auto lerp = [&](const T* A, long row) { return A[row * Tt + i0] * w0 + A[row * Tt + i1] * wf; };
109
+ // q_ref, qd_ref (_ref_at_frames: scalars linear, quaternion blocks sign-aligned nlerp)
110
+ T qr[NQ], qdr[NV];
111
+ for (int i = 0; i < NQ; ++i) qr[i] = R.ref_q[i0 * NQ + i] * w0 + R.ref_q[i1 * NQ + i] * wf;
112
+ for (int i = 0; i < NV; ++i) qdr[i] = R.ref_qd[i0 * NV + i] * w0 + R.ref_qd[i1 * NV + i] * wf;
113
+ const int qb[3] = {3, 24, 32};
114
+ for (int b = 0; b < 3; ++b) {
115
+ const T* a = R.ref_q + i0 * NQ + qb[b];
116
+ const T* c = R.ref_q + i1 * NQ + qb[b];
117
+ const T d = a[0] * c[0] + a[1] * c[1] + a[2] * c[2] + a[3] * c[3];
118
+ T bl[4], n2 = T(0);
119
+ for (int k = 0; k < 4; ++k) { bl[k] = a[k] * w0 + (d < T(0) ? -c[k] : c[k]) * wf; n2 = n2 + bl[k] * bl[k]; }
120
+ const T nn = sqrt(n2) + T(1e-9);
121
+ for (int k = 0; k < 4; ++k) qr[qb[b] + k] = bl[k] / nn;
122
+ }
123
+ const int fb = M.root_b;
124
+ // qpos: the scalar coordinates squared, mean; plus the mean geodesic angle of the quaternion blocks
125
+ T eq = T(0);
126
+ int nsc = 0;
127
+ for (int i = 0; i < NQ; ++i) {
128
+ const bool quat = (i >= 3 && i < 7) || (i >= 24 && i < 28) || (i >= 32 && i < 36);
129
+ if (quat) continue;
130
+ const T d = q[i] - qr[i];
131
+ eq = eq + d * d;
132
+ ++nsc;
133
+ }
134
+ eq = eq / static_cast<T>(nsc);
135
+ T ang3 = T(0);
136
+ for (int b = 0; b < 3; ++b) ang3 = ang3 + r14_angle(q + qb[b], qr + qb[b]);
137
+ o.e[0] = eq + ang3 / T(3);
138
+ // the root's reference orientation (lerp, then normalized by its norm)
139
+ T rq[4], rn = T(0);
140
+ for (int k = 0; k < 4; ++k) { rq[k] = lerp(R.root_q, k); rn = rn + rq[k] * rq[k]; }
141
+ rn = sqrt(rn);
142
+ for (int k = 0; k < 4; ++k) rq[k] = rq[k] / rn;
143
+ // qvel: [v world, w body, the other dof rates] against [lerp(root_vw), the reference's w body, its other rates]
144
+ T eqv = T(0);
145
+ for (int k = 0; k < 3; ++k) { const T d = v[k] - lerp(R.root_vw, k); eqv = eqv + d * d; }
146
+ for (int k = 0; k < 3; ++k) { const T d = v[3 + k] - qdr[k]; eqv = eqv + d * d; } // the old chart's qd[0:3] = w body
147
+ for (int i = 6; i < NV; ++i) { const T d = v[i] - qdr[i]; eqv = eqv + d * d; }
148
+ o.e[1] = eqv / static_cast<T>(NV);
149
+ // root_pos (the FK root position) and root_vel (the old chart's [w body, v body] against the reference's)
150
+ T rp[3], erp = T(0);
151
+ for (int k = 0; k < 3; ++k) { rp[k] = lerp(R.root_p, k); const T d = s.xpos[fb][k] - rp[k]; erp = erp + d * d; }
152
+ o.e[2] = erp / T(3);
153
+ T Rr[9], vb[3];
154
+ qmat(s.xquat[fb], Rr);
155
+ mtv(Rr, v, vb); // v body = R' v world
156
+ T erv = T(0);
157
+ for (int k = 0; k < 3; ++k) { const T d = v[3 + k] - qdr[k]; erv = erv + d * d; }
158
+ #ifdef REW14_RV_ANG
159
+ erv = erv * (T(6) * T(REW14_RV_ANG) / M.k[3]); // the angular sum only (KT-width)
160
+ #endif
161
+ for (int k = 0; k < 3; ++k) { const T d = vb[k] - qdr[3 + k]; erv = erv + d * d; }
162
+ o.e[3] = erv / T(6);
163
+ // the sites: P = x_b + R_b p, Q = q_b (x) q_s, V = vo_b + w_b x (R_b p), W = w_b
164
+ T P[kRS][3], Q[kRS][4], Vs[kRS][3], Ws[kRS][3];
165
+ for (int st = 0; st < kRS; ++st) {
166
+ const int b = M.site_b[st];
167
+ T off[3];
168
+ r14_quat_rot(s.xquat[b], M.site_p[st], off);
169
+ if (REW14_PLANT == 3 && st == 2) for (int k = 0; k < 3; ++k) off[k] = M.site_p[st][k];
170
+ for (int k = 0; k < 3; ++k) { P[st][k] = s.xpos[b][k] + off[k]; Ws[st][k] = s.w[b][k]; }
171
+ qmul(s.xquat[b], M.site_q[st], Q[st]);
172
+ T wo[3];
173
+ crs(s.w[b], off, wo);
174
+ for (int k = 0; k < 3; ++k) Vs[st][k] = s.vo[b][k] + wo[k];
175
+ }
176
+ // relative to site 0 (MuscleMimic's quirks kept): rpos world; rrot = log(q0* qs); ang = R_rel' W_s - W_0; lin = R_0 (V_0 - V_s)
177
+ T sr = T(0), sq = T(0), sa = T(0), sl = T(0), dsum = T(0);
178
+ const T q0c[4] = {Q[0][0], -Q[0][1], -Q[0][2], -Q[0][3]};
179
+ for (int st = 1; st < kRS; ++st) {
180
+ const int j = st - 1;
181
+ T qrel[4], lg[3], qrc[4], an[3], dv[3], ln[3];
182
+ qmul(q0c, Q[st], qrel);
183
+ r14_log(qrel, lg);
184
+ qrc[0] = qrel[0]; qrc[1] = -qrel[1]; qrc[2] = -qrel[2]; qrc[3] = -qrel[3];
185
+ r14_quat_rot(qrc, Ws[st], an);
186
+ for (int k = 0; k < 3; ++k) { an[k] = an[k] - Ws[0][k]; dv[k] = Vs[0][k] - Vs[st][k]; }
187
+ if (REW14_PLANT == 1) r14_quat_rot(q0c, dv, ln); else r14_quat_rot(Q[0], dv, ln);
188
+ T dn = T(0);
189
+ for (int k = 0; k < 3; ++k) {
190
+ const long row = 3 * j + k;
191
+ const T d = (P[st][k] - P[0][k]) - lerp(R.rpos, row);
192
+ sr = sr + d * d; dn = dn + d * d;
193
+ const T e2 = lg[k] - lerp(R.rrot, row); sq = sq + e2 * e2;
194
+ const T e3 = an[k] - lerp(R.ang, row); sa = sa + e3 * e3;
195
+ const T e4 = ln[k] - lerp(R.lin, row); sl = sl + e4 * e4;
196
+ }
197
+ dsum = dsum + sqrt(dn);
198
+ }
199
+ const T ns = static_cast<T>(3 * (kRS - 1));
200
+ o.e[4] = sr / ns; o.e[5] = sq / ns; o.e[6] = sa / ns; o.e[7] = sl / ns;
201
+ T r = T(0);
202
+ for (int t = 0; t < kRT; ++t) r = r + M.w[t] * exp(-M.k[t] * o.e[t]);
203
+ o.r = r;
204
+ // the deviation measures mimic_failed reads
205
+ o.dev[0] = dsum / static_cast<T>(kRS - 1);
206
+ T de = T(0);
207
+ for (int k = 0; k < 3; ++k) { const T d = s.xpos[fb][k] - rp[k]; de = de + d * d; }
208
+ o.dev[1] = sqrt(de);
209
+ o.dev[2] = r14_angle(s.xquat[fb], rq);
210
+ // the fall gates' inputs (gpu_fullbody_vec_env.py step / _upright at 4fd262cd) and the finite mask's (q, v, lce part)
211
+ using std::isfinite;
212
+ o.height = q[2];
213
+ o.upright = T(1) - T(2) * (q[4] * q[4] + q[5] * q[5]);
214
+ {
215
+ T m = T(0);
216
+ const T qo[6] = {v[3], v[4], v[5], vb[0], vb[1], vb[2]};
217
+ for (int k = 0; k < 6; ++k) { const T x = qo[k] < T(0) ? -qo[k] : qo[k]; if (x > m) m = x; }
218
+ for (int i = 6; i < NV; ++i) { const T x = v[i] < T(0) ? -v[i] : v[i]; if (x > m) m = x; }
219
+ o.maxqd = m;
220
+ int fin = 1;
221
+ for (int i = 0; i < NQ; ++i) fin &= isfinite(q[i]) ? 1 : 0;
222
+ for (int i = 0; i < NV; ++i) fin &= isfinite(v[i]) ? 1 : 0;
223
+ if (lce) for (int i = 0; i < kNM14; ++i) fin &= isfinite(lce[i]) ? 1 : 0; // (the device checks lce on lanes)
224
+ o.finite = fin;
225
+ }
226
+ }
227
+
228
+ // the obs (lanes over its 708 entries): [q[2:], qd (old chart), lce, mimic_goal_obs(phase)]; vb = R' v world (the core's)
229
+ template <class T>
230
+ DN_HOST_DEVICE inline void reward14_obs(const Rew14Ref<T>& R, const Rew14World<T>& wd, const T* q, const T* v, const T* lce,
231
+ const T* vb, T* obs, int lane) {
232
+ (void)lane;
233
+ using std::rint;
234
+ long kf = static_cast<long>(rint(wd.phase * static_cast<T>(wd.clipT)));
235
+ if (kf < 0) kf = 0;
236
+ if (kf > wd.clipT - 1) kf = wd.clipT - 1;
237
+ const long f = wd.start + kf, end = wd.start + wd.clipT - 1;
238
+ X14_FOR(p, kObs) {
239
+ T x;
240
+ if (p < 38) x = q[p + 2];
241
+ else if (p < 41) x = v[3 + (p - 38)];
242
+ else if (p < 44) x = vb[p - 41];
243
+ else if (p < 75) x = v[6 + (p - 44)];
244
+ else if (p < 75 + kNM14) x = lce[p - 75];
245
+ else {
246
+ const int g0 = p - (75 + kNM14); // the goal block: 48, then 4 x (3 + 6 + 48), then the phase
247
+ if (g0 < 48) x = R.goal_rpos[f * 48 + g0];
248
+ else if (g0 < 48 + 4 * 57) {
249
+ const int jj = (g0 - 48) / 57 + 1, c = (g0 - 48) % 57;
250
+ const long g = f + 20 * jj < end ? f + 20 * jj : end;
251
+ if (c < 3) x = R.goal_root_p[g * 3 + c] - R.goal_root_p[f * 3 + c];
252
+ else if (c < 9) x = R.goal_root_qvel[g * 6 + (c - 3)] - R.goal_root_qvel[f * 6 + (c - 3)];
253
+ else x = R.goal_rpos[g * 48 + (c - 9)];
254
+ } else {
255
+ x = static_cast<T>(kf) / static_cast<T>(wd.clipT);
256
+ }
257
+ }
258
+ obs[p] = x;
259
+ }
260
+ X14_SYNC();
261
+ }
262
+
263
+ // the host forward for one world (E1's build): the frames, the chains, the core, the obs
264
+ template <class T>
265
+ inline void reward14_host(Tree14<T>& s, const T* V, const Rew14Model<T>& M, const Rew14Ref<T>& R, const Rew14World<T>& wd,
266
+ const T* q, const T* v, const T* lce, Rew14Out<T>& o) {
267
+ for (int i = 0; i < NQ; ++i) s.q[i] = q[i];
268
+ for (int i = 0; i < NV; ++i) { s.v[i] = v[i]; s.a[i] = T(0); s.lam[i] = T(0); }
269
+ tree14_pose(s, V);
270
+ tree14_chains(s, V, 0);
271
+ reward14_core(s, M, R, wd, q, v, lce, o);
272
+ T Rr[9], vb[3];
273
+ qmat(s.xquat[M.root_b], Rr);
274
+ mtv(Rr, v, vb);
275
+ reward14_obs(R, wd, q, v, lce, vb, o.obs, 0);
276
+ }
277
+
278
+
279
+ // ---- Bwd14r's host reverse (E2's reference build): rb = r's cotangent, ob [708] the obs'. Out (added): qg [40] RAW (each
280
+ // rotation's tangent cotangent t goes out as 2 q (x) [0, t], which Step14.backward projects back, 1/2 Im(conj(q) (x) g)), vg [37]
281
+ // (the law chart), lg [356]. The sites' cotangents become each body's wrench (force; torque about O = the root's origin, tree14's
282
+ // convention) and its twist cotangents (w_bar, vo_bar); tree14_up (the transposed rounds, the couples, the projections) takes them
283
+ // to the reduced tangent dofs. REW14_PLANT 11 / 12 / 13 (E2's plants): the site velocity's rotation couple dropped / rrot's
284
+ // inverse-Jacobian correction dropped / the root's R' v couple dropped.
285
+ template <class T> DN_HOST_DEVICE inline void r14_angle_grad(const T* a, const T* b, T scale, T* ga) { // ga += scale d r14_angle(a, b) / d a (raw)
286
+ using std::sqrt; using std::abs;
287
+ const T w = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
288
+ const T c0 = a[0] * b[1] - a[1] * b[0] - a[2] * b[3] + a[3] * b[2];
289
+ const T c1 = a[0] * b[2] + a[1] * b[3] - a[2] * b[0] - a[3] * b[1];
290
+ const T c2 = a[0] * b[3] - a[1] * b[2] + a[2] * b[1] - a[3] * b[0];
291
+ const T s2 = c0 * c0 + c1 * c1 + c2 * c2;
292
+ const bool live = !(s2 < T(1e-24));
293
+ const T y = sqrt(live ? s2 : T(1e-24)), x = abs(w), den = x * x + y * y;
294
+ const T sw = w > T(0) ? T(1) : (w < T(0) ? T(-1) : T(0));
295
+ const T dy_c = live ? T(1) / y : T(0); // dy = (c . dc) / y
296
+ const T fy = T(2) * x / den, fx = -T(2) * y / den;
297
+ const T dc0[4] = {b[1], -b[0], -b[3], b[2]}, dc1[4] = {b[2], b[3], -b[0], -b[1]}, dc2[4] = {b[3], -b[2], b[1], -b[0]};
298
+ for (int k = 0; k < 4; ++k)
299
+ ga[k] += scale * (fy * dy_c * (c0 * dc0[k] + c1 * dc1[k] + c2 * dc2[k]) + fx * sw * b[k]);
300
+ }
301
+
302
+ // the reverse (one thread), after the frames, the chains and the core (o): the raw parts into qg / vg / lg, the sites' wrenches and
303
+ // twist cotangents into s.acc (zeroed here), the root's body-frame couple into troot. tree14_up and reward14_raw finish it.
304
+ template <class T>
305
+ DN_HOST_DEVICE inline void reward14_reverse(Tree14<T>& s, const Rew14Model<T>& M, const Rew14Ref<T>& R, const Rew14Out<T>& o,
306
+ const T* q, const T* v, T rb, const T* ob, T* qg, T* vg, T* lg, T* troot) {
307
+ using std::sqrt; using std::exp; using std::sin; using std::cos;
308
+ const long Tt = R.ttot, i0 = o.i0, i1 = o.i1;
309
+ const T wf = REW14_PLANT == 2 ? T(1) - o.wf : o.wf, w0 = T(1) - wf;
310
+ auto lerp = [&](const T* A, long row) { return A[row * Tt + i0] * w0 + A[row * Tt + i1] * wf; };
311
+ T eb[kRT];
312
+ for (int t = 0; t < kRT; ++t) eb[t] = rb * M.w[t] * (-M.k[t]) * exp(-M.k[t] * o.e[t]);
313
+ T qr[NQ], qdr[NV]; // the reference again (as the forward)
314
+ for (int i = 0; i < NQ; ++i) qr[i] = R.ref_q[i0 * NQ + i] * w0 + R.ref_q[i1 * NQ + i] * wf;
315
+ for (int i = 0; i < NV; ++i) qdr[i] = R.ref_qd[i0 * NV + i] * w0 + R.ref_qd[i1 * NV + i] * wf;
316
+ const int qb[3] = {3, 24, 32};
317
+ for (int b = 0; b < 3; ++b) {
318
+ const T* a = R.ref_q + i0 * NQ + qb[b];
319
+ const T* c = R.ref_q + i1 * NQ + qb[b];
320
+ const T d = a[0] * c[0] + a[1] * c[1] + a[2] * c[2] + a[3] * c[3];
321
+ T bl[4], n2 = T(0);
322
+ for (int k = 0; k < 4; ++k) { bl[k] = a[k] * w0 + (d < T(0) ? -c[k] : c[k]) * wf; n2 = n2 + bl[k] * bl[k]; }
323
+ const T nn = sqrt(n2) + T(1e-9);
324
+ for (int k = 0; k < 4; ++k) qr[qb[b] + k] = bl[k] / nn;
325
+ }
326
+ const int fb = M.root_b;
327
+ // qpos: the scalars, then each quaternion block's angle (raw)
328
+ int nsc = 0;
329
+ for (int i = 0; i < NQ; ++i) if (!((i >= 3 && i < 7) || (i >= 24 && i < 28) || (i >= 32 && i < 36))) ++nsc;
330
+ for (int i = 0; i < NQ; ++i) {
331
+ if ((i >= 3 && i < 7) || (i >= 24 && i < 28) || (i >= 32 && i < 36)) continue;
332
+ qg[i] += eb[0] * T(2) * (q[i] - qr[i]) / static_cast<T>(nsc);
333
+ }
334
+ for (int b = 0; b < 3; ++b) r14_angle_grad(q + qb[b], qr + qb[b], eb[0] / T(3), qg + qb[b]);
335
+ // qvel (the law chart's v directly)
336
+ for (int k = 0; k < 3; ++k) vg[k] += eb[1] * T(2) * (v[k] - lerp(R.root_vw, k)) / static_cast<T>(NV);
337
+ for (int k = 0; k < 3; ++k) vg[3 + k] += eb[1] * T(2) * (v[3 + k] - qdr[k]) / static_cast<T>(NV);
338
+ for (int i = 6; i < NV; ++i) vg[i] += eb[1] * T(2) * (v[i] - qdr[i]) / static_cast<T>(NV);
339
+ // root_pos: x_root = q[0:3]
340
+ for (int k = 0; k < 3; ++k) qg[k] += eb[2] * T(2) * (s.xpos[fb][k] - lerp(R.root_p, k)) / T(3);
341
+ // root_vel and the obs's v body u = R' v world: u_bar from both; v_bar[0:3] += R u_bar; the root's body-frame couple u_bar x u
342
+ T Rr[9], u[3], ub[3];
343
+ qmat(s.xquat[fb], Rr);
344
+ mtv(Rr, v, u);
345
+ #ifdef REW14_RV_ANG
346
+ const T rv_s = T(6) * T(REW14_RV_ANG) / M.k[3]; // the forward's angular scale (KT-width)
347
+ #endif
348
+ for (int k = 0; k < 3; ++k) {
349
+ #ifdef REW14_RV_ANG
350
+ vg[3 + k] += eb[3] * T(2) * rv_s * (v[3 + k] - qdr[k]) / T(6);
351
+ #else
352
+ vg[3 + k] += eb[3] * T(2) * (v[3 + k] - qdr[k]) / T(6);
353
+ #endif
354
+ ub[k] = eb[3] * T(2) * (u[k] - qdr[3 + k]) / T(6) + ob[41 + k];
355
+ }
356
+ T Rub[3];
357
+ mv(Rr, ub, Rub);
358
+ for (int k = 0; k < 3; ++k) vg[k] += Rub[k];
359
+ troot[0] = troot[1] = troot[2] = T(0);
360
+ if (REW14_PLANT != 13) crs(ub, u, troot);
361
+ // the obs's other slices
362
+ for (int i = 2; i < NQ; ++i) qg[i] += ob[i - 2];
363
+ for (int k = 0; k < 3; ++k) vg[3 + k] += ob[38 + k];
364
+ for (int i = 6; i < NV; ++i) vg[i] += ob[44 + (i - 6)];
365
+ if (lg) for (int m = 0; m < kNM14; ++m) lg[m] += ob[75 + m];
366
+ // the sites (the forward's quantities again)
367
+ T P[kRS][3], Q[kRS][4], Vs[kRS][3], Ws[kRS][3], off[kRS][3];
368
+ for (int st = 0; st < kRS; ++st) {
369
+ const int b = M.site_b[st];
370
+ r14_quat_rot(s.xquat[b], M.site_p[st], off[st]);
371
+ if (REW14_PLANT == 3 && st == 2) for (int k = 0; k < 3; ++k) off[st][k] = M.site_p[st][k];
372
+ for (int k = 0; k < 3; ++k) { P[st][k] = s.xpos[b][k] + off[st][k]; Ws[st][k] = s.w[b][k]; }
373
+ qmul(s.xquat[b], M.site_q[st], Q[st]);
374
+ T wo[3];
375
+ crs(s.w[b], off[st], wo);
376
+ for (int k = 0; k < 3; ++k) Vs[st][k] = s.vo[b][k] + wo[k];
377
+ }
378
+ T Pb[kRS][3] = {}, eps[kRS][3] = {}, Vb[kRS][3] = {}, Wb[kRS][3] = {};
379
+ const T q0c[4] = {Q[0][0], -Q[0][1], -Q[0][2], -Q[0][3]};
380
+ T R0[9];
381
+ qmat(Q[0], R0);
382
+ const T ns = static_cast<T>(3 * (kRS - 1));
383
+ for (int st = 1; st < kRS; ++st) {
384
+ const int j = st - 1;
385
+ T qrel[4], phi[3], qrc[4], an[3], dv[3], ln[3], Rrel[9];
386
+ qmul(q0c, Q[st], qrel);
387
+ r14_log(qrel, phi);
388
+ qrc[0] = qrel[0]; qrc[1] = -qrel[1]; qrc[2] = -qrel[2]; qrc[3] = -qrel[3];
389
+ r14_quat_rot(qrc, Ws[st], an);
390
+ for (int k = 0; k < 3; ++k) { an[k] = an[k] - Ws[0][k]; dv[k] = Vs[0][k] - Vs[st][k]; }
391
+ if (REW14_PLANT == 1) r14_quat_rot(q0c, dv, ln); else r14_quat_rot(Q[0], dv, ln);
392
+ qmat(qrel, Rrel);
393
+ T gp[3], gr[3], ga[3], gl[3];
394
+ for (int k = 0; k < 3; ++k) {
395
+ const long row = 3 * j + k;
396
+ gp[k] = eb[4] * T(2) * ((P[st][k] - P[0][k]) - lerp(R.rpos, row)) / ns;
397
+ gr[k] = eb[5] * T(2) * (phi[k] - lerp(R.rrot, row)) / ns;
398
+ ga[k] = eb[6] * T(2) * (an[k] - lerp(R.ang, row)) / ns;
399
+ gl[k] = eb[7] * T(2) * (ln[k] - lerp(R.lin, row)) / ns;
400
+ }
401
+ // rpos
402
+ for (int k = 0; k < 3; ++k) { Pb[st][k] += gp[k]; Pb[0][k] -= gp[k]; }
403
+ // rrot = log(qrel), qrel -> Exp(eta) qrel: eta_bar = J_l^-1(phi)' g = g + 1/2 phi x g + c phi x (phi x g)
404
+ T eta[3], pg[3], ppg[3];
405
+ const T th2 = phi[0] * phi[0] + phi[1] * phi[1] + phi[2] * phi[2], th = sqrt(th2);
406
+ const T c = th < T(1e-4) ? T(1) / T(12) + th2 / T(720) : (T(1) / th2 - (T(1) + cos(th)) / (T(2) * th * sin(th)));
407
+ crs(phi, gr, pg); crs(phi, pg, ppg);
408
+ for (int k = 0; k < 3; ++k) eta[k] = REW14_PLANT == 12 ? gr[k] : gr[k] + T(0.5) * pg[k] + c * ppg[k];
409
+ // ang = R_rel' W_s - W_0: W_bar_s += R_rel g; W_bar_0 -= g; eta_bar += (R_rel g) x W_s
410
+ T Rg[3], e2[3];
411
+ mv(Rrel, ga, Rg);
412
+ crs(Rg, Ws[st], e2);
413
+ for (int k = 0; k < 3; ++k) { Wb[st][k] += Rg[k]; Wb[0][k] -= ga[k]; eta[k] += e2[k]; }
414
+ T e0w[3];
415
+ mv(R0, eta, e0w); // eta lives in site 0's frame: eps_s += R_0 eta, eps_0 -= R_0 eta
416
+ for (int k = 0; k < 3; ++k) { eps[st][k] += e0w[k]; eps[0][k] -= e0w[k]; }
417
+ // lin = R_0 (V_0 - V_s): V_bar_0 += R_0' g; V_bar_s -= R_0' g; eps_0 += lin x g
418
+ T Rtg[3], lg3[3];
419
+ mtv(R0, gl, Rtg);
420
+ crs(ln, gl, lg3);
421
+ for (int k = 0; k < 3; ++k) { Vb[0][k] += Rtg[k]; Vb[st][k] -= Rtg[k]; eps[0][k] += lg3[k]; }
422
+ }
423
+ // the sites into their bodies: force, torque about O (the root's origin), w_bar, vo_bar
424
+ #if !defined(__CUDA_ARCH__)
425
+ for (int b = 0; b < NB; ++b) for (int w = 0; w < kMsg; ++w) s.acc[b][w] = T(0); // (the device zeroes it on lanes)
426
+ #endif
427
+ for (int st = 0; st < kRS; ++st) {
428
+ const int b = M.site_b[st];
429
+ T rel[3], tq[3], vw[3], cpl[3], ow[3];
430
+ for (int k = 0; k < 3; ++k) rel[k] = P[st][k] - s.xpos[fb][k];
431
+ crs(rel, Pb[st], tq);
432
+ crs(Vb[st], s.w[b], vw);
433
+ crs(off[st], vw, cpl);
434
+ crs(off[st], Vb[st], ow);
435
+ for (int k = 0; k < 3; ++k) {
436
+ s.acc[b][kMF + k] += Pb[st][k];
437
+ s.acc[b][kMT + k] += tq[k] + eps[st][k] + (REW14_PLANT == 11 ? T(0) : cpl[k]);
438
+ s.acc[b][kMW + k] += ow[k] + Wb[st][k];
439
+ s.acc[b][kMVO + k] += Vb[st][k];
440
+ }
441
+ }
442
+ }
443
+
444
+ // after tree14_up: the reduced tangent dofs tq (+ the root's couple) to the raw q (one thread)
445
+ template <class T> DN_HOST_DEVICE inline void reward14_raw(const T* q, const T* tqin, const T* troot, T* qg) {
446
+ T tq[NV];
447
+ for (int i = 0; i < NV; ++i) tq[i] = tqin[i];
448
+ for (int k = 0; k < 3; ++k) tq[3 + k] += troot[k];
449
+ for (int k = 0; k < 3; ++k) qg[k] += tq[k];
450
+ const int rq[3] = {3, 24, 32}, rd[3] = {3, 23, 30};
451
+ for (int b = 0; b < 3; ++b) {
452
+ const T tv4[4] = {T(0), T(2) * tq[rd[b]], T(2) * tq[rd[b] + 1], T(2) * tq[rd[b] + 2]};
453
+ T g4[4];
454
+ qmul(q + rq[b], tv4, g4);
455
+ for (int k = 0; k < 4; ++k) qg[rq[b] + k] += g4[k];
456
+ }
457
+ for (int d = 6; d < NV; ++d) {
458
+ if ((d >= 23 && d < 26) || (d >= 30 && d < 33)) continue;
459
+ qg[d < 23 ? d + 1 : (d < 30 ? d + 2 : d + 3)] += tq[d];
460
+ }
461
+ #if !defined(__CUDA_ARCH__)
462
+ for (int b = 1; b < NB; ++b) { // the address map against the generated tables
463
+ const int qa = X14T(Qadr)[b], da = X14T(Dadr)[b];
464
+ if (qa < 0 || da < 6 || (da >= 23 && da < 26) || (da >= 30 && da < 33)) continue;
465
+ assert((da < 23 ? da + 1 : (da < 30 ? da + 2 : da + 3)) == qa && "reward14: the hinge dof -> q address map");
466
+ (void)qa;
467
+ }
468
+ #endif
469
+ }
470
+
471
+ // the host reverse for one world (E2's build)
472
+ template <class T>
473
+ inline void reward14_vjp_host(Tree14<T>& s, const T* V, const Rew14Model<T>& M, const Rew14Ref<T>& R, const Rew14World<T>& wd,
474
+ const T* q, const T* v, const T* lce, T rb, const T* ob, T* qg, T* vg, T* lg, Rew14Out<T>& o) {
475
+ reward14_host(s, V, M, R, wd, q, v, lce, o);
476
+ T troot[3];
477
+ reward14_reverse(s, M, R, o, q, v, rb, ob, qg, vg, lg, troot);
478
+ T tq[NV] = {}, tv[NV] = {};
479
+ tree14_up(s, V, tq, tv, 0);
480
+ for (int i = 0; i < NV; ++i) vg[i] += tv[i];
481
+ reward14_raw(q, tq, troot, qg);
482
+ }
483
+
484
+ } // namespace d16::x14adj