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,439 @@
1
+ #pragma once
2
+ // D16 adjoint (engine B, 2026-11-02): the closed-form reverse of the constraint-row term of one substep,
3
+ // G_rows = - sum_{quadratic rows r} D_r (J_r lambda) (J_r a* - aref_r),
4
+ // and of the PD actuator term G_act = lambda^T act (unclamped actuators), with lambda, a* held and the decisions held.
5
+ // The primal is the core/soft (rows.h, collide.h, impedance.h, kin.h point_jacobian) and is recomputed here from the
6
+ // body states; the outputs are the world-frame body pose cotangents (xpos_bar, xrot_bar: rotation-vector cotangent of
7
+ // delta R = [dtheta]x R) for d5's adj_tree pull-back, plus the direct q_bar (limit rows, PD), v_bar (aref's J v, PD) and
8
+ // u_bar (PD). Templated on S; this CPU serial form is the reference the lane-parallel device code is gated against.
9
+ // Derivation: tools/d16_adj/INTERFACE.md "Revision of the slot"; collision: the capsule-capsule closest points are
10
+ // differentiated through their stationarity conditions on the coordinates free in the primal's branch.
11
+ #include "diffneusim/macros.h" // JS_DEVICE_ASSERT
12
+ #include <cassert>
13
+ #include <type_traits>
14
+ #include <vector>
15
+
16
+ #include "../rows.h"
17
+ #include "../step.h" // SoftModel, SoftActuator
18
+
19
+ namespace js::soft::adj {
20
+
21
+ #ifdef DN_ADJ_TEST_HOOKS
22
+ inline int g_test_flip = 0; // positive controls (tests only): 1 drops the impedance path, 2 flips the frame cotangent, 3 drops the
23
+ // capsule stationarity correction
24
+ #endif
25
+
26
+ template <class S> using V = V3<S>;
27
+ template <class S> DN_HOST_DEVICE V<S> vadd(V<S> a, V<S> b) { return so3::add(a, b); }
28
+ template <class S> DN_HOST_DEVICE V<S> vsub(V<S> a, V<S> b) { return so3::sub(a, b); }
29
+ template <class S> DN_HOST_DEVICE V<S> vsc(V<S> a, S s) { return so3::scale(a, s); }
30
+ template <class S> DN_HOST_DEVICE S vdot(V<S> a, V<S> b) { return so3::dot(a, b); }
31
+ template <class S> DN_HOST_DEVICE V<S> vcr(V<S> a, V<S> b) { return so3::cross(a, b); }
32
+ template <class S> DN_HOST_DEVICE V<S> vz() { return V<S>{S(0), S(0), S(0)}; }
33
+ template <class S> DN_HOST_DEVICE V<S> va(const S* p) { return V<S>{p[0], p[1], p[2]}; }
34
+ template <class S> DN_HOST_DEVICE void vacc(S* p, V<S> a) { p[0] = p[0] + a.x; p[1] = p[1] + a.y; p[2] = p[2] + a.z; }
35
+
36
+ // a body with no dof on its chain to the world (the world, the terrain): its pose is constant
37
+ DN_HOST_DEVICE inline bool body_static(const SoftBody* B, int b) {
38
+ for (; b > 0; b = B[b].parent) if (B[b].jnt_type != -1) return false;
39
+ return true;
40
+ }
41
+
42
+ // the pose cotangents of the bodies (world frame), nb x 3 each
43
+ template <class S> struct PoseBar {
44
+ std::vector<S> xpos, xrot;
45
+ void reset(int nb) { xpos.assign(3 * nb, S(0)); xrot.assign(3 * nb, S(0)); }
46
+ };
47
+
48
+ // d imp / d pos of getimpedance (impedance.h), 0 in the saturated and constant branches; P: the parameters' type (double, or float
49
+ // on the f32 device path: the P-templated law)
50
+ template <class S, class P = double> DN_HOST_DEVICE S impedance_dpos(const P* solimp, S pos, P margin) {
51
+ if (solimp[0] == solimp[1] || solimp[2] <= P(kMinVal)) return S(0);
52
+ using L = lit_t<S>;
53
+ S x = (pos - S(margin)) / S(solimp[2]);
54
+ S sg = S(1);
55
+ if (x < L(0)) { x = S(0) - x; sg = S(-1); }
56
+ if (x >= L(1) || x <= L(0)) return S(0);
57
+ S dy;
58
+ if (solimp[4] == 1) {
59
+ dy = S(1);
60
+ } else if (x <= solimp[3]) {
61
+ const P a = P(1) / power_(solimp[3], solimp[4] - P(1));
62
+ dy = S(a * solimp[4]) * power_(x, solimp[4] - P(1));
63
+ } else {
64
+ const P b = P(1) / power_(P(1) - solimp[3], solimp[4] - P(1));
65
+ dy = S(b * solimp[4]) * power_(S(1) - x, solimp[4] - P(1));
66
+ }
67
+ return dy * S(solimp[1] - solimp[0]) * sg / S(solimp[2]);
68
+ }
69
+
70
+ // mju_makeFrame's reverse (collide.h make_frame): frame_bar[3] -> normal_bar, tangent_bar (only if the tangent hint was used)
71
+ template <class S>
72
+ DN_HOST_DEVICE void make_frame_reverse(V<S> normal, V<S> tangent, const V<S>* fbar, V<S>& normal_bar, V<S>& tangent_bar,
73
+ bool& tangent_used) {
74
+ V<S> x = normal;
75
+ const S nx = normalize3(x);
76
+ using L = lit_t<S>;
77
+ V<S> y0 = tangent;
78
+ tangent_used = !(vdot(y0, y0) < L(0.25));
79
+ if (!tangent_used) y0 = (x.y > L(-0.5) && x.y < L(0.5)) ? V<S>{S(0), S(1), S(0)} : V<S>{S(0), S(0), S(1)};
80
+ const V<S> y1 = vsub(y0, vsc(x, vdot(x, y0)));
81
+ V<S> y = y1;
82
+ const S ny = normalize3(y);
83
+ // z = x cross y
84
+ V<S> xb = vadd(fbar[0], vcr(y, fbar[2]));
85
+ V<S> yb = vadd(fbar[1], vcr(fbar[2], x));
86
+ // y = y1 / |y1|
87
+ const V<S> y1b = vsc(vsub(yb, vsc(y, vdot(y, yb))), S(1) / ny);
88
+ // y1 = y0 - x (x . y0)
89
+ const S xy0 = vdot(x, y0), xy1b = vdot(x, y1b);
90
+ xb = vsub(xb, vadd(vsc(y1b, xy0), vsc(y0, xy1b)));
91
+ tangent_bar = vsub(y1b, vsc(x, xy1b));
92
+ // x = normal / |normal|
93
+ normal_bar = vsc(vsub(xb, vsc(x, vdot(x, xb))), S(1) / nx);
94
+ }
95
+
96
+ // sphere_sphere's reverse: (dist_bar, pos_bar, normal_bar) -> centre cotangents c1_bar, c2_bar (radii constant)
97
+ template <class S, class P>
98
+ DN_HOST_DEVICE void sphere_sphere_reverse(V<S> c1, P r1, V<S> c2, S dist_bar, V<S> pos_bar, V<S> normal_bar,
99
+ V<S>& c1_bar, V<S>& c2_bar) {
100
+ V<S> u = vsub(c2, c1);
101
+ V<S> n = u;
102
+ const S len = normalize3(n);
103
+ JS_DEVICE_ASSERT(!(len < lit_t<S>(kMinVal)) && "sphere_sphere_reverse: coincident centres (the cross-product normal is not differentiated)"); // data: gate builds
104
+ using so3::js_sqrt;
105
+ const S dist = len - S(r1); // only dist / 2 + r1 enters below, with dist = |u| - r1 - r2: r1 + dist / 2 = (len + r1 - r2) / 2
106
+ (void)dist;
107
+ c1_bar = vadd(c1_bar, pos_bar);
108
+ // pos = c1 + n (r1 + dist / 2), dist = len - r1 - r2 -> r1 + dist / 2 = (len + r1 - r2) / 2 is computed by the caller
109
+ // (it knows r2); here the caller passes normal_bar already including (r1 + dist / 2) pos_bar and dist_bar including
110
+ // (n . pos_bar) / 2. len_bar = dist_bar.
111
+ const V<S> ub = vadd(vsc(vsub(normal_bar, vsc(n, vdot(n, normal_bar))), S(1) / len), vsc(n, dist_bar));
112
+ c2_bar = vadd(c2_bar, ub);
113
+ c1_bar = vsub(c1_bar, ub);
114
+ }
115
+
116
+ // one contact's geometry cotangents -> the two geoms' pose cotangents (p_bar, z axis bar); the primal is recomputed from the
117
+ // geom poses and must reproduce the contact (asserted by the caller through dist / pos)
118
+ template <class S> struct GeomBar { V<S> p, z; };
119
+
120
+ template <class S, class G>
121
+ DN_HOST_DEVICE void collide_reverse(bool a_static, const G& ga, const GeomPose<S>& pa, const G& gb, const GeomPose<S>& pb,
122
+ int slot, S dist_bar, V<S> pos_bar, V<S> normal_bar, V<S> tangent_bar, GeomBar<S>& ba,
123
+ GeomBar<S>& bb) {
124
+ const int t1 = ga.type, t2 = gb.type;
125
+ using L = lit_t<S>;
126
+ using P = typename std::remove_cv<typename std::remove_reference<decltype(ga.size[0])>::type>::type;
127
+ auto ss = [&](V<S> c1, P r1, V<S> c2, P r2, V<S>& c1b, V<S>& c2b) {
128
+ V<S> n = vsub(c2, c1);
129
+ const S len = normalize3(n);
130
+ const S d = len - S(r1) - S(r2);
131
+ const V<S> nb = vadd(normal_bar, vsc(pos_bar, S(r1) + d / S(2)));
132
+ const S db = dist_bar + vdot(n, pos_bar) / S(2);
133
+ c1b = vz<S>(); c2b = vz<S>();
134
+ sphere_sphere_reverse(c1, r1, c2, db, pos_bar, nb, c1b, c2b);
135
+ };
136
+ if (t1 == 0) { // plane (geom a): the world floor, static
137
+ JS_DEVICE_ASSERT(a_static && "collide_reverse: a moving plane is not differentiated"); // structural: the binding checks it at init
138
+ const V<S> n = zaxis(pa.R);
139
+ V<S> c = pb.p;
140
+ const P r = gb.size[0];
141
+ const V<S> axis = zaxis(pb.R);
142
+ if (t2 == 3) c = slot == 0 ? vadd(pb.p, vsc(axis, S(gb.size[1]))) : vsub(pb.p, vsc(axis, S(gb.size[1])));
143
+ // pos = c - n (dist / 2 + r): c_bar += pos_bar; dist_bar_total = dist_bar - (n . pos_bar) / 2; c_bar += dist_bar_total n
144
+ const S dtot = dist_bar - vdot(n, pos_bar) / S(2);
145
+ const V<S> cb = vadd(pos_bar, vsc(n, dtot));
146
+ bb.p = vadd(bb.p, cb);
147
+ if (t2 == 3) {
148
+ bb.z = vadd(bb.z, vsc(cb, S(slot == 0 ? gb.size[1] : -gb.size[1])));
149
+ bb.z = vadd(bb.z, tangent_bar); // the contact's tangent hint is the capsule axis
150
+ }
151
+ (void)r;
152
+ return;
153
+ }
154
+ if (t1 == 2 && t2 == 2) {
155
+ V<S> c1b, c2b;
156
+ ss(pa.p, ga.size[0], pb.p, gb.size[0], c1b, c2b);
157
+ ba.p = vadd(ba.p, c1b); bb.p = vadd(bb.p, c2b);
158
+ return;
159
+ }
160
+ if (t1 == 2 && t2 == 3) {
161
+ const V<S> axis = zaxis(pb.R), w = vsub(pa.p, pb.p);
162
+ const P L = gb.size[1];
163
+ const S x0 = vdot(axis, w);
164
+ const bool clipped = x0 < -L || x0 > L;
165
+ const S x = clip(x0, -L, L);
166
+ const V<S> c2 = vadd(pb.p, vsc(axis, x));
167
+ V<S> c1b, c2b;
168
+ ss(pa.p, ga.size[0], c2, gb.size[0], c1b, c2b);
169
+ ba.p = vadd(ba.p, c1b);
170
+ bb.p = vadd(bb.p, c2b);
171
+ bb.z = vadd(bb.z, vsc(c2b, x));
172
+ if (!clipped) {
173
+ const S xb = vdot(axis, c2b);
174
+ bb.z = vadd(bb.z, vsc(w, xb));
175
+ ba.p = vadd(ba.p, vsc(axis, xb));
176
+ bb.p = vsub(bb.p, vsc(axis, xb));
177
+ }
178
+ return;
179
+ }
180
+ JS_DEVICE_ASSERT(t1 == 3 && t2 == 3 && "collide_reverse: a geom-type pair the G1 law does not handle"); // structural: collide_handles at init
181
+ const P L1 = ga.size[1], L2 = gb.size[1];
182
+ const V<S> z1 = zaxis(pa.R), z2 = zaxis(pb.R);
183
+ const V<S> a1 = vsc(z1, S(L1)), a2 = vsc(z2, S(L2));
184
+ const V<S> dif = vsub(pa.p, pb.p);
185
+ const S ma = vdot(a1, a1), mb = S(0) - vdot(a1, a2), mc = vdot(a2, a2);
186
+ const S u = S(0) - vdot(a1, dif), v = vdot(a2, dif);
187
+ const V<S> cr = vcr(a1, a2);
188
+ const S det = vdot(cr, cr);
189
+ S x1, x2;
190
+ bool f1, f2; // x1 / x2 free (an interior stationary coordinate) in the primal's branch
191
+ if (det > S(1e-8) * ma * mc) {
192
+ JS_DEVICE_ASSERT(slot == 0); // data (the collider: one contact when not parallel): gate builds
193
+ const S x1r = vdot(cr, vcr(a2, dif)) / det;
194
+ x1 = clip(x1r, L(-1), L(1));
195
+ f1 = !(x1r < L(-1) || x1r > L(1));
196
+ x2 = (v - mb * x1) / mc;
197
+ f2 = true;
198
+ if (x2 > L(1) || x2 < L(-1)) {
199
+ x2 = clip(x2, L(-1), L(1));
200
+ f2 = false;
201
+ const S x1s = (u - mb * x2) / ma;
202
+ x1 = clip(x1s, L(-1), L(1));
203
+ f1 = !(x1s < L(-1) || x1s > L(1));
204
+ }
205
+ } else { // the parallel branch: slot 0 / 1: x1 = +-1, x2 = clip(stationary); slot 2 / 3: x2 = +-1, x1 = clip(stationary)
206
+ if (slot <= 1) {
207
+ x1 = S(slot == 0 ? 1.0 : -1.0); f1 = false;
208
+ const S x2s = (v - mb * x1) / mc;
209
+ x2 = clip(x2s, L(-1), L(1)); f2 = !(x2s < L(-1) || x2s > L(1));
210
+ } else {
211
+ x2 = S(slot == 2 ? 1.0 : -1.0); f2 = false;
212
+ const S x1s = (u - mb * x2) / ma;
213
+ x1 = clip(x1s, L(-1), L(1)); f1 = !(x1s < L(-1) || x1s > L(1));
214
+ }
215
+ }
216
+ const V<S> P1 = vadd(pa.p, vsc(a1, x1)), P2 = vadd(pb.p, vsc(a2, x2));
217
+ V<S> P1b, P2b;
218
+ ss(P1, ga.size[0], P2, gb.size[0], P1b, P2b);
219
+ V<S> a1b = vsc(P1b, x1), a2b = vsc(P2b, x2), difb = vz<S>();
220
+ ba.p = vadd(ba.p, P1b);
221
+ bb.p = vadd(bb.p, P2b);
222
+ const S x1b = vdot(a1, P1b), x2b = vdot(a2, P2b);
223
+ #ifndef DN_ADJ_FREEZE_PARALLEL_SOFT
224
+ const bool freeze = false;
225
+ #else
226
+ const bool freeze = f1 && f2 && det < S(L(1.2e-3)) * ma * mc; // NablaEngine's near-parallel rule: x_bar held at 0
227
+ #endif
228
+ #ifdef DN_ADJ_TEST_HOOKS
229
+ if (g_test_flip == 3) f1 = f2 = false;
230
+ #endif
231
+ if ((f1 || f2) && !freeze) {
232
+ // stationarity e1 = a1 . d = 0 (x1 free), e2 = a2 . d = 0 (x2 free), d = dif + a1 x1 - a2 x2
233
+ const V<S> d = vsub(vadd(dif, vsc(a1, x1)), vsc(a2, x2));
234
+ const S A11 = ma, A12 = mb, A21 = S(0) - mb, A22 = S(0) - mc; // de1/dx = (a1.a1, -a1.a2), de2/dx = (a1.a2, -a2.a2)
235
+ S mu1 = S(0), mu2 = S(0);
236
+ if (f1 && f2) { // A^T mu = -x_bar
237
+ const S dt = A11 * A22 - A12 * A21;
238
+ mu1 = (S(0) - x1b * A22 + x2b * A21) / dt;
239
+ mu2 = (S(0) - x2b * A11 + x1b * A12) / dt;
240
+ } else if (f1) {
241
+ mu1 = (S(0) - x1b) / A11;
242
+ } else {
243
+ mu2 = (S(0) - x2b) / A22;
244
+ }
245
+ if (f1) {
246
+ a1b = vadd(a1b, vsc(vadd(d, vsc(a1, x1)), mu1));
247
+ a2b = vadd(a2b, vsc(a1, S(0) - x2 * mu1));
248
+ difb = vadd(difb, vsc(a1, mu1));
249
+ }
250
+ if (f2) {
251
+ a1b = vadd(a1b, vsc(a2, x1 * mu2));
252
+ a2b = vadd(a2b, vsc(vsub(d, vsc(a2, x2)), mu2));
253
+ difb = vadd(difb, vsc(a2, mu2));
254
+ }
255
+ }
256
+ ba.p = vadd(ba.p, difb);
257
+ bb.p = vsub(bb.p, difb);
258
+ ba.z = vadd(ba.z, vsc(a1b, S(L1)));
259
+ bb.z = vadd(bb.z, vsc(a2b, S(L2)));
260
+ }
261
+
262
+ // the reverse of G_rows + G_act for one substep. X: the body states at q (double primal recomputed by the caller, or the tape's
263
+ // POSE block); con / rows: the primal contacts and rows at X (double); zone: the quadratic rows; clamp: the actuator clamps.
264
+ // ADDS into q_bar / v_bar / u_bar and pose (xpos / xrot).
265
+ template <class S>
266
+ void rows_act_reverse(const SoftModel& m, const BodyState<S>* X, const std::vector<SoftContact<S>>& con, const Rows<S>& rows,
267
+ const int* zone, const int* clamp, const S* qvel, const S* lambda, const S* a_star, S* q_bar,
268
+ S* v_bar, S* u_bar, PoseBar<S>& pose) {
269
+ const int nv = m.nv, nb = static_cast<int>(m.bodies.size());
270
+ const SoftBody* B = m.bodies.data();
271
+ const int n = rows.n;
272
+ // 1. per row: the scalar cotangents
273
+ std::vector<S> cs(n, S(0)), ct(n, S(0)), cv(n, S(0)), Db(n, S(0)), impb(n, S(0)), posb(n, S(0));
274
+ for (int r = 0; r < n; ++r) {
275
+ if (!zone[r]) continue;
276
+ const S* J = rows.J.data() + static_cast<size_t>(r) * nv;
277
+ S s(0), t(0);
278
+ for (int i = 0; i < nv; ++i) { s = s + J[i] * lambda[i]; t = t + J[i] * a_star[i]; }
279
+ const S e = t - rows.aref[r];
280
+ Db[r] = S(0) - s * e;
281
+ cs[r] = S(0) - rows.D[r] * e;
282
+ ct[r] = S(0) - rows.D[r] * s;
283
+ const S arb = rows.D[r] * s;
284
+ cv[r] = S(0) - S(rows.B[r]) * arb;
285
+ impb[r] = S(0) - S(rows.K[r]) * (rows.pos[r] - S(rows.margin[r])) * arb;
286
+ posb[r] = S(0) - S(rows.K[r]) * rows.imp[r] * arb;
287
+ for (int i = 0; i < nv; ++i) v_bar[i] = v_bar[i] + cv[r] * J[i];
288
+ }
289
+ // 2. D -> imp (pyramid: the four rows share D = 1 / (c R0)); 3. imp -> pos
290
+ for (int r = 0; r < n;) {
291
+ const bool pyr = rows.type[r] == kRowPyramidal;
292
+ const int k = pyr ? 4 : 1;
293
+ S dbs(0), ibs(0), pbs(0);
294
+ for (int j = 0; j < k; ++j) { dbs = dbs + Db[r + j]; ibs = ibs + impb[r + j]; pbs = pbs + posb[r + j]; }
295
+ const S imp = rows.imp[r];
296
+ const double dA = rows.diagA[r];
297
+ double c = 1;
298
+ if (pyr) c = 2 * con[rows.id[r]].mu * con[rows.id[r]].mu / smax(kMinVal, m.impratio);
299
+ const S R0 = (S(1) - imp) * S(dA) / imp;
300
+ assert(R0 > kMinVal && "rows_act_reverse: the regularizer sits at mjMINVAL (its derivative is 0, not handled)");
301
+ const S D = rows.D[r];
302
+ ibs = ibs + dbs * D * D * S(c * dA) / (imp * imp);
303
+ const double* solimp = rows.type[r] == kRowLimit ? m.joints[rows.id[r]].solimp : con[rows.id[r]].solimp;
304
+ const SolParam sp = rows.type[r] == kRowLimit ? sol_param(m.joints[rows.id[r]].solref, solimp, m.timestep)
305
+ : sol_param(con[rows.id[r]].solref, solimp, m.timestep);
306
+ S dimp = impedance_dpos(sp.imp, rows.pos[r], rows.margin[r]);
307
+ #ifdef DN_ADJ_TEST_HOOKS
308
+ if (g_test_flip == 1) dimp = S(0);
309
+ #endif
310
+ pbs = pbs + ibs * dimp;
311
+ for (int j = 0; j < k; ++j) posb[r + j] = S(0);
312
+ posb[r] = pbs; // the group's total pos cotangent sits on its first row
313
+ r += k;
314
+ }
315
+ // limit rows: pos = +-(q - range), J = +-1 at the dof: q_bar += pos_bar J
316
+ for (int r = 0; r < n; ++r)
317
+ if (rows.type[r] == kRowLimit) {
318
+ const int d = m.joints[rows.id[r]].dof;
319
+ q_bar[d] = q_bar[d] + posb[r] * rows.J[static_cast<size_t>(r) * nv + d];
320
+ }
321
+ // 4. contacts: J_r x = d_r . (Vp2(x) - Vp1(x)), d_r = frame0 + sg mu frame_k
322
+ const int ng = static_cast<int>(m.geoms.size());
323
+ std::vector<GeomPose<S>> gp(ng);
324
+ for (int g = 0; g < ng; ++g) gp[g] = geom_pose(X[m.geoms[g].body], m.geoms[g]);
325
+ const S* xs[3] = {lambda, a_star, qvel};
326
+ int r = 0;
327
+ while (r < n && rows.type[r] == kRowLimit) ++r;
328
+ for (size_t ci = 0; ci < con.size(); ++ci) {
329
+ const SoftContact<S>& c = con[ci];
330
+ const SoftPair& pr = m.pairs[c.pair];
331
+ const int b1 = m.geoms[pr.g1].body, b2 = m.geoms[pr.g2].body;
332
+ const int k = c.condim == 1 ? 1 : 4;
333
+ assert(rows.id[r] == static_cast<int>(ci));
334
+ // row directions and coefficients
335
+ V<S> dr[4];
336
+ S co[4][3];
337
+ for (int j = 0; j < k; ++j) {
338
+ if (c.condim == 1) dr[j] = c.frame[0];
339
+ else {
340
+ const int kk = 1 + j / 2;
341
+ const S sg = S(j % 2 == 0 ? c.mu : -c.mu);
342
+ dr[j] = vadd(c.frame[0], vsc(c.frame[kk], sg));
343
+ }
344
+ co[j][0] = cs[r + j]; co[j][1] = ct[r + j]; co[j][2] = cv[r + j];
345
+ }
346
+ V<S> W[3];
347
+ for (int x = 0; x < 3; ++x) {
348
+ W[x] = vz<S>();
349
+ for (int j = 0; j < k; ++j) W[x] = vadd(W[x], vsc(dr[j], co[j][x]));
350
+ }
351
+ const V<S> p = c.pos;
352
+ V<S> pbar = vz<S>(), fbar[3] = {vz<S>(), vz<S>(), vz<S>()};
353
+ // the chains of b2 (+) and b1 (-)
354
+ for (int side = 0; side < 2; ++side) {
355
+ const int bs = side == 0 ? b2 : b1;
356
+ const S sgn = S(side == 0 ? 1.0 : -1.0);
357
+ V<S> dV[3] = {vz<S>(), vz<S>(), vz<S>()}; // this body's point velocity per x (for the frame cotangent)
358
+ for (int b = bs; b > 0; b = B[b].parent) {
359
+ const SoftBody& bd = B[b];
360
+ const V<S> anc = va(X[b].xpos);
361
+ if (bd.jnt_type == kJntHinge) {
362
+ S aw[3];
363
+ mat_vec(X[b].xmat, bd.axis, aw);
364
+ const V<S> a = va(aw), rr = vsub(p, anc);
365
+ V<S> ab = vz<S>(), anb = vz<S>();
366
+ for (int x = 0; x < 3; ++x) {
367
+ const S xi = xs[x][bd.dadr];
368
+ dV[x] = vadd(dV[x], vsc(vcr(a, rr), xi));
369
+ ab = vadd(ab, vsc(vcr(rr, W[x]), sgn * xi));
370
+ anb = vsub(anb, vsc(vcr(W[x], a), sgn * xi));
371
+ pbar = vadd(pbar, vsc(vcr(W[x], a), sgn * xi));
372
+ }
373
+ vacc(&pose.xrot[3 * b], vcr(a, ab));
374
+ vacc(&pose.xpos[3 * b], anb);
375
+ } else if (bd.jnt_type == kJntFree) {
376
+ const V<S> rr = vsub(p, anc);
377
+ for (int x = 0; x < 3; ++x)
378
+ dV[x] = vadd(dV[x], V<S>{xs[x][bd.dadr], xs[x][bd.dadr + 1], xs[x][bd.dadr + 2]});
379
+ for (int e = 0; e < 3; ++e) {
380
+ const V<S> a{X[b].xmat[e], X[b].xmat[3 + e], X[b].xmat[6 + e]};
381
+ V<S> ab = vz<S>(), anb = vz<S>();
382
+ for (int x = 0; x < 3; ++x) {
383
+ const S xi = xs[x][bd.dadr + 3 + e];
384
+ dV[x] = vadd(dV[x], vsc(vcr(a, rr), xi));
385
+ ab = vadd(ab, vsc(vcr(rr, W[x]), sgn * xi));
386
+ anb = vsub(anb, vsc(vcr(W[x], a), sgn * xi));
387
+ pbar = vadd(pbar, vsc(vcr(W[x], a), sgn * xi));
388
+ }
389
+ vacc(&pose.xrot[3 * b], vcr(a, ab));
390
+ vacc(&pose.xpos[3 * b], anb);
391
+ }
392
+ }
393
+ }
394
+ for (int j = 0; j < k; ++j) {
395
+ V<S> g = vz<S>();
396
+ for (int x = 0; x < 3; ++x) g = vadd(g, vsc(dV[x], co[j][x] * sgn));
397
+ fbar[0] = vadd(fbar[0], g);
398
+ if (c.condim != 1) fbar[1 + j / 2] = vadd(fbar[1 + j / 2], vsc(g, S(j % 2 == 0 ? c.mu : -c.mu)));
399
+ }
400
+ }
401
+ // 5. the frame -> normal / tangent; 6. the collider -> geom poses; 7. geom -> body
402
+ PreContact<S> pc[4];
403
+ const SoftGeom &ga = m.geoms[pr.g1], &gb = m.geoms[pr.g2];
404
+ const int nc = collide(pc, pr.margin + pr.gap, ga.type, gp[pr.g1], ga.size, gb.type, gp[pr.g2], gb.size);
405
+ int hit = -1;
406
+ for (int q = 0; q < nc; ++q) if (pc[q].slot == c.slot) hit = q;
407
+ assert(hit >= 0 && "rows_act_reverse: the contact does not reproduce");
408
+ V<S> nb_, tb_;
409
+ bool tused;
410
+ #ifdef DN_ADJ_TEST_HOOKS
411
+ if (g_test_flip == 2) for (V<S>& f : fbar) f = vsc(f, S(-1));
412
+ #endif
413
+ make_frame_reverse(pc[hit].normal, pc[hit].tangent, fbar, nb_, tb_, tused);
414
+ if (!tused) tb_ = vz<S>();
415
+ GeomBar<S> bA{vz<S>(), vz<S>()}, bB{vz<S>(), vz<S>()};
416
+ collide_reverse(body_static(B, ga.body), ga, gp[pr.g1], gb, gp[pr.g2], c.slot, posb[r], pbar, nb_, tb_, bA, bB);
417
+ for (int side = 0; side < 2; ++side) {
418
+ const SoftGeom& g = side == 0 ? ga : gb;
419
+ const GeomBar<S>& gbar = side == 0 ? bA : bB;
420
+ const GeomPose<S>& P = side == 0 ? gp[pr.g1] : gp[pr.g2];
421
+ if (body_static(B, g.body)) continue;
422
+ const V<S> off = vsub(P.p, va(X[g.body].xpos)); // R_b g.pos
423
+ vacc(&pose.xpos[3 * g.body], gbar.p);
424
+ vacc(&pose.xrot[3 * g.body], vadd(vcr(off, gbar.p), vcr(zaxis(P.R), gbar.z)));
425
+ }
426
+ r += k;
427
+ }
428
+ // PD: act = kp u - kp q - kd v on unclamped actuators; G_act = lambda^T act
429
+ for (size_t a = 0; a < m.actuators.size(); ++a) {
430
+ const SoftActuator& A = m.actuators[a];
431
+ if (clamp[A.dof]) continue;
432
+ u_bar[a] = u_bar[a] + lambda[A.dof] * S(A.kp);
433
+ q_bar[A.dof] = q_bar[A.dof] - lambda[A.dof] * S(A.kp);
434
+ v_bar[A.dof] = v_bar[A.dof] - lambda[A.dof] * S(A.kd);
435
+ }
436
+ (void)nb;
437
+ }
438
+
439
+ } // namespace js::soft::adj
@@ -0,0 +1,89 @@
1
+ #pragma once
2
+ // D16 adjoint (engine B, 2026-11-02): B's row / PD reverse as the shell's Rows functor (d5's shell_adj.h, step 5:
3
+ // rows(s, q, v, lambda, a*, q_bar, v_bar, u_bar, xpos_bar, xrot_bar), all ADDED).
4
+ // It reads substep s's record of the control step (rec + s L.words, the core/soft/tape.h layout): the zone and clamp bits, the
5
+ // contact table (u16 pair | slot << 9, hdr's ncon), and the POSE block when the layout has one (npose = kNB; the A/B's READ arm).
6
+ // Without it (npose 0, the RECOMPUTE arm) it runs a level-parallel FK pre-pass (d5's body_kin, the replay's rounding) into scratch.
7
+ // scratch: the shell's adj_tree staging area, idle during step 5 (1,152 words): twists 576 + one contact batch 288 + pose 224.
8
+ #include "rows_lanes.h"
9
+ #include "../tape.h"
10
+
11
+ namespace js::soft::adj {
12
+
13
+ constexpr int kRowsScratch = kNB * kTw + kConBatch * kConRec + kPoseWords;
14
+
15
+ template <class S, class Tab, class CTab>
16
+ struct RowsB {
17
+ Tab B;
18
+ CTab C;
19
+ const S* rec; // the control step's first record
20
+ TapeLayout L;
21
+ double foot_friction; // the world's (DR); < 0: the pairs' own
22
+ S* scratch; // kRowsScratch words, free during step 5
23
+ uint32_t* flag; // the shell's flag word: kRowsNoContact if a recorded contact did not reproduce
24
+
25
+ DN_HOST_DEVICE void operator()(int s, const S* q, const S* v, const S* lambda, const S* a_star, S* q_bar, S* v_bar,
26
+ S* u_bar, S* xpos_bar, S* xrot_bar) const {
27
+ const S* r = rec + static_cast<size_t>(s) * L.words;
28
+ const int ncon = static_cast<int>(tape_get_u(r, L.hdr) & 255u);
29
+ S* work = scratch;
30
+ const S* pose = nullptr;
31
+ if (L.npose == kNB) {
32
+ pose = r + L.pose;
33
+ } else { // RECOMPUTE: the body frames from q, level by level (body_kin: kernel P's per-body FK and rounding)
34
+ S* P = scratch + kNB * kTw + kConBatch * kConRec;
35
+ ADJ_LANES(lane) {
36
+ if (lane == 0) {
37
+ for (int k = 0; k < 3; ++k) pose_xpos(P, 0)[k] = S(0);
38
+ pose_xquat(P, 0)[0] = S(1); pose_xquat(P, 0)[1] = pose_xquat(P, 0)[2] = pose_xquat(P, 0)[3] = S(0);
39
+ }
40
+ }
41
+ for (int d = 1; d <= B.maxdepth(); ++d) {
42
+ ADJ_LANES(lane) {
43
+ if (lane < B.nb() && B.depth(lane) == d) {
44
+ const int p = B.parent(lane);
45
+ S R[9], rr[3], a[3];
46
+ body_kin(B, lane, q, pose_xquat(P, p), pose_xpos(P, p), pose_xquat(P, lane), pose_xpos(P, lane), R, rr, a);
47
+ }
48
+ }
49
+ }
50
+ pose = P;
51
+ }
52
+ struct Zone {
53
+ const S* r; int w;
54
+ DN_HOST_DEVICE bool operator()(int i) const { return (tape_get_u(r, w + (i >> 5)) >> (i & 31)) & 1u; }
55
+ };
56
+ struct Con {
57
+ const S* r; int w;
58
+ DN_HOST_DEVICE void operator()(int i, int& pair, int& slot) const {
59
+ const uint32_t u = tape_get_u(r, w + (i >> 1));
60
+ const uint32_t e = (i & 1) ? (u >> 16) : (u & 0xFFFFu); // low half first
61
+ pair = static_cast<int>(e & 511u);
62
+ slot = static_cast<int>(e >> 9);
63
+ }
64
+ };
65
+ rows_act_reverse_lanes<S>(B, C, pose, q, v, lambda, a_star, Zone{r, L.zone}, Zone{r, L.clamp}, Con{r, L.con}, ncon, foot_friction,
66
+ q_bar, v_bar, u_bar, xpos_bar, xrot_bar, work, flag,
67
+ #if defined(ADJ_SECT)
68
+ s
69
+ #else
70
+ -1
71
+ #endif
72
+ );
73
+ }
74
+ };
75
+
76
+ // The kernel's per-world binding (d5's k_adjoint_step: rows.bind(w, recs_w, scratch, flag) before adj_control_step): the model tables
77
+ // and the layout are shared, the world's records, foot friction, scratch and flag word are bound per world.
78
+ template <class S, class Tab, class CTab>
79
+ struct RowsBFactory {
80
+ Tab B;
81
+ CTab C;
82
+ TapeLayout L;
83
+ const double* foot; // [nw] the worlds' foot friction (DR), or nullptr: the pairs' own
84
+ DN_HOST_DEVICE RowsB<S, Tab, CTab> bind(int w, const S* recs_w, S* scratch, uint32_t* flag) const {
85
+ return RowsB<S, Tab, CTab>{B, C, recs_w, L, foot ? foot[w] : -1.0, scratch, flag};
86
+ }
87
+ };
88
+
89
+ } // namespace js::soft::adj