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