objects.h 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. #ifndef _ODE_OBJECTS_H_
  23. #define _ODE_OBJECTS_H_
  24. #include <ode/common.h>
  25. #include <ode/mass.h>
  26. #include <ode/contact.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * @defgroup world World
  32. *
  33. * The world object is a container for rigid bodies and joints. Objects in
  34. * different worlds can not interact, for example rigid bodies from two
  35. * different worlds can not collide.
  36. *
  37. * All the objects in a world exist at the same point in time, thus one
  38. * reason to use separate worlds is to simulate systems at different rates.
  39. * Most applications will only need one world.
  40. */
  41. /**
  42. * @brief Create a new, empty world and return its ID number.
  43. * @return an identifier
  44. * @ingroup world
  45. */
  46. ODE_API dWorldID dWorldCreate(void);
  47. /**
  48. * @brief Destroy a world and everything in it.
  49. *
  50. * This includes all bodies, and all joints that are not part of a joint
  51. * group. Joints that are part of a joint group will be deactivated, and
  52. * can be destroyed by calling, for example, dJointGroupEmpty().
  53. * @ingroup world
  54. * @param world the identifier for the world the be destroyed.
  55. */
  56. ODE_API void dWorldDestroy (dWorldID world);
  57. /**
  58. * @brief Set the world's global gravity vector.
  59. *
  60. * The units are m/s^2, so Earth's gravity vector would be (0,0,-9.81),
  61. * assuming that +z is up. The default is no gravity, i.e. (0,0,0).
  62. *
  63. * @ingroup world
  64. */
  65. ODE_API void dWorldSetGravity (dWorldID, dReal x, dReal y, dReal z);
  66. /**
  67. * @brief Get the gravity vector for a given world.
  68. * @ingroup world
  69. */
  70. ODE_API void dWorldGetGravity (dWorldID, dVector3 gravity);
  71. /**
  72. * @brief Set the global ERP value, that controls how much error
  73. * correction is performed in each time step.
  74. * @ingroup world
  75. * @param dWorldID the identifier of the world.
  76. * @param erp Typical values are in the range 0.1--0.8. The default is 0.2.
  77. */
  78. ODE_API void dWorldSetERP (dWorldID, dReal erp);
  79. /**
  80. * @brief Get the error reduction parameter.
  81. * @ingroup world
  82. * @return ERP value
  83. */
  84. ODE_API dReal dWorldGetERP (dWorldID);
  85. /**
  86. * @brief Set the global CFM (constraint force mixing) value.
  87. * @ingroup world
  88. * @param cfm Typical values are in the range @m{10^{-9}} -- 1.
  89. * The default is 10^-5 if single precision is being used, or 10^-10
  90. * if double precision is being used.
  91. */
  92. ODE_API void dWorldSetCFM (dWorldID, dReal cfm);
  93. /**
  94. * @brief Get the constraint force mixing value.
  95. * @ingroup world
  96. * @return CFM value
  97. */
  98. ODE_API dReal dWorldGetCFM (dWorldID);
  99. /**
  100. * @brief Step the world.
  101. *
  102. * This uses a "big matrix" method that takes time on the order of m^3
  103. * and memory on the order of m^2, where m is the total number of constraint
  104. * rows. For large systems this will use a lot of memory and can be very slow,
  105. * but this is currently the most accurate method.
  106. * @ingroup world
  107. * @param stepsize The number of seconds that the simulation has to advance.
  108. */
  109. ODE_API void dWorldStep (dWorldID, dReal stepsize);
  110. /**
  111. * @brief Converts an impulse to a force.
  112. * @ingroup world
  113. * @remarks
  114. * If you want to apply a linear or angular impulse to a rigid body,
  115. * instead of a force or a torque, then you can use this function to convert
  116. * the desired impulse into a force/torque vector before calling the
  117. * BodyAdd... function.
  118. * The current algorithm simply scales the impulse by 1/stepsize,
  119. * where stepsize is the step size for the next step that will be taken.
  120. * This function is given a dWorldID because, in the future, the force
  121. * computation may depend on integrator parameters that are set as
  122. * properties of the world.
  123. */
  124. ODE_API void dWorldImpulseToForce
  125. (
  126. dWorldID, dReal stepsize,
  127. dReal ix, dReal iy, dReal iz, dVector3 force
  128. );
  129. /**
  130. * @brief Step the world.
  131. * @ingroup world
  132. * @remarks
  133. * This uses an iterative method that takes time on the order of m*N
  134. * and memory on the order of m, where m is the total number of constraint
  135. * rows N is the number of iterations.
  136. * For large systems this is a lot faster than dWorldStep(),
  137. * but it is less accurate.
  138. * @remarks
  139. * QuickStep is great for stacks of objects especially when the
  140. * auto-disable feature is used as well.
  141. * However, it has poor accuracy for near-singular systems.
  142. * Near-singular systems can occur when using high-friction contacts, motors,
  143. * or certain articulated structures. For example, a robot with multiple legs
  144. * sitting on the ground may be near-singular.
  145. * @remarks
  146. * There are ways to help overcome QuickStep's inaccuracy problems:
  147. * \li Increase CFM.
  148. * \li Reduce the number of contacts in your system (e.g. use the minimum
  149. * number of contacts for the feet of a robot or creature).
  150. * \li Don't use excessive friction in the contacts.
  151. * \li Use contact slip if appropriate
  152. * \li Avoid kinematic loops (however, kinematic loops are inevitable in
  153. * legged creatures).
  154. * \li Don't use excessive motor strength.
  155. * \liUse force-based motors instead of velocity-based motors.
  156. *
  157. * Increasing the number of QuickStep iterations may help a little bit, but
  158. * it is not going to help much if your system is really near singular.
  159. */
  160. ODE_API void dWorldQuickStep (dWorldID w, dReal stepsize);
  161. /**
  162. * @brief Set the number of iterations that the QuickStep method performs per
  163. * step.
  164. * @ingroup world
  165. * @remarks
  166. * More iterations will give a more accurate solution, but will take
  167. * longer to compute.
  168. * @param num The default is 20 iterations.
  169. */
  170. ODE_API void dWorldSetQuickStepNumIterations (dWorldID, int num);
  171. /**
  172. * @brief Get the number of iterations that the QuickStep method performs per
  173. * step.
  174. * @ingroup world
  175. * @return nr of iterations
  176. */
  177. ODE_API int dWorldGetQuickStepNumIterations (dWorldID);
  178. /**
  179. * @brief Set the SOR over-relaxation parameter
  180. * @ingroup world
  181. * @param over_relaxation value to use by SOR
  182. */
  183. ODE_API void dWorldSetQuickStepW (dWorldID, dReal over_relaxation);
  184. /**
  185. * @brief Get the SOR over-relaxation parameter
  186. * @ingroup world
  187. * @returns the over-relaxation setting
  188. */
  189. ODE_API dReal dWorldGetQuickStepW (dWorldID);
  190. /* World contact parameter functions */
  191. /**
  192. * @brief Set the maximum correcting velocity that contacts are allowed
  193. * to generate.
  194. * @ingroup world
  195. * @param vel The default value is infinity (i.e. no limit).
  196. * @remarks
  197. * Reducing this value can help prevent "popping" of deeply embedded objects.
  198. */
  199. ODE_API void dWorldSetContactMaxCorrectingVel (dWorldID, dReal vel);
  200. /**
  201. * @brief Get the maximum correcting velocity that contacts are allowed
  202. * to generated.
  203. * @ingroup world
  204. */
  205. ODE_API dReal dWorldGetContactMaxCorrectingVel (dWorldID);
  206. /**
  207. * @brief Set the depth of the surface layer around all geometry objects.
  208. * @ingroup world
  209. * @remarks
  210. * Contacts are allowed to sink into the surface layer up to the given
  211. * depth before coming to rest.
  212. * @param depth The default value is zero.
  213. * @remarks
  214. * Increasing this to some small value (e.g. 0.001) can help prevent
  215. * jittering problems due to contacts being repeatedly made and broken.
  216. */
  217. ODE_API void dWorldSetContactSurfaceLayer (dWorldID, dReal depth);
  218. /**
  219. * @brief Get the depth of the surface layer around all geometry objects.
  220. * @ingroup world
  221. * @returns the depth
  222. */
  223. ODE_API dReal dWorldGetContactSurfaceLayer (dWorldID);
  224. /* StepFast1 functions */
  225. /**
  226. * @brief Step the world using the StepFast1 algorithm.
  227. * @param stepsize the nr of seconds to advance the simulation.
  228. * @param maxiterations The number of iterations to perform.
  229. * @ingroup world
  230. */
  231. ODE_API void dWorldStepFast1(dWorldID, dReal stepsize, int maxiterations);
  232. /**
  233. * @defgroup disable Automatic Enabling and Disabling
  234. * @ingroup world bodies
  235. *
  236. * Every body can be enabled or disabled. Enabled bodies participate in the
  237. * simulation, while disabled bodies are turned off and do not get updated
  238. * during a simulation step. New bodies are always created in the enabled state.
  239. *
  240. * A disabled body that is connected through a joint to an enabled body will be
  241. * automatically re-enabled at the next simulation step.
  242. *
  243. * Disabled bodies do not consume CPU time, therefore to speed up the simulation
  244. * bodies should be disabled when they come to rest. This can be done automatically
  245. * with the auto-disable feature.
  246. *
  247. * If a body has its auto-disable flag turned on, it will automatically disable
  248. * itself when
  249. * @li It has been idle for a given number of simulation steps.
  250. * @li It has also been idle for a given amount of simulation time.
  251. *
  252. * A body is considered to be idle when the magnitudes of both its
  253. * linear average velocity and angular average velocity are below given thresholds.
  254. * The sample size for the average defaults to one and can be disabled by setting
  255. * to zero with
  256. *
  257. * Thus, every body has six auto-disable parameters: an enabled flag, a idle step
  258. * count, an idle time, linear/angular average velocity thresholds, and the
  259. * average samples count.
  260. *
  261. * Newly created bodies get these parameters from world.
  262. */
  263. /**
  264. * @brief Set the AutoEnableDepth parameter used by the StepFast1 algorithm.
  265. * @ingroup disable
  266. */
  267. ODE_API void dWorldSetAutoEnableDepthSF1(dWorldID, int autoEnableDepth);
  268. /**
  269. * @brief Get the AutoEnableDepth parameter used by the StepFast1 algorithm.
  270. * @ingroup disable
  271. */
  272. ODE_API int dWorldGetAutoEnableDepthSF1(dWorldID);
  273. /**
  274. * @brief Get auto disable linear threshold for newly created bodies.
  275. * @ingroup disable
  276. * @return the threshold
  277. */
  278. ODE_API dReal dWorldGetAutoDisableLinearThreshold (dWorldID);
  279. /**
  280. * @brief Set auto disable linear threshold for newly created bodies.
  281. * @param linear_threshold default is 0.01
  282. * @ingroup disable
  283. */
  284. ODE_API void dWorldSetAutoDisableLinearThreshold (dWorldID, dReal linear_threshold);
  285. /**
  286. * @brief Get auto disable angular threshold for newly created bodies.
  287. * @ingroup disable
  288. * @return the threshold
  289. */
  290. ODE_API dReal dWorldGetAutoDisableAngularThreshold (dWorldID);
  291. /**
  292. * @brief Set auto disable angular threshold for newly created bodies.
  293. * @param linear_threshold default is 0.01
  294. * @ingroup disable
  295. */
  296. ODE_API void dWorldSetAutoDisableAngularThreshold (dWorldID, dReal angular_threshold);
  297. /**
  298. * @brief Get auto disable linear average threshold for newly created bodies.
  299. * @ingroup disable
  300. * @return the threshold
  301. */
  302. ODE_API dReal dWorldGetAutoDisableLinearAverageThreshold (dWorldID);
  303. /**
  304. * @brief Set auto disable linear average threshold for newly created bodies.
  305. * @param linear_average_threshold default is 0.01
  306. * @ingroup disable
  307. */
  308. ODE_API void dWorldSetAutoDisableLinearAverageThreshold (dWorldID, dReal linear_average_threshold);
  309. /**
  310. * @brief Get auto disable angular average threshold for newly created bodies.
  311. * @ingroup disable
  312. * @return the threshold
  313. */
  314. ODE_API dReal dWorldGetAutoDisableAngularAverageThreshold (dWorldID);
  315. /**
  316. * @brief Set auto disable angular average threshold for newly created bodies.
  317. * @param linear_average_threshold default is 0.01
  318. * @ingroup disable
  319. */
  320. ODE_API void dWorldSetAutoDisableAngularAverageThreshold (dWorldID, dReal angular_average_threshold);
  321. /**
  322. * @brief Get auto disable sample count for newly created bodies.
  323. * @ingroup disable
  324. * @return number of samples used
  325. */
  326. ODE_API int dWorldGetAutoDisableAverageSamplesCount (dWorldID);
  327. /**
  328. * @brief Set auto disable average sample count for newly created bodies.
  329. * @ingroup disable
  330. * @param average_samples_count Default is 1, meaning only instantaneous velocity is used.
  331. * Set to zero to disable sampling and thus prevent any body from auto-disabling.
  332. */
  333. ODE_API void dWorldSetAutoDisableAverageSamplesCount (dWorldID, unsigned int average_samples_count );
  334. /**
  335. * @brief Get auto disable steps for newly created bodies.
  336. * @ingroup disable
  337. * @return nr of steps
  338. */
  339. ODE_API int dWorldGetAutoDisableSteps (dWorldID);
  340. /**
  341. * @brief Set auto disable steps for newly created bodies.
  342. * @ingroup disable
  343. * @param steps default is 10
  344. */
  345. ODE_API void dWorldSetAutoDisableSteps (dWorldID, int steps);
  346. /**
  347. * @brief Get auto disable time for newly created bodies.
  348. * @ingroup disable
  349. * @return nr of seconds
  350. */
  351. ODE_API dReal dWorldGetAutoDisableTime (dWorldID);
  352. /**
  353. * @brief Set auto disable time for newly created bodies.
  354. * @ingroup disable
  355. * @param time default is 0 seconds
  356. */
  357. ODE_API void dWorldSetAutoDisableTime (dWorldID, dReal time);
  358. /**
  359. * @brief Get auto disable flag for newly created bodies.
  360. * @ingroup disable
  361. * @return 0 or 1
  362. */
  363. ODE_API int dWorldGetAutoDisableFlag (dWorldID);
  364. /**
  365. * @brief Set auto disable flag for newly created bodies.
  366. * @ingroup disable
  367. * @param do_auto_disable default is false.
  368. */
  369. ODE_API void dWorldSetAutoDisableFlag (dWorldID, int do_auto_disable);
  370. /**
  371. * @defgroup damping Damping
  372. * @ingroup bodies world
  373. *
  374. * Damping serves two purposes: reduce simulation instability, and to allow
  375. * the bodies to come to rest (and possibly auto-disabling them).
  376. *
  377. * Bodies are constructed using the world's current damping parameters. Setting
  378. * the scales to 0 disables the damping.
  379. *
  380. * Here is how it is done: after every time step linear and angular
  381. * velocities are tested against the corresponding thresholds. If they
  382. * are above, they are multiplied by (1 - scale). So a negative scale value
  383. * will actually increase the speed, and values greater than one will
  384. * make the object oscillate every step; both can make the simulation unstable.
  385. *
  386. * To disable damping just set the damping scale to zero.
  387. *
  388. * You can also limit the maximum angular velocity. In contrast to the damping
  389. * functions, the angular velocity is affected before the body is moved.
  390. * This means that it will introduce errors in joints that are forcing the body
  391. * to rotate too fast. Some bodies have naturally high angular velocities
  392. * (like cars' wheels), so you may want to give them a very high (like the default,
  393. * dInfinity) limit.
  394. *
  395. * @note The velocities are damped after the stepper function has moved the
  396. * object. Otherwise the damping could introduce errors in joints. First the
  397. * joint constraints are processed by the stepper (moving the body), then
  398. * the damping is applied.
  399. *
  400. * @note The damping happens right after the moved callback is called; this way
  401. * it still possible use the exact velocities the body has acquired during the
  402. * step. You can even use the callback to create your own customized damping.
  403. */
  404. /**
  405. * @brief Get the world's linear damping threshold.
  406. * @ingroup damping
  407. */
  408. ODE_API dReal dWorldGetLinearDampingThreshold (dWorldID w);
  409. /**
  410. * @brief Set the world's linear damping threshold.
  411. * @param threshold The damping won't be applied if the linear speed is
  412. * below this threshold. Default is 0.01.
  413. * @ingroup damping
  414. */
  415. ODE_API void dWorldSetLinearDampingThreshold(dWorldID w, dReal threshold);
  416. /**
  417. * @brief Get the world's angular damping threshold.
  418. * @ingroup damping
  419. */
  420. ODE_API dReal dWorldGetAngularDampingThreshold (dWorldID w);
  421. /**
  422. * @brief Set the world's angular damping threshold.
  423. * @param threshold The damping won't be applied if the angular speed is
  424. * below this threshold. Default is 0.01.
  425. * @ingroup damping
  426. */
  427. ODE_API void dWorldSetAngularDampingThreshold(dWorldID w, dReal threshold);
  428. /**
  429. * @brief Get the world's linear damping scale.
  430. * @ingroup damping
  431. */
  432. ODE_API dReal dWorldGetLinearDamping (dWorldID w);
  433. /**
  434. * @brief Set the world's linear damping scale.
  435. * @param scale The linear damping scale that is to be applied to bodies.
  436. * Default is 0 (no damping). Should be in the interval [0, 1].
  437. * @ingroup damping
  438. */
  439. ODE_API void dWorldSetLinearDamping (dWorldID w, dReal scale);
  440. /**
  441. * @brief Get the world's angular damping scale.
  442. * @ingroup damping
  443. */
  444. ODE_API dReal dWorldGetAngularDamping (dWorldID w);
  445. /**
  446. * @brief Set the world's angular damping scale.
  447. * @param scale The angular damping scale that is to be applied to bodies.
  448. * Default is 0 (no damping). Should be in the interval [0, 1].
  449. * @ingroup damping
  450. */
  451. ODE_API void dWorldSetAngularDamping(dWorldID w, dReal scale);
  452. /**
  453. * @brief Convenience function to set body linear and angular scales.
  454. * @param linear_scale The linear damping scale that is to be applied to bodies.
  455. * @param angular_scale The angular damping scale that is to be applied to bodies.
  456. * @ingroup damping
  457. */
  458. ODE_API void dWorldSetDamping(dWorldID w,
  459. dReal linear_scale,
  460. dReal angular_scale);
  461. /**
  462. * @brief Get the default maximum angular speed.
  463. * @ingroup damping
  464. * @sa dBodyGetMaxAngularSpeed()
  465. */
  466. ODE_API dReal dWorldGetMaxAngularSpeed (dWorldID w);
  467. /**
  468. * @brief Set the default maximum angular speed for new bodies.
  469. * @ingroup damping
  470. * @sa dBodySetMaxAngularSpeed()
  471. */
  472. ODE_API void dWorldSetMaxAngularSpeed (dWorldID w, dReal max_speed);
  473. /**
  474. * @defgroup bodies Rigid Bodies
  475. *
  476. * A rigid body has various properties from the point of view of the
  477. * simulation. Some properties change over time:
  478. *
  479. * @li Position vector (x,y,z) of the body's point of reference.
  480. * Currently the point of reference must correspond to the body's center of mass.
  481. * @li Linear velocity of the point of reference, a vector (vx,vy,vz).
  482. * @li Orientation of a body, represented by a quaternion (qs,qx,qy,qz) or
  483. * a 3x3 rotation matrix.
  484. * @li Angular velocity vector (wx,wy,wz) which describes how the orientation
  485. * changes over time.
  486. *
  487. * Other body properties are usually constant over time:
  488. *
  489. * @li Mass of the body.
  490. * @li Position of the center of mass with respect to the point of reference.
  491. * In the current implementation the center of mass and the point of
  492. * reference must coincide.
  493. * @li Inertia matrix. This is a 3x3 matrix that describes how the body's mass
  494. * is distributed around the center of mass. Conceptually each body has an
  495. * x-y-z coordinate frame embedded in it that moves and rotates with the body.
  496. *
  497. * The origin of this coordinate frame is the body's point of reference. Some values
  498. * in ODE (vectors, matrices etc) are relative to the body coordinate frame, and others
  499. * are relative to the global coordinate frame.
  500. *
  501. * Note that the shape of a rigid body is not a dynamical property (except insofar as
  502. * it influences the various mass properties). It is only collision detection that cares
  503. * about the detailed shape of the body.
  504. */
  505. /**
  506. * @brief Get auto disable linear average threshold.
  507. * @ingroup bodies disable
  508. * @return the threshold
  509. */
  510. ODE_API dReal dBodyGetAutoDisableLinearThreshold (dBodyID);
  511. /**
  512. * @brief Set auto disable linear average threshold.
  513. * @ingroup bodies disable
  514. * @return the threshold
  515. */
  516. ODE_API void dBodySetAutoDisableLinearThreshold (dBodyID, dReal linear_average_threshold);
  517. /**
  518. * @brief Get auto disable angular average threshold.
  519. * @ingroup bodies disable
  520. * @return the threshold
  521. */
  522. ODE_API dReal dBodyGetAutoDisableAngularThreshold (dBodyID);
  523. /**
  524. * @brief Set auto disable angular average threshold.
  525. * @ingroup bodies disable
  526. * @return the threshold
  527. */
  528. ODE_API void dBodySetAutoDisableAngularThreshold (dBodyID, dReal angular_average_threshold);
  529. /**
  530. * @brief Get auto disable average size (samples count).
  531. * @ingroup bodies disable
  532. * @return the nr of steps/size.
  533. */
  534. ODE_API int dBodyGetAutoDisableAverageSamplesCount (dBodyID);
  535. /**
  536. * @brief Set auto disable average buffer size (average steps).
  537. * @ingroup bodies disable
  538. * @param average_samples_count the nr of samples to review.
  539. */
  540. ODE_API void dBodySetAutoDisableAverageSamplesCount (dBodyID, unsigned int average_samples_count);
  541. /**
  542. * @brief Get auto steps a body must be thought of as idle to disable
  543. * @ingroup bodies disable
  544. * @return the nr of steps
  545. */
  546. ODE_API int dBodyGetAutoDisableSteps (dBodyID);
  547. /**
  548. * @brief Set auto disable steps.
  549. * @ingroup bodies disable
  550. * @param steps the nr of steps.
  551. */
  552. ODE_API void dBodySetAutoDisableSteps (dBodyID, int steps);
  553. /**
  554. * @brief Get auto disable time.
  555. * @ingroup bodies disable
  556. * @return nr of seconds
  557. */
  558. ODE_API dReal dBodyGetAutoDisableTime (dBodyID);
  559. /**
  560. * @brief Set auto disable time.
  561. * @ingroup bodies disable
  562. * @param time nr of seconds.
  563. */
  564. ODE_API void dBodySetAutoDisableTime (dBodyID, dReal time);
  565. /**
  566. * @brief Get auto disable flag.
  567. * @ingroup bodies disable
  568. * @return 0 or 1
  569. */
  570. ODE_API int dBodyGetAutoDisableFlag (dBodyID);
  571. /**
  572. * @brief Set auto disable flag.
  573. * @ingroup bodies disable
  574. * @param do_auto_disable 0 or 1
  575. */
  576. ODE_API void dBodySetAutoDisableFlag (dBodyID, int do_auto_disable);
  577. /**
  578. * @brief Set auto disable defaults.
  579. * @remarks
  580. * Set the values for the body to those set as default for the world.
  581. * @ingroup bodies disable
  582. */
  583. ODE_API void dBodySetAutoDisableDefaults (dBodyID);
  584. /**
  585. * @brief Retrieves the world attached to te given body.
  586. * @remarks
  587. *
  588. * @ingroup bodies
  589. */
  590. ODE_API dWorldID dBodyGetWorld (dBodyID);
  591. /**
  592. * @brief Create a body in given world.
  593. * @remarks
  594. * Default mass parameters are at position (0,0,0).
  595. * @ingroup bodies
  596. */
  597. ODE_API dBodyID dBodyCreate (dWorldID);
  598. /**
  599. * @brief Destroy a body.
  600. * @remarks
  601. * All joints that are attached to this body will be put into limbo:
  602. * i.e. unattached and not affecting the simulation, but they will NOT be
  603. * deleted.
  604. * @ingroup bodies
  605. */
  606. ODE_API void dBodyDestroy (dBodyID);
  607. /**
  608. * @brief Set the body's user-data pointer.
  609. * @ingroup bodies
  610. * @param data arbitraty pointer
  611. */
  612. ODE_API void dBodySetData (dBodyID, void *data);
  613. /**
  614. * @brief Get the body's user-data pointer.
  615. * @ingroup bodies
  616. * @return a pointer to the user's data.
  617. */
  618. ODE_API void *dBodyGetData (dBodyID);
  619. /**
  620. * @brief Set position of a body.
  621. * @remarks
  622. * After setting, the outcome of the simulation is undefined
  623. * if the new configuration is inconsistent with the joints/constraints
  624. * that are present.
  625. * @ingroup bodies
  626. */
  627. ODE_API void dBodySetPosition (dBodyID, dReal x, dReal y, dReal z);
  628. /**
  629. * @brief Set the orientation of a body.
  630. * @ingroup bodies
  631. * @remarks
  632. * After setting, the outcome of the simulation is undefined
  633. * if the new configuration is inconsistent with the joints/constraints
  634. * that are present.
  635. */
  636. ODE_API void dBodySetRotation (dBodyID, const dMatrix3 R);
  637. /**
  638. * @brief Set the orientation of a body.
  639. * @ingroup bodies
  640. * @remarks
  641. * After setting, the outcome of the simulation is undefined
  642. * if the new configuration is inconsistent with the joints/constraints
  643. * that are present.
  644. */
  645. ODE_API void dBodySetQuaternion (dBodyID, const dQuaternion q);
  646. /**
  647. * @brief Set the linear velocity of a body.
  648. * @ingroup bodies
  649. */
  650. ODE_API void dBodySetLinearVel (dBodyID, dReal x, dReal y, dReal z);
  651. /**
  652. * @brief Set the angular velocity of a body.
  653. * @ingroup bodies
  654. */
  655. ODE_API void dBodySetAngularVel (dBodyID, dReal x, dReal y, dReal z);
  656. /**
  657. * @brief Get the position of a body.
  658. * @ingroup bodies
  659. * @remarks
  660. * When getting, the returned values are pointers to internal data structures,
  661. * so the vectors are valid until any changes are made to the rigid body
  662. * system structure.
  663. * @sa dBodyCopyPosition
  664. */
  665. ODE_API const dReal * dBodyGetPosition (dBodyID);
  666. /**
  667. * @brief Copy the position of a body into a vector.
  668. * @ingroup bodies
  669. * @param body the body to query
  670. * @param pos a copy of the body position
  671. * @sa dBodyGetPosition
  672. */
  673. ODE_API void dBodyCopyPosition (dBodyID body, dVector3 pos);
  674. /**
  675. * @brief Get the rotation of a body.
  676. * @ingroup bodies
  677. * @return pointer to a 4x3 rotation matrix.
  678. */
  679. ODE_API const dReal * dBodyGetRotation (dBodyID);
  680. /**
  681. * @brief Copy the rotation of a body.
  682. * @ingroup bodies
  683. * @param body the body to query
  684. * @param R a copy of the rotation matrix
  685. * @sa dBodyGetRotation
  686. */
  687. ODE_API void dBodyCopyRotation (dBodyID, dMatrix3 R);
  688. /**
  689. * @brief Get the rotation of a body.
  690. * @ingroup bodies
  691. * @return pointer to 4 scalars that represent the quaternion.
  692. */
  693. ODE_API const dReal * dBodyGetQuaternion (dBodyID);
  694. /**
  695. * @brief Copy the orientation of a body into a quaternion.
  696. * @ingroup bodies
  697. * @param body the body to query
  698. * @param quat a copy of the orientation quaternion
  699. * @sa dBodyGetQuaternion
  700. */
  701. ODE_API void dBodyCopyQuaternion(dBodyID body, dQuaternion quat);
  702. /**
  703. * @brief Get the linear velocity of a body.
  704. * @ingroup bodies
  705. */
  706. ODE_API const dReal * dBodyGetLinearVel (dBodyID);
  707. /**
  708. * @brief Get the angular velocity of a body.
  709. * @ingroup bodies
  710. */
  711. ODE_API const dReal * dBodyGetAngularVel (dBodyID);
  712. /**
  713. * @brief Set the mass of a body.
  714. * @ingroup bodies
  715. */
  716. ODE_API void dBodySetMass (dBodyID, const dMass *mass);
  717. /**
  718. * @brief Get the mass of a body.
  719. * @ingroup bodies
  720. */
  721. ODE_API void dBodyGetMass (dBodyID, dMass *mass);
  722. /**
  723. * @brief Add force at centre of mass of body in absolute coordinates.
  724. * @ingroup bodies
  725. */
  726. ODE_API void dBodyAddForce (dBodyID, dReal fx, dReal fy, dReal fz);
  727. /**
  728. * @brief Add torque at centre of mass of body in absolute coordinates.
  729. * @ingroup bodies
  730. */
  731. ODE_API void dBodyAddTorque (dBodyID, dReal fx, dReal fy, dReal fz);
  732. /**
  733. * @brief Add force at centre of mass of body in coordinates relative to body.
  734. * @ingroup bodies
  735. */
  736. ODE_API void dBodyAddRelForce (dBodyID, dReal fx, dReal fy, dReal fz);
  737. /**
  738. * @brief Add torque at centre of mass of body in coordinates relative to body.
  739. * @ingroup bodies
  740. */
  741. ODE_API void dBodyAddRelTorque (dBodyID, dReal fx, dReal fy, dReal fz);
  742. /**
  743. * @brief Add force at specified point in body in global coordinates.
  744. * @ingroup bodies
  745. */
  746. ODE_API void dBodyAddForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz,
  747. dReal px, dReal py, dReal pz);
  748. /**
  749. * @brief Add force at specified point in body in local coordinates.
  750. * @ingroup bodies
  751. */
  752. ODE_API void dBodyAddForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz,
  753. dReal px, dReal py, dReal pz);
  754. /**
  755. * @brief Add force at specified point in body in global coordinates.
  756. * @ingroup bodies
  757. */
  758. ODE_API void dBodyAddRelForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz,
  759. dReal px, dReal py, dReal pz);
  760. /**
  761. * @brief Add force at specified point in body in local coordinates.
  762. * @ingroup bodies
  763. */
  764. ODE_API void dBodyAddRelForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz,
  765. dReal px, dReal py, dReal pz);
  766. /**
  767. * @brief Return the current accumulated force vector.
  768. * @return points to an array of 3 reals.
  769. * @remarks
  770. * The returned values are pointers to internal data structures, so
  771. * the vectors are only valid until any changes are made to the rigid
  772. * body system.
  773. * @ingroup bodies
  774. */
  775. ODE_API const dReal * dBodyGetForce (dBodyID);
  776. /**
  777. * @brief Return the current accumulated torque vector.
  778. * @return points to an array of 3 reals.
  779. * @remarks
  780. * The returned values are pointers to internal data structures, so
  781. * the vectors are only valid until any changes are made to the rigid
  782. * body system.
  783. * @ingroup bodies
  784. */
  785. ODE_API const dReal * dBodyGetTorque (dBodyID);
  786. /**
  787. * @brief Set the body force accumulation vector.
  788. * @remarks
  789. * This is mostly useful to zero the force and torque for deactivated bodies
  790. * before they are reactivated, in the case where the force-adding functions
  791. * were called on them while they were deactivated.
  792. * @ingroup bodies
  793. */
  794. ODE_API void dBodySetForce (dBodyID b, dReal x, dReal y, dReal z);
  795. /**
  796. * @brief Set the body torque accumulation vector.
  797. * @remarks
  798. * This is mostly useful to zero the force and torque for deactivated bodies
  799. * before they are reactivated, in the case where the force-adding functions
  800. * were called on them while they were deactivated.
  801. * @ingroup bodies
  802. */
  803. ODE_API void dBodySetTorque (dBodyID b, dReal x, dReal y, dReal z);
  804. /**
  805. * @brief Get world position of a relative point on body.
  806. * @ingroup bodies
  807. * @param result will contain the result.
  808. */
  809. ODE_API void dBodyGetRelPointPos
  810. (
  811. dBodyID, dReal px, dReal py, dReal pz,
  812. dVector3 result
  813. );
  814. /**
  815. * @brief Get velocity vector in global coords of a relative point on body.
  816. * @ingroup bodies
  817. * @param result will contain the result.
  818. */
  819. ODE_API void dBodyGetRelPointVel
  820. (
  821. dBodyID, dReal px, dReal py, dReal pz,
  822. dVector3 result
  823. );
  824. /**
  825. * @brief Get velocity vector in global coords of a globally
  826. * specified point on a body.
  827. * @ingroup bodies
  828. * @param result will contain the result.
  829. */
  830. ODE_API void dBodyGetPointVel
  831. (
  832. dBodyID, dReal px, dReal py, dReal pz,
  833. dVector3 result
  834. );
  835. /**
  836. * @brief takes a point in global coordinates and returns
  837. * the point's position in body-relative coordinates.
  838. * @remarks
  839. * This is the inverse of dBodyGetRelPointPos()
  840. * @ingroup bodies
  841. * @param result will contain the result.
  842. */
  843. ODE_API void dBodyGetPosRelPoint
  844. (
  845. dBodyID, dReal px, dReal py, dReal pz,
  846. dVector3 result
  847. );
  848. /**
  849. * @brief Convert from local to world coordinates.
  850. * @ingroup bodies
  851. * @param result will contain the result.
  852. */
  853. ODE_API void dBodyVectorToWorld
  854. (
  855. dBodyID, dReal px, dReal py, dReal pz,
  856. dVector3 result
  857. );
  858. /**
  859. * @brief Convert from world to local coordinates.
  860. * @ingroup bodies
  861. * @param result will contain the result.
  862. */
  863. ODE_API void dBodyVectorFromWorld
  864. (
  865. dBodyID, dReal px, dReal py, dReal pz,
  866. dVector3 result
  867. );
  868. /**
  869. * @brief controls the way a body's orientation is updated at each timestep.
  870. * @ingroup bodies
  871. * @param mode can be 0 or 1:
  872. * \li 0: An ``infinitesimal'' orientation update is used.
  873. * This is fast to compute, but it can occasionally cause inaccuracies
  874. * for bodies that are rotating at high speed, especially when those
  875. * bodies are joined to other bodies.
  876. * This is the default for every new body that is created.
  877. * \li 1: A ``finite'' orientation update is used.
  878. * This is more costly to compute, but will be more accurate for high
  879. * speed rotations.
  880. * @remarks
  881. * Note however that high speed rotations can result in many types of
  882. * error in a simulation, and the finite mode will only fix one of those
  883. * sources of error.
  884. */
  885. ODE_API void dBodySetFiniteRotationMode (dBodyID, int mode);
  886. /**
  887. * @brief sets the finite rotation axis for a body.
  888. * @ingroup bodies
  889. * @remarks
  890. * This is axis only has meaning when the finite rotation mode is set
  891. * If this axis is zero (0,0,0), full finite rotations are performed on
  892. * the body.
  893. * If this axis is nonzero, the body is rotated by performing a partial finite
  894. * rotation along the axis direction followed by an infinitesimal rotation
  895. * along an orthogonal direction.
  896. * @remarks
  897. * This can be useful to alleviate certain sources of error caused by quickly
  898. * spinning bodies. For example, if a car wheel is rotating at high speed
  899. * you can call this function with the wheel's hinge axis as the argument to
  900. * try and improve its behavior.
  901. */
  902. ODE_API void dBodySetFiniteRotationAxis (dBodyID, dReal x, dReal y, dReal z);
  903. /**
  904. * @brief Get the way a body's orientation is updated each timestep.
  905. * @ingroup bodies
  906. * @return the mode 0 (infitesimal) or 1 (finite).
  907. */
  908. ODE_API int dBodyGetFiniteRotationMode (dBodyID);
  909. /**
  910. * @brief Get the finite rotation axis.
  911. * @param result will contain the axis.
  912. * @ingroup bodies
  913. */
  914. ODE_API void dBodyGetFiniteRotationAxis (dBodyID, dVector3 result);
  915. /**
  916. * @brief Get the number of joints that are attached to this body.
  917. * @ingroup bodies
  918. * @return nr of joints
  919. */
  920. ODE_API int dBodyGetNumJoints (dBodyID b);
  921. /**
  922. * @brief Return a joint attached to this body, given by index.
  923. * @ingroup bodies
  924. * @param index valid range is 0 to n-1 where n is the value returned by
  925. * dBodyGetNumJoints().
  926. */
  927. ODE_API dJointID dBodyGetJoint (dBodyID, int index);
  928. /**
  929. * @brief Set rigid body to dynamic state (default).
  930. * @param dBodyID identification of body.
  931. * @ingroup bodies
  932. */
  933. ODE_API void dBodySetDynamic (dBodyID);
  934. /**
  935. * @brief Set rigid body to kinematic state.
  936. * When in kinematic state the body isn't simulated as a dynamic
  937. * body (it's "unstoppable", doesn't respond to forces),
  938. * but can still affect dynamic bodies (e.g. in joints).
  939. * Kinematic bodies can be controlled by position and velocity.
  940. * @note A kinematic body has infinite mass. If you set its mass
  941. * to something else, it loses the kinematic state and behaves
  942. * as a normal dynamic body.
  943. * @param dBodyID identification of body.
  944. * @ingroup bodies
  945. */
  946. ODE_API void dBodySetKinematic (dBodyID);
  947. /**
  948. * @brief Check wether a body is in kinematic state.
  949. * @ingroup bodies
  950. * @return 1 if a body is kinematic or 0 if it is dynamic.
  951. */
  952. ODE_API int dBodyIsKinematic (dBodyID);
  953. /**
  954. * @brief Manually enable a body.
  955. * @param dBodyID identification of body.
  956. * @ingroup bodies
  957. */
  958. ODE_API void dBodyEnable (dBodyID);
  959. /**
  960. * @brief Manually disable a body.
  961. * @ingroup bodies
  962. * @remarks
  963. * A disabled body that is connected through a joint to an enabled body will
  964. * be automatically re-enabled at the next simulation step.
  965. */
  966. ODE_API void dBodyDisable (dBodyID);
  967. /**
  968. * @brief Check wether a body is enabled.
  969. * @ingroup bodies
  970. * @return 1 if a body is currently enabled or 0 if it is disabled.
  971. */
  972. ODE_API int dBodyIsEnabled (dBodyID);
  973. /**
  974. * @brief Set whether the body is influenced by the world's gravity or not.
  975. * @ingroup bodies
  976. * @param mode when nonzero gravity affects this body.
  977. * @remarks
  978. * Newly created bodies are always influenced by the world's gravity.
  979. */
  980. ODE_API void dBodySetGravityMode (dBodyID b, int mode);
  981. /**
  982. * @brief Get whether the body is influenced by the world's gravity or not.
  983. * @ingroup bodies
  984. * @return nonzero means gravity affects this body.
  985. */
  986. ODE_API int dBodyGetGravityMode (dBodyID b);
  987. /**
  988. * @brief Set the 'moved' callback of a body.
  989. *
  990. * Whenever a body has its position or rotation changed during the
  991. * timestep, the callback will be called (with body as the argument).
  992. * Use it to know which body may need an update in an external
  993. * structure (like a 3D engine).
  994. *
  995. * @param b the body that needs to be watched.
  996. * @param callback the callback to be invoked when the body moves. Set to zero
  997. * to disable.
  998. * @ingroup bodies
  999. */
  1000. ODE_API void dBodySetMovedCallback(dBodyID b, void (*callback)(dBodyID));
  1001. /**
  1002. * @brief Return the first geom associated with the body.
  1003. *
  1004. * You can traverse through the geoms by repeatedly calling
  1005. * dBodyGetNextGeom().
  1006. *
  1007. * @return the first geom attached to this body, or 0.
  1008. * @ingroup bodies
  1009. */
  1010. ODE_API dGeomID dBodyGetFirstGeom (dBodyID b);
  1011. /**
  1012. * @brief returns the next geom associated with the same body.
  1013. * @param g a geom attached to some body.
  1014. * @return the next geom attached to the same body, or 0.
  1015. * @sa dBodyGetFirstGeom
  1016. * @ingroup bodies
  1017. */
  1018. ODE_API dGeomID dBodyGetNextGeom (dGeomID g);
  1019. /**
  1020. * @brief Resets the damping settings to the current world's settings.
  1021. * @ingroup bodies damping
  1022. */
  1023. ODE_API void dBodySetDampingDefaults(dBodyID b);
  1024. /**
  1025. * @brief Get the body's linear damping scale.
  1026. * @ingroup bodies damping
  1027. */
  1028. ODE_API dReal dBodyGetLinearDamping (dBodyID b);
  1029. /**
  1030. * @brief Set the body's linear damping scale.
  1031. * @param scale The linear damping scale. Should be in the interval [0, 1].
  1032. * @ingroup bodies damping
  1033. * @remarks From now on the body will not use the world's linear damping
  1034. * scale until dBodySetDampingDefaults() is called.
  1035. * @sa dBodySetDampingDefaults()
  1036. */
  1037. ODE_API void dBodySetLinearDamping(dBodyID b, dReal scale);
  1038. /**
  1039. * @brief Get the body's angular damping scale.
  1040. * @ingroup bodies damping
  1041. * @remarks If the body's angular damping scale was not set, this function
  1042. * returns the world's angular damping scale.
  1043. */
  1044. ODE_API dReal dBodyGetAngularDamping (dBodyID b);
  1045. /**
  1046. * @brief Set the body's angular damping scale.
  1047. * @param scale The angular damping scale. Should be in the interval [0, 1].
  1048. * @ingroup bodies damping
  1049. * @remarks From now on the body will not use the world's angular damping
  1050. * scale until dBodyResetAngularDamping() is called.
  1051. * @sa dBodyResetAngularDamping()
  1052. */
  1053. ODE_API void dBodySetAngularDamping(dBodyID b, dReal scale);
  1054. /**
  1055. * @brief Convenience function to set linear and angular scales at once.
  1056. * @param linear_scale The linear damping scale. Should be in the interval [0, 1].
  1057. * @param angular_scale The angular damping scale. Should be in the interval [0, 1].
  1058. * @ingroup bodies damping
  1059. * @sa dBodySetLinearDamping() dBodySetAngularDamping()
  1060. */
  1061. ODE_API void dBodySetDamping(dBodyID b, dReal linear_scale, dReal angular_scale);
  1062. /**
  1063. * @brief Get the body's linear damping threshold.
  1064. * @ingroup bodies damping
  1065. */
  1066. ODE_API dReal dBodyGetLinearDampingThreshold (dBodyID b);
  1067. /**
  1068. * @brief Set the body's linear damping threshold.
  1069. * @param threshold The linear threshold to be used. Damping
  1070. * is only applied if the linear speed is above this limit.
  1071. * @ingroup bodies damping
  1072. */
  1073. ODE_API void dBodySetLinearDampingThreshold(dBodyID b, dReal threshold);
  1074. /**
  1075. * @brief Get the body's angular damping threshold.
  1076. * @ingroup bodies damping
  1077. */
  1078. ODE_API dReal dBodyGetAngularDampingThreshold (dBodyID b);
  1079. /**
  1080. * @brief Set the body's angular damping threshold.
  1081. * @param threshold The angular threshold to be used. Damping is
  1082. * only used if the angular speed is above this limit.
  1083. * @ingroup bodies damping
  1084. */
  1085. ODE_API void dBodySetAngularDampingThreshold(dBodyID b, dReal threshold);
  1086. /**
  1087. * @brief Get the body's maximum angular speed.
  1088. * @ingroup damping bodies
  1089. * @sa dWorldGetMaxAngularSpeed()
  1090. */
  1091. ODE_API dReal dBodyGetMaxAngularSpeed (dBodyID b);
  1092. /**
  1093. * @brief Set the body's maximum angular speed.
  1094. * @ingroup damping bodies
  1095. * @sa dWorldSetMaxAngularSpeed() dBodyResetMaxAngularSpeed()
  1096. * The default value is dInfinity, but it's a good idea to limit
  1097. * it at less than 500 if the body has the gyroscopic term
  1098. * enabled.
  1099. */
  1100. ODE_API void dBodySetMaxAngularSpeed(dBodyID b, dReal max_speed);
  1101. /**
  1102. * @brief Get the body's gyroscopic state.
  1103. *
  1104. * @return nonzero if gyroscopic term computation is enabled (default),
  1105. * zero otherwise.
  1106. * @ingroup bodies
  1107. */
  1108. ODE_API int dBodyGetGyroscopicMode(dBodyID b);
  1109. /**
  1110. * @brief Enable/disable the body's gyroscopic term.
  1111. *
  1112. * Disabling the gyroscopic term of a body usually improves
  1113. * stability. It also helps turning spining objects, like cars'
  1114. * wheels.
  1115. *
  1116. * @param enabled nonzero (default) to enable gyroscopic term, 0
  1117. * to disable.
  1118. * @ingroup bodies
  1119. */
  1120. ODE_API void dBodySetGyroscopicMode(dBodyID b, int enabled);
  1121. /**
  1122. * @defgroup joints Joints
  1123. *
  1124. * In real life a joint is something like a hinge, that is used to connect two
  1125. * objects.
  1126. * In ODE a joint is very similar: It is a relationship that is enforced between
  1127. * two bodies so that they can only have certain positions and orientations
  1128. * relative to each other.
  1129. * This relationship is called a constraint -- the words joint and
  1130. * constraint are often used interchangeably.
  1131. *
  1132. * A joint has a set of parameters that can be set. These include:
  1133. *
  1134. *
  1135. * \li dParamLoStop Low stop angle or position. Setting this to
  1136. * -dInfinity (the default value) turns off the low stop.
  1137. * For rotational joints, this stop must be greater than -pi to be
  1138. * effective.
  1139. * \li dParamHiStop High stop angle or position. Setting this to
  1140. * dInfinity (the default value) turns off the high stop.
  1141. * For rotational joints, this stop must be less than pi to be
  1142. * effective.
  1143. * If the high stop is less than the low stop then both stops will
  1144. * be ineffective.
  1145. * \li dParamVel Desired motor velocity (this will be an angular or
  1146. * linear velocity).
  1147. * \li dParamFMax The maximum force or torque that the motor will use to
  1148. * achieve the desired velocity.
  1149. * This must always be greater than or equal to zero.
  1150. * Setting this to zero (the default value) turns off the motor.
  1151. * \li dParamFudgeFactor The current joint stop/motor implementation has
  1152. * a small problem:
  1153. * when the joint is at one stop and the motor is set to move it away
  1154. * from the stop, too much force may be applied for one time step,
  1155. * causing a ``jumping'' motion.
  1156. * This fudge factor is used to scale this excess force.
  1157. * It should have a value between zero and one (the default value).
  1158. * If the jumping motion is too visible in a joint, the value can be
  1159. * reduced.
  1160. * Making this value too small can prevent the motor from being able to
  1161. * move the joint away from a stop.
  1162. * \li dParamBounce The bouncyness of the stops.
  1163. * This is a restitution parameter in the range 0..1.
  1164. * 0 means the stops are not bouncy at all, 1 means maximum bouncyness.
  1165. * \li dParamCFM The constraint force mixing (CFM) value used when not
  1166. * at a stop.
  1167. * \li dParamStopERP The error reduction parameter (ERP) used by the
  1168. * stops.
  1169. * \li dParamStopCFM The constraint force mixing (CFM) value used by the
  1170. * stops. Together with the ERP value this can be used to get spongy or
  1171. * soft stops.
  1172. * Note that this is intended for unpowered joints, it does not really
  1173. * work as expected when a powered joint reaches its limit.
  1174. * \li dParamSuspensionERP Suspension error reduction parameter (ERP).
  1175. * Currently this is only implemented on the hinge-2 joint.
  1176. * \li dParamSuspensionCFM Suspension constraint force mixing (CFM) value.
  1177. * Currently this is only implemented on the hinge-2 joint.
  1178. *
  1179. * If a particular parameter is not implemented by a given joint, setting it
  1180. * will have no effect.
  1181. * These parameter names can be optionally followed by a digit (2 or 3)
  1182. * to indicate the second or third set of parameters, e.g. for the second axis
  1183. * in a hinge-2 joint, or the third axis in an AMotor joint.
  1184. */
  1185. /**
  1186. * @brief Create a new joint of the ball type.
  1187. * @ingroup joints
  1188. * @remarks
  1189. * The joint is initially in "limbo" (i.e. it has no effect on the simulation)
  1190. * because it does not connect to any bodies.
  1191. * @param dJointGroupID set to 0 to allocate the joint normally.
  1192. * If it is nonzero the joint is allocated in the given joint group.
  1193. */
  1194. ODE_API dJointID dJointCreateBall (dWorldID, dJointGroupID);
  1195. /**
  1196. * @brief Create a new joint of the hinge type.
  1197. * @ingroup joints
  1198. * @param dJointGroupID set to 0 to allocate the joint normally.
  1199. * If it is nonzero the joint is allocated in the given joint group.
  1200. */
  1201. ODE_API dJointID dJointCreateHinge (dWorldID, dJointGroupID);
  1202. /**
  1203. * @brief Create a new joint of the slider type.
  1204. * @ingroup joints
  1205. * @param dJointGroupID set to 0 to allocate the joint normally.
  1206. * If it is nonzero the joint is allocated in the given joint group.
  1207. */
  1208. ODE_API dJointID dJointCreateSlider (dWorldID, dJointGroupID);
  1209. /**
  1210. * @brief Create a new joint of the contact type.
  1211. * @ingroup joints
  1212. * @param dJointGroupID set to 0 to allocate the joint normally.
  1213. * If it is nonzero the joint is allocated in the given joint group.
  1214. */
  1215. ODE_API dJointID dJointCreateContact (dWorldID, dJointGroupID, const dContact *);
  1216. /**
  1217. * @brief Create a new joint of the hinge2 type.
  1218. * @ingroup joints
  1219. * @param dJointGroupID set to 0 to allocate the joint normally.
  1220. * If it is nonzero the joint is allocated in the given joint group.
  1221. */
  1222. ODE_API dJointID dJointCreateHinge2 (dWorldID, dJointGroupID);
  1223. /**
  1224. * @brief Create a new joint of the universal type.
  1225. * @ingroup joints
  1226. * @param dJointGroupID set to 0 to allocate the joint normally.
  1227. * If it is nonzero the joint is allocated in the given joint group.
  1228. */
  1229. ODE_API dJointID dJointCreateUniversal (dWorldID, dJointGroupID);
  1230. /**
  1231. * @brief Create a new joint of the PR (Prismatic and Rotoide) type.
  1232. * @ingroup joints
  1233. * @param dJointGroupID set to 0 to allocate the joint normally.
  1234. * If it is nonzero the joint is allocated in the given joint group.
  1235. */
  1236. ODE_API dJointID dJointCreatePR (dWorldID, dJointGroupID);
  1237. /**
  1238. * @brief Create a new joint of the PU (Prismatic and Universal) type.
  1239. * @ingroup joints
  1240. * @param dJointGroupID set to 0 to allocate the joint normally.
  1241. * If it is nonzero the joint is allocated in the given joint group.
  1242. */
  1243. ODE_API dJointID dJointCreatePU (dWorldID, dJointGroupID);
  1244. /**
  1245. * @brief Create a new joint of the Piston type.
  1246. * @ingroup joints
  1247. * @param dJointGroupID set to 0 to allocate the joint normally.
  1248. * If it is nonzero the joint is allocated in the given
  1249. * joint group.
  1250. */
  1251. ODE_API dJointID dJointCreatePiston (dWorldID, dJointGroupID);
  1252. /**
  1253. * @brief Create a new joint of the fixed type.
  1254. * @ingroup joints
  1255. * @param dJointGroupID set to 0 to allocate the joint normally.
  1256. * If it is nonzero the joint is allocated in the given joint group.
  1257. */
  1258. ODE_API dJointID dJointCreateFixed (dWorldID, dJointGroupID);
  1259. ODE_API dJointID dJointCreateNull (dWorldID, dJointGroupID);
  1260. /**
  1261. * @brief Create a new joint of the A-motor type.
  1262. * @ingroup joints
  1263. * @param dJointGroupID set to 0 to allocate the joint normally.
  1264. * If it is nonzero the joint is allocated in the given joint group.
  1265. */
  1266. ODE_API dJointID dJointCreateAMotor (dWorldID, dJointGroupID);
  1267. /**
  1268. * @brief Create a new joint of the L-motor type.
  1269. * @ingroup joints
  1270. * @param dJointGroupID set to 0 to allocate the joint normally.
  1271. * If it is nonzero the joint is allocated in the given joint group.
  1272. */
  1273. ODE_API dJointID dJointCreateLMotor (dWorldID, dJointGroupID);
  1274. /**
  1275. * @brief Create a new joint of the plane-2d type.
  1276. * @ingroup joints
  1277. * @param dJointGroupID set to 0 to allocate the joint normally.
  1278. * If it is nonzero the joint is allocated in the given joint group.
  1279. */
  1280. ODE_API dJointID dJointCreatePlane2D (dWorldID, dJointGroupID);
  1281. /**
  1282. * @brief Destroy a joint.
  1283. * @ingroup joints
  1284. *
  1285. * disconnects it from its attached bodies and removing it from the world.
  1286. * However, if the joint is a member of a group then this function has no
  1287. * effect - to destroy that joint the group must be emptied or destroyed.
  1288. */
  1289. ODE_API void dJointDestroy (dJointID);
  1290. /**
  1291. * @brief Create a joint group
  1292. * @ingroup joints
  1293. * @param max_size deprecated. Set to 0.
  1294. */
  1295. ODE_API dJointGroupID dJointGroupCreate (int max_size);
  1296. /**
  1297. * @brief Destroy a joint group.
  1298. * @ingroup joints
  1299. *
  1300. * All joints in the joint group will be destroyed.
  1301. */
  1302. ODE_API void dJointGroupDestroy (dJointGroupID);
  1303. /**
  1304. * @brief Empty a joint group.
  1305. * @ingroup joints
  1306. *
  1307. * All joints in the joint group will be destroyed,
  1308. * but the joint group itself will not be destroyed.
  1309. */
  1310. ODE_API void dJointGroupEmpty (dJointGroupID);
  1311. /**
  1312. * @brief Return the number of bodies attached to the joint
  1313. * @ingroup joints
  1314. */
  1315. ODE_API int dJointGetNumBodies(dJointID);
  1316. /**
  1317. * @brief Attach the joint to some new bodies.
  1318. * @ingroup joints
  1319. *
  1320. * If the joint is already attached, it will be detached from the old bodies
  1321. * first.
  1322. * To attach this joint to only one body, set body1 or body2 to zero - a zero
  1323. * body refers to the static environment.
  1324. * Setting both bodies to zero puts the joint into "limbo", i.e. it will
  1325. * have no effect on the simulation.
  1326. * @remarks
  1327. * Some joints, like hinge-2 need to be attached to two bodies to work.
  1328. */
  1329. ODE_API void dJointAttach (dJointID, dBodyID body1, dBodyID body2);
  1330. /**
  1331. * @brief Manually enable a joint.
  1332. * @param dJointID identification of joint.
  1333. * @ingroup joints
  1334. */
  1335. ODE_API void dJointEnable (dJointID);
  1336. /**
  1337. * @brief Manually disable a joint.
  1338. * @ingroup joints
  1339. * @remarks
  1340. * A disabled joint will not affect the simulation, but will maintain the anchors and
  1341. * axes so it can be enabled later.
  1342. */
  1343. ODE_API void dJointDisable (dJointID);
  1344. /**
  1345. * @brief Check wether a joint is enabled.
  1346. * @ingroup joints
  1347. * @return 1 if a joint is currently enabled or 0 if it is disabled.
  1348. */
  1349. ODE_API int dJointIsEnabled (dJointID);
  1350. /**
  1351. * @brief Set the user-data pointer
  1352. * @ingroup joints
  1353. */
  1354. ODE_API void dJointSetData (dJointID, void *data);
  1355. /**
  1356. * @brief Get the user-data pointer
  1357. * @ingroup joints
  1358. */
  1359. ODE_API void *dJointGetData (dJointID);
  1360. /**
  1361. * @brief Get the type of the joint
  1362. * @ingroup joints
  1363. * @return the type, being one of these:
  1364. * \li dJointTypeBall
  1365. * \li dJointTypeHinge
  1366. * \li dJointTypeSlider
  1367. * \li dJointTypeContact
  1368. * \li dJointTypeUniversal
  1369. * \li dJointTypeHinge2
  1370. * \li dJointTypeFixed
  1371. * \li dJointTypeNull
  1372. * \li dJointTypeAMotor
  1373. * \li dJointTypeLMotor
  1374. * \li dJointTypePlane2D
  1375. * \li dJointTypePR
  1376. * \li dJointTypePU
  1377. * \li dJointTypePiston
  1378. */
  1379. ODE_API dJointType dJointGetType (dJointID);
  1380. /**
  1381. * @brief Return the bodies that this joint connects.
  1382. * @ingroup joints
  1383. * @param index return the first (0) or second (1) body.
  1384. * @remarks
  1385. * If one of these returned body IDs is zero, the joint connects the other body
  1386. * to the static environment.
  1387. * If both body IDs are zero, the joint is in ``limbo'' and has no effect on
  1388. * the simulation.
  1389. */
  1390. ODE_API dBodyID dJointGetBody (dJointID, int index);
  1391. /**
  1392. * @brief Sets the datastructure that is to receive the feedback.
  1393. *
  1394. * The feedback can be used by the user, so that it is known how
  1395. * much force an individual joint exerts.
  1396. * @ingroup joints
  1397. */
  1398. ODE_API void dJointSetFeedback (dJointID, dJointFeedback *);
  1399. /**
  1400. * @brief Gets the datastructure that is to receive the feedback.
  1401. * @ingroup joints
  1402. */
  1403. ODE_API dJointFeedback *dJointGetFeedback (dJointID);
  1404. /**
  1405. * @brief Set the joint anchor point.
  1406. * @ingroup joints
  1407. *
  1408. * The joint will try to keep this point on each body
  1409. * together. The input is specified in world coordinates.
  1410. */
  1411. ODE_API void dJointSetBallAnchor (dJointID, dReal x, dReal y, dReal z);
  1412. /**
  1413. * @brief Set the joint anchor point.
  1414. * @ingroup joints
  1415. */
  1416. ODE_API void dJointSetBallAnchor2 (dJointID, dReal x, dReal y, dReal z);
  1417. /**
  1418. * @brief Param setting for Ball joints
  1419. * @ingroup joints
  1420. */
  1421. ODE_API void dJointSetBallParam (dJointID, int parameter, dReal value);
  1422. /**
  1423. * @brief Set hinge anchor parameter.
  1424. * @ingroup joints
  1425. */
  1426. ODE_API void dJointSetHingeAnchor (dJointID, dReal x, dReal y, dReal z);
  1427. ODE_API void dJointSetHingeAnchorDelta (dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
  1428. /**
  1429. * @brief Set hinge axis.
  1430. * @ingroup joints
  1431. */
  1432. ODE_API void dJointSetHingeAxis (dJointID, dReal x, dReal y, dReal z);
  1433. /**
  1434. * @brief Set the Hinge axis as if the 2 bodies were already at angle appart.
  1435. * @ingroup joints
  1436. *
  1437. * This function initialize the Axis and the relative orientation of each body
  1438. * as if body1 was rotated around the axis by the angle value. \br
  1439. * Ex:
  1440. * <PRE>
  1441. * dJointSetHingeAxis(jId, 1, 0, 0);
  1442. * // If you request the position you will have: dJointGetHingeAngle(jId) == 0
  1443. * dJointSetHingeAxisDelta(jId, 1, 0, 0, 0.23);
  1444. * // If you request the position you will have: dJointGetHingeAngle(jId) == 0.23
  1445. * </PRE>
  1446. * @param j The Hinge joint ID for which the axis will be set
  1447. * @param x The X component of the axis in world frame
  1448. * @param y The Y component of the axis in world frame
  1449. * @param z The Z component of the axis in world frame
  1450. * @param angle The angle for the offset of the relative orientation.
  1451. * As if body1 was rotated by angle when the Axis was set (see below).
  1452. * The rotation is around the new Hinge axis.
  1453. *
  1454. * @note Usually the function dJointSetHingeAxis set the current position of body1
  1455. * and body2 as the zero angle position. This function set the current position
  1456. * as the if the 2 bodies where \b angle appart.
  1457. * @warning Calling dJointSetHingeAnchor or dJointSetHingeAxis will reset the "zero"
  1458. * angle position.
  1459. */
  1460. ODE_API void dJointSetHingeAxisOffset (dJointID j, dReal x, dReal y, dReal z, dReal angle);
  1461. /**
  1462. * @brief set joint parameter
  1463. * @ingroup joints
  1464. */
  1465. ODE_API void dJointSetHingeParam (dJointID, int parameter, dReal value);
  1466. /**
  1467. * @brief Applies the torque about the hinge axis.
  1468. *
  1469. * That is, it applies a torque with specified magnitude in the direction
  1470. * of the hinge axis, to body 1, and with the same magnitude but in opposite
  1471. * direction to body 2. This function is just a wrapper for dBodyAddTorque()}
  1472. * @ingroup joints
  1473. */
  1474. ODE_API void dJointAddHingeTorque(dJointID joint, dReal torque);
  1475. /**
  1476. * @brief set the joint axis
  1477. * @ingroup joints
  1478. */
  1479. ODE_API void dJointSetSliderAxis (dJointID, dReal x, dReal y, dReal z);
  1480. /**
  1481. * @ingroup joints
  1482. */
  1483. ODE_API void dJointSetSliderAxisDelta (dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
  1484. /**
  1485. * @brief set joint parameter
  1486. * @ingroup joints
  1487. */
  1488. ODE_API void dJointSetSliderParam (dJointID, int parameter, dReal value);
  1489. /**
  1490. * @brief Applies the given force in the slider's direction.
  1491. *
  1492. * That is, it applies a force with specified magnitude, in the direction of
  1493. * slider's axis, to body1, and with the same magnitude but opposite
  1494. * direction to body2. This function is just a wrapper for dBodyAddForce().
  1495. * @ingroup joints
  1496. */
  1497. ODE_API void dJointAddSliderForce(dJointID joint, dReal force);
  1498. /**
  1499. * @brief set anchor
  1500. * @ingroup joints
  1501. */
  1502. ODE_API void dJointSetHinge2Anchor (dJointID, dReal x, dReal y, dReal z);
  1503. /**
  1504. * @brief set axis
  1505. * @ingroup joints
  1506. */
  1507. ODE_API void dJointSetHinge2Axis1 (dJointID, dReal x, dReal y, dReal z);
  1508. /**
  1509. * @brief set axis
  1510. * @ingroup joints
  1511. */
  1512. ODE_API void dJointSetHinge2Axis2 (dJointID, dReal x, dReal y, dReal z);
  1513. /**
  1514. * @brief set joint parameter
  1515. * @ingroup joints
  1516. */
  1517. ODE_API void dJointSetHinge2Param (dJointID, int parameter, dReal value);
  1518. /**
  1519. * @brief Applies torque1 about the hinge2's axis 1, torque2 about the
  1520. * hinge2's axis 2.
  1521. * @remarks This function is just a wrapper for dBodyAddTorque().
  1522. * @ingroup joints
  1523. */
  1524. ODE_API void dJointAddHinge2Torques(dJointID joint, dReal torque1, dReal torque2);
  1525. /**
  1526. * @brief set anchor
  1527. * @ingroup joints
  1528. */
  1529. ODE_API void dJointSetUniversalAnchor (dJointID, dReal x, dReal y, dReal z);
  1530. /**
  1531. * @brief set axis
  1532. * @ingroup joints
  1533. */
  1534. ODE_API void dJointSetUniversalAxis1 (dJointID, dReal x, dReal y, dReal z);
  1535. /**
  1536. * @brief Set the Universal axis1 as if the 2 bodies were already at
  1537. * offset1 and offset2 appart with respect to axis1 and axis2.
  1538. * @ingroup joints
  1539. *
  1540. * This function initialize the axis1 and the relative orientation of
  1541. * each body as if body1 was rotated around the new axis1 by the offset1
  1542. * value and as if body2 was rotated around the axis2 by offset2. \br
  1543. * Ex:
  1544. * <PRE>
  1545. * dJointSetHuniversalAxis1(jId, 1, 0, 0);
  1546. * // If you request the position you will have: dJointGetUniversalAngle1(jId) == 0
  1547. * // If you request the position you will have: dJointGetUniversalAngle2(jId) == 0
  1548. * dJointSetHuniversalAxis1Offset(jId, 1, 0, 0, 0.2, 0.17);
  1549. * // If you request the position you will have: dJointGetUniversalAngle1(jId) == 0.2
  1550. * // If you request the position you will have: dJointGetUniversalAngle2(jId) == 0.17
  1551. * </PRE>
  1552. *
  1553. * @param j The Hinge joint ID for which the axis will be set
  1554. * @param x The X component of the axis in world frame
  1555. * @param y The Y component of the axis in world frame
  1556. * @param z The Z component of the axis in world frame
  1557. * @param angle The angle for the offset of the relative orientation.
  1558. * As if body1 was rotated by angle when the Axis was set (see below).
  1559. * The rotation is around the new Hinge axis.
  1560. *
  1561. * @note Usually the function dJointSetHingeAxis set the current position of body1
  1562. * and body2 as the zero angle position. This function set the current position
  1563. * as the if the 2 bodies where \b offsets appart.
  1564. *
  1565. * @note Any previous offsets are erased.
  1566. *
  1567. * @warning Calling dJointSetUniversalAnchor, dJointSetUnivesalAxis1,
  1568. * dJointSetUniversalAxis2, dJointSetUniversalAxis2Offset
  1569. * will reset the "zero" angle position.
  1570. */
  1571. ODE_API void dJointSetUniversalAxis1Offset (dJointID, dReal x, dReal y, dReal z,
  1572. dReal offset1, dReal offset2);
  1573. /**
  1574. * @brief set axis
  1575. * @ingroup joints
  1576. */
  1577. ODE_API void dJointSetUniversalAxis2 (dJointID, dReal x, dReal y, dReal z);
  1578. /**
  1579. * @brief Set the Universal axis2 as if the 2 bodies were already at
  1580. * offset1 and offset2 appart with respect to axis1 and axis2.
  1581. * @ingroup joints
  1582. *
  1583. * This function initialize the axis2 and the relative orientation of
  1584. * each body as if body1 was rotated around the axis1 by the offset1
  1585. * value and as if body2 was rotated around the new axis2 by offset2. \br
  1586. * Ex:
  1587. * <PRE>
  1588. * dJointSetHuniversalAxis2(jId, 0, 1, 0);
  1589. * // If you request the position you will have: dJointGetUniversalAngle1(jId) == 0
  1590. * // If you request the position you will have: dJointGetUniversalAngle2(jId) == 0
  1591. * dJointSetHuniversalAxis2Offset(jId, 0, 1, 0, 0.2, 0.17);
  1592. * // If you request the position you will have: dJointGetUniversalAngle1(jId) == 0.2
  1593. * // If you request the position you will have: dJointGetUniversalAngle2(jId) == 0.17
  1594. * </PRE>
  1595. * @param j The Hinge joint ID for which the axis will be set
  1596. * @param x The X component of the axis in world frame
  1597. * @param y The Y component of the axis in world frame
  1598. * @param z The Z component of the axis in world frame
  1599. * @param angle The angle for the offset of the relative orientation.
  1600. * As if body1 was rotated by angle when the Axis was set (see below).
  1601. * The rotation is around the new Hinge axis.
  1602. *
  1603. * @note Usually the function dJointSetHingeAxis set the current position of body1
  1604. * and body2 as the zero angle position. This function set the current position
  1605. * as the if the 2 bodies where \b offsets appart.
  1606. *
  1607. * @note Any previous offsets are erased.
  1608. *
  1609. * @warning Calling dJointSetUniversalAnchor, dJointSetUnivesalAxis1,
  1610. * dJointSetUniversalAxis2, dJointSetUniversalAxis2Offset
  1611. * will reset the "zero" angle position.
  1612. */
  1613. ODE_API void dJointSetUniversalAxis2Offset (dJointID, dReal x, dReal y, dReal z,
  1614. dReal offset1, dReal offset2);
  1615. /**
  1616. * @brief set joint parameter
  1617. * @ingroup joints
  1618. */
  1619. ODE_API void dJointSetUniversalParam (dJointID, int parameter, dReal value);
  1620. /**
  1621. * @brief Applies torque1 about the universal's axis 1, torque2 about the
  1622. * universal's axis 2.
  1623. * @remarks This function is just a wrapper for dBodyAddTorque().
  1624. * @ingroup joints
  1625. */
  1626. ODE_API void dJointAddUniversalTorques(dJointID joint, dReal torque1, dReal torque2);
  1627. /**
  1628. * @brief set anchor
  1629. * @ingroup joints
  1630. */
  1631. ODE_API void dJointSetPRAnchor (dJointID, dReal x, dReal y, dReal z);
  1632. /**
  1633. * @brief set the axis for the prismatic articulation
  1634. * @ingroup joints
  1635. */
  1636. ODE_API void dJointSetPRAxis1 (dJointID, dReal x, dReal y, dReal z);
  1637. /**
  1638. * @brief set the axis for the rotoide articulation
  1639. * @ingroup joints
  1640. */
  1641. ODE_API void dJointSetPRAxis2 (dJointID, dReal x, dReal y, dReal z);
  1642. /**
  1643. * @brief set joint parameter
  1644. * @ingroup joints
  1645. *
  1646. * @note parameterX where X equal 2 refer to parameter for the rotoide articulation
  1647. */
  1648. ODE_API void dJointSetPRParam (dJointID, int parameter, dReal value);
  1649. /**
  1650. * @brief Applies the torque about the rotoide axis of the PR joint
  1651. *
  1652. * That is, it applies a torque with specified magnitude in the direction
  1653. * of the rotoide axis, to body 1, and with the same magnitude but in opposite
  1654. * direction to body 2. This function is just a wrapper for dBodyAddTorque()}
  1655. * @ingroup joints
  1656. */
  1657. ODE_API void dJointAddPRTorque (dJointID j, dReal torque);
  1658. /**
  1659. * @brief set anchor
  1660. * @ingroup joints
  1661. */
  1662. ODE_API void dJointSetPUAnchor (dJointID, dReal x, dReal y, dReal z);
  1663. /**
  1664. * @brief set anchor
  1665. * @ingroup joints
  1666. */
  1667. ODE_API_DEPRECATED ODE_API void dJointSetPUAnchorDelta (dJointID, dReal x, dReal y, dReal z,
  1668. dReal dx, dReal dy, dReal dz);
  1669. /**
  1670. * @brief Set the PU anchor as if the 2 bodies were already at [dx, dy, dz] appart.
  1671. * @ingroup joints
  1672. *
  1673. * This function initialize the anchor and the relative position of each body
  1674. * as if the position between body1 and body2 was already the projection of [dx, dy, dz]
  1675. * along the Piston axis. (i.e as if the body1 was at its current position - [dx,dy,dy] when the
  1676. * axis is set).
  1677. * Ex:
  1678. * <PRE>
  1679. * dReal offset = 3;
  1680. * dVector3 axis;
  1681. * dJointGetPUAxis(jId, axis);
  1682. * dJointSetPUAnchor(jId, 0, 0, 0);
  1683. * // If you request the position you will have: dJointGetPUPosition(jId) == 0
  1684. * dJointSetPUAnchorOffset(jId, 0, 0, 0, axis[X]*offset, axis[Y]*offset, axis[Z]*offset);
  1685. * // If you request the position you will have: dJointGetPUPosition(jId) == offset
  1686. * </PRE>
  1687. * @param j The PU joint for which the anchor point will be set
  1688. * @param x The X position of the anchor point in world frame
  1689. * @param y The Y position of the anchor point in world frame
  1690. * @param z The Z position of the anchor point in world frame
  1691. * @param dx A delta to be substracted to the X position as if the anchor was set
  1692. * when body1 was at current_position[X] - dx
  1693. * @param dx A delta to be substracted to the Y position as if the anchor was set
  1694. * when body1 was at current_position[Y] - dy
  1695. * @param dx A delta to be substracted to the Z position as if the anchor was set
  1696. * when body1 was at current_position[Z] - dz
  1697. */
  1698. ODE_API void dJointSetPUAnchorOffset (dJointID, dReal x, dReal y, dReal z,
  1699. dReal dx, dReal dy, dReal dz);
  1700. /**
  1701. * @brief set the axis for the first axis or the universal articulation
  1702. * @ingroup joints
  1703. */
  1704. ODE_API void dJointSetPUAxis1 (dJointID, dReal x, dReal y, dReal z);
  1705. /**
  1706. * @brief set the axis for the second axis or the universal articulation
  1707. * @ingroup joints
  1708. */
  1709. ODE_API void dJointSetPUAxis2 (dJointID, dReal x, dReal y, dReal z);
  1710. /**
  1711. * @brief set the axis for the prismatic articulation
  1712. * @ingroup joints
  1713. */
  1714. ODE_API void dJointSetPUAxis3 (dJointID, dReal x, dReal y, dReal z);
  1715. /**
  1716. * @brief set the axis for the prismatic articulation
  1717. * @ingroup joints
  1718. * @note This function was added for convenience it is the same as
  1719. * dJointSetPUAxis3
  1720. */
  1721. ODE_API void dJointSetPUAxisP (dJointID id, dReal x, dReal y, dReal z);
  1722. /**
  1723. * @brief set joint parameter
  1724. * @ingroup joints
  1725. *
  1726. * @note parameterX where X equal 2 refer to parameter for second axis of the
  1727. * universal articulation
  1728. * @note parameterX where X equal 3 refer to parameter for prismatic
  1729. * articulation
  1730. */
  1731. ODE_API void dJointSetPUParam (dJointID, int parameter, dReal value);
  1732. /**
  1733. * @brief Applies the torque about the rotoide axis of the PU joint
  1734. *
  1735. * That is, it applies a torque with specified magnitude in the direction
  1736. * of the rotoide axis, to body 1, and with the same magnitude but in opposite
  1737. * direction to body 2. This function is just a wrapper for dBodyAddTorque()}
  1738. * @ingroup joints
  1739. */
  1740. ODE_API void dJointAddPUTorque (dJointID j, dReal torque);
  1741. /**
  1742. * @brief set the joint anchor
  1743. * @ingroup joints
  1744. */
  1745. ODE_API void dJointSetPistonAnchor (dJointID, dReal x, dReal y, dReal z);
  1746. /**
  1747. * @brief Set the Piston anchor as if the 2 bodies were already at [dx,dy, dz] appart.
  1748. * @ingroup joints
  1749. *
  1750. * This function initialize the anchor and the relative position of each body
  1751. * as if the position between body1 and body2 was already the projection of [dx, dy, dz]
  1752. * along the Piston axis. (i.e as if the body1 was at its current position - [dx,dy,dy] when the
  1753. * axis is set).
  1754. * Ex:
  1755. * <PRE>
  1756. * dReal offset = 3;
  1757. * dVector3 axis;
  1758. * dJointGetPistonAxis(jId, axis);
  1759. * dJointSetPistonAnchor(jId, 0, 0, 0);
  1760. * // If you request the position you will have: dJointGetPistonPosition(jId) == 0
  1761. * dJointSetPistonAnchorOffset(jId, 0, 0, 0, axis[X]*offset, axis[Y]*offset, axis[Z]*offset);
  1762. * // If you request the position you will have: dJointGetPistonPosition(jId) == offset
  1763. * </PRE>
  1764. * @param j The Piston joint for which the anchor point will be set
  1765. * @param x The X position of the anchor point in world frame
  1766. * @param y The Y position of the anchor point in world frame
  1767. * @param z The Z position of the anchor point in world frame
  1768. * @param dx A delta to be substracted to the X position as if the anchor was set
  1769. * when body1 was at current_position[X] - dx
  1770. * @param dx A delta to be substracted to the Y position as if the anchor was set
  1771. * when body1 was at current_position[Y] - dy
  1772. * @param dx A delta to be substracted to the Z position as if the anchor was set
  1773. * when body1 was at current_position[Z] - dz
  1774. */
  1775. ODE_API void dJointSetPistonAnchorOffset(dJointID j, dReal x, dReal y, dReal z,
  1776. dReal dx, dReal dy, dReal dz);
  1777. /**
  1778. * @brief set the joint axis
  1779. * @ingroup joints
  1780. */
  1781. ODE_API void dJointSetPistonAxis (dJointID, dReal x, dReal y, dReal z);
  1782. /**
  1783. * This function set prismatic axis of the joint and also set the position
  1784. * of the joint.
  1785. *
  1786. * @ingroup joints
  1787. * @param j The joint affected by this function
  1788. * @param x The x component of the axis
  1789. * @param y The y component of the axis
  1790. * @param z The z component of the axis
  1791. * @param dx The Initial position of the prismatic join in the x direction
  1792. * @param dy The Initial position of the prismatic join in the y direction
  1793. * @param dz The Initial position of the prismatic join in the z direction
  1794. */
  1795. ODE_API_DEPRECATED ODE_API void dJointSetPistonAxisDelta (dJointID j, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
  1796. /**
  1797. * @brief set joint parameter
  1798. * @ingroup joints
  1799. */
  1800. ODE_API void dJointSetPistonParam (dJointID, int parameter, dReal value);
  1801. /**
  1802. * @brief Applies the given force in the slider's direction.
  1803. *
  1804. * That is, it applies a force with specified magnitude, in the direction of
  1805. * prismatic's axis, to body1, and with the same magnitude but opposite
  1806. * direction to body2. This function is just a wrapper for dBodyAddForce().
  1807. * @ingroup joints
  1808. */
  1809. ODE_API void dJointAddPistonForce (dJointID joint, dReal force);
  1810. /**
  1811. * @brief Call this on the fixed joint after it has been attached to
  1812. * remember the current desired relative offset and desired relative
  1813. * rotation between the bodies.
  1814. * @ingroup joints
  1815. */
  1816. ODE_API void dJointSetFixed (dJointID);
  1817. /*
  1818. * @brief Sets joint parameter
  1819. *
  1820. * @ingroup joints
  1821. */
  1822. ODE_API void dJointSetFixedParam (dJointID, int parameter, dReal value);
  1823. /**
  1824. * @brief set the nr of axes
  1825. * @param num 0..3
  1826. * @ingroup joints
  1827. */
  1828. ODE_API void dJointSetAMotorNumAxes (dJointID, int num);
  1829. /**
  1830. * @brief set axis
  1831. * @ingroup joints
  1832. */
  1833. ODE_API void dJointSetAMotorAxis (dJointID, int anum, int rel,
  1834. dReal x, dReal y, dReal z);
  1835. /**
  1836. * @brief Tell the AMotor what the current angle is along axis anum.
  1837. *
  1838. * This function should only be called in dAMotorUser mode, because in this
  1839. * mode the AMotor has no other way of knowing the joint angles.
  1840. * The angle information is needed if stops have been set along the axis,
  1841. * but it is not needed for axis motors.
  1842. * @ingroup joints
  1843. */
  1844. ODE_API void dJointSetAMotorAngle (dJointID, int anum, dReal angle);
  1845. /**
  1846. * @brief set joint parameter
  1847. * @ingroup joints
  1848. */
  1849. ODE_API void dJointSetAMotorParam (dJointID, int parameter, dReal value);
  1850. /**
  1851. * @brief set mode
  1852. * @ingroup joints
  1853. */
  1854. ODE_API void dJointSetAMotorMode (dJointID, int mode);
  1855. /**
  1856. * @brief Applies torque0 about the AMotor's axis 0, torque1 about the
  1857. * AMotor's axis 1, and torque2 about the AMotor's axis 2.
  1858. * @remarks
  1859. * If the motor has fewer than three axes, the higher torques are ignored.
  1860. * This function is just a wrapper for dBodyAddTorque().
  1861. * @ingroup joints
  1862. */
  1863. ODE_API void dJointAddAMotorTorques (dJointID, dReal torque1, dReal torque2, dReal torque3);
  1864. /**
  1865. * @brief Set the number of axes that will be controlled by the LMotor.
  1866. * @param num can range from 0 (which effectively deactivates the joint) to 3.
  1867. * @ingroup joints
  1868. */
  1869. ODE_API void dJointSetLMotorNumAxes (dJointID, int num);
  1870. /**
  1871. * @brief Set the AMotor axes.
  1872. * @param anum selects the axis to change (0,1 or 2).
  1873. * @param rel Each axis can have one of three ``relative orientation'' modes
  1874. * \li 0: The axis is anchored to the global frame.
  1875. * \li 1: The axis is anchored to the first body.
  1876. * \li 2: The axis is anchored to the second body.
  1877. * @remarks The axis vector is always specified in global coordinates
  1878. * regardless of the setting of rel.
  1879. * @ingroup joints
  1880. */
  1881. ODE_API void dJointSetLMotorAxis (dJointID, int anum, int rel, dReal x, dReal y, dReal z);
  1882. /**
  1883. * @brief set joint parameter
  1884. * @ingroup joints
  1885. */
  1886. ODE_API void dJointSetLMotorParam (dJointID, int parameter, dReal value);
  1887. /**
  1888. * @ingroup joints
  1889. */
  1890. ODE_API void dJointSetPlane2DXParam (dJointID, int parameter, dReal value);
  1891. /**
  1892. * @ingroup joints
  1893. */
  1894. ODE_API void dJointSetPlane2DYParam (dJointID, int parameter, dReal value);
  1895. /**
  1896. * @ingroup joints
  1897. */
  1898. ODE_API void dJointSetPlane2DAngleParam (dJointID, int parameter, dReal value);
  1899. /**
  1900. * @brief Get the joint anchor point, in world coordinates.
  1901. *
  1902. * This returns the point on body 1. If the joint is perfectly satisfied,
  1903. * this will be the same as the point on body 2.
  1904. */
  1905. ODE_API void dJointGetBallAnchor (dJointID, dVector3 result);
  1906. /**
  1907. * @brief Get the joint anchor point, in world coordinates.
  1908. *
  1909. * This returns the point on body 2. You can think of a ball and socket
  1910. * joint as trying to keep the result of dJointGetBallAnchor() and
  1911. * dJointGetBallAnchor2() the same. If the joint is perfectly satisfied,
  1912. * this function will return the same value as dJointGetBallAnchor() to
  1913. * within roundoff errors. dJointGetBallAnchor2() can be used, along with
  1914. * dJointGetBallAnchor(), to see how far the joint has come apart.
  1915. */
  1916. ODE_API void dJointGetBallAnchor2 (dJointID, dVector3 result);
  1917. /**
  1918. * @brief get joint parameter
  1919. * @ingroup joints
  1920. */
  1921. ODE_API dReal dJointGetBallParam (dJointID, int parameter);
  1922. /**
  1923. * @brief Get the hinge anchor point, in world coordinates.
  1924. *
  1925. * This returns the point on body 1. If the joint is perfectly satisfied,
  1926. * this will be the same as the point on body 2.
  1927. * @ingroup joints
  1928. */
  1929. ODE_API void dJointGetHingeAnchor (dJointID, dVector3 result);
  1930. /**
  1931. * @brief Get the joint anchor point, in world coordinates.
  1932. * @return The point on body 2. If the joint is perfectly satisfied,
  1933. * this will return the same value as dJointGetHingeAnchor().
  1934. * If not, this value will be slightly different.
  1935. * This can be used, for example, to see how far the joint has come apart.
  1936. * @ingroup joints
  1937. */
  1938. ODE_API void dJointGetHingeAnchor2 (dJointID, dVector3 result);
  1939. /**
  1940. * @brief get axis
  1941. * @ingroup joints
  1942. */
  1943. ODE_API void dJointGetHingeAxis (dJointID, dVector3 result);
  1944. /**
  1945. * @brief get joint parameter
  1946. * @ingroup joints
  1947. */
  1948. ODE_API dReal dJointGetHingeParam (dJointID, int parameter);
  1949. /**
  1950. * @brief Get the hinge angle.
  1951. *
  1952. * The angle is measured between the two bodies, or between the body and
  1953. * the static environment.
  1954. * The angle will be between -pi..pi.
  1955. * Give the relative rotation with respect to the Hinge axis of Body 1 with
  1956. * respect to Body 2.
  1957. * When the hinge anchor or axis is set, the current position of the attached
  1958. * bodies is examined and that position will be the zero angle.
  1959. * @ingroup joints
  1960. */
  1961. ODE_API dReal dJointGetHingeAngle (dJointID);
  1962. /**
  1963. * @brief Get the hinge angle time derivative.
  1964. * @ingroup joints
  1965. */
  1966. ODE_API dReal dJointGetHingeAngleRate (dJointID);
  1967. /**
  1968. * @brief Get the slider linear position (i.e. the slider's extension)
  1969. *
  1970. * When the axis is set, the current position of the attached bodies is
  1971. * examined and that position will be the zero position.
  1972. * The position is the distance, with respect to the zero position,
  1973. * along the slider axis of body 1 with respect to
  1974. * body 2. (A NULL body is replaced by the world).
  1975. * @ingroup joints
  1976. */
  1977. ODE_API dReal dJointGetSliderPosition (dJointID);
  1978. /**
  1979. * @brief Get the slider linear position's time derivative.
  1980. * @ingroup joints
  1981. */
  1982. ODE_API dReal dJointGetSliderPositionRate (dJointID);
  1983. /**
  1984. * @brief Get the slider axis
  1985. * @ingroup joints
  1986. */
  1987. ODE_API void dJointGetSliderAxis (dJointID, dVector3 result);
  1988. /**
  1989. * @brief get joint parameter
  1990. * @ingroup joints
  1991. */
  1992. ODE_API dReal dJointGetSliderParam (dJointID, int parameter);
  1993. /**
  1994. * @brief Get the joint anchor point, in world coordinates.
  1995. * @return the point on body 1. If the joint is perfectly satisfied,
  1996. * this will be the same as the point on body 2.
  1997. * @ingroup joints
  1998. */
  1999. ODE_API void dJointGetHinge2Anchor (dJointID, dVector3 result);
  2000. /**
  2001. * @brief Get the joint anchor point, in world coordinates.
  2002. * This returns the point on body 2. If the joint is perfectly satisfied,
  2003. * this will return the same value as dJointGetHinge2Anchor.
  2004. * If not, this value will be slightly different.
  2005. * This can be used, for example, to see how far the joint has come apart.
  2006. * @ingroup joints
  2007. */
  2008. ODE_API void dJointGetHinge2Anchor2 (dJointID, dVector3 result);
  2009. /**
  2010. * @brief Get joint axis
  2011. * @ingroup joints
  2012. */
  2013. ODE_API void dJointGetHinge2Axis1 (dJointID, dVector3 result);
  2014. /**
  2015. * @brief Get joint axis
  2016. * @ingroup joints
  2017. */
  2018. ODE_API void dJointGetHinge2Axis2 (dJointID, dVector3 result);
  2019. /**
  2020. * @brief get joint parameter
  2021. * @ingroup joints
  2022. */
  2023. ODE_API dReal dJointGetHinge2Param (dJointID, int parameter);
  2024. /**
  2025. * @brief Get angle
  2026. * @ingroup joints
  2027. */
  2028. ODE_API dReal dJointGetHinge2Angle1 (dJointID);
  2029. /**
  2030. * @brief Get time derivative of angle
  2031. * @ingroup joints
  2032. */
  2033. ODE_API dReal dJointGetHinge2Angle1Rate (dJointID);
  2034. /**
  2035. * @brief Get time derivative of angle
  2036. * @ingroup joints
  2037. */
  2038. ODE_API dReal dJointGetHinge2Angle2Rate (dJointID);
  2039. /**
  2040. * @brief Get the joint anchor point, in world coordinates.
  2041. * @return the point on body 1. If the joint is perfectly satisfied,
  2042. * this will be the same as the point on body 2.
  2043. * @ingroup joints
  2044. */
  2045. ODE_API void dJointGetUniversalAnchor (dJointID, dVector3 result);
  2046. /**
  2047. * @brief Get the joint anchor point, in world coordinates.
  2048. * @return This returns the point on body 2.
  2049. * @remarks
  2050. * You can think of the ball and socket part of a universal joint as
  2051. * trying to keep the result of dJointGetBallAnchor() and
  2052. * dJointGetBallAnchor2() the same. If the joint is
  2053. * perfectly satisfied, this function will return the same value
  2054. * as dJointGetUniversalAnchor() to within roundoff errors.
  2055. * dJointGetUniversalAnchor2() can be used, along with
  2056. * dJointGetUniversalAnchor(), to see how far the joint has come apart.
  2057. * @ingroup joints
  2058. */
  2059. ODE_API void dJointGetUniversalAnchor2 (dJointID, dVector3 result);
  2060. /**
  2061. * @brief Get axis
  2062. * @ingroup joints
  2063. */
  2064. ODE_API void dJointGetUniversalAxis1 (dJointID, dVector3 result);
  2065. /**
  2066. * @brief Get axis
  2067. * @ingroup joints
  2068. */
  2069. ODE_API void dJointGetUniversalAxis2 (dJointID, dVector3 result);
  2070. /**
  2071. * @brief get joint parameter
  2072. * @ingroup joints
  2073. */
  2074. ODE_API dReal dJointGetUniversalParam (dJointID, int parameter);
  2075. /**
  2076. * @brief Get both angles at the same time.
  2077. * @ingroup joints
  2078. *
  2079. * @param joint The universal joint for which we want to calculate the angles
  2080. * @param angle1 The angle between the body1 and the axis 1
  2081. * @param angle2 The angle between the body2 and the axis 2
  2082. *
  2083. * @note This function combine getUniversalAngle1 and getUniversalAngle2 together
  2084. * and try to avoid redundant calculation
  2085. */
  2086. ODE_API void dJointGetUniversalAngles (dJointID, dReal *angle1, dReal *angle2);
  2087. /**
  2088. * @brief Get angle
  2089. * @ingroup joints
  2090. */
  2091. ODE_API dReal dJointGetUniversalAngle1 (dJointID);
  2092. /**
  2093. * @brief Get angle
  2094. * @ingroup joints
  2095. */
  2096. ODE_API dReal dJointGetUniversalAngle2 (dJointID);
  2097. /**
  2098. * @brief Get time derivative of angle
  2099. * @ingroup joints
  2100. */
  2101. ODE_API dReal dJointGetUniversalAngle1Rate (dJointID);
  2102. /**
  2103. * @brief Get time derivative of angle
  2104. * @ingroup joints
  2105. */
  2106. ODE_API dReal dJointGetUniversalAngle2Rate (dJointID);
  2107. /**
  2108. * @brief Get the joint anchor point, in world coordinates.
  2109. * @return the point on body 1. If the joint is perfectly satisfied,
  2110. * this will be the same as the point on body 2.
  2111. * @ingroup joints
  2112. */
  2113. ODE_API void dJointGetPRAnchor (dJointID, dVector3 result);
  2114. /**
  2115. * @brief Get the PR linear position (i.e. the prismatic's extension)
  2116. *
  2117. * When the axis is set, the current position of the attached bodies is
  2118. * examined and that position will be the zero position.
  2119. *
  2120. * The position is the "oriented" length between the
  2121. * position = (Prismatic axis) dot_product [(body1 + offset) - (body2 + anchor2)]
  2122. *
  2123. * @ingroup joints
  2124. */
  2125. ODE_API dReal dJointGetPRPosition (dJointID);
  2126. /**
  2127. * @brief Get the PR linear position's time derivative
  2128. *
  2129. * @ingroup joints
  2130. */
  2131. ODE_API dReal dJointGetPRPositionRate (dJointID);
  2132. /**
  2133. * @brief Get the PR angular position (i.e. the twist between the 2 bodies)
  2134. *
  2135. * When the axis is set, the current position of the attached bodies is
  2136. * examined and that position will be the zero position.
  2137. * @ingroup joints
  2138. */
  2139. ODE_API dReal dJointGetPRAngle (dJointID);
  2140. /**
  2141. * @brief Get the PR angular position's time derivative
  2142. *
  2143. * @ingroup joints
  2144. */
  2145. ODE_API dReal dJointGetPRAngleRate (dJointID);
  2146. /**
  2147. * @brief Get the prismatic axis
  2148. * @ingroup joints
  2149. */
  2150. ODE_API void dJointGetPRAxis1 (dJointID, dVector3 result);
  2151. /**
  2152. * @brief Get the Rotoide axis
  2153. * @ingroup joints
  2154. */
  2155. ODE_API void dJointGetPRAxis2 (dJointID, dVector3 result);
  2156. /**
  2157. * @brief get joint parameter
  2158. * @ingroup joints
  2159. */
  2160. ODE_API dReal dJointGetPRParam (dJointID, int parameter);
  2161. /**
  2162. * @brief Get the joint anchor point, in world coordinates.
  2163. * @return the point on body 1. If the joint is perfectly satisfied,
  2164. * this will be the same as the point on body 2.
  2165. * @ingroup joints
  2166. */
  2167. ODE_API void dJointGetPUAnchor (dJointID, dVector3 result);
  2168. /**
  2169. * @brief Get the PU linear position (i.e. the prismatic's extension)
  2170. *
  2171. * When the axis is set, the current position of the attached bodies is
  2172. * examined and that position will be the zero position.
  2173. *
  2174. * The position is the "oriented" length between the
  2175. * position = (Prismatic axis) dot_product [(body1 + offset) - (body2 + anchor2)]
  2176. *
  2177. * @ingroup joints
  2178. */
  2179. ODE_API dReal dJointGetPUPosition (dJointID);
  2180. /**
  2181. * @brief Get the PR linear position's time derivative
  2182. *
  2183. * @ingroup joints
  2184. */
  2185. ODE_API dReal dJointGetPUPositionRate (dJointID);
  2186. /**
  2187. * @brief Get the first axis of the universal component of the joint
  2188. * @ingroup joints
  2189. */
  2190. ODE_API void dJointGetPUAxis1 (dJointID, dVector3 result);
  2191. /**
  2192. * @brief Get the second axis of the Universal component of the joint
  2193. * @ingroup joints
  2194. */
  2195. ODE_API void dJointGetPUAxis2 (dJointID, dVector3 result);
  2196. /**
  2197. * @brief Get the prismatic axis
  2198. * @ingroup joints
  2199. */
  2200. ODE_API void dJointGetPUAxis3 (dJointID, dVector3 result);
  2201. /**
  2202. * @brief Get the prismatic axis
  2203. * @ingroup joints
  2204. *
  2205. * @note This function was added for convenience it is the same as
  2206. * dJointGetPUAxis3
  2207. */
  2208. ODE_API void dJointGetPUAxisP (dJointID id, dVector3 result);
  2209. /**
  2210. * @brief Get both angles at the same time.
  2211. * @ingroup joints
  2212. *
  2213. * @param joint The Prismatic universal joint for which we want to calculate the angles
  2214. * @param angle1 The angle between the body1 and the axis 1
  2215. * @param angle2 The angle between the body2 and the axis 2
  2216. *
  2217. * @note This function combine dJointGetPUAngle1 and dJointGetPUAngle2 together
  2218. * and try to avoid redundant calculation
  2219. */
  2220. ODE_API void dJointGetPUAngles (dJointID, dReal *angle1, dReal *angle2);
  2221. /**
  2222. * @brief Get angle
  2223. * @ingroup joints
  2224. */
  2225. ODE_API dReal dJointGetPUAngle1 (dJointID);
  2226. /**
  2227. * @brief * @brief Get time derivative of angle1
  2228. *
  2229. * @ingroup joints
  2230. */
  2231. ODE_API dReal dJointGetPUAngle1Rate (dJointID);
  2232. /**
  2233. * @brief Get angle
  2234. * @ingroup joints
  2235. */
  2236. ODE_API dReal dJointGetPUAngle2 (dJointID);
  2237. /**
  2238. * @brief * @brief Get time derivative of angle2
  2239. *
  2240. * @ingroup joints
  2241. */
  2242. ODE_API dReal dJointGetPUAngle2Rate (dJointID);
  2243. /**
  2244. * @brief get joint parameter
  2245. * @ingroup joints
  2246. */
  2247. ODE_API dReal dJointGetPUParam (dJointID, int parameter);
  2248. /**
  2249. * @brief Get the Piston linear position (i.e. the piston's extension)
  2250. *
  2251. * When the axis is set, the current position of the attached bodies is
  2252. * examined and that position will be the zero position.
  2253. * @ingroup joints
  2254. */
  2255. ODE_API dReal dJointGetPistonPosition (dJointID);
  2256. /**
  2257. * @brief Get the piston linear position's time derivative.
  2258. * @ingroup joints
  2259. */
  2260. ODE_API dReal dJointGetPistonPositionRate (dJointID);
  2261. /**
  2262. * @brief Get the Piston angular position (i.e. the twist between the 2 bodies)
  2263. *
  2264. * When the axis is set, the current position of the attached bodies is
  2265. * examined and that position will be the zero position.
  2266. * @ingroup joints
  2267. */
  2268. ODE_API dReal dJointGetPistonAngle (dJointID);
  2269. /**
  2270. * @brief Get the piston angular position's time derivative.
  2271. * @ingroup joints
  2272. */
  2273. ODE_API dReal dJointGetPistonAngleRate (dJointID);
  2274. /**
  2275. * @brief Get the joint anchor
  2276. *
  2277. * This returns the point on body 1. If the joint is perfectly satisfied,
  2278. * this will be the same as the point on body 2 in direction perpendicular
  2279. * to the prismatic axis.
  2280. *
  2281. * @ingroup joints
  2282. */
  2283. ODE_API void dJointGetPistonAnchor (dJointID, dVector3 result);
  2284. /**
  2285. * @brief Get the joint anchor w.r.t. body 2
  2286. *
  2287. * This returns the point on body 2. You can think of a Piston
  2288. * joint as trying to keep the result of dJointGetPistonAnchor() and
  2289. * dJointGetPistonAnchor2() the same in the direction perpendicular to the
  2290. * pirsmatic axis. If the joint is perfectly satisfied,
  2291. * this function will return the same value as dJointGetPistonAnchor() to
  2292. * within roundoff errors. dJointGetPistonAnchor2() can be used, along with
  2293. * dJointGetPistonAnchor(), to see how far the joint has come apart.
  2294. *
  2295. * @ingroup joints
  2296. */
  2297. ODE_API void dJointGetPistonAnchor2 (dJointID, dVector3 result);
  2298. /**
  2299. * @brief Get the prismatic axis (This is also the rotoide axis.
  2300. * @ingroup joints
  2301. */
  2302. ODE_API void dJointGetPistonAxis (dJointID, dVector3 result);
  2303. /**
  2304. * @brief get joint parameter
  2305. * @ingroup joints
  2306. */
  2307. ODE_API dReal dJointGetPistonParam (dJointID, int parameter);
  2308. /**
  2309. * @brief Get the number of angular axes that will be controlled by the
  2310. * AMotor.
  2311. * @param num can range from 0 (which effectively deactivates the
  2312. * joint) to 3.
  2313. * This is automatically set to 3 in dAMotorEuler mode.
  2314. * @ingroup joints
  2315. */
  2316. ODE_API int dJointGetAMotorNumAxes (dJointID);
  2317. /**
  2318. * @brief Get the AMotor axes.
  2319. * @param anum selects the axis to change (0,1 or 2).
  2320. * @param rel Each axis can have one of three ``relative orientation'' modes.
  2321. * \li 0: The axis is anchored to the global frame.
  2322. * \li 1: The axis is anchored to the first body.
  2323. * \li 2: The axis is anchored to the second body.
  2324. * @ingroup joints
  2325. */
  2326. ODE_API void dJointGetAMotorAxis (dJointID, int anum, dVector3 result);
  2327. /**
  2328. * @brief Get axis
  2329. * @remarks
  2330. * The axis vector is always specified in global coordinates regardless
  2331. * of the setting of rel.
  2332. * There are two GetAMotorAxis functions, one to return the axis and one to
  2333. * return the relative mode.
  2334. *
  2335. * For dAMotorEuler mode:
  2336. * \li Only axes 0 and 2 need to be set. Axis 1 will be determined
  2337. automatically at each time step.
  2338. * \li Axes 0 and 2 must be perpendicular to each other.
  2339. * \li Axis 0 must be anchored to the first body, axis 2 must be anchored
  2340. to the second body.
  2341. * @ingroup joints
  2342. */
  2343. ODE_API int dJointGetAMotorAxisRel (dJointID, int anum);
  2344. /**
  2345. * @brief Get the current angle for axis.
  2346. * @remarks
  2347. * In dAMotorUser mode this is simply the value that was set with
  2348. * dJointSetAMotorAngle().
  2349. * In dAMotorEuler mode this is the corresponding euler angle.
  2350. * @ingroup joints
  2351. */
  2352. ODE_API dReal dJointGetAMotorAngle (dJointID, int anum);
  2353. /**
  2354. * @brief Get the current angle rate for axis anum.
  2355. * @remarks
  2356. * In dAMotorUser mode this is always zero, as not enough information is
  2357. * available.
  2358. * In dAMotorEuler mode this is the corresponding euler angle rate.
  2359. * @ingroup joints
  2360. */
  2361. ODE_API dReal dJointGetAMotorAngleRate (dJointID, int anum);
  2362. /**
  2363. * @brief get joint parameter
  2364. * @ingroup joints
  2365. */
  2366. ODE_API dReal dJointGetAMotorParam (dJointID, int parameter);
  2367. /**
  2368. * @brief Get the angular motor mode.
  2369. * @param mode must be one of the following constants:
  2370. * \li dAMotorUser The AMotor axes and joint angle settings are entirely
  2371. * controlled by the user. This is the default mode.
  2372. * \li dAMotorEuler Euler angles are automatically computed.
  2373. * The axis a1 is also automatically computed.
  2374. * The AMotor axes must be set correctly when in this mode,
  2375. * as described below.
  2376. * When this mode is initially set the current relative orientations
  2377. * of the bodies will correspond to all euler angles at zero.
  2378. * @ingroup joints
  2379. */
  2380. ODE_API int dJointGetAMotorMode (dJointID);
  2381. /**
  2382. * @brief Get nr of axes.
  2383. * @ingroup joints
  2384. */
  2385. ODE_API int dJointGetLMotorNumAxes (dJointID);
  2386. /**
  2387. * @brief Get axis.
  2388. * @ingroup joints
  2389. */
  2390. ODE_API void dJointGetLMotorAxis (dJointID, int anum, dVector3 result);
  2391. /**
  2392. * @brief get joint parameter
  2393. * @ingroup joints
  2394. */
  2395. ODE_API dReal dJointGetLMotorParam (dJointID, int parameter);
  2396. /**
  2397. * @brief get joint parameter
  2398. * @ingroup joints
  2399. */
  2400. ODE_API dReal dJointGetFixedParam (dJointID, int parameter);
  2401. /**
  2402. * @ingroup joints
  2403. */
  2404. ODE_API dJointID dConnectingJoint (dBodyID, dBodyID);
  2405. /**
  2406. * @ingroup joints
  2407. */
  2408. ODE_API int dConnectingJointList (dBodyID, dBodyID, dJointID*);
  2409. /**
  2410. * @brief Utility function
  2411. * @return 1 if the two bodies are connected together by
  2412. * a joint, otherwise return 0.
  2413. * @ingroup joints
  2414. */
  2415. ODE_API int dAreConnected (dBodyID, dBodyID);
  2416. /**
  2417. * @brief Utility function
  2418. * @return 1 if the two bodies are connected together by
  2419. * a joint that does not have type @arg{joint_type}, otherwise return 0.
  2420. * @param body1 A body to check.
  2421. * @param body2 A body to check.
  2422. * @param joint_type is a dJointTypeXXX constant.
  2423. * This is useful for deciding whether to add contact joints between two bodies:
  2424. * if they are already connected by non-contact joints then it may not be
  2425. * appropriate to add contacts, however it is okay to add more contact between-
  2426. * bodies that already have contacts.
  2427. * @ingroup joints
  2428. */
  2429. ODE_API int dAreConnectedExcluding (dBodyID body1, dBodyID body2, int joint_type);
  2430. #ifdef __cplusplus
  2431. }
  2432. #endif
  2433. #endif