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,273 @@
1
+ #pragma once
2
+ // Phase 2: minimal-coordinate kinematic tree + forward kinematics.
3
+ //
4
+ // Codex-debated (discuss_20260621_1008): minimal/generalized coordinates (matches
5
+ // mujoco-son for parity, smallest solve). FK is a per-body assembly stage — the
6
+ // batch maps env x body in parallel (NOT one thread per env walking the whole
7
+ // tree, which is the mjwarp env-serial trap, postmortem). Bodies are stored in
8
+ // tree order (parent index < child), so a single forward sweep resolves poses.
9
+ //
10
+ // Pose = body->world (quat q, position p), matching mujoco xquat/xpos so the
11
+ // FK parity check is direct. Per body i:
12
+ // pose[i] = pose[parent] ∘ ( T_tree[i] · T_joint(q_i) )
13
+ // where T_tree is the fixed rest offset (parent frame -> joint frame) and
14
+ // T_joint is the joint displacement. Reuses so3 (quat mul/rotate/exp_map).
15
+ #include "diffneusim/macros.h"
16
+ #include "../math/so3.h"
17
+
18
+ namespace js::kin {
19
+
20
+ using so3::Vec3;
21
+ using so3::Quat;
22
+
23
+ enum class JointType { Fixed = 0, Revolute, Slide, Ball, Free };
24
+
25
+ // nq (q coords) / nv (dof) per joint type.
26
+ DN_HOST_DEVICE inline int joint_nq(JointType t) {
27
+ switch (t) {
28
+ case JointType::Fixed: return 0;
29
+ case JointType::Revolute: case JointType::Slide: return 1;
30
+ case JointType::Ball: return 4;
31
+ case JointType::Free: return 7;
32
+ }
33
+ return 0;
34
+ }
35
+ DN_HOST_DEVICE inline int joint_nv(JointType t) {
36
+ switch (t) {
37
+ case JointType::Fixed: return 0;
38
+ case JointType::Revolute: case JointType::Slide: return 1;
39
+ case JointType::Ball: return 3;
40
+ case JointType::Free: return 6;
41
+ }
42
+ return 0;
43
+ }
44
+
45
+ // Read-only model parameters (shared across envs; q is per-env state). Pointer
46
+ // view so the same struct is host- and device-usable.
47
+ //
48
+ // Compound joints (MuJoCo-style ordered scalar primitive stacks) are ADDITIVE:
49
+ // the four stack_* / jnt_* members default to nullptr, so every existing
50
+ // aggregate-initialized KinModel (Ant, myoLeg, all tests) is unchanged and
51
+ // single-joint behaviour is bit-identical. A body i is a compound stack iff
52
+ // m.jnt_num && m.jnt_num[i] > 1
53
+ // in which case its jnt_num[i] primitive scalar joints live at stack index
54
+ // jnt_adr[i] .. jnt_adr[i]+jnt_num[i]-1 (each a Revolute/Slide with one nq=nv=1
55
+ // scalar dof; q-offsets accumulate per primitive from qadr[i], v-offsets from
56
+ // vadr[i]). Otherwise the legacy jtype[i]/jaxis[i] path is used verbatim.
57
+ // Primitive k applies first (nearest the parent); the body frame is AFTER all
58
+ // primitives (see compound_joint_transform / compound_subspace_axis).
59
+ template <class S> struct KinModel {
60
+ int nbody;
61
+ const int* parent; // [nbody], <0 = attached to world
62
+ const JointType* jtype; // [nbody]
63
+ const Vec3<S>* jaxis; // [nbody] revolute/slide axis (joint frame, unit)
64
+ const Quat<S>* quat_tree; // [nbody] rest orientation: parent -> joint frame
65
+ const Vec3<S>* pos_tree; // [nbody] rest position: joint origin in parent frame
66
+ const int* qadr; // [nbody] start index of this joint's coords in q
67
+ // --- compound-joint stack (optional; nullptr => single-joint legacy path) ---
68
+ const int* jnt_num = nullptr; // [nbody] primitives in this body's stack (0 => use jtype[i])
69
+ const int* jnt_adr = nullptr; // [nbody] start index into stack_type/stack_axis
70
+ const JointType* stack_type = nullptr; // [n_stack] per-primitive type (Revolute|Slide)
71
+ const Vec3<S>* stack_axis = nullptr; // [n_stack] per-primitive axis (its own frame, unit)
72
+ // --- coupled ("mimic") joint (optional; nullptr => no coupling) ---
73
+ // A coupled body has ZERO own coords in q; its scalar joint (jtype[i]/jaxis[i], a hinge or slide)
74
+ // is DRIVEN by a master DOF: q_dep = Σ_k coef[5*i+k]·q[master]^k (a quartic, so it covers the
75
+ // source mjEQ_JOINT couplings — the same quartic-in-one-master form MuJoCo's mjEQ_JOINT uses;
76
+ // linear for the spine, quartic for the knee). This is the
77
+ // coordinate-reduction of the MuJoCo equality constraints the engine cannot solve; it REMOVES the
78
+ // dependent coord from nq/nv. coupled_master_qadr[i] < 0 => body i is not coupled (legacy path).
79
+ const int* coupled_master_qadr = nullptr; // [nbody] master coord index in q, or <0 if uncoupled
80
+ const int* coupled_master_vadr = nullptr; // [nbody] master velocity-dof index (dynamics reads qd/writes tau here)
81
+ const S* coupled_coef = nullptr; // [nbody*5] per-body quartic coef c0..c4
82
+ };
83
+
84
+ #if defined(DN_KIN_SIMPLE_JOINTS)
85
+ // A build for models without compound stacks or coupled joints (the rigid GPU ext, which refuses any other model at load):
86
+ // both tests are false at compile time, so the per-body null-pointer tests and their branches inside every FK / RNE / M loop
87
+ // disappear (forward item (c), 2026-11-01: about 10-17% of the forward kernel's stall samples on an RTX 3080 Ti laptop GPU). The same answers
88
+ // as the runtime tests give for such a model, so the arithmetic is unchanged.
89
+ template <class S>
90
+ DN_HOST_DEVICE inline constexpr bool is_compound(const KinModel<S>&, int) { return false; }
91
+ template <class S>
92
+ DN_HOST_DEVICE inline constexpr bool is_coupled(const KinModel<S>&, int) { return false; }
93
+ #else
94
+ // True iff body i owns a >1-primitive scalar stack (else the single-joint path).
95
+ template <class S>
96
+ DN_HOST_DEVICE inline bool is_compound(const KinModel<S>& m, int i) {
97
+ return m.jnt_num != nullptr && m.jnt_num[i] > 1;
98
+ }
99
+
100
+ // True iff body i's joint is DRIVEN by a master DOF (q_dep = poly(q_master), 0 own coords).
101
+ template <class S>
102
+ DN_HOST_DEVICE inline bool is_coupled(const KinModel<S>& m, int i) {
103
+ return m.coupled_master_qadr != nullptr && m.coupled_master_qadr[i] >= 0;
104
+ }
105
+ #endif
106
+
107
+ // Dependent joint coordinate q_dep = f(q_master) = Σ_k coef[k]·q_master^k (Horner), plus its first
108
+ // and second derivatives when the out-pointers are non-null.
109
+ //
110
+ // BOTH derivatives are load-bearing, and for a while only the first one existed anywhere and only its
111
+ // CONSTANT term was used (docs/logs/bug-grad-audits.md, 2026-08-27). The kinematic relations are
112
+ // q̇_dep = f'(q_m) q̇_m -- the coupling Jacobian G
113
+ // q̈_dep = f'(q_m) q̈_m + f''(q_m) q̇_m² -- the second term is the joint's Ṡq̇ bias
114
+ // so a non-linear coupling needs f' at every site that projects through G (velocity, force, the mass
115
+ // matrix) AND f'' wherever a velocity-product acceleration is formed. For a LINEAR coupling f' is the
116
+ // constant c1 and f'' is 0, which is why the spine worked while both were missing.
117
+ template <class S>
118
+ DN_HOST_DEVICE inline S coupled_q(const KinModel<S>& m, int i, const S* q, S* dcoef = nullptr,
119
+ S* d2coef = nullptr) {
120
+ const S qm = q[m.coupled_master_qadr[i]];
121
+ const S* c = m.coupled_coef + 5 * i;
122
+ if (dcoef) *dcoef = c[1] + qm * (S(2) * c[2] + qm * (S(3) * c[3] + qm * S(4) * c[4]));
123
+ if (d2coef) *d2coef = S(2) * c[2] + qm * (S(6) * c[3] + qm * S(12) * c[4]);
124
+ return c[0] + qm * (c[1] + qm * (c[2] + qm * (c[3] + qm * c[4])));
125
+ }
126
+
127
+ // The coupling Jacobian f'(q_master) alone -- the value that must be used wherever the old code read
128
+ // `coupled_coef[5*i + 1]`. Identical to that read for a linear coupling.
129
+ template <class S>
130
+ DN_HOST_DEVICE inline S coupled_dcoef(const KinModel<S>& m, int i, const S* q) {
131
+ const S qm = q[m.coupled_master_qadr[i]];
132
+ const S* c = m.coupled_coef + 5 * i;
133
+ return c[1] + qm * (S(2) * c[2] + qm * (S(3) * c[3] + qm * S(4) * c[4]));
134
+ }
135
+
136
+ // THIRD derivative of f. Needed only by the ADJOINT: the acceleration carries an f''(q_m) qd_m^2
137
+ // term, and that term's own q-derivative brings in the third. Zero below a cubic coupling.
138
+ template <class S>
139
+ DN_HOST_DEVICE inline S coupled_d3coef(const KinModel<S>& m, int i, const S* q) {
140
+ const S qm = q[m.coupled_master_qadr[i]];
141
+ const S* c = m.coupled_coef + 5 * i;
142
+ return S(6) * c[3] + qm * S(24) * c[4];
143
+ }
144
+
145
+ // f''(q_master): the second-order term of q̈_dep. Zero for a linear coupling.
146
+ template <class S>
147
+ DN_HOST_DEVICE inline S coupled_d2coef(const KinModel<S>& m, int i, const S* q) {
148
+ const S qm = q[m.coupled_master_qadr[i]];
149
+ const S* c = m.coupled_coef + 5 * i;
150
+ return S(2) * c[2] + qm * (S(6) * c[3] + qm * S(12) * c[4]);
151
+ }
152
+
153
+ template <class S> struct Pose { Quat<S> q; Vec3<S> p; }; // body -> world
154
+
155
+ // Joint displacement transform (R_j, p_j) from this joint's q coords. A Ball / Free quaternion is normalized here,
156
+ // the one place every path reads a joint rotation from q (forward_kinematics, the spatial transforms of
157
+ // body_velocities / RNE / ABA, the contact and muscle chains, their adjoints). The GPU state stores q in f32, so its
158
+ // quaternions are unit only to ~1e-7; read raw, from_pose -> quat_to_mat built a non-orthogonal transform while the
159
+ // pose chains normalized, and the two paths disagreed by ~|q| - 1 (docs/logs/bug-grad-audits.md 2026-10-29). Every q
160
+ // cotangent is in the right-trivialized chart (q (x) exp(d) keeps |q|), where the normalization's Jacobian
161
+ // (I - qh qh^T) / |q| acts as the identity; a Dual-seeded VJP carries it through this quat_normalize. The lift to a raw
162
+ // 4-component cotangent (gpu_bridge._lift_quat) applies it explicitly.
163
+ template <class S>
164
+ DN_HOST_DEVICE void joint_transform(JointType t, Vec3<S> axis, const S* q,
165
+ Quat<S>& R_j, Vec3<S>& p_j) {
166
+ using namespace so3;
167
+ R_j = {S(1), S(0), S(0), S(0)};
168
+ p_j = {S(0), S(0), S(0)};
169
+ switch (t) {
170
+ case JointType::Fixed: break;
171
+ case JointType::Revolute: R_j = exp_map(scale(axis, q[0])); break;
172
+ case JointType::Slide: p_j = scale(axis, q[0]); break;
173
+ case JointType::Ball: R_j = quat_normalize(Quat<S>{q[0], q[1], q[2], q[3]}); break;
174
+ case JointType::Free:
175
+ p_j = {q[0], q[1], q[2]};
176
+ R_j = quat_normalize(Quat<S>{q[3], q[4], q[5], q[6]});
177
+ break;
178
+ }
179
+ }
180
+
181
+ // Compound-joint displacement transform: the ordered composition of the body's
182
+ // primitive scalar joints T_J = T_0(q0)·T_1(q1)·…·T_{n-1}, with primitive 0
183
+ // applied first (nearest the parent) and the body frame AFTER the last primitive.
184
+ // q points at this body's first coord; primitive k consumes joint_nq(stack[k])
185
+ // (== 1 for Revolute/Slide) coords. (Used only when is_compound(m,i).)
186
+ template <class S>
187
+ DN_HOST_DEVICE void compound_joint_transform(const KinModel<S>& m, int i, const S* q,
188
+ Quat<S>& R_j, Vec3<S>& p_j) {
189
+ using namespace so3;
190
+ const int base = m.jnt_adr[i], n = m.jnt_num[i];
191
+ R_j = {S(1), S(0), S(0), S(0)};
192
+ p_j = {S(0), S(0), S(0)};
193
+ int qoff = 0;
194
+ for (int k = 0; k < n; ++k) {
195
+ Quat<S> R_k; Vec3<S> p_k;
196
+ joint_transform(m.stack_type[base + k], m.stack_axis[base + k], q + qoff, R_k, p_k);
197
+ // T_J <- T_J · T_k : p_J += R_J p_k ; R_J = R_J R_k.
198
+ p_j = add(p_j, quat_rotate(R_j, p_k));
199
+ R_j = quat_mul(R_j, R_k);
200
+ qoff += joint_nq(m.stack_type[base + k]);
201
+ }
202
+ }
203
+
204
+ // Body-frame screw AXIS of compound primitive k (local index 0..jnt_num[i]-1):
205
+ // axis_k^body = (R_{k+1}·…·R_{n-1})^T · axis_k
206
+ // where R_j is primitive j's joint rotation. The screw direction axis_k is
207
+ // invariant under its OWN rotation/translation T_k (a hinge rotation is about
208
+ // axis_k; a slide has identity rotation), so axis_k expressed in the frame just
209
+ // AFTER T_k equals axis_k; the remaining primitives k+1..n-1 rotate it into the
210
+ // body frame. The last primitive (k=n-1) has an empty product => its axis is the
211
+ // body-frame axis directly (today's single-joint convention). Caller forms the
212
+ // 6-column from this: hinge S_k=[axis_k^body;0], slide S_k=[0;axis_k^body].
213
+ template <class S>
214
+ DN_HOST_DEVICE so3::Vec3<S> compound_subspace_axis(const KinModel<S>& m, int i, int k, const S* q) {
215
+ using namespace so3;
216
+ const int base = m.jnt_adr[i], n = m.jnt_num[i];
217
+ // R_rest = R_{k+1}·…·R_{n-1} (product of the LATER primitives' joint rotations).
218
+ Quat<S> R_rest{S(1), S(0), S(0), S(0)};
219
+ int qoff = 0;
220
+ for (int j = 0; j < k; ++j) qoff += joint_nq(m.stack_type[base + j]); // skip to primitive k's coords
221
+ int qoff_j = qoff + joint_nq(m.stack_type[base + k]); // first coord of primitive k+1
222
+ for (int j = k + 1; j < n; ++j) {
223
+ Quat<S> R_jj; Vec3<S> p_jj;
224
+ joint_transform(m.stack_type[base + j], m.stack_axis[base + j], q + qoff_j, R_jj, p_jj);
225
+ R_rest = quat_mul(R_rest, R_jj);
226
+ qoff_j += joint_nq(m.stack_type[base + j]);
227
+ }
228
+ // (R_{k+1}…R_{n-1})^T · axis_k = quat_rotate(conj(R_rest), axis_k).
229
+ return quat_rotate(quat_conj(R_rest), m.stack_axis[base + k]);
230
+ }
231
+
232
+ // Joint displacement (R_j, p_j) of body i read from the FULL coordinate vector q. A coupled body
233
+ // evaluates its driven q_dep = poly(q_master) (its own qadr is a phantom that aliases another body's
234
+ // coordinate), a compound body composes its stack, and a single joint reads its own coords. Every
235
+ // sweep that rebuilds a body transform from q goes through here, so none of them can read a coupled
236
+ // body through its phantom address (the contact velocity sweeps did, docs/logs/bug-grad-audits.md
237
+ // 2026-10-25).
238
+ template <class S>
239
+ DN_HOST_DEVICE void body_joint_transform(const KinModel<S>& m, int i, const S* q, Quat<S>& R_j,
240
+ Vec3<S>& p_j) {
241
+ if (is_coupled(m, i)) {
242
+ const S qc = coupled_q(m, i, q);
243
+ joint_transform(m.jtype[i], m.jaxis[i], &qc, R_j, p_j);
244
+ } else if (is_compound(m, i)) {
245
+ compound_joint_transform(m, i, q + m.qadr[i], R_j, p_j);
246
+ } else {
247
+ joint_transform(m.jtype[i], m.jaxis[i], q + m.qadr[i], R_j, p_j);
248
+ }
249
+ }
250
+
251
+ // Forward kinematics: fill pose[i] (body->world) for all bodies. q = one env's
252
+ // generalized coords. Single forward sweep (bodies in tree order). Compound
253
+ // bodies compose their primitive stack; single-joint bodies use joint_transform.
254
+ template <class S>
255
+ DN_HOST_DEVICE void forward_kinematics(const KinModel<S>& m, const S* q, Pose<S>* pose) {
256
+ using namespace so3;
257
+ for (int i = 0; i < m.nbody; ++i) {
258
+ Quat<S> R_j; Vec3<S> p_j;
259
+ body_joint_transform(m, i, q, R_j, p_j);
260
+ // relative pose parent-frame -> body: T_tree · T_joint
261
+ Quat<S> R_rel = quat_mul(m.quat_tree[i], R_j);
262
+ Vec3<S> p_rel = add(quat_rotate(m.quat_tree[i], p_j), m.pos_tree[i]);
263
+ if (m.parent[i] < 0) {
264
+ pose[i] = {quat_normalize(R_rel), p_rel};
265
+ } else {
266
+ const Pose<S>& pp = pose[m.parent[i]];
267
+ pose[i] = {quat_normalize(quat_mul(pp.q, R_rel)),
268
+ add(quat_rotate(pp.q, p_rel), pp.p)};
269
+ }
270
+ }
271
+ }
272
+
273
+ } // namespace js::kin
@@ -0,0 +1,182 @@
1
+ #pragma once
2
+ // SO(3) / unit-quaternion tangent algebra (Phase 1).
3
+ //
4
+ // Conventions (pinned; everything downstream — FK, free-body integration, the
5
+ // IFT adjoint — builds on these, and they match the mujoco-son f64 oracle so
6
+ // parity is well-defined):
7
+ // * Quaternion: Hamilton convention, scalar-first layout [w, x, y, z], unit
8
+ // norm = rotation. (MuJoCo/mujoco-son use scalar-first Hamilton.)
9
+ // * Tangent: rotation-vector phi in R^3 (axis * angle). exp: R^3 -> quat,
10
+ // log: quat -> R^3.
11
+ // * Right Jacobian J_r(phi): exp(phi + d) ~= exp(phi) (x) exp(J_r(phi) d)
12
+ // for small d. Used by the adjoint (Phase 3) to map tangent perturbations.
13
+ //
14
+ // Pure precision-agnostic primitives templated on the scalar S: a component
15
+ // instantiates them at its PrecisionTraits<C>::Scalar (the precision *policy*
16
+ // stays in component_scalars.h; these are just math). Same source compiles for
17
+ // the CPU f64 oracle and CUDA (DN_HOST_DEVICE).
18
+ //
19
+ // Small-angle error budget (dev-rules §3): below kSmallAngle the 1/theta and
20
+ // 1/theta^2 forms are replaced by their leading Taylor terms. The threshold is
21
+ // set so the dropped O(theta^2) correction is below f32 round-off; truncation
22
+ // error at the switch is O(theta^2) ~ 1e-12 (f32) / negligible (f64).
23
+ #include <cmath>
24
+
25
+ #include "diffneusim/macros.h"
26
+
27
+ namespace js::so3 {
28
+
29
+ template <class S> struct Vec3 { S x, y, z; };
30
+ template <class S> struct Quat { S w, x, y, z; }; // scalar-first Hamilton
31
+ template <class S> struct Mat3 { S m[9]; }; // row-major
32
+
33
+ // theta below which small-angle Taylor forms are used (rotation-vector norm).
34
+ template <class S> DN_HOST_DEVICE constexpr S kSmallAngle() { return S(1e-7); } // default (f64-grade; e.g. Dual)
35
+ template <> DN_HOST_DEVICE constexpr float kSmallAngle<float>() { return 1e-4f; }
36
+ template <> DN_HOST_DEVICE constexpr double kSmallAngle<double>() { return 1e-7; }
37
+
38
+ // sqrt/sin/cos/atan2 that resolve to the right precision on host and device.
39
+ // Declared before the vec3/quat templates that use them (built-in scalar args
40
+ // give no ADL, so they must be visible at template definition).
41
+ DN_HOST_DEVICE inline float js_sqrt(float x) { return sqrtf(x); }
42
+ DN_HOST_DEVICE inline double js_sqrt(double x) { return sqrt(x); }
43
+ DN_HOST_DEVICE inline float js_sin(float x) { return sinf(x); }
44
+ DN_HOST_DEVICE inline double js_sin(double x) { return sin(x); }
45
+ DN_HOST_DEVICE inline float js_cos(float x) { return cosf(x); }
46
+ DN_HOST_DEVICE inline double js_cos(double x) { return cos(x); }
47
+ DN_HOST_DEVICE inline float js_atan2(float y, float x) { return atan2f(y, x); }
48
+ DN_HOST_DEVICE inline double js_atan2(double y, double x) { return atan2(y, x); }
49
+ DN_HOST_DEVICE inline float js_acos(float x) { return acosf(x); }
50
+ DN_HOST_DEVICE inline double js_acos(double x) { return acos(x); }
51
+ DN_HOST_DEVICE inline float js_exp(float x) { return expf(x); }
52
+ DN_HOST_DEVICE inline double js_exp(double x) { return exp(x); }
53
+ DN_HOST_DEVICE inline float js_log(float x) { return logf(x); }
54
+ DN_HOST_DEVICE inline double js_log(double x) { return log(x); }
55
+
56
+ // --- vec3 ---------------------------------------------------------------
57
+ template <class S> DN_HOST_DEVICE Vec3<S> add(Vec3<S> a, Vec3<S> b) { return {a.x+b.x, a.y+b.y, a.z+b.z}; }
58
+ template <class S> DN_HOST_DEVICE Vec3<S> sub(Vec3<S> a, Vec3<S> b) { return {a.x-b.x, a.y-b.y, a.z-b.z}; }
59
+ template <class S> DN_HOST_DEVICE Vec3<S> scale(Vec3<S> a, S s) { return {a.x*s, a.y*s, a.z*s}; }
60
+ template <class S> DN_HOST_DEVICE S dot(Vec3<S> a, Vec3<S> b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
61
+ template <class S> DN_HOST_DEVICE Vec3<S> cross(Vec3<S> a, Vec3<S> b) {
62
+ return {a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x};
63
+ }
64
+ template <class S> DN_HOST_DEVICE S norm(Vec3<S> a) { return js_sqrt(dot(a, a)); }
65
+
66
+ // --- quaternion ---------------------------------------------------------
67
+ template <class S> DN_HOST_DEVICE Quat<S> quat_mul(Quat<S> a, Quat<S> b) {
68
+ return {a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z,
69
+ a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y,
70
+ a.w*b.y - a.x*b.z + a.y*b.w + a.z*b.x,
71
+ a.w*b.z + a.x*b.y - a.y*b.x + a.z*b.w};
72
+ }
73
+ template <class S> DN_HOST_DEVICE Quat<S> quat_conj(Quat<S> q) { return {q.w, -q.x, -q.y, -q.z}; }
74
+
75
+ template <class S> DN_HOST_DEVICE Quat<S> quat_normalize(Quat<S> q) {
76
+ S n = js_sqrt(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
77
+ S inv = S(1) / n;
78
+ return {q.w*inv, q.x*inv, q.y*inv, q.z*inv};
79
+ }
80
+
81
+ // Rotate v by q: v' = q (x) [0,v] (x) q* (Rodrigues form, no matrix).
82
+ template <class S> DN_HOST_DEVICE Vec3<S> quat_rotate(Quat<S> q, Vec3<S> v) {
83
+ Vec3<S> u{q.x, q.y, q.z};
84
+ Vec3<S> t = scale(cross(u, v), S(2));
85
+ return add(add(v, scale(t, q.w)), cross(u, t));
86
+ }
87
+
88
+ // --- exp / log ----------------------------------------------------------
89
+ // exp: rotation vector phi (axis*angle) -> unit quaternion.
90
+ template <class S> DN_HOST_DEVICE Quat<S> exp_map(Vec3<S> phi) {
91
+ S theta = norm(phi);
92
+ S half = theta * S(0.5);
93
+ S w = js_cos(half);
94
+ // sin(theta/2)/theta = (1/2) * sinc(theta/2); smooth at 0.
95
+ S k;
96
+ if (theta < kSmallAngle<S>()) {
97
+ // (1/2)(1 - (theta/2)^2/6 + ...) ; leading term dominates below threshold.
98
+ k = S(0.5) - theta*theta * S(1.0/48.0);
99
+ } else {
100
+ k = js_sin(half) / theta;
101
+ }
102
+ return {w, phi.x*k, phi.y*k, phi.z*k};
103
+ }
104
+
105
+ // log: unit quaternion -> rotation vector phi. Returns the shortest rotation
106
+ // (canonicalizes to w >= 0).
107
+ template <class S> DN_HOST_DEVICE Vec3<S> log_map(Quat<S> q) {
108
+ if (q.w < S(0)) { q.w = -q.w; q.x = -q.x; q.y = -q.y; q.z = -q.z; }
109
+ Vec3<S> v{q.x, q.y, q.z};
110
+ S nv = norm(v);
111
+ S theta = S(2) * js_atan2(nv, q.w);
112
+ S k; // phi = k * v, where k = theta / nv
113
+ if (nv < kSmallAngle<S>()) {
114
+ // theta/nv -> 2/w as nv->0 (atan2(nv,w) ~ nv/w); w ~ 1 here.
115
+ k = S(2) / q.w;
116
+ } else {
117
+ k = theta / nv;
118
+ }
119
+ return {v.x*k, v.y*k, v.z*k};
120
+ }
121
+
122
+ // --- right Jacobian -----------------------------------------------------
123
+ // J_r(phi) = I - a [phi]x + b [phi]x^2, a=(1-cos t)/t^2, b=(t-sin t)/t^3.
124
+ // Satisfies exp(phi + d) ~= exp(phi) (x) exp(J_r(phi) d) for small d.
125
+ template <class S> DN_HOST_DEVICE Mat3<S> right_jacobian(Vec3<S> phi) {
126
+ S t2 = dot(phi, phi);
127
+ S t = js_sqrt(t2);
128
+ S a, b;
129
+ if (t < kSmallAngle<S>()) {
130
+ a = S(0.5) - t2 * S(1.0/24.0); // (1-cos t)/t^2
131
+ b = S(1.0/6.0) - t2 * S(1.0/120.0); // (t-sin t)/t^3
132
+ } else {
133
+ a = (S(1) - js_cos(t)) / t2;
134
+ b = (t - js_sin(t)) / (t2 * t);
135
+ }
136
+ // [phi]x
137
+ const S x = phi.x, y = phi.y, z = phi.z;
138
+ // [phi]x^2 = phi phi^T - t2 I
139
+ Mat3<S> J;
140
+ // I
141
+ J.m[0]=1; J.m[1]=0; J.m[2]=0;
142
+ J.m[3]=0; J.m[4]=1; J.m[5]=0;
143
+ J.m[6]=0; J.m[7]=0; J.m[8]=1;
144
+ // - a [phi]x ([phi]x = [[0,-z,y],[z,0,-x],[-y,x,0]])
145
+ J.m[1] -= a*(-z); J.m[2] -= a*( y);
146
+ J.m[3] -= a*( z); J.m[5] -= a*(-x);
147
+ J.m[6] -= a*(-y); J.m[7] -= a*( x);
148
+ // + b [phi]x^2 = b (phi phi^T - t2 I)
149
+ J.m[0] += b*(x*x - t2); J.m[1] += b*(x*y); J.m[2] += b*(x*z);
150
+ J.m[3] += b*(y*x); J.m[4] += b*(y*y - t2); J.m[5] += b*(y*z);
151
+ J.m[6] += b*(z*x); J.m[7] += b*(z*y); J.m[8] += b*(z*z - t2);
152
+ return J;
153
+ }
154
+
155
+ // --- Mat3 (row-major) ops ----------------------------------------------
156
+ template <class S> DN_HOST_DEVICE Mat3<S> identity3() {
157
+ return {{S(1),0,0, 0,S(1),0, 0,0,S(1)}};
158
+ }
159
+ template <class S> DN_HOST_DEVICE Vec3<S> mat_vec(const Mat3<S>& A, Vec3<S> v) {
160
+ return {A.m[0]*v.x + A.m[1]*v.y + A.m[2]*v.z,
161
+ A.m[3]*v.x + A.m[4]*v.y + A.m[5]*v.z,
162
+ A.m[6]*v.x + A.m[7]*v.y + A.m[8]*v.z};
163
+ }
164
+ template <class S> DN_HOST_DEVICE Mat3<S> transpose(const Mat3<S>& A) {
165
+ return {{A.m[0],A.m[3],A.m[6], A.m[1],A.m[4],A.m[7], A.m[2],A.m[5],A.m[8]}};
166
+ }
167
+ template <class S> DN_HOST_DEVICE Mat3<S> mat_mul(const Mat3<S>& A, const Mat3<S>& B) {
168
+ Mat3<S> C;
169
+ for (int i = 0; i < 3; ++i)
170
+ for (int j = 0; j < 3; ++j)
171
+ C.m[3*i+j] = A.m[3*i]*B.m[j] + A.m[3*i+1]*B.m[3+j] + A.m[3*i+2]*B.m[6+j];
172
+ return C;
173
+ }
174
+ // Rotation matrix from a unit quaternion (body->world).
175
+ template <class S> DN_HOST_DEVICE Mat3<S> quat_to_mat(Quat<S> q) {
176
+ S w=q.w,x=q.x,y=q.y,z=q.z;
177
+ return {{ S(1)-2*(y*y+z*z), 2*(x*y-z*w), 2*(x*z+y*w),
178
+ 2*(x*y+z*w), S(1)-2*(x*x+z*z), 2*(y*z-x*w),
179
+ 2*(x*z-y*w), 2*(y*z+x*w), S(1)-2*(x*x+y*y) }};
180
+ }
181
+
182
+ } // namespace js::so3
@@ -0,0 +1,102 @@
1
+ #pragma once
2
+ // D16 adjoint, the control step's OUTPUT pull-back (d5, 2026-11-02; tools/d16_adj_shell/PREREG.md, gate G-TW): the tracked bodies'
3
+ // world poses and twists at (q, v) = (q_{t+1}, v_{t+1}), the trainer's definition [v_b; w_b] = J_b(q) v (v_b the body origin's
4
+ // world velocity, w_b its world angular velocity), and their cotangents pulled back to the q tangent and to v:
5
+ // s = sum_b xpos_bar_b . xpos_b + xrot_bar_b . theta_b + vb_bar_b . v_b + wb_bar_b . w_b
6
+ // q_bar += ds/dq (tangent; through fk and through dJ/dq along v), v_bar += J' [vb_bar; wb_bar]
7
+ // One level sweep each way, lane = body, the same conventions and phases as rnea_adj.h (host-emulable, deterministic).
8
+ #include "rnea_adj.h"
9
+
10
+ namespace js::soft::adj {
11
+
12
+ constexpr int kSlotO = 16; // publish: xq 4, xp 3, w 3, vo 3 (+3 pad); message: xpb 3, tau 3, wbar 3, vobar 3
13
+
14
+ // cotangent arrays are nb x 3 (world frame), nullptr for none; PC (the gate's positive control, 0 in real builds): 1 drops the
15
+ // q terms through dJ/dq (the velocities' dependence on the frames)
16
+ template <class S, int PC = 0, class Tab>
17
+ DN_HOST_DEVICE void adj_out_pullback(const Tab& B, const S* q, const S* v, const S* xpos_bar, const S* xrot_bar,
18
+ const S* vb_bar, const S* wb_bar, S* q_bar, S* v_bar, S* scratch) {
19
+ S (*slot)[kSlotO] = reinterpret_cast<S (*)[kSlotO]>(scratch);
20
+ const int nb = B.nb();
21
+ LANEA(S, R, 9); LANEA(S, r, 3); LANEA(S, a, 3);
22
+ ADJ_LANES(lane) {
23
+ if (lane == 0) { S* s = slot[0]; s[0] = S(1); for (int k = 1; k < kSlotO; ++k) s[k] = S(0); }
24
+ }
25
+ for (int d = 1; d <= B.maxdepth(); ++d) {
26
+ ADJ_LANES(lane) {
27
+ if (lane < nb && B.depth(lane) == d) {
28
+ const int b = lane, jt = B.jnt(b);
29
+ const S* ps = slot[B.parent(b)];
30
+ S xq[4], xp[3], w[3], vo[3];
31
+ body_kin(B, b, q, ps, ps + 4, xq, xp, LV(R), LV(r), LV(a));
32
+ if (jt == kJntFree) {
33
+ const int dd = B.dadr(b);
34
+ const S wbody[3] = {v[dd + 3], v[dd + 4], v[dd + 5]};
35
+ mat_vec(LV(R), wbody, w);
36
+ for (int k = 0; k < 3; ++k) vo[k] = v[dd + k];
37
+ } else {
38
+ const S *wp = ps + 7, *vop = ps + 10;
39
+ S t[3];
40
+ cross3(wp, LV(r), t);
41
+ for (int k = 0; k < 3; ++k) vo[k] = vop[k] + t[k];
42
+ const S vb = jt == kJntHinge ? v[B.dadr(b)] : S(0);
43
+ for (int k = 0; k < 3; ++k) w[k] = wp[k] + LV(a)[k] * vb;
44
+ }
45
+ S* s = slot[b];
46
+ for (int k = 0; k < 4; ++k) s[k] = xq[k];
47
+ for (int k = 0; k < 3; ++k) { s[4 + k] = xp[k]; s[7 + k] = w[k]; s[10 + k] = vo[k]; }
48
+ }
49
+ }
50
+ }
51
+ for (int d = B.maxdepth(); d >= 1; --d) {
52
+ ADJ_LANES(lane) {
53
+ if (lane < nb && B.depth(lane) == d) {
54
+ const int b = lane, jt = B.jnt(b);
55
+ S xpb[3], tau[3], wb[3], vob[3], t[3];
56
+ for (int k = 0; k < 3; ++k) {
57
+ xpb[k] = xpos_bar ? xpos_bar[3 * b + k] : S(0); tau[k] = xrot_bar ? xrot_bar[3 * b + k] : S(0);
58
+ wb[k] = wb_bar ? wb_bar[3 * b + k] : S(0); vob[k] = vb_bar ? vb_bar[3 * b + k] : S(0);
59
+ }
60
+ for (int ci = 0; ci < B.nchild(b); ++ci) { // the children, in increasing index
61
+ const S* mc = slot[B.child(b, ci)];
62
+ add3(xpb, mc); add3(tau, mc + 3); add3(wb, mc + 6); add3(vob, mc + 9);
63
+ }
64
+ const S* s = slot[b];
65
+ if (jt == kJntFree) {
66
+ const int dd = B.dadr(b);
67
+ const S* w = s + 7;
68
+ if (PC != 1) { cross3(w, wb, t); add3(tau, t); } // w = R w_body
69
+ mat_tvec(LV(R), wb, t);
70
+ for (int k = 0; k < 3; ++k) { v_bar[dd + 3 + k] = v_bar[dd + 3 + k] + t[k]; v_bar[dd + k] = v_bar[dd + k] + vob[k]; }
71
+ mat_tvec(LV(R), tau, t);
72
+ for (int k = 0; k < 3; ++k) { q_bar[dd + k] = q_bar[dd + k] + xpb[k]; q_bar[dd + 3 + k] = q_bar[dd + 3 + k] + t[k]; }
73
+ } else {
74
+ const S* ps = slot[B.parent(b)]; // the parent's forward values (overwritten only in the next phase)
75
+ const S* wp = ps + 7;
76
+ S rb[3] = {xpb[0], xpb[1], xpb[2]}, out[kSlotO];
77
+ for (int k = 0; k < kSlotO; ++k) out[k] = S(0);
78
+ // vo = vo_p + w_p x r
79
+ for (int k = 0; k < 3; ++k) out[9 + k] = vob[k];
80
+ cross3(LV(r), vob, t); for (int k = 0; k < 3; ++k) out[6 + k] = t[k];
81
+ if (PC != 1) { cross3(vob, wp, t); add3(rb, t); }
82
+ // w = w_p + a v_b
83
+ add3(out + 6, wb);
84
+ if (jt == kJntHinge) {
85
+ const int dd = B.dadr(b);
86
+ v_bar[dd] = v_bar[dd] + dot3(LV(a), wb);
87
+ S ab3[3];
88
+ for (int k = 0; k < 3; ++k) ab3[k] = v[dd] * wb[k];
89
+ if (PC != 1) { cross3(LV(a), ab3, t); add3(tau, t); } // a = R axis
90
+ q_bar[dd] = q_bar[dd] + dot3(LV(a), tau);
91
+ }
92
+ for (int k = 0; k < 3; ++k) out[k] = xpb[k];
93
+ cross3(LV(r), rb, t);
94
+ for (int k = 0; k < 3; ++k) out[3 + k] = tau[k] + t[k];
95
+ for (int k = 0; k < kSlotO; ++k) slot[b][k] = out[k]; // read by the parent in the next phase
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ } // namespace js::soft::adj