GXS.PhysJoints.pas 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. //
  2. // The graphics engine GXScene
  3. //
  4. unit GXS.PhysJoints;
  5. (*
  6. This unit isn't used at all at the moment, just putting down some ideas
  7. for serial-link manipulators
  8. *)
  9. interface
  10. uses
  11. GXS.Scene,
  12. Stage.VectorTypes,
  13. Stage.VectorGeometry;
  14. type
  15. (*
  16. //
  17. // Joint(Z1) Joint(Z3)
  18. // / \ |_| (Wrist)
  19. // / \/\ //
  20. // / / \ \ //
  21. // / / \ \(1) //(2)
  22. // Link(0) / / \ \ //
  23. // / / \ \ //
  24. // / / \ \ //
  25. // / / \/\/
  26. // Joint(Z0)/ / \/
  27. // |------| Joint(Z2)
  28. // | Base |
  29. // --------------------------------------------
  30. // X(n) = Common normal between joint axis Z(n-1) & Z(n)
  31. *)
  32. TGLBaseJoint = class(TObject)
  33. end;
  34. TGLBaseLink = class(TObject)
  35. end;
  36. TGLJoint = class(TGLBaseJoint)
  37. Link1: TGLBaseLink; // if Link1 is nil, assumed to be base
  38. Link2: TGLBaseLink; // if Link2 is nil, assumed to be wrist
  39. // Object1:TgxBaseSceneObject;
  40. // Object2:TgxBaseSceneObject;
  41. end;
  42. // Links are mainly for used for Serial-Link manipulators
  43. // Direct & Inverse Kinematics algorithms are planned
  44. TGLLink = class(TGLBaseLink)
  45. // Link Parameters
  46. fLinkLength: Real; // Length of common normal which is orthogonal to both
  47. // joint axes Z[n-1] and Z[n] (a.k.a. L)
  48. fTwistAngle: Real; // Twist angle between joint axes, if joint frames were
  49. // coincident (a.k.a. Theta?)
  50. fLinkAngle: Real;
  51. // Angle between common normals X[n-1] and X[n] (a.k.a. Alpha?)
  52. fLinkDistance: Real;
  53. // Distance along joint axis Z[n-1] between intersection
  54. // points of common normals X[n-1] and X[n] (a.k.a. d)
  55. (*
  56. //
  57. // A-Matrix
  58. // [ Cos(Theta) -Sin(Theta)*Cos(Alpha) Sin(Theta)*Sin(Alpha) L*Cos(Theta) ]
  59. // [ Sin(Theta) Cos(Theta)*cos(Alpha) -Cos(Theta)*Sin(Alpha) L*Sin(Theta) ]
  60. // [ 0 Sin(Alpha) Cos(Alpha) d ]
  61. // [ 0 0 0 1 ]
  62. //
  63. *)
  64. A: TGLMatrix;
  65. constructor Create(LinkLength, TwistAngle, LinkAngle, LinkDistance: Real);
  66. // constructor Create();virtual;
  67. end;
  68. // see html file for description of the different links
  69. (*
  70. // Type 1 Two-Link Manipulator
  71. //
  72. // _ ________
  73. // / \ \
  74. // / \/________/
  75. // / /
  76. // / /
  77. // / /
  78. // / /
  79. // / /
  80. // \_/
  81. //
  82. *)
  83. TGLType1Link = class(TGLLink)
  84. Length: Real; // fixed
  85. Angle: Real; // variable
  86. (*
  87. // A-Matrix
  88. // [ C1 -S1 0 L1C1 ]
  89. // [ S1 C1 0 L1S1 ]
  90. // [ 0 0 1 0 ]
  91. // [ 0 0 0 1 ]
  92. //
  93. *)
  94. constructor Create(Length, Angle: Real);
  95. end;
  96. (*
  97. // Type 2 Two-Link Manipulator
  98. // ___
  99. // / \___________________
  100. // | + |___________________|
  101. // \ /
  102. // | |
  103. // | |
  104. // | |
  105. // | |
  106. // | |
  107. // | |
  108. // __|_|__
  109. // |___.___|
  110. //
  111. *)
  112. TGLType2Link = class(TGLLink)
  113. Length: Real; // fixed
  114. Angle: Real; // variable
  115. constructor Create(Length, Angle: Real);
  116. end;
  117. (*
  118. // Type 3 Two-Link Manipulator
  119. // _______
  120. // _________| |__
  121. // <-|_________| |__|->
  122. // |__ __|
  123. // | |
  124. // | |
  125. // | |
  126. // | |
  127. // | |
  128. // _|_|_
  129. // |__.__|
  130. *)
  131. TGLType3Link = class(TGLLink)
  132. Length: Real; // fixed
  133. Angle: Real; // variable
  134. (*
  135. // A-Matrix
  136. // [ 1 0 0 0 ]
  137. // [ 0 1 0 0 ]
  138. // [ 0 0 1 d2 ]
  139. // [ 0 0 0 1 ]
  140. //
  141. *)
  142. constructor Create(Length, Angle: Real);
  143. end;
  144. TGLType4Link = class(TGLLink)
  145. Length: Real; // fixed
  146. Angle: Real; // variable
  147. constructor Create(Length, Angle: Real);
  148. end;
  149. (*
  150. // Type 5 Two-Link Manipulator
  151. //
  152. // _
  153. // ________|_|__
  154. // <-|_____________|->
  155. // | |
  156. // | |
  157. // | |
  158. // | |
  159. // | |
  160. // __| |__
  161. // |__| |__|
  162. // |_|
  163. // |
  164. // V
  165. //
  166. *)
  167. TGLType5Link = class(TGLLink)
  168. Length: Real; // variable
  169. constructor Create(Length, Angle: Real);
  170. end;
  171. TGLType6Link = class(TGLLink)
  172. Length: Real; // fixed
  173. Angle: Real; // variable
  174. constructor Create(Length, Angle: Real);
  175. end;
  176. TGLType7Link = class(TGLLink)
  177. Length: Real; // fixed
  178. Angle: Real; // variable
  179. constructor Create(Length, Angle: Real);
  180. end;
  181. TGLType8Link = class(TGLLink)
  182. Length: Real; // variable
  183. constructor Create(Length, Angle: Real);
  184. end;
  185. TGLPrismaticJoint = class(TGLJoint)
  186. end;
  187. TGLRevoluteJoint = class(TGLJoint)
  188. end;
  189. TGLBallAndSocketJoint = class(TGLJoint)
  190. end;
  191. implementation //--------------------------------------------------------------
  192. constructor TGLLink.Create(LinkLength, TwistAngle, LinkAngle,
  193. LinkDistance: Real);
  194. begin
  195. fLinkLength := LinkLength;
  196. fTwistAngle := TwistAngle;
  197. fLinkAngle := LinkAngle;
  198. fLinkDistance := LinkDistance;
  199. end;
  200. constructor TGLType1Link.Create(Length, Angle: Real);
  201. begin
  202. inherited Create(Length, 0, Angle, 0);
  203. end;
  204. constructor TGLType2Link.Create(Length, Angle: Real);
  205. begin
  206. inherited Create(Length, 0, Angle, 0);
  207. end;
  208. constructor TGLType3Link.Create(Length, Angle: Real);
  209. begin
  210. inherited Create(Length, 0, Angle, 0);
  211. end;
  212. constructor TGLType4Link.Create(Length, Angle: Real);
  213. begin
  214. inherited Create(Length, 0, Angle, 0);
  215. end;
  216. constructor TGLType5Link.Create(Length, Angle: Real);
  217. begin
  218. inherited Create(Length, 0, Angle, 0);
  219. end;
  220. constructor TGLType6Link.Create(Length, Angle: Real);
  221. begin
  222. inherited Create(Length, 0, Angle, 0);
  223. end;
  224. constructor TGLType7Link.Create(Length, Angle: Real);
  225. begin
  226. inherited Create(Length, 0, Angle, 0);
  227. end;
  228. constructor TGLType8Link.Create(Length, Angle: Real);
  229. begin
  230. inherited Create(Length, 0, Angle, 0);
  231. end;
  232. //---------------------------------------------------------------------------
  233. end.