2
0

GLS.PhysicsJoints.pas 5.9 KB

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