objects.h 95 KB

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