objects.h 105 KB

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