objects.h 106 KB

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