references.h 195 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675
  1. // Copyright 2022 DeepMind Technologies Limited
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // DO NOT EDIT. THIS FILE IS AUTOMATICALLY GENERATED.
  15. // Error: C reference not found
  16. // NOLINTBEGIN
  17. typedef enum mjtState_ { // state elements
  18. mjSTATE_TIME = 1<<0, // time
  19. mjSTATE_QPOS = 1<<1, // position
  20. mjSTATE_QVEL = 1<<2, // velocity
  21. mjSTATE_ACT = 1<<3, // actuator activation
  22. mjSTATE_WARMSTART = 1<<4, // acceleration used for warmstart
  23. mjSTATE_CTRL = 1<<5, // control
  24. mjSTATE_QFRC_APPLIED = 1<<6, // applied generalized force
  25. mjSTATE_XFRC_APPLIED = 1<<7, // applied Cartesian force/torque
  26. mjSTATE_EQ_ACTIVE = 1<<8, // enable/disable constraints
  27. mjSTATE_MOCAP_POS = 1<<9, // positions of mocap bodies
  28. mjSTATE_MOCAP_QUAT = 1<<10, // orientations of mocap bodies
  29. mjSTATE_USERDATA = 1<<11, // user data
  30. mjSTATE_PLUGIN = 1<<12, // plugin state
  31. mjNSTATE = 13, // number of state elements
  32. // convenience values for commonly used state specifications
  33. mjSTATE_PHYSICS = mjSTATE_QPOS | mjSTATE_QVEL | mjSTATE_ACT,
  34. mjSTATE_FULLPHYSICS = mjSTATE_TIME | mjSTATE_PHYSICS | mjSTATE_PLUGIN,
  35. mjSTATE_USER = mjSTATE_CTRL | mjSTATE_QFRC_APPLIED | mjSTATE_XFRC_APPLIED |
  36. mjSTATE_EQ_ACTIVE | mjSTATE_MOCAP_POS | mjSTATE_MOCAP_QUAT |
  37. mjSTATE_USERDATA,
  38. mjSTATE_INTEGRATION = mjSTATE_FULLPHYSICS | mjSTATE_USER | mjSTATE_WARMSTART
  39. } mjtState;
  40. typedef enum mjtWarning_ { // warning types
  41. mjWARN_INERTIA = 0, // (near) singular inertia matrix
  42. mjWARN_CONTACTFULL, // too many contacts in contact list
  43. mjWARN_CNSTRFULL, // too many constraints
  44. mjWARN_VGEOMFULL, // too many visual geoms
  45. mjWARN_BADQPOS, // bad number in qpos
  46. mjWARN_BADQVEL, // bad number in qvel
  47. mjWARN_BADQACC, // bad number in qacc
  48. mjWARN_BADCTRL, // bad number in ctrl
  49. mjNWARNING // number of warnings
  50. } mjtWarning;
  51. typedef enum mjtTimer_ { // internal timers
  52. // main api
  53. mjTIMER_STEP = 0, // step
  54. mjTIMER_FORWARD, // forward
  55. mjTIMER_INVERSE, // inverse
  56. // breakdown of step/forward
  57. mjTIMER_POSITION, // fwdPosition
  58. mjTIMER_VELOCITY, // fwdVelocity
  59. mjTIMER_ACTUATION, // fwdActuation
  60. mjTIMER_CONSTRAINT, // fwdConstraint
  61. mjTIMER_ADVANCE, // mj_Euler, mj_implicit
  62. // breakdown of fwdPosition
  63. mjTIMER_POS_KINEMATICS, // kinematics, com, tendon, transmission
  64. mjTIMER_POS_INERTIA, // inertia computations
  65. mjTIMER_POS_COLLISION, // collision detection
  66. mjTIMER_POS_MAKE, // make constraints
  67. mjTIMER_POS_PROJECT, // project constraints
  68. // breakdown of mj_collision
  69. mjTIMER_COL_BROAD, // broadphase
  70. mjTIMER_COL_NARROW, // narrowphase
  71. mjNTIMER // number of timers
  72. } mjtTimer;
  73. struct mjContact_ { // result of collision detection functions
  74. // contact parameters set by near-phase collision function
  75. mjtNum dist; // distance between nearest points; neg: penetration
  76. mjtNum pos[3]; // position of contact point: midpoint between geoms
  77. mjtNum frame[9]; // normal is in [0-2], points from geom[0] to geom[1]
  78. // contact parameters set by mj_collideGeoms
  79. mjtNum includemargin; // include if dist<includemargin=margin-gap
  80. mjtNum friction[5]; // tangent1, 2, spin, roll1, 2
  81. mjtNum solref[mjNREF]; // constraint solver reference, normal direction
  82. mjtNum solreffriction[mjNREF]; // constraint solver reference, friction directions
  83. mjtNum solimp[mjNIMP]; // constraint solver impedance
  84. // internal storage used by solver
  85. mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
  86. mjtNum H[36]; // cone Hessian, set by mj_constraintUpdate
  87. // contact descriptors set by mj_collideXXX
  88. int dim; // contact space dimensionality: 1, 3, 4 or 6
  89. int geom1; // id of geom 1; deprecated, use geom[0]
  90. int geom2; // id of geom 2; deprecated, use geom[1]
  91. int geom[2]; // geom ids; -1 for flex
  92. int flex[2]; // flex ids; -1 for geom
  93. int elem[2]; // element ids; -1 for geom or flex vertex
  94. int vert[2]; // vertex ids; -1 for geom or flex element
  95. // flag set by mj_setContact or mj_instantiateContact
  96. int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
  97. // address computed by mj_instantiateContact
  98. int efc_address; // address in efc; -1: not included
  99. };
  100. typedef struct mjContact_ mjContact;
  101. struct mjWarningStat_ { // warning statistics
  102. int lastinfo; // info from last warning
  103. int number; // how many times was warning raised
  104. };
  105. typedef struct mjWarningStat_ mjWarningStat;
  106. struct mjTimerStat_ { // timer statistics
  107. mjtNum duration; // cumulative duration
  108. int number; // how many times was timer called
  109. };
  110. typedef struct mjTimerStat_ mjTimerStat;
  111. struct mjSolverStat_ { // per-iteration solver statistics
  112. mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0))
  113. mjtNum gradient; // gradient norm (primal only, scaled)
  114. mjtNum lineslope; // slope in linesearch
  115. int nactive; // number of active constraints
  116. int nchange; // number of constraint state changes
  117. int neval; // number of cost evaluations in line search
  118. int nupdate; // number of Cholesky updates in line search
  119. };
  120. typedef struct mjSolverStat_ mjSolverStat;
  121. struct mjData_ {
  122. // constant sizes
  123. size_t narena; // size of the arena in bytes (inclusive of the stack)
  124. size_t nbuffer; // size of main buffer in bytes
  125. int nplugin; // number of plugin instances
  126. // stack pointer
  127. size_t pstack; // first available byte in stack
  128. size_t pbase; // value of pstack when mj_markStack was last called
  129. // arena pointer
  130. size_t parena; // first available byte in arena
  131. // memory utilization statistics
  132. size_t maxuse_stack; // maximum stack allocation in bytes
  133. size_t maxuse_threadstack[mjMAXTHREAD]; // maximum stack allocation per thread in bytes
  134. size_t maxuse_arena; // maximum arena allocation in bytes
  135. int maxuse_con; // maximum number of contacts
  136. int maxuse_efc; // maximum number of scalar constraints
  137. // solver statistics
  138. mjSolverStat solver[mjNISLAND*mjNSOLVER]; // solver statistics per island, per iteration
  139. int solver_nisland; // number of islands processed by solver
  140. int solver_niter[mjNISLAND]; // number of solver iterations, per island
  141. int solver_nnz[mjNISLAND]; // number of nonzeros in Hessian or efc_AR, per island
  142. mjtNum solver_fwdinv[2]; // forward-inverse comparison: qfrc, efc
  143. // diagnostics
  144. mjWarningStat warning[mjNWARNING]; // warning statistics
  145. mjTimerStat timer[mjNTIMER]; // timer statistics
  146. // variable sizes
  147. int ncon; // number of detected contacts
  148. int ne; // number of equality constraints
  149. int nf; // number of friction constraints
  150. int nl; // number of limit constraints
  151. int nefc; // number of constraints
  152. int nnzJ; // number of non-zeros in constraint Jacobian
  153. int nisland; // number of detected constraint islands
  154. // global properties
  155. mjtNum time; // simulation time
  156. mjtNum energy[2]; // potential, kinetic energy
  157. //-------------------- end of info header
  158. // buffers
  159. void* buffer; // main buffer; all pointers point in it (nbuffer bytes)
  160. void* arena; // arena+stack buffer (narena bytes)
  161. //-------------------- main inputs and outputs of the computation
  162. // state
  163. mjtNum* qpos; // position (nq x 1)
  164. mjtNum* qvel; // velocity (nv x 1)
  165. mjtNum* act; // actuator activation (na x 1)
  166. mjtNum* qacc_warmstart; // acceleration used for warmstart (nv x 1)
  167. mjtNum* plugin_state; // plugin state (npluginstate x 1)
  168. // control
  169. mjtNum* ctrl; // control (nu x 1)
  170. mjtNum* qfrc_applied; // applied generalized force (nv x 1)
  171. mjtNum* xfrc_applied; // applied Cartesian force/torque (nbody x 6)
  172. mjtByte* eq_active; // enable/disable constraints (neq x 1)
  173. // mocap data
  174. mjtNum* mocap_pos; // positions of mocap bodies (nmocap x 3)
  175. mjtNum* mocap_quat; // orientations of mocap bodies (nmocap x 4)
  176. // dynamics
  177. mjtNum* qacc; // acceleration (nv x 1)
  178. mjtNum* act_dot; // time-derivative of actuator activation (na x 1)
  179. // user data
  180. mjtNum* userdata; // user data, not touched by engine (nuserdata x 1)
  181. // sensors
  182. mjtNum* sensordata; // sensor data array (nsensordata x 1)
  183. // plugins
  184. int* plugin; // copy of m->plugin, required for deletion (nplugin x 1)
  185. uintptr_t* plugin_data; // pointer to plugin-managed data structure (nplugin x 1)
  186. //-------------------- POSITION dependent
  187. // computed by mj_fwdPosition/mj_kinematics
  188. mjtNum* xpos; // Cartesian position of body frame (nbody x 3)
  189. mjtNum* xquat; // Cartesian orientation of body frame (nbody x 4)
  190. mjtNum* xmat; // Cartesian orientation of body frame (nbody x 9)
  191. mjtNum* xipos; // Cartesian position of body com (nbody x 3)
  192. mjtNum* ximat; // Cartesian orientation of body inertia (nbody x 9)
  193. mjtNum* xanchor; // Cartesian position of joint anchor (njnt x 3)
  194. mjtNum* xaxis; // Cartesian joint axis (njnt x 3)
  195. mjtNum* geom_xpos; // Cartesian geom position (ngeom x 3)
  196. mjtNum* geom_xmat; // Cartesian geom orientation (ngeom x 9)
  197. mjtNum* site_xpos; // Cartesian site position (nsite x 3)
  198. mjtNum* site_xmat; // Cartesian site orientation (nsite x 9)
  199. mjtNum* cam_xpos; // Cartesian camera position (ncam x 3)
  200. mjtNum* cam_xmat; // Cartesian camera orientation (ncam x 9)
  201. mjtNum* light_xpos; // Cartesian light position (nlight x 3)
  202. mjtNum* light_xdir; // Cartesian light direction (nlight x 3)
  203. // computed by mj_fwdPosition/mj_comPos
  204. mjtNum* subtree_com; // center of mass of each subtree (nbody x 3)
  205. mjtNum* cdof; // com-based motion axis of each dof (rot:lin) (nv x 6)
  206. mjtNum* cinert; // com-based body inertia and mass (nbody x 10)
  207. // computed by mj_fwdPosition/mj_flex
  208. mjtNum* flexvert_xpos; // Cartesian flex vertex positions (nflexvert x 3)
  209. mjtNum* flexelem_aabb; // flex element bounding boxes (center, size) (nflexelem x 6)
  210. int* flexedge_J_rownnz; // number of non-zeros in Jacobian row (nflexedge x 1)
  211. int* flexedge_J_rowadr; // row start address in colind array (nflexedge x 1)
  212. int* flexedge_J_colind; // column indices in sparse Jacobian (nflexedge x nv)
  213. mjtNum* flexedge_J; // flex edge Jacobian (nflexedge x nv)
  214. mjtNum* flexedge_length; // flex edge lengths (nflexedge x 1)
  215. // computed by mj_fwdPosition/mj_tendon
  216. int* ten_wrapadr; // start address of tendon's path (ntendon x 1)
  217. int* ten_wrapnum; // number of wrap points in path (ntendon x 1)
  218. int* ten_J_rownnz; // number of non-zeros in Jacobian row (ntendon x 1)
  219. int* ten_J_rowadr; // row start address in colind array (ntendon x 1)
  220. int* ten_J_colind; // column indices in sparse Jacobian (ntendon x nv)
  221. mjtNum* ten_J; // tendon Jacobian (ntendon x nv)
  222. mjtNum* ten_length; // tendon lengths (ntendon x 1)
  223. int* wrap_obj; // geom id; -1: site; -2: pulley (nwrap x 2)
  224. mjtNum* wrap_xpos; // Cartesian 3D points in all paths (nwrap x 6)
  225. // computed by mj_fwdPosition/mj_transmission
  226. mjtNum* actuator_length; // actuator lengths (nu x 1)
  227. int* moment_rownnz; // number of non-zeros in actuator_moment row (nu x 1)
  228. int* moment_rowadr; // row start address in colind array (nu x 1)
  229. int* moment_colind; // column indices in sparse Jacobian (nu x nv)
  230. mjtNum* actuator_moment; // actuator moments (nu x nv)
  231. // computed by mj_fwdPosition/mj_crb
  232. mjtNum* crb; // com-based composite inertia and mass (nbody x 10)
  233. mjtNum* qM; // total inertia (sparse) (nM x 1)
  234. // computed by mj_fwdPosition/mj_factorM
  235. mjtNum* qLD; // L'*D*L factorization of M (sparse) (nM x 1)
  236. mjtNum* qLDiagInv; // 1/diag(D) (nv x 1)
  237. mjtNum* qLDiagSqrtInv; // 1/sqrt(diag(D)) (nv x 1)
  238. // computed by mj_collisionTree
  239. mjtNum* bvh_aabb_dyn; // global bounding box (center, size) (nbvhdynamic x 6)
  240. mjtByte* bvh_active; // was bounding volume checked for collision (nbvh x 1)
  241. //-------------------- POSITION, VELOCITY dependent
  242. // computed by mj_fwdVelocity
  243. mjtNum* flexedge_velocity; // flex edge velocities (nflexedge x 1)
  244. mjtNum* ten_velocity; // tendon velocities (ntendon x 1)
  245. mjtNum* actuator_velocity; // actuator velocities (nu x 1)
  246. // computed by mj_fwdVelocity/mj_comVel
  247. mjtNum* cvel; // com-based velocity (rot:lin) (nbody x 6)
  248. mjtNum* cdof_dot; // time-derivative of cdof (rot:lin) (nv x 6)
  249. // computed by mj_fwdVelocity/mj_rne (without acceleration)
  250. mjtNum* qfrc_bias; // C(qpos,qvel) (nv x 1)
  251. // computed by mj_fwdVelocity/mj_passive
  252. mjtNum* qfrc_spring; // passive spring force (nv x 1)
  253. mjtNum* qfrc_damper; // passive damper force (nv x 1)
  254. mjtNum* qfrc_gravcomp; // passive gravity compensation force (nv x 1)
  255. mjtNum* qfrc_fluid; // passive fluid force (nv x 1)
  256. mjtNum* qfrc_passive; // total passive force (nv x 1)
  257. // computed by mj_sensorVel/mj_subtreeVel if needed
  258. mjtNum* subtree_linvel; // linear velocity of subtree com (nbody x 3)
  259. mjtNum* subtree_angmom; // angular momentum about subtree com (nbody x 3)
  260. // computed by mj_Euler or mj_implicit
  261. mjtNum* qH; // L'*D*L factorization of modified M (nM x 1)
  262. mjtNum* qHDiagInv; // 1/diag(D) of modified M (nv x 1)
  263. // computed by mj_resetData
  264. int* B_rownnz; // body-dof: non-zeros in each row (nbody x 1)
  265. int* B_rowadr; // body-dof: address of each row in B_colind (nbody x 1)
  266. int* B_colind; // body-dof: column indices of non-zeros (nB x 1)
  267. int* C_rownnz; // reduced dof-dof: non-zeros in each row (nv x 1)
  268. int* C_rowadr; // reduced dof-dof: address of each row in C_colind (nv x 1)
  269. int* C_colind; // reduced dof-dof: column indices of non-zeros (nC x 1)
  270. int* mapM2C; // index mapping from M to C (nC x 1)
  271. int* D_rownnz; // dof-dof: non-zeros in each row (nv x 1)
  272. int* D_rowadr; // dof-dof: address of each row in D_colind (nv x 1)
  273. int* D_colind; // dof-dof: column indices of non-zeros (nD x 1)
  274. int* mapM2D; // index mapping from M to D (nD x 1)
  275. int* mapD2M; // index mapping from D to M (nM x 1)
  276. // computed by mj_implicit/mj_derivative
  277. mjtNum* qDeriv; // d (passive + actuator - bias) / d qvel (nD x 1)
  278. // computed by mj_implicit/mju_factorLUSparse
  279. mjtNum* qLU; // sparse LU of (qM - dt*qDeriv) (nD x 1)
  280. //-------------------- POSITION, VELOCITY, CONTROL/ACCELERATION dependent
  281. // computed by mj_fwdActuation
  282. mjtNum* actuator_force; // actuator force in actuation space (nu x 1)
  283. mjtNum* qfrc_actuator; // actuator force (nv x 1)
  284. // computed by mj_fwdAcceleration
  285. mjtNum* qfrc_smooth; // net unconstrained force (nv x 1)
  286. mjtNum* qacc_smooth; // unconstrained acceleration (nv x 1)
  287. // computed by mj_fwdConstraint/mj_inverse
  288. mjtNum* qfrc_constraint; // constraint force (nv x 1)
  289. // computed by mj_inverse
  290. mjtNum* qfrc_inverse; // net external force; should equal: (nv x 1)
  291. // qfrc_applied + J'*xfrc_applied + qfrc_actuator
  292. // computed by mj_sensorAcc/mj_rnePostConstraint if needed; rotation:translation format
  293. mjtNum* cacc; // com-based acceleration (nbody x 6)
  294. mjtNum* cfrc_int; // com-based interaction force with parent (nbody x 6)
  295. mjtNum* cfrc_ext; // com-based external force on body (nbody x 6)
  296. //-------------------- arena-allocated: POSITION dependent
  297. // computed by mj_collision
  298. mjContact* contact; // array of all detected contacts (ncon x 1)
  299. // computed by mj_makeConstraint
  300. int* efc_type; // constraint type (mjtConstraint) (nefc x 1)
  301. int* efc_id; // id of object of specified type (nefc x 1)
  302. int* efc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
  303. int* efc_J_rowadr; // row start address in colind array (nefc x 1)
  304. int* efc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
  305. int* efc_J_colind; // column indices in constraint Jacobian (nnzJ x 1)
  306. int* efc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nv x 1)
  307. int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
  308. int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
  309. int* efc_JT_colind; // column indices in constraint Jacobian T (nnzJ x 1)
  310. mjtNum* efc_J; // constraint Jacobian (nnzJ x 1)
  311. mjtNum* efc_JT; // constraint Jacobian transposed (nnzJ x 1)
  312. mjtNum* efc_pos; // constraint position (equality, contact) (nefc x 1)
  313. mjtNum* efc_margin; // inclusion margin (contact) (nefc x 1)
  314. mjtNum* efc_frictionloss; // frictionloss (friction) (nefc x 1)
  315. mjtNum* efc_diagApprox; // approximation to diagonal of A (nefc x 1)
  316. mjtNum* efc_KBIP; // stiffness, damping, impedance, imp' (nefc x 4)
  317. mjtNum* efc_D; // constraint mass (nefc x 1)
  318. mjtNum* efc_R; // inverse constraint mass (nefc x 1)
  319. int* tendon_efcadr; // first efc address involving tendon; -1: none (ntendon x 1)
  320. // computed by mj_island
  321. int* dof_island; // island id of this dof; -1: none (nv x 1)
  322. int* island_dofnum; // number of dofs in island (nisland x 1)
  323. int* island_dofadr; // start address in island_dofind (nisland x 1)
  324. int* island_dofind; // island dof indices; -1: none (nv x 1)
  325. int* dof_islandind; // dof island indices; -1: none (nv x 1)
  326. int* efc_island; // island id of this constraint (nefc x 1)
  327. int* island_efcnum; // number of constraints in island (nisland x 1)
  328. int* island_efcadr; // start address in island_efcind (nisland x 1)
  329. int* island_efcind; // island constraint indices (nefc x 1)
  330. // computed by mj_projectConstraint (PGS solver)
  331. int* efc_AR_rownnz; // number of non-zeros in AR (nefc x 1)
  332. int* efc_AR_rowadr; // row start address in colind array (nefc x 1)
  333. int* efc_AR_colind; // column indices in sparse AR (nefc x nefc)
  334. mjtNum* efc_AR; // J*inv(M)*J' + R (nefc x nefc)
  335. //-------------------- arena-allocated: POSITION, VELOCITY dependent
  336. // computed by mj_fwdVelocity/mj_referenceConstraint
  337. mjtNum* efc_vel; // velocity in constraint space: J*qvel (nefc x 1)
  338. mjtNum* efc_aref; // reference pseudo-acceleration (nefc x 1)
  339. //-------------------- arena-allocated: POSITION, VELOCITY, CONTROL/ACCELERATION dependent
  340. // computed by mj_fwdConstraint/mj_inverse
  341. mjtNum* efc_b; // linear cost term: J*qacc_smooth - aref (nefc x 1)
  342. mjtNum* efc_force; // constraint force in constraint space (nefc x 1)
  343. int* efc_state; // constraint state (mjtConstraintState) (nefc x 1)
  344. // thread pool pointer
  345. uintptr_t threadpool;
  346. };
  347. typedef struct mjData_ mjData;
  348. typedef enum mjtDisableBit_ { // disable default feature bitflags
  349. mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver
  350. mjDSBL_EQUALITY = 1<<1, // equality constraints
  351. mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints
  352. mjDSBL_LIMIT = 1<<3, // joint and tendon limit constraints
  353. mjDSBL_CONTACT = 1<<4, // contact constraints
  354. mjDSBL_PASSIVE = 1<<5, // passive forces
  355. mjDSBL_GRAVITY = 1<<6, // gravitational forces
  356. mjDSBL_CLAMPCTRL = 1<<7, // clamp control to specified range
  357. mjDSBL_WARMSTART = 1<<8, // warmstart constraint solver
  358. mjDSBL_FILTERPARENT = 1<<9, // remove collisions with parent body
  359. mjDSBL_ACTUATION = 1<<10, // apply actuation forces
  360. mjDSBL_REFSAFE = 1<<11, // integrator safety: make ref[0]>=2*timestep
  361. mjDSBL_SENSOR = 1<<12, // sensors
  362. mjDSBL_MIDPHASE = 1<<13, // mid-phase collision filtering
  363. mjDSBL_EULERDAMP = 1<<14, // implicit integration of joint damping in Euler integrator
  364. mjDSBL_AUTORESET = 1<<15, // automatic reset when numerical issues are detected
  365. mjNDISABLE = 16 // number of disable flags
  366. } mjtDisableBit;
  367. typedef enum mjtEnableBit_ { // enable optional feature bitflags
  368. mjENBL_OVERRIDE = 1<<0, // override contact parameters
  369. mjENBL_ENERGY = 1<<1, // energy computation
  370. mjENBL_FWDINV = 1<<2, // record solver statistics
  371. mjENBL_INVDISCRETE = 1<<3, // discrete-time inverse dynamics
  372. // experimental features:
  373. mjENBL_MULTICCD = 1<<4, // multi-point convex collision detection
  374. mjENBL_ISLAND = 1<<5, // constraint island discovery
  375. mjENBL_NATIVECCD = 1<<6, // native convex collision detection
  376. mjNENABLE = 7 // number of enable flags
  377. } mjtEnableBit;
  378. typedef enum mjtJoint_ { // type of degree of freedom
  379. mjJNT_FREE = 0, // global position and orientation (quat) (7)
  380. mjJNT_BALL, // orientation (quat) relative to parent (4)
  381. mjJNT_SLIDE, // sliding distance along body-fixed axis (1)
  382. mjJNT_HINGE // rotation angle (rad) around body-fixed axis (1)
  383. } mjtJoint;
  384. typedef enum mjtGeom_ { // type of geometric shape
  385. // regular geom types
  386. mjGEOM_PLANE = 0, // plane
  387. mjGEOM_HFIELD, // height field
  388. mjGEOM_SPHERE, // sphere
  389. mjGEOM_CAPSULE, // capsule
  390. mjGEOM_ELLIPSOID, // ellipsoid
  391. mjGEOM_CYLINDER, // cylinder
  392. mjGEOM_BOX, // box
  393. mjGEOM_MESH, // mesh
  394. mjGEOM_SDF, // signed distance field
  395. mjNGEOMTYPES, // number of regular geom types
  396. // rendering-only geom types: not used in mjModel, not counted in mjNGEOMTYPES
  397. mjGEOM_ARROW = 100, // arrow
  398. mjGEOM_ARROW1, // arrow without wedges
  399. mjGEOM_ARROW2, // arrow in both directions
  400. mjGEOM_LINE, // line
  401. mjGEOM_LINEBOX, // box with line edges
  402. mjGEOM_FLEX, // flex
  403. mjGEOM_SKIN, // skin
  404. mjGEOM_LABEL, // text label
  405. mjGEOM_TRIANGLE, // triangle
  406. mjGEOM_NONE = 1001 // missing geom type
  407. } mjtGeom;
  408. typedef enum mjtCamLight_ { // tracking mode for camera and light
  409. mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body
  410. mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global
  411. mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body
  412. mjCAMLIGHT_TARGETBODY, // pos fixed in body, rot tracks target body
  413. mjCAMLIGHT_TARGETBODYCOM // pos fixed in body, rot tracks target subtree com
  414. } mjtCamLight;
  415. typedef enum mjtTexture_ { // type of texture
  416. mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields
  417. mjTEXTURE_CUBE, // cube texture, suitable for all other geom types
  418. mjTEXTURE_SKYBOX // cube texture used as skybox
  419. } mjtTexture;
  420. typedef enum mjtTextureRole_ { // role of texture map in rendering
  421. mjTEXROLE_USER = 0, // unspecified
  422. mjTEXROLE_RGB, // base color (albedo)
  423. mjTEXROLE_OCCLUSION, // ambient occlusion
  424. mjTEXROLE_ROUGHNESS, // roughness
  425. mjTEXROLE_METALLIC, // metallic
  426. mjTEXROLE_NORMAL, // normal (bump) map
  427. mjTEXROLE_OPACITY, // transperancy
  428. mjTEXROLE_EMISSIVE, // light emission
  429. mjTEXROLE_RGBA, // base color, opacity
  430. mjTEXROLE_ORM, // occlusion, roughness, metallic
  431. mjNTEXROLE
  432. } mjtTextureRole;
  433. typedef enum mjtIntegrator_ { // integrator mode
  434. mjINT_EULER = 0, // semi-implicit Euler
  435. mjINT_RK4, // 4th-order Runge Kutta
  436. mjINT_IMPLICIT, // implicit in velocity
  437. mjINT_IMPLICITFAST // implicit in velocity, no rne derivative
  438. } mjtIntegrator;
  439. typedef enum mjtCone_ { // type of friction cone
  440. mjCONE_PYRAMIDAL = 0, // pyramidal
  441. mjCONE_ELLIPTIC // elliptic
  442. } mjtCone;
  443. typedef enum mjtJacobian_ { // type of constraint Jacobian
  444. mjJAC_DENSE = 0, // dense
  445. mjJAC_SPARSE, // sparse
  446. mjJAC_AUTO // dense if nv<60, sparse otherwise
  447. } mjtJacobian;
  448. typedef enum mjtSolver_ { // constraint solver algorithm
  449. mjSOL_PGS = 0, // PGS (dual)
  450. mjSOL_CG, // CG (primal)
  451. mjSOL_NEWTON // Newton (primal)
  452. } mjtSolver;
  453. typedef enum mjtEq_ { // type of equality constraint
  454. mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint)
  455. mjEQ_WELD, // fix relative position and orientation of two bodies
  456. mjEQ_JOINT, // couple the values of two scalar joints with cubic
  457. mjEQ_TENDON, // couple the lengths of two tendons with cubic
  458. mjEQ_FLEX, // fix all edge lengths of a flex
  459. mjEQ_DISTANCE // unsupported, will cause an error if used
  460. } mjtEq;
  461. typedef enum mjtWrap_ { // type of tendon wrap object
  462. mjWRAP_NONE = 0, // null object
  463. mjWRAP_JOINT, // constant moment arm
  464. mjWRAP_PULLEY, // pulley used to split tendon
  465. mjWRAP_SITE, // pass through site
  466. mjWRAP_SPHERE, // wrap around sphere
  467. mjWRAP_CYLINDER // wrap around (infinite) cylinder
  468. } mjtWrap;
  469. typedef enum mjtTrn_ { // type of actuator transmission
  470. mjTRN_JOINT = 0, // force on joint
  471. mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame
  472. mjTRN_SLIDERCRANK, // force via slider-crank linkage
  473. mjTRN_TENDON, // force on tendon
  474. mjTRN_SITE, // force on site
  475. mjTRN_BODY, // adhesion force on a body's geoms
  476. mjTRN_UNDEFINED = 1000 // undefined transmission type
  477. } mjtTrn;
  478. typedef enum mjtDyn_ { // type of actuator dynamics
  479. mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force
  480. mjDYN_INTEGRATOR, // integrator: da/dt = u
  481. mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau
  482. mjDYN_FILTEREXACT, // linear filter: da/dt = (u-a) / tau, with exact integration
  483. mjDYN_MUSCLE, // piece-wise linear filter with two time constants
  484. mjDYN_USER // user-defined dynamics type
  485. } mjtDyn;
  486. typedef enum mjtGain_ { // type of actuator gain
  487. mjGAIN_FIXED = 0, // fixed gain
  488. mjGAIN_AFFINE, // const + kp*length + kv*velocity
  489. mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain()
  490. mjGAIN_USER // user-defined gain type
  491. } mjtGain;
  492. typedef enum mjtBias_ { // type of actuator bias
  493. mjBIAS_NONE = 0, // no bias
  494. mjBIAS_AFFINE, // const + kp*length + kv*velocity
  495. mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias()
  496. mjBIAS_USER // user-defined bias type
  497. } mjtBias;
  498. typedef enum mjtObj_ { // type of MujoCo object
  499. mjOBJ_UNKNOWN = 0, // unknown object type
  500. mjOBJ_BODY, // body
  501. mjOBJ_XBODY, // body, used to access regular frame instead of i-frame
  502. mjOBJ_JOINT, // joint
  503. mjOBJ_DOF, // dof
  504. mjOBJ_GEOM, // geom
  505. mjOBJ_SITE, // site
  506. mjOBJ_CAMERA, // camera
  507. mjOBJ_LIGHT, // light
  508. mjOBJ_FLEX, // flex
  509. mjOBJ_MESH, // mesh
  510. mjOBJ_SKIN, // skin
  511. mjOBJ_HFIELD, // heightfield
  512. mjOBJ_TEXTURE, // texture
  513. mjOBJ_MATERIAL, // material for rendering
  514. mjOBJ_PAIR, // geom pair to include
  515. mjOBJ_EXCLUDE, // body pair to exclude
  516. mjOBJ_EQUALITY, // equality constraint
  517. mjOBJ_TENDON, // tendon
  518. mjOBJ_ACTUATOR, // actuator
  519. mjOBJ_SENSOR, // sensor
  520. mjOBJ_NUMERIC, // numeric
  521. mjOBJ_TEXT, // text
  522. mjOBJ_TUPLE, // tuple
  523. mjOBJ_KEY, // keyframe
  524. mjOBJ_PLUGIN, // plugin instance
  525. mjNOBJECT, // number of object types
  526. // meta elements, do not appear in mjModel
  527. mjOBJ_FRAME = 100 // frame
  528. } mjtObj;
  529. typedef enum mjtConstraint_ { // type of constraint
  530. mjCNSTR_EQUALITY = 0, // equality constraint
  531. mjCNSTR_FRICTION_DOF, // dof friction
  532. mjCNSTR_FRICTION_TENDON, // tendon friction
  533. mjCNSTR_LIMIT_JOINT, // joint limit
  534. mjCNSTR_LIMIT_TENDON, // tendon limit
  535. mjCNSTR_CONTACT_FRICTIONLESS, // frictionless contact
  536. mjCNSTR_CONTACT_PYRAMIDAL, // frictional contact, pyramidal friction cone
  537. mjCNSTR_CONTACT_ELLIPTIC // frictional contact, elliptic friction cone
  538. } mjtConstraint;
  539. typedef enum mjtConstraintState_ { // constraint state
  540. mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact)
  541. mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact)
  542. mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction)
  543. mjCNSTRSTATE_LINEARPOS, // linear cost, positive side (friction)
  544. mjCNSTRSTATE_CONE // squared distance to cone cost (elliptic contact)
  545. } mjtConstraintState;
  546. typedef enum mjtSensor_ { // type of sensor
  547. // common robotic sensors, attached to a site
  548. mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone
  549. mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame
  550. mjSENS_VELOCIMETER, // 3D linear velocity, in local frame
  551. mjSENS_GYRO, // 3D angular velocity, in local frame
  552. mjSENS_FORCE, // 3D force between site's body and its parent body
  553. mjSENS_TORQUE, // 3D torque between site's body and its parent body
  554. mjSENS_MAGNETOMETER, // 3D magnetometer
  555. mjSENS_RANGEFINDER, // scalar distance to nearest geom or site along z-axis
  556. mjSENS_CAMPROJECTION, // pixel coordinates of a site in the camera image
  557. // sensors related to scalar joints, tendons, actuators
  558. mjSENS_JOINTPOS, // scalar joint position (hinge and slide only)
  559. mjSENS_JOINTVEL, // scalar joint velocity (hinge and slide only)
  560. mjSENS_TENDONPOS, // scalar tendon position
  561. mjSENS_TENDONVEL, // scalar tendon velocity
  562. mjSENS_ACTUATORPOS, // scalar actuator position
  563. mjSENS_ACTUATORVEL, // scalar actuator velocity
  564. mjSENS_ACTUATORFRC, // scalar actuator force
  565. mjSENS_JOINTACTFRC, // scalar actuator force, measured at the joint
  566. // sensors related to ball joints
  567. mjSENS_BALLQUAT, // 4D ball joint quaternion
  568. mjSENS_BALLANGVEL, // 3D ball joint angular velocity
  569. // joint and tendon limit sensors, in constraint space
  570. mjSENS_JOINTLIMITPOS, // joint limit distance-margin
  571. mjSENS_JOINTLIMITVEL, // joint limit velocity
  572. mjSENS_JOINTLIMITFRC, // joint limit force
  573. mjSENS_TENDONLIMITPOS, // tendon limit distance-margin
  574. mjSENS_TENDONLIMITVEL, // tendon limit velocity
  575. mjSENS_TENDONLIMITFRC, // tendon limit force
  576. // sensors attached to an object with spatial frame: (x)body, geom, site, camera
  577. mjSENS_FRAMEPOS, // 3D position
  578. mjSENS_FRAMEQUAT, // 4D unit quaternion orientation
  579. mjSENS_FRAMEXAXIS, // 3D unit vector: x-axis of object's frame
  580. mjSENS_FRAMEYAXIS, // 3D unit vector: y-axis of object's frame
  581. mjSENS_FRAMEZAXIS, // 3D unit vector: z-axis of object's frame
  582. mjSENS_FRAMELINVEL, // 3D linear velocity
  583. mjSENS_FRAMEANGVEL, // 3D angular velocity
  584. mjSENS_FRAMELINACC, // 3D linear acceleration
  585. mjSENS_FRAMEANGACC, // 3D angular acceleration
  586. // sensors related to kinematic subtrees; attached to a body (which is the subtree root)
  587. mjSENS_SUBTREECOM, // 3D center of mass of subtree
  588. mjSENS_SUBTREELINVEL, // 3D linear velocity of subtree
  589. mjSENS_SUBTREEANGMOM, // 3D angular momentum of subtree
  590. // sensors for geometric distance; attached to geoms or bodies
  591. mjSENS_GEOMDIST, // signed distance between two geoms
  592. mjSENS_GEOMNORMAL, // normal direction between two geoms
  593. mjSENS_GEOMFROMTO, // segment between two geoms
  594. // global sensors
  595. mjSENS_CLOCK, // simulation time
  596. // plugin-controlled sensors
  597. mjSENS_PLUGIN, // plugin-controlled
  598. // user-defined sensor
  599. mjSENS_USER // sensor data provided by mjcb_sensor callback
  600. } mjtSensor;
  601. typedef enum mjtStage_ { // computation stage
  602. mjSTAGE_NONE = 0, // no computations
  603. mjSTAGE_POS, // position-dependent computations
  604. mjSTAGE_VEL, // velocity-dependent computations
  605. mjSTAGE_ACC // acceleration/force-dependent computations
  606. } mjtStage;
  607. typedef enum mjtDataType_ { // data type for sensors
  608. mjDATATYPE_REAL = 0, // real values, no constraints
  609. mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive
  610. mjDATATYPE_AXIS, // 3D unit vector
  611. mjDATATYPE_QUATERNION // unit quaternion
  612. } mjtDataType;
  613. typedef enum mjtSameFrame_ { // frame alignment of bodies with their children
  614. mjSAMEFRAME_NONE = 0, // no alignment
  615. mjSAMEFRAME_BODY, // frame is same as body frame
  616. mjSAMEFRAME_INERTIA, // frame is same as inertial frame
  617. mjSAMEFRAME_BODYROT, // frame orientation is same as body orientation
  618. mjSAMEFRAME_INERTIAROT // frame orientation is same as inertia orientation
  619. } mjtSameFrame;
  620. typedef enum mjtLRMode_ { // mode for actuator length range computation
  621. mjLRMODE_NONE = 0, // do not process any actuators
  622. mjLRMODE_MUSCLE, // process muscle actuators
  623. mjLRMODE_MUSCLEUSER, // process muscle and user actuators
  624. mjLRMODE_ALL // process all actuators
  625. } mjtLRMode;
  626. typedef enum mjtFlexSelf_ { // mode for flex selfcollide
  627. mjFLEXSELF_NONE = 0, // no self-collisions
  628. mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase
  629. mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled)
  630. mjFLEXSELF_SAP, // use SAP in midphase
  631. mjFLEXSELF_AUTO // choose between BVH and SAP automatically
  632. } mjtFlexSelf;
  633. struct mjLROpt_ { // options for mj_setLengthRange()
  634. // flags
  635. int mode; // which actuators to process (mjtLRMode)
  636. int useexisting; // use existing length range if available
  637. int uselimit; // use joint and tendon limits if available
  638. // algorithm parameters
  639. mjtNum accel; // target acceleration used to compute force
  640. mjtNum maxforce; // maximum force; 0: no limit
  641. mjtNum timeconst; // time constant for velocity reduction; min 0.01
  642. mjtNum timestep; // simulation timestep; 0: use mjOption.timestep
  643. mjtNum inttotal; // total simulation time interval
  644. mjtNum interval; // evaluation time interval (at the end)
  645. mjtNum tolrange; // convergence tolerance (relative to range)
  646. };
  647. typedef struct mjLROpt_ mjLROpt;
  648. struct mjVFS_ { // virtual file system for loading from memory
  649. void* impl_; // internal pointer to VFS memory
  650. };
  651. typedef struct mjVFS_ mjVFS;
  652. struct mjOption_ { // physics options
  653. // timing parameters
  654. mjtNum timestep; // timestep
  655. mjtNum apirate; // update rate for remote API (Hz)
  656. // solver parameters
  657. mjtNum impratio; // ratio of friction-to-normal contact impedance
  658. mjtNum tolerance; // main solver tolerance
  659. mjtNum ls_tolerance; // CG/Newton linesearch tolerance
  660. mjtNum noslip_tolerance; // noslip solver tolerance
  661. mjtNum ccd_tolerance; // convex collision solver tolerance
  662. // physical constants
  663. mjtNum gravity[3]; // gravitational acceleration
  664. mjtNum wind[3]; // wind (for lift, drag and viscosity)
  665. mjtNum magnetic[3]; // global magnetic flux
  666. mjtNum density; // density of medium
  667. mjtNum viscosity; // viscosity of medium
  668. // override contact solver parameters (if enabled)
  669. mjtNum o_margin; // margin
  670. mjtNum o_solref[mjNREF]; // solref
  671. mjtNum o_solimp[mjNIMP]; // solimp
  672. mjtNum o_friction[5]; // friction
  673. // discrete settings
  674. int integrator; // integration mode (mjtIntegrator)
  675. int cone; // type of friction cone (mjtCone)
  676. int jacobian; // type of Jacobian (mjtJacobian)
  677. int solver; // solver algorithm (mjtSolver)
  678. int iterations; // maximum number of main solver iterations
  679. int ls_iterations; // maximum number of CG/Newton linesearch iterations
  680. int noslip_iterations; // maximum number of noslip solver iterations
  681. int ccd_iterations; // maximum number of convex collision solver iterations
  682. int disableflags; // bit flags for disabling standard features
  683. int enableflags; // bit flags for enabling optional features
  684. int disableactuator; // bit flags for disabling actuators by group id
  685. // sdf collision settings
  686. int sdf_initpoints; // number of starting points for gradient descent
  687. int sdf_iterations; // max number of iterations for gradient descent
  688. };
  689. typedef struct mjOption_ mjOption;
  690. struct mjVisual_ { // visualization options
  691. struct { // global parameters
  692. int orthographic; // is the free camera orthographic (0: no, 1: yes)
  693. float fovy; // y field-of-view of free camera (orthographic ? length : degree)
  694. float ipd; // inter-pupilary distance for free camera
  695. float azimuth; // initial azimuth of free camera (degrees)
  696. float elevation; // initial elevation of free camera (degrees)
  697. float linewidth; // line width for wireframe and ray rendering
  698. float glow; // glow coefficient for selected body
  699. float realtime; // initial real-time factor (1: real time)
  700. int offwidth; // width of offscreen buffer
  701. int offheight; // height of offscreen buffer
  702. int ellipsoidinertia; // geom for inertia visualization (0: box, 1: ellipsoid)
  703. int bvactive; // visualize active bounding volumes (0: no, 1: yes)
  704. } global;
  705. struct { // rendering quality
  706. int shadowsize; // size of shadowmap texture
  707. int offsamples; // number of multisamples for offscreen rendering
  708. int numslices; // number of slices for builtin geom drawing
  709. int numstacks; // number of stacks for builtin geom drawing
  710. int numquads; // number of quads for box rendering
  711. } quality;
  712. struct { // head light
  713. float ambient[3]; // ambient rgb (alpha=1)
  714. float diffuse[3]; // diffuse rgb (alpha=1)
  715. float specular[3]; // specular rgb (alpha=1)
  716. int active; // is headlight active
  717. } headlight;
  718. struct { // mapping
  719. float stiffness; // mouse perturbation stiffness (space->force)
  720. float stiffnessrot; // mouse perturbation stiffness (space->torque)
  721. float force; // from force units to space units
  722. float torque; // from torque units to space units
  723. float alpha; // scale geom alphas when transparency is enabled
  724. float fogstart; // OpenGL fog starts at fogstart * mjModel.stat.extent
  725. float fogend; // OpenGL fog ends at fogend * mjModel.stat.extent
  726. float znear; // near clipping plane = znear * mjModel.stat.extent
  727. float zfar; // far clipping plane = zfar * mjModel.stat.extent
  728. float haze; // haze ratio
  729. float shadowclip; // directional light: shadowclip * mjModel.stat.extent
  730. float shadowscale; // spot light: shadowscale * light.cutoff
  731. float actuatortendon; // scale tendon width
  732. } map;
  733. struct { // scale of decor elements relative to mean body size
  734. float forcewidth; // width of force arrow
  735. float contactwidth; // contact width
  736. float contactheight; // contact height
  737. float connect; // autoconnect capsule width
  738. float com; // com radius
  739. float camera; // camera object
  740. float light; // light object
  741. float selectpoint; // selection point
  742. float jointlength; // joint length
  743. float jointwidth; // joint width
  744. float actuatorlength; // actuator length
  745. float actuatorwidth; // actuator width
  746. float framelength; // bodyframe axis length
  747. float framewidth; // bodyframe axis width
  748. float constraint; // constraint width
  749. float slidercrank; // slidercrank width
  750. float frustum; // frustum zfar plane
  751. } scale;
  752. struct { // color of decor elements
  753. float fog[4]; // fog
  754. float haze[4]; // haze
  755. float force[4]; // external force
  756. float inertia[4]; // inertia box
  757. float joint[4]; // joint
  758. float actuator[4]; // actuator, neutral
  759. float actuatornegative[4]; // actuator, negative limit
  760. float actuatorpositive[4]; // actuator, positive limit
  761. float com[4]; // center of mass
  762. float camera[4]; // camera object
  763. float light[4]; // light object
  764. float selectpoint[4]; // selection point
  765. float connect[4]; // auto connect
  766. float contactpoint[4]; // contact point
  767. float contactforce[4]; // contact force
  768. float contactfriction[4]; // contact friction force
  769. float contacttorque[4]; // contact torque
  770. float contactgap[4]; // contact point in gap
  771. float rangefinder[4]; // rangefinder ray
  772. float constraint[4]; // constraint
  773. float slidercrank[4]; // slidercrank
  774. float crankbroken[4]; // used when crank must be stretched/broken
  775. float frustum[4]; // camera frustum
  776. float bv[4]; // bounding volume
  777. float bvactive[4]; // active bounding volume
  778. } rgba;
  779. };
  780. typedef struct mjVisual_ mjVisual;
  781. struct mjStatistic_ { // model statistics (in qpos0)
  782. mjtNum meaninertia; // mean diagonal inertia
  783. mjtNum meanmass; // mean body mass
  784. mjtNum meansize; // mean body size
  785. mjtNum extent; // spatial extent
  786. mjtNum center[3]; // center of model
  787. };
  788. typedef struct mjStatistic_ mjStatistic;
  789. struct mjModel_ {
  790. // ------------------------------- sizes
  791. // sizes needed at mjModel construction
  792. int nq; // number of generalized coordinates = dim(qpos)
  793. int nv; // number of degrees of freedom = dim(qvel)
  794. int nu; // number of actuators/controls = dim(ctrl)
  795. int na; // number of activation states = dim(act)
  796. int nbody; // number of bodies
  797. int nbvh; // number of total bounding volumes in all bodies
  798. int nbvhstatic; // number of static bounding volumes (aabb stored in mjModel)
  799. int nbvhdynamic; // number of dynamic bounding volumes (aabb stored in mjData)
  800. int njnt; // number of joints
  801. int ngeom; // number of geoms
  802. int nsite; // number of sites
  803. int ncam; // number of cameras
  804. int nlight; // number of lights
  805. int nflex; // number of flexes
  806. int nflexvert; // number of vertices in all flexes
  807. int nflexedge; // number of edges in all flexes
  808. int nflexelem; // number of elements in all flexes
  809. int nflexelemdata; // number of element vertex ids in all flexes
  810. int nflexelemedge; // number of element edge ids in all flexes
  811. int nflexshelldata; // number of shell fragment vertex ids in all flexes
  812. int nflexevpair; // number of element-vertex pairs in all flexes
  813. int nflextexcoord; // number of vertices with texture coordinates
  814. int nmesh; // number of meshes
  815. int nmeshvert; // number of vertices in all meshes
  816. int nmeshnormal; // number of normals in all meshes
  817. int nmeshtexcoord; // number of texcoords in all meshes
  818. int nmeshface; // number of triangular faces in all meshes
  819. int nmeshgraph; // number of ints in mesh auxiliary data
  820. int nskin; // number of skins
  821. int nskinvert; // number of vertices in all skins
  822. int nskintexvert; // number of vertiex with texcoords in all skins
  823. int nskinface; // number of triangular faces in all skins
  824. int nskinbone; // number of bones in all skins
  825. int nskinbonevert; // number of vertices in all skin bones
  826. int nhfield; // number of heightfields
  827. int nhfielddata; // number of data points in all heightfields
  828. int ntex; // number of textures
  829. int ntexdata; // number of bytes in texture rgb data
  830. int nmat; // number of materials
  831. int npair; // number of predefined geom pairs
  832. int nexclude; // number of excluded geom pairs
  833. int neq; // number of equality constraints
  834. int ntendon; // number of tendons
  835. int nwrap; // number of wrap objects in all tendon paths
  836. int nsensor; // number of sensors
  837. int nnumeric; // number of numeric custom fields
  838. int nnumericdata; // number of mjtNums in all numeric fields
  839. int ntext; // number of text custom fields
  840. int ntextdata; // number of mjtBytes in all text fields
  841. int ntuple; // number of tuple custom fields
  842. int ntupledata; // number of objects in all tuple fields
  843. int nkey; // number of keyframes
  844. int nmocap; // number of mocap bodies
  845. int nplugin; // number of plugin instances
  846. int npluginattr; // number of chars in all plugin config attributes
  847. int nuser_body; // number of mjtNums in body_user
  848. int nuser_jnt; // number of mjtNums in jnt_user
  849. int nuser_geom; // number of mjtNums in geom_user
  850. int nuser_site; // number of mjtNums in site_user
  851. int nuser_cam; // number of mjtNums in cam_user
  852. int nuser_tendon; // number of mjtNums in tendon_user
  853. int nuser_actuator; // number of mjtNums in actuator_user
  854. int nuser_sensor; // number of mjtNums in sensor_user
  855. int nnames; // number of chars in all names
  856. int nnames_map; // number of slots in the names hash map
  857. int npaths; // number of chars in all paths
  858. // sizes set after mjModel construction (only affect mjData)
  859. int nM; // number of non-zeros in sparse inertia matrix
  860. int nB; // number of non-zeros in sparse body-dof matrix
  861. int nC; // number of non-zeros in sparse reduced dof-dof matrix
  862. int nD; // number of non-zeros in sparse dof-dof matrix
  863. int ntree; // number of kinematic trees under world body
  864. int ngravcomp; // number of bodies with nonzero gravcomp
  865. int nemax; // number of potential equality-constraint rows
  866. int njmax; // number of available rows in constraint Jacobian
  867. int nconmax; // number of potential contacts in contact list
  868. int nuserdata; // number of mjtNums reserved for the user
  869. int nsensordata; // number of mjtNums in sensor data vector
  870. int npluginstate; // number of mjtNums in plugin state vector
  871. size_t narena; // number of bytes in the mjData arena (inclusive of stack)
  872. size_t nbuffer; // number of bytes in buffer
  873. // ------------------------------- options and statistics
  874. mjOption opt; // physics options
  875. mjVisual vis; // visualization options
  876. mjStatistic stat; // model statistics
  877. // ------------------------------- buffers
  878. // main buffer
  879. void* buffer; // main buffer; all pointers point in it (nbuffer)
  880. // default generalized coordinates
  881. mjtNum* qpos0; // qpos values at default pose (nq x 1)
  882. mjtNum* qpos_spring; // reference pose for springs (nq x 1)
  883. // bodies
  884. int* body_parentid; // id of body's parent (nbody x 1)
  885. int* body_rootid; // id of root above body (nbody x 1)
  886. int* body_weldid; // id of body that this body is welded to (nbody x 1)
  887. int* body_mocapid; // id of mocap data; -1: none (nbody x 1)
  888. int* body_jntnum; // number of joints for this body (nbody x 1)
  889. int* body_jntadr; // start addr of joints; -1: no joints (nbody x 1)
  890. int* body_dofnum; // number of motion degrees of freedom (nbody x 1)
  891. int* body_dofadr; // start addr of dofs; -1: no dofs (nbody x 1)
  892. int* body_treeid; // id of body's kinematic tree; -1: static (nbody x 1)
  893. int* body_geomnum; // number of geoms (nbody x 1)
  894. int* body_geomadr; // start addr of geoms; -1: no geoms (nbody x 1)
  895. mjtByte* body_simple; // 1: diag M; 2: diag M, sliders only (nbody x 1)
  896. mjtByte* body_sameframe; // same frame as inertia (mjtSameframe) (nbody x 1)
  897. mjtNum* body_pos; // position offset rel. to parent body (nbody x 3)
  898. mjtNum* body_quat; // orientation offset rel. to parent body (nbody x 4)
  899. mjtNum* body_ipos; // local position of center of mass (nbody x 3)
  900. mjtNum* body_iquat; // local orientation of inertia ellipsoid (nbody x 4)
  901. mjtNum* body_mass; // mass (nbody x 1)
  902. mjtNum* body_subtreemass; // mass of subtree starting at this body (nbody x 1)
  903. mjtNum* body_inertia; // diagonal inertia in ipos/iquat frame (nbody x 3)
  904. mjtNum* body_invweight0; // mean inv inert in qpos0 (trn, rot) (nbody x 2)
  905. mjtNum* body_gravcomp; // antigravity force, units of body weight (nbody x 1)
  906. mjtNum* body_margin; // MAX over all geom margins (nbody x 1)
  907. mjtNum* body_user; // user data (nbody x nuser_body)
  908. int* body_plugin; // plugin instance id; -1: not in use (nbody x 1)
  909. int* body_contype; // OR over all geom contypes (nbody x 1)
  910. int* body_conaffinity; // OR over all geom conaffinities (nbody x 1)
  911. int* body_bvhadr; // address of bvh root (nbody x 1)
  912. int* body_bvhnum; // number of bounding volumes (nbody x 1)
  913. // bounding volume hierarchy
  914. int* bvh_depth; // depth in the bounding volume hierarchy (nbvh x 1)
  915. int* bvh_child; // left and right children in tree (nbvh x 2)
  916. int* bvh_nodeid; // geom or elem id of node; -1: non-leaf (nbvh x 1)
  917. mjtNum* bvh_aabb; // local bounding box (center, size) (nbvhstatic x 6)
  918. // joints
  919. int* jnt_type; // type of joint (mjtJoint) (njnt x 1)
  920. int* jnt_qposadr; // start addr in 'qpos' for joint's data (njnt x 1)
  921. int* jnt_dofadr; // start addr in 'qvel' for joint's data (njnt x 1)
  922. int* jnt_bodyid; // id of joint's body (njnt x 1)
  923. int* jnt_group; // group for visibility (njnt x 1)
  924. mjtByte* jnt_limited; // does joint have limits (njnt x 1)
  925. mjtByte* jnt_actfrclimited; // does joint have actuator force limits (njnt x 1)
  926. mjtByte* jnt_actgravcomp; // is gravcomp force applied via actuators (njnt x 1)
  927. mjtNum* jnt_solref; // constraint solver reference: limit (njnt x mjNREF)
  928. mjtNum* jnt_solimp; // constraint solver impedance: limit (njnt x mjNIMP)
  929. mjtNum* jnt_pos; // local anchor position (njnt x 3)
  930. mjtNum* jnt_axis; // local joint axis (njnt x 3)
  931. mjtNum* jnt_stiffness; // stiffness coefficient (njnt x 1)
  932. mjtNum* jnt_range; // joint limits (njnt x 2)
  933. mjtNum* jnt_actfrcrange; // range of total actuator force (njnt x 2)
  934. mjtNum* jnt_margin; // min distance for limit detection (njnt x 1)
  935. mjtNum* jnt_user; // user data (njnt x nuser_jnt)
  936. // dofs
  937. int* dof_bodyid; // id of dof's body (nv x 1)
  938. int* dof_jntid; // id of dof's joint (nv x 1)
  939. int* dof_parentid; // id of dof's parent; -1: none (nv x 1)
  940. int* dof_treeid; // id of dof's kinematic tree (nv x 1)
  941. int* dof_Madr; // dof address in M-diagonal (nv x 1)
  942. int* dof_simplenum; // number of consecutive simple dofs (nv x 1)
  943. mjtNum* dof_solref; // constraint solver reference:frictionloss (nv x mjNREF)
  944. mjtNum* dof_solimp; // constraint solver impedance:frictionloss (nv x mjNIMP)
  945. mjtNum* dof_frictionloss; // dof friction loss (nv x 1)
  946. mjtNum* dof_armature; // dof armature inertia/mass (nv x 1)
  947. mjtNum* dof_damping; // damping coefficient (nv x 1)
  948. mjtNum* dof_invweight0; // diag. inverse inertia in qpos0 (nv x 1)
  949. mjtNum* dof_M0; // diag. inertia in qpos0 (nv x 1)
  950. // geoms
  951. int* geom_type; // geometric type (mjtGeom) (ngeom x 1)
  952. int* geom_contype; // geom contact type (ngeom x 1)
  953. int* geom_conaffinity; // geom contact affinity (ngeom x 1)
  954. int* geom_condim; // contact dimensionality (1, 3, 4, 6) (ngeom x 1)
  955. int* geom_bodyid; // id of geom's body (ngeom x 1)
  956. int* geom_dataid; // id of geom's mesh/hfield; -1: none (ngeom x 1)
  957. int* geom_matid; // material id for rendering; -1: none (ngeom x 1)
  958. int* geom_group; // group for visibility (ngeom x 1)
  959. int* geom_priority; // geom contact priority (ngeom x 1)
  960. int* geom_plugin; // plugin instance id; -1: not in use (ngeom x 1)
  961. mjtByte* geom_sameframe; // same frame as body (mjtSameframe) (ngeom x 1)
  962. mjtNum* geom_solmix; // mixing coef for solref/imp in geom pair (ngeom x 1)
  963. mjtNum* geom_solref; // constraint solver reference: contact (ngeom x mjNREF)
  964. mjtNum* geom_solimp; // constraint solver impedance: contact (ngeom x mjNIMP)
  965. mjtNum* geom_size; // geom-specific size parameters (ngeom x 3)
  966. mjtNum* geom_aabb; // bounding box, (center, size) (ngeom x 6)
  967. mjtNum* geom_rbound; // radius of bounding sphere (ngeom x 1)
  968. mjtNum* geom_pos; // local position offset rel. to body (ngeom x 3)
  969. mjtNum* geom_quat; // local orientation offset rel. to body (ngeom x 4)
  970. mjtNum* geom_friction; // friction for (slide, spin, roll) (ngeom x 3)
  971. mjtNum* geom_margin; // detect contact if dist<margin (ngeom x 1)
  972. mjtNum* geom_gap; // include in solver if dist<margin-gap (ngeom x 1)
  973. mjtNum* geom_fluid; // fluid interaction parameters (ngeom x mjNFLUID)
  974. mjtNum* geom_user; // user data (ngeom x nuser_geom)
  975. float* geom_rgba; // rgba when material is omitted (ngeom x 4)
  976. // sites
  977. int* site_type; // geom type for rendering (mjtGeom) (nsite x 1)
  978. int* site_bodyid; // id of site's body (nsite x 1)
  979. int* site_matid; // material id for rendering; -1: none (nsite x 1)
  980. int* site_group; // group for visibility (nsite x 1)
  981. mjtByte* site_sameframe; // same frame as body (mjtSameframe) (nsite x 1)
  982. mjtNum* site_size; // geom size for rendering (nsite x 3)
  983. mjtNum* site_pos; // local position offset rel. to body (nsite x 3)
  984. mjtNum* site_quat; // local orientation offset rel. to body (nsite x 4)
  985. mjtNum* site_user; // user data (nsite x nuser_site)
  986. float* site_rgba; // rgba when material is omitted (nsite x 4)
  987. // cameras
  988. int* cam_mode; // camera tracking mode (mjtCamLight) (ncam x 1)
  989. int* cam_bodyid; // id of camera's body (ncam x 1)
  990. int* cam_targetbodyid; // id of targeted body; -1: none (ncam x 1)
  991. mjtNum* cam_pos; // position rel. to body frame (ncam x 3)
  992. mjtNum* cam_quat; // orientation rel. to body frame (ncam x 4)
  993. mjtNum* cam_poscom0; // global position rel. to sub-com in qpos0 (ncam x 3)
  994. mjtNum* cam_pos0; // global position rel. to body in qpos0 (ncam x 3)
  995. mjtNum* cam_mat0; // global orientation in qpos0 (ncam x 9)
  996. int* cam_orthographic; // orthographic camera; 0: no, 1: yes (ncam x 1)
  997. mjtNum* cam_fovy; // y field-of-view (ortho ? len : deg) (ncam x 1)
  998. mjtNum* cam_ipd; // inter-pupilary distance (ncam x 1)
  999. int* cam_resolution; // resolution: pixels [width, height] (ncam x 2)
  1000. float* cam_sensorsize; // sensor size: length [width, height] (ncam x 2)
  1001. float* cam_intrinsic; // [focal length; principal point] (ncam x 4)
  1002. mjtNum* cam_user; // user data (ncam x nuser_cam)
  1003. // lights
  1004. int* light_mode; // light tracking mode (mjtCamLight) (nlight x 1)
  1005. int* light_bodyid; // id of light's body (nlight x 1)
  1006. int* light_targetbodyid; // id of targeted body; -1: none (nlight x 1)
  1007. mjtByte* light_directional; // directional light (nlight x 1)
  1008. mjtByte* light_castshadow; // does light cast shadows (nlight x 1)
  1009. float* light_bulbradius; // light radius for soft shadows (nlight x 1)
  1010. mjtByte* light_active; // is light on (nlight x 1)
  1011. mjtNum* light_pos; // position rel. to body frame (nlight x 3)
  1012. mjtNum* light_dir; // direction rel. to body frame (nlight x 3)
  1013. mjtNum* light_poscom0; // global position rel. to sub-com in qpos0 (nlight x 3)
  1014. mjtNum* light_pos0; // global position rel. to body in qpos0 (nlight x 3)
  1015. mjtNum* light_dir0; // global direction in qpos0 (nlight x 3)
  1016. float* light_attenuation; // OpenGL attenuation (quadratic model) (nlight x 3)
  1017. float* light_cutoff; // OpenGL cutoff (nlight x 1)
  1018. float* light_exponent; // OpenGL exponent (nlight x 1)
  1019. float* light_ambient; // ambient rgb (alpha=1) (nlight x 3)
  1020. float* light_diffuse; // diffuse rgb (alpha=1) (nlight x 3)
  1021. float* light_specular; // specular rgb (alpha=1) (nlight x 3)
  1022. // flexes: contact properties
  1023. int* flex_contype; // flex contact type (nflex x 1)
  1024. int* flex_conaffinity; // flex contact affinity (nflex x 1)
  1025. int* flex_condim; // contact dimensionality (1, 3, 4, 6) (nflex x 1)
  1026. int* flex_priority; // flex contact priority (nflex x 1)
  1027. mjtNum* flex_solmix; // mix coef for solref/imp in contact pair (nflex x 1)
  1028. mjtNum* flex_solref; // constraint solver reference: contact (nflex x mjNREF)
  1029. mjtNum* flex_solimp; // constraint solver impedance: contact (nflex x mjNIMP)
  1030. mjtNum* flex_friction; // friction for (slide, spin, roll) (nflex x 3)
  1031. mjtNum* flex_margin; // detect contact if dist<margin (nflex x 1)
  1032. mjtNum* flex_gap; // include in solver if dist<margin-gap (nflex x 1)
  1033. mjtByte* flex_internal; // internal flex collision enabled (nflex x 1)
  1034. int* flex_selfcollide; // self collision mode (mjtFlexSelf) (nflex x 1)
  1035. int* flex_activelayers; // number of active element layers, 3D only (nflex x 1)
  1036. // flexes: other properties
  1037. int* flex_dim; // 1: lines, 2: triangles, 3: tetrahedra (nflex x 1)
  1038. int* flex_matid; // material id for rendering (nflex x 1)
  1039. int* flex_group; // group for visibility (nflex x 1)
  1040. int* flex_vertadr; // first vertex address (nflex x 1)
  1041. int* flex_vertnum; // number of vertices (nflex x 1)
  1042. int* flex_edgeadr; // first edge address (nflex x 1)
  1043. int* flex_edgenum; // number of edges (nflex x 1)
  1044. int* flex_elemadr; // first element address (nflex x 1)
  1045. int* flex_elemnum; // number of elements (nflex x 1)
  1046. int* flex_elemdataadr; // first element vertex id address (nflex x 1)
  1047. int* flex_elemedgeadr; // first element edge id address (nflex x 1)
  1048. int* flex_shellnum; // number of shells (nflex x 1)
  1049. int* flex_shelldataadr; // first shell data address (nflex x 1)
  1050. int* flex_evpairadr; // first evpair address (nflex x 1)
  1051. int* flex_evpairnum; // number of evpairs (nflex x 1)
  1052. int* flex_texcoordadr; // address in flex_texcoord; -1: none (nflex x 1)
  1053. int* flex_vertbodyid; // vertex body ids (nflexvert x 1)
  1054. int* flex_edge; // edge vertex ids (2 per edge) (nflexedge x 2)
  1055. int* flex_elem; // element vertex ids (dim+1 per elem) (nflexelemdata x 1)
  1056. int* flex_elemedge; // element edge ids (nflexelemedge x 1)
  1057. int* flex_elemlayer; // element distance from surface, 3D only (nflexelem x 1)
  1058. int* flex_shell; // shell fragment vertex ids (dim per frag) (nflexshelldata x 1)
  1059. int* flex_evpair; // (element, vertex) collision pairs (nflexevpair x 2)
  1060. mjtNum* flex_vert; // vertex positions in local body frames (nflexvert x 3)
  1061. mjtNum* flex_xvert0; // Cartesian vertex positions in qpos0 (nflexvert x 3)
  1062. mjtNum* flexedge_length0; // edge lengths in qpos0 (nflexedge x 1)
  1063. mjtNum* flexedge_invweight0; // edge inv. weight in qpos0 (nflexedge x 1)
  1064. mjtNum* flex_radius; // radius around primitive element (nflex x 1)
  1065. mjtNum* flex_stiffness; // finite element stiffness matrix (nflexelem x 21)
  1066. mjtNum* flex_damping; // Rayleigh's damping coefficient (nflex x 1)
  1067. mjtNum* flex_edgestiffness; // edge stiffness (nflex x 1)
  1068. mjtNum* flex_edgedamping; // edge damping (nflex x 1)
  1069. mjtByte* flex_edgeequality; // is edge equality constraint defined (nflex x 1)
  1070. mjtByte* flex_rigid; // are all verices in the same body (nflex x 1)
  1071. mjtByte* flexedge_rigid; // are both edge vertices in same body (nflexedge x 1)
  1072. mjtByte* flex_centered; // are all vertex coordinates (0,0,0) (nflex x 1)
  1073. mjtByte* flex_flatskin; // render flex skin with flat shading (nflex x 1)
  1074. int* flex_bvhadr; // address of bvh root; -1: no bvh (nflex x 1)
  1075. int* flex_bvhnum; // number of bounding volumes (nflex x 1)
  1076. float* flex_rgba; // rgba when material is omitted (nflex x 4)
  1077. float* flex_texcoord; // vertex texture coordinates (nflextexcoord x 2)
  1078. // meshes
  1079. int* mesh_vertadr; // first vertex address (nmesh x 1)
  1080. int* mesh_vertnum; // number of vertices (nmesh x 1)
  1081. int* mesh_faceadr; // first face address (nmesh x 1)
  1082. int* mesh_facenum; // number of faces (nmesh x 1)
  1083. int* mesh_bvhadr; // address of bvh root (nmesh x 1)
  1084. int* mesh_bvhnum; // number of bvh (nmesh x 1)
  1085. int* mesh_normaladr; // first normal address (nmesh x 1)
  1086. int* mesh_normalnum; // number of normals (nmesh x 1)
  1087. int* mesh_texcoordadr; // texcoord data address; -1: no texcoord (nmesh x 1)
  1088. int* mesh_texcoordnum; // number of texcoord (nmesh x 1)
  1089. int* mesh_graphadr; // graph data address; -1: no graph (nmesh x 1)
  1090. float* mesh_vert; // vertex positions for all meshes (nmeshvert x 3)
  1091. float* mesh_normal; // normals for all meshes (nmeshnormal x 3)
  1092. float* mesh_texcoord; // vertex texcoords for all meshes (nmeshtexcoord x 2)
  1093. int* mesh_face; // vertex face data (nmeshface x 3)
  1094. int* mesh_facenormal; // normal face data (nmeshface x 3)
  1095. int* mesh_facetexcoord; // texture face data (nmeshface x 3)
  1096. int* mesh_graph; // convex graph data (nmeshgraph x 1)
  1097. mjtNum* mesh_scale; // scaling applied to asset vertices (nmesh x 3)
  1098. mjtNum* mesh_pos; // translation applied to asset vertices (nmesh x 3)
  1099. mjtNum* mesh_quat; // rotation applied to asset vertices (nmesh x 4)
  1100. int* mesh_pathadr; // address of asset path for mesh; -1: none (nmesh x 1)
  1101. // skins
  1102. int* skin_matid; // skin material id; -1: none (nskin x 1)
  1103. int* skin_group; // group for visibility (nskin x 1)
  1104. float* skin_rgba; // skin rgba (nskin x 4)
  1105. float* skin_inflate; // inflate skin in normal direction (nskin x 1)
  1106. int* skin_vertadr; // first vertex address (nskin x 1)
  1107. int* skin_vertnum; // number of vertices (nskin x 1)
  1108. int* skin_texcoordadr; // texcoord data address; -1: no texcoord (nskin x 1)
  1109. int* skin_faceadr; // first face address (nskin x 1)
  1110. int* skin_facenum; // number of faces (nskin x 1)
  1111. int* skin_boneadr; // first bone in skin (nskin x 1)
  1112. int* skin_bonenum; // number of bones in skin (nskin x 1)
  1113. float* skin_vert; // vertex positions for all skin meshes (nskinvert x 3)
  1114. float* skin_texcoord; // vertex texcoords for all skin meshes (nskintexvert x 2)
  1115. int* skin_face; // triangle faces for all skin meshes (nskinface x 3)
  1116. int* skin_bonevertadr; // first vertex in each bone (nskinbone x 1)
  1117. int* skin_bonevertnum; // number of vertices in each bone (nskinbone x 1)
  1118. float* skin_bonebindpos; // bind pos of each bone (nskinbone x 3)
  1119. float* skin_bonebindquat; // bind quat of each bone (nskinbone x 4)
  1120. int* skin_bonebodyid; // body id of each bone (nskinbone x 1)
  1121. int* skin_bonevertid; // mesh ids of vertices in each bone (nskinbonevert x 1)
  1122. float* skin_bonevertweight; // weights of vertices in each bone (nskinbonevert x 1)
  1123. int* skin_pathadr; // address of asset path for skin; -1: none (nskin x 1)
  1124. // height fields
  1125. mjtNum* hfield_size; // (x, y, z_top, z_bottom) (nhfield x 4)
  1126. int* hfield_nrow; // number of rows in grid (nhfield x 1)
  1127. int* hfield_ncol; // number of columns in grid (nhfield x 1)
  1128. int* hfield_adr; // address in hfield_data (nhfield x 1)
  1129. float* hfield_data; // elevation data (nhfielddata x 1)
  1130. int* hfield_pathadr; // address of hfield asset path; -1: none (nhfield x 1)
  1131. // textures
  1132. int* tex_type; // texture type (mjtTexture) (ntex x 1)
  1133. int* tex_height; // number of rows in texture image (ntex x 1)
  1134. int* tex_width; // number of columns in texture image (ntex x 1)
  1135. int* tex_nchannel; // number of channels in texture image (ntex x 1)
  1136. int* tex_adr; // start address in tex_data (ntex x 1)
  1137. mjtByte* tex_data; // pixel values (ntexdata x 1)
  1138. int* tex_pathadr; // address of texture asset path; -1: none (ntex x 1)
  1139. // materials
  1140. int* mat_texid; // indices of textures; -1: none (nmat x mjNTEXROLE)
  1141. mjtByte* mat_texuniform; // make texture cube uniform (nmat x 1)
  1142. float* mat_texrepeat; // texture repetition for 2d mapping (nmat x 2)
  1143. float* mat_emission; // emission (x rgb) (nmat x 1)
  1144. float* mat_specular; // specular (x white) (nmat x 1)
  1145. float* mat_shininess; // shininess coef (nmat x 1)
  1146. float* mat_reflectance; // reflectance (0: disable) (nmat x 1)
  1147. float* mat_metallic; // metallic coef (nmat x 1)
  1148. float* mat_roughness; // roughness coef (nmat x 1)
  1149. float* mat_rgba; // rgba (nmat x 4)
  1150. // predefined geom pairs for collision detection; has precedence over exclude
  1151. int* pair_dim; // contact dimensionality (npair x 1)
  1152. int* pair_geom1; // id of geom1 (npair x 1)
  1153. int* pair_geom2; // id of geom2 (npair x 1)
  1154. int* pair_signature; // body1 << 16 + body2 (npair x 1)
  1155. mjtNum* pair_solref; // solver reference: contact normal (npair x mjNREF)
  1156. mjtNum* pair_solreffriction; // solver reference: contact friction (npair x mjNREF)
  1157. mjtNum* pair_solimp; // solver impedance: contact (npair x mjNIMP)
  1158. mjtNum* pair_margin; // detect contact if dist<margin (npair x 1)
  1159. mjtNum* pair_gap; // include in solver if dist<margin-gap (npair x 1)
  1160. mjtNum* pair_friction; // tangent1, 2, spin, roll1, 2 (npair x 5)
  1161. // excluded body pairs for collision detection
  1162. int* exclude_signature; // body1 << 16 + body2 (nexclude x 1)
  1163. // equality constraints
  1164. int* eq_type; // constraint type (mjtEq) (neq x 1)
  1165. int* eq_obj1id; // id of object 1 (neq x 1)
  1166. int* eq_obj2id; // id of object 2 (neq x 1)
  1167. int* eq_objtype; // type of both objects (mjtObj) (neq x 1)
  1168. mjtByte* eq_active0; // initial enable/disable constraint state (neq x 1)
  1169. mjtNum* eq_solref; // constraint solver reference (neq x mjNREF)
  1170. mjtNum* eq_solimp; // constraint solver impedance (neq x mjNIMP)
  1171. mjtNum* eq_data; // numeric data for constraint (neq x mjNEQDATA)
  1172. // tendons
  1173. int* tendon_adr; // address of first object in tendon's path (ntendon x 1)
  1174. int* tendon_num; // number of objects in tendon's path (ntendon x 1)
  1175. int* tendon_matid; // material id for rendering (ntendon x 1)
  1176. int* tendon_group; // group for visibility (ntendon x 1)
  1177. mjtByte* tendon_limited; // does tendon have length limits (ntendon x 1)
  1178. mjtNum* tendon_width; // width for rendering (ntendon x 1)
  1179. mjtNum* tendon_solref_lim; // constraint solver reference: limit (ntendon x mjNREF)
  1180. mjtNum* tendon_solimp_lim; // constraint solver impedance: limit (ntendon x mjNIMP)
  1181. mjtNum* tendon_solref_fri; // constraint solver reference: friction (ntendon x mjNREF)
  1182. mjtNum* tendon_solimp_fri; // constraint solver impedance: friction (ntendon x mjNIMP)
  1183. mjtNum* tendon_range; // tendon length limits (ntendon x 2)
  1184. mjtNum* tendon_margin; // min distance for limit detection (ntendon x 1)
  1185. mjtNum* tendon_stiffness; // stiffness coefficient (ntendon x 1)
  1186. mjtNum* tendon_damping; // damping coefficient (ntendon x 1)
  1187. mjtNum* tendon_frictionloss; // loss due to friction (ntendon x 1)
  1188. mjtNum* tendon_lengthspring; // spring resting length range (ntendon x 2)
  1189. mjtNum* tendon_length0; // tendon length in qpos0 (ntendon x 1)
  1190. mjtNum* tendon_invweight0; // inv. weight in qpos0 (ntendon x 1)
  1191. mjtNum* tendon_user; // user data (ntendon x nuser_tendon)
  1192. float* tendon_rgba; // rgba when material is omitted (ntendon x 4)
  1193. // list of all wrap objects in tendon paths
  1194. int* wrap_type; // wrap object type (mjtWrap) (nwrap x 1)
  1195. int* wrap_objid; // object id: geom, site, joint (nwrap x 1)
  1196. mjtNum* wrap_prm; // divisor, joint coef, or site id (nwrap x 1)
  1197. // actuators
  1198. int* actuator_trntype; // transmission type (mjtTrn) (nu x 1)
  1199. int* actuator_dyntype; // dynamics type (mjtDyn) (nu x 1)
  1200. int* actuator_gaintype; // gain type (mjtGain) (nu x 1)
  1201. int* actuator_biastype; // bias type (mjtBias) (nu x 1)
  1202. int* actuator_trnid; // transmission id: joint, tendon, site (nu x 2)
  1203. int* actuator_actadr; // first activation address; -1: stateless (nu x 1)
  1204. int* actuator_actnum; // number of activation variables (nu x 1)
  1205. int* actuator_group; // group for visibility (nu x 1)
  1206. mjtByte* actuator_ctrllimited; // is control limited (nu x 1)
  1207. mjtByte* actuator_forcelimited;// is force limited (nu x 1)
  1208. mjtByte* actuator_actlimited; // is activation limited (nu x 1)
  1209. mjtNum* actuator_dynprm; // dynamics parameters (nu x mjNDYN)
  1210. mjtNum* actuator_gainprm; // gain parameters (nu x mjNGAIN)
  1211. mjtNum* actuator_biasprm; // bias parameters (nu x mjNBIAS)
  1212. mjtByte* actuator_actearly; // step activation before force (nu x 1)
  1213. mjtNum* actuator_ctrlrange; // range of controls (nu x 2)
  1214. mjtNum* actuator_forcerange; // range of forces (nu x 2)
  1215. mjtNum* actuator_actrange; // range of activations (nu x 2)
  1216. mjtNum* actuator_gear; // scale length and transmitted force (nu x 6)
  1217. mjtNum* actuator_cranklength; // crank length for slider-crank (nu x 1)
  1218. mjtNum* actuator_acc0; // acceleration from unit force in qpos0 (nu x 1)
  1219. mjtNum* actuator_length0; // actuator length in qpos0 (nu x 1)
  1220. mjtNum* actuator_lengthrange; // feasible actuator length range (nu x 2)
  1221. mjtNum* actuator_user; // user data (nu x nuser_actuator)
  1222. int* actuator_plugin; // plugin instance id; -1: not a plugin (nu x 1)
  1223. // sensors
  1224. int* sensor_type; // sensor type (mjtSensor) (nsensor x 1)
  1225. int* sensor_datatype; // numeric data type (mjtDataType) (nsensor x 1)
  1226. int* sensor_needstage; // required compute stage (mjtStage) (nsensor x 1)
  1227. int* sensor_objtype; // type of sensorized object (mjtObj) (nsensor x 1)
  1228. int* sensor_objid; // id of sensorized object (nsensor x 1)
  1229. int* sensor_reftype; // type of reference frame (mjtObj) (nsensor x 1)
  1230. int* sensor_refid; // id of reference frame; -1: global frame (nsensor x 1)
  1231. int* sensor_dim; // number of scalar outputs (nsensor x 1)
  1232. int* sensor_adr; // address in sensor array (nsensor x 1)
  1233. mjtNum* sensor_cutoff; // cutoff for real and positive; 0: ignore (nsensor x 1)
  1234. mjtNum* sensor_noise; // noise standard deviation (nsensor x 1)
  1235. mjtNum* sensor_user; // user data (nsensor x nuser_sensor)
  1236. int* sensor_plugin; // plugin instance id; -1: not a plugin (nsensor x 1)
  1237. // plugin instances
  1238. int* plugin; // globally registered plugin slot number (nplugin x 1)
  1239. int* plugin_stateadr; // address in the plugin state array (nplugin x 1)
  1240. int* plugin_statenum; // number of states in the plugin instance (nplugin x 1)
  1241. char* plugin_attr; // config attributes of plugin instances (npluginattr x 1)
  1242. int* plugin_attradr; // address to each instance's config attrib (nplugin x 1)
  1243. // custom numeric fields
  1244. int* numeric_adr; // address of field in numeric_data (nnumeric x 1)
  1245. int* numeric_size; // size of numeric field (nnumeric x 1)
  1246. mjtNum* numeric_data; // array of all numeric fields (nnumericdata x 1)
  1247. // custom text fields
  1248. int* text_adr; // address of text in text_data (ntext x 1)
  1249. int* text_size; // size of text field (strlen+1) (ntext x 1)
  1250. char* text_data; // array of all text fields (0-terminated) (ntextdata x 1)
  1251. // custom tuple fields
  1252. int* tuple_adr; // address of text in text_data (ntuple x 1)
  1253. int* tuple_size; // number of objects in tuple (ntuple x 1)
  1254. int* tuple_objtype; // array of object types in all tuples (ntupledata x 1)
  1255. int* tuple_objid; // array of object ids in all tuples (ntupledata x 1)
  1256. mjtNum* tuple_objprm; // array of object params in all tuples (ntupledata x 1)
  1257. // keyframes
  1258. mjtNum* key_time; // key time (nkey x 1)
  1259. mjtNum* key_qpos; // key position (nkey x nq)
  1260. mjtNum* key_qvel; // key velocity (nkey x nv)
  1261. mjtNum* key_act; // key activation (nkey x na)
  1262. mjtNum* key_mpos; // key mocap position (nkey x nmocap*3)
  1263. mjtNum* key_mquat; // key mocap quaternion (nkey x nmocap*4)
  1264. mjtNum* key_ctrl; // key control (nkey x nu)
  1265. // names
  1266. int* name_bodyadr; // body name pointers (nbody x 1)
  1267. int* name_jntadr; // joint name pointers (njnt x 1)
  1268. int* name_geomadr; // geom name pointers (ngeom x 1)
  1269. int* name_siteadr; // site name pointers (nsite x 1)
  1270. int* name_camadr; // camera name pointers (ncam x 1)
  1271. int* name_lightadr; // light name pointers (nlight x 1)
  1272. int* name_flexadr; // flex name pointers (nflex x 1)
  1273. int* name_meshadr; // mesh name pointers (nmesh x 1)
  1274. int* name_skinadr; // skin name pointers (nskin x 1)
  1275. int* name_hfieldadr; // hfield name pointers (nhfield x 1)
  1276. int* name_texadr; // texture name pointers (ntex x 1)
  1277. int* name_matadr; // material name pointers (nmat x 1)
  1278. int* name_pairadr; // geom pair name pointers (npair x 1)
  1279. int* name_excludeadr; // exclude name pointers (nexclude x 1)
  1280. int* name_eqadr; // equality constraint name pointers (neq x 1)
  1281. int* name_tendonadr; // tendon name pointers (ntendon x 1)
  1282. int* name_actuatoradr; // actuator name pointers (nu x 1)
  1283. int* name_sensoradr; // sensor name pointers (nsensor x 1)
  1284. int* name_numericadr; // numeric name pointers (nnumeric x 1)
  1285. int* name_textadr; // text name pointers (ntext x 1)
  1286. int* name_tupleadr; // tuple name pointers (ntuple x 1)
  1287. int* name_keyadr; // keyframe name pointers (nkey x 1)
  1288. int* name_pluginadr; // plugin instance name pointers (nplugin x 1)
  1289. char* names; // names of all objects, 0-terminated (nnames x 1)
  1290. int* names_map; // internal hash map of names (nnames_map x 1)
  1291. // paths
  1292. char* paths; // paths to assets, 0-terminated (npaths x 1)
  1293. };
  1294. typedef struct mjModel_ mjModel;
  1295. struct mjResource_ {
  1296. char* name; // name of resource (filename, etc)
  1297. void* data; // opaque data pointer
  1298. char timestamp[512]; // timestamp of the resource
  1299. const struct mjpResourceProvider* provider; // pointer to the provider
  1300. };
  1301. typedef struct mjResource_ mjResource;
  1302. struct mjpResourceProvider {
  1303. const char* prefix; // prefix for match against a resource name
  1304. mjfOpenResource open; // opening callback
  1305. mjfReadResource read; // reading callback
  1306. mjfCloseResource close; // closing callback
  1307. mjfGetResourceDir getdir; // get directory callback (optional)
  1308. mjfResourceModified modified; // resource modified callback (optional)
  1309. void* data; // opaque data pointer (resource invariant)
  1310. };
  1311. typedef struct mjpResourceProvider mjpResourceProvider;
  1312. typedef enum mjtPluginCapabilityBit_ {
  1313. mjPLUGIN_ACTUATOR = 1<<0, // actuator forces
  1314. mjPLUGIN_SENSOR = 1<<1, // sensor measurements
  1315. mjPLUGIN_PASSIVE = 1<<2, // passive forces
  1316. mjPLUGIN_SDF = 1<<3, // signed distance fields
  1317. } mjtPluginCapabilityBit;
  1318. struct mjpPlugin_ {
  1319. const char* name; // globally unique name identifying the plugin
  1320. int nattribute; // number of configuration attributes
  1321. const char* const* attributes; // name of configuration attributes
  1322. int capabilityflags; // plugin capabilities: bitfield of mjtPluginCapabilityBit
  1323. int needstage; // sensor computation stage (mjtStage)
  1324. // number of mjtNums needed to store the state of a plugin instance (required)
  1325. int (*nstate)(const mjModel* m, int instance);
  1326. // dimension of the specified sensor's output (required only for sensor plugins)
  1327. int (*nsensordata)(const mjModel* m, int instance, int sensor_id);
  1328. // called when a new mjData is being created (required), returns 0 on success or -1 on failure
  1329. int (*init)(const mjModel* m, mjData* d, int instance);
  1330. // called when an mjData is being freed (optional)
  1331. void (*destroy)(mjData* d, int instance);
  1332. // called when an mjData is being copied (optional)
  1333. void (*copy)(mjData* dest, const mjModel* m, const mjData* src, int instance);
  1334. // called when an mjData is being reset (required)
  1335. void (*reset)(const mjModel* m, mjtNum* plugin_state, void* plugin_data, int instance);
  1336. // called when the plugin needs to update its outputs (required)
  1337. void (*compute)(const mjModel* m, mjData* d, int instance, int capability_bit);
  1338. // called when time integration occurs (optional)
  1339. void (*advance)(const mjModel* m, mjData* d, int instance);
  1340. // called by mjv_updateScene (optional)
  1341. void (*visualize)(const mjModel*m, mjData* d, const mjvOption* opt, mjvScene* scn, int instance);
  1342. // methods specific to actuators (optional)
  1343. // updates the actuator plugin's entries in act_dot
  1344. // called after native act_dot is computed and before the compute callback
  1345. void (*actuator_act_dot)(const mjModel* m, mjData* d, int instance);
  1346. // methods specific to signed distance fields (optional)
  1347. // signed distance from the surface
  1348. mjtNum (*sdf_distance)(const mjtNum point[3], const mjData* d, int instance);
  1349. // gradient of distance with respect to local coordinates
  1350. void (*sdf_gradient)(mjtNum gradient[3], const mjtNum point[3], const mjData* d, int instance);
  1351. // called during compilation for marching cubes
  1352. mjtNum (*sdf_staticdistance)(const mjtNum point[3], const mjtNum* attributes);
  1353. // convert attributes and provide defaults if not present
  1354. void (*sdf_attribute)(mjtNum attribute[], const char* name[], const char* value[]);
  1355. // bounding box of implicit surface
  1356. void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes);
  1357. };
  1358. typedef struct mjpPlugin_ mjpPlugin;
  1359. typedef enum mjtGridPos_ { // grid position for overlay
  1360. mjGRID_TOPLEFT = 0, // top left
  1361. mjGRID_TOPRIGHT, // top right
  1362. mjGRID_BOTTOMLEFT, // bottom left
  1363. mjGRID_BOTTOMRIGHT, // bottom right
  1364. mjGRID_TOP, // top center
  1365. mjGRID_BOTTOM, // bottom center
  1366. mjGRID_LEFT, // left center
  1367. mjGRID_RIGHT // right center
  1368. } mjtGridPos;
  1369. typedef enum mjtFramebuffer_ { // OpenGL framebuffer option
  1370. mjFB_WINDOW = 0, // default/window buffer
  1371. mjFB_OFFSCREEN // offscreen buffer
  1372. } mjtFramebuffer;
  1373. typedef enum mjtDepthMap_ { // depth mapping for `mjr_readPixels`
  1374. mjDEPTH_ZERONEAR = 0, // standard depth map; 0: znear, 1: zfar
  1375. mjDEPTH_ZEROFAR = 1 // reversed depth map; 1: znear, 0: zfar
  1376. } mjtDepthMap;
  1377. typedef enum mjtFontScale_ { // font scale, used at context creation
  1378. mjFONTSCALE_50 = 50, // 50% scale, suitable for low-res rendering
  1379. mjFONTSCALE_100 = 100, // normal scale, suitable in the absence of DPI scaling
  1380. mjFONTSCALE_150 = 150, // 150% scale
  1381. mjFONTSCALE_200 = 200, // 200% scale
  1382. mjFONTSCALE_250 = 250, // 250% scale
  1383. mjFONTSCALE_300 = 300 // 300% scale
  1384. } mjtFontScale;
  1385. typedef enum mjtFont_ { // font type, used at each text operation
  1386. mjFONT_NORMAL = 0, // normal font
  1387. mjFONT_SHADOW, // normal font with shadow (for higher contrast)
  1388. mjFONT_BIG // big font (for user alerts)
  1389. } mjtFont;
  1390. struct mjrRect_ { // OpenGL rectangle
  1391. int left; // left (usually 0)
  1392. int bottom; // bottom (usually 0)
  1393. int width; // width (usually buffer width)
  1394. int height; // height (usually buffer height)
  1395. };
  1396. typedef struct mjrRect_ mjrRect;
  1397. struct mjrContext_ { // custom OpenGL context
  1398. // parameters copied from mjVisual
  1399. float lineWidth; // line width for wireframe rendering
  1400. float shadowClip; // clipping radius for directional lights
  1401. float shadowScale; // fraction of light cutoff for spot lights
  1402. float fogStart; // fog start = stat.extent * vis.map.fogstart
  1403. float fogEnd; // fog end = stat.extent * vis.map.fogend
  1404. float fogRGBA[4]; // fog rgba
  1405. int shadowSize; // size of shadow map texture
  1406. int offWidth; // width of offscreen buffer
  1407. int offHeight; // height of offscreen buffer
  1408. int offSamples; // number of offscreen buffer multisamples
  1409. // parameters specified at creation
  1410. int fontScale; // font scale
  1411. int auxWidth[mjNAUX]; // auxiliary buffer width
  1412. int auxHeight[mjNAUX]; // auxiliary buffer height
  1413. int auxSamples[mjNAUX]; // auxiliary buffer multisamples
  1414. // offscreen rendering objects
  1415. unsigned int offFBO; // offscreen framebuffer object
  1416. unsigned int offFBO_r; // offscreen framebuffer for resolving multisamples
  1417. unsigned int offColor; // offscreen color buffer
  1418. unsigned int offColor_r; // offscreen color buffer for resolving multisamples
  1419. unsigned int offDepthStencil; // offscreen depth and stencil buffer
  1420. unsigned int offDepthStencil_r; // offscreen depth and stencil buffer for multisamples
  1421. // shadow rendering objects
  1422. unsigned int shadowFBO; // shadow map framebuffer object
  1423. unsigned int shadowTex; // shadow map texture
  1424. // auxiliary buffers
  1425. unsigned int auxFBO[mjNAUX]; // auxiliary framebuffer object
  1426. unsigned int auxFBO_r[mjNAUX]; // auxiliary framebuffer object for resolving
  1427. unsigned int auxColor[mjNAUX]; // auxiliary color buffer
  1428. unsigned int auxColor_r[mjNAUX]; // auxiliary color buffer for resolving
  1429. // materials with textures
  1430. int mat_texid[mjMAXMATERIAL*mjNTEXROLE]; // material texture ids (-1: no texture)
  1431. int mat_texuniform[mjMAXMATERIAL]; // texture repetition for 2d mapping
  1432. int mat_texrepeat[mjMAXMATERIAL*2]; // texture repetition for 2d mapping
  1433. // texture objects and info
  1434. int ntexture; // number of allocated textures
  1435. int textureType[mjMAXTEXTURE]; // type of texture (mjtTexture) (ntexture)
  1436. unsigned int texture[mjMAXTEXTURE]; // texture names
  1437. // displaylist starting positions
  1438. unsigned int basePlane; // all planes from model
  1439. unsigned int baseMesh; // all meshes from model
  1440. unsigned int baseHField; // all height fields from model
  1441. unsigned int baseBuiltin; // all builtin geoms, with quality from model
  1442. unsigned int baseFontNormal; // normal font
  1443. unsigned int baseFontShadow; // shadow font
  1444. unsigned int baseFontBig; // big font
  1445. // displaylist ranges
  1446. int rangePlane; // all planes from model
  1447. int rangeMesh; // all meshes from model
  1448. int rangeHField; // all hfields from model
  1449. int rangeBuiltin; // all builtin geoms, with quality from model
  1450. int rangeFont; // all characters in font
  1451. // skin VBOs
  1452. int nskin; // number of skins
  1453. unsigned int* skinvertVBO; // skin vertex position VBOs (nskin)
  1454. unsigned int* skinnormalVBO; // skin vertex normal VBOs (nskin)
  1455. unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs (nskin)
  1456. unsigned int* skinfaceVBO; // skin face index VBOs (nskin)
  1457. // character info
  1458. int charWidth[127]; // character widths: normal and shadow
  1459. int charWidthBig[127]; // chacarter widths: big
  1460. int charHeight; // character heights: normal and shadow
  1461. int charHeightBig; // character heights: big
  1462. // capabilities
  1463. int glInitialized; // is OpenGL initialized
  1464. int windowAvailable; // is default/window framebuffer available
  1465. int windowSamples; // number of samples for default/window framebuffer
  1466. int windowStereo; // is stereo available for default/window framebuffer
  1467. int windowDoublebuffer; // is default/window framebuffer double buffered
  1468. // framebuffer
  1469. int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
  1470. // pixel output format
  1471. int readPixelFormat; // default color pixel format for mjr_readPixels
  1472. // depth output format
  1473. int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR
  1474. };
  1475. typedef struct mjrContext_ mjrContext;
  1476. typedef enum mjtGeomInertia_ { // type of inertia inference
  1477. mjINERTIA_VOLUME, // mass distributed in the volume
  1478. mjINERTIA_SHELL, // mass distributed on the surface
  1479. } mjtGeomInertia;
  1480. typedef enum mjtBuiltin_ { // type of built-in procedural texture
  1481. mjBUILTIN_NONE = 0, // no built-in texture
  1482. mjBUILTIN_GRADIENT, // gradient: rgb1->rgb2
  1483. mjBUILTIN_CHECKER, // checker pattern: rgb1, rgb2
  1484. mjBUILTIN_FLAT // 2d: rgb1; cube: rgb1-up, rgb2-side, rgb3-down
  1485. } mjtBuiltin;
  1486. typedef enum mjtMark_ { // mark type for procedural textures
  1487. mjMARK_NONE = 0, // no mark
  1488. mjMARK_EDGE, // edges
  1489. mjMARK_CROSS, // cross
  1490. mjMARK_RANDOM // random dots
  1491. } mjtMark;
  1492. typedef enum mjtLimited_ { // type of limit specification
  1493. mjLIMITED_FALSE = 0, // not limited
  1494. mjLIMITED_TRUE, // limited
  1495. mjLIMITED_AUTO, // limited inferred from presence of range
  1496. } mjtLimited;
  1497. typedef enum mjtAlignFree_ { // whether to align free joints with the inertial frame
  1498. mjALIGNFREE_FALSE = 0, // don't align
  1499. mjALIGNFREE_TRUE, // align
  1500. mjALIGNFREE_AUTO, // respect the global compiler flag
  1501. } mjtAlignFree;
  1502. typedef enum mjtInertiaFromGeom_ { // whether to infer body inertias from child geoms
  1503. mjINERTIAFROMGEOM_FALSE = 0, // do not use; inertial element required
  1504. mjINERTIAFROMGEOM_TRUE, // always use; overwrite inertial element
  1505. mjINERTIAFROMGEOM_AUTO // use only if inertial element is missing
  1506. } mjtInertiaFromGeom;
  1507. typedef enum mjtOrientation_ { // type of orientation specifier
  1508. mjORIENTATION_QUAT = 0, // quaternion
  1509. mjORIENTATION_AXISANGLE, // axis and angle
  1510. mjORIENTATION_XYAXES, // x and y axes
  1511. mjORIENTATION_ZAXIS, // z axis (minimal rotation)
  1512. mjORIENTATION_EULER, // Euler angles
  1513. } mjtOrientation;
  1514. typedef struct mjsElement_ { // element type, do not modify
  1515. mjtObj elemtype; // element type
  1516. } mjsElement;
  1517. typedef struct mjSpec_ { // model specification
  1518. mjsElement* element; // element type
  1519. mjString* modelname; // model name
  1520. // compiler settings
  1521. mjtByte autolimits; // infer "limited" attribute based on range
  1522. double boundmass; // enforce minimum body mass
  1523. double boundinertia; // enforce minimum body diagonal inertia
  1524. double settotalmass; // rescale masses and inertias; <=0: ignore
  1525. mjtByte balanceinertia; // automatically impose A + B >= C rule
  1526. mjtByte strippath; // automatically strip paths from mesh files
  1527. mjtByte fitaabb; // meshfit to aabb instead of inertia box
  1528. mjtByte degree; // angles in radians or degrees
  1529. char eulerseq[3]; // sequence for euler rotations
  1530. mjString* meshdir; // mesh and hfield directory
  1531. mjString* texturedir; // texture directory
  1532. mjtByte discardvisual; // discard visual geoms in parser
  1533. mjtByte convexhull; // compute mesh convex hulls
  1534. mjtByte usethread; // use multiple threads to speed up compiler
  1535. mjtByte fusestatic; // fuse static bodies with parent
  1536. int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom)
  1537. int inertiagrouprange[2]; // range of geom groups used to compute inertia
  1538. mjtByte exactmeshinertia; // if false, use old formula
  1539. int alignfree; // align free joints with inertial frame
  1540. mjLROpt LRopt; // options for lengthrange computation
  1541. // engine data
  1542. mjOption option; // physics options
  1543. mjVisual visual; // visual options
  1544. mjStatistic stat; // statistics override (if defined)
  1545. // sizes
  1546. size_t memory; // number of bytes in arena+stack memory
  1547. int nemax; // max number of equality constraints
  1548. int nuserdata; // number of mjtNums in userdata
  1549. int nuser_body; // number of mjtNums in body_user
  1550. int nuser_jnt; // number of mjtNums in jnt_user
  1551. int nuser_geom; // number of mjtNums in geom_user
  1552. int nuser_site; // number of mjtNums in site_user
  1553. int nuser_cam; // number of mjtNums in cam_user
  1554. int nuser_tendon; // number of mjtNums in tendon_user
  1555. int nuser_actuator; // number of mjtNums in actuator_user
  1556. int nuser_sensor; // number of mjtNums in sensor_user
  1557. int nkey; // number of keyframes
  1558. int njmax; // (deprecated) max number of constraints
  1559. int nconmax; // (deprecated) max number of detected contacts
  1560. size_t nstack; // (deprecated) number of mjtNums in mjData stack
  1561. // global data
  1562. mjString* comment; // comment at top of XML
  1563. mjString* modelfiledir; // path to model file
  1564. // other
  1565. mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator
  1566. } mjSpec;
  1567. typedef struct mjsOrientation_ { // alternative orientation specifiers
  1568. mjtOrientation type; // active orientation specifier
  1569. double axisangle[4]; // axis and angle
  1570. double xyaxes[6]; // x and y axes
  1571. double zaxis[3]; // z axis (minimal rotation)
  1572. double euler[3]; // Euler angles
  1573. } mjsOrientation;
  1574. typedef struct mjsPlugin_ { // plugin specification
  1575. mjsElement* element; // element type
  1576. mjString* name; // instance name
  1577. mjString* plugin_name; // plugin name
  1578. mjtByte active; // is the plugin active
  1579. mjString* info; // message appended to compiler errors
  1580. } mjsPlugin;
  1581. typedef struct mjsBody_ { // body specification
  1582. mjsElement* element; // element type
  1583. mjString* name; // name
  1584. mjString* childclass; // childclass name
  1585. // body frame
  1586. double pos[3]; // frame position
  1587. double quat[4]; // frame orientation
  1588. mjsOrientation alt; // frame alternative orientation
  1589. // inertial frame
  1590. double mass; // mass
  1591. double ipos[3]; // inertial frame position
  1592. double iquat[4]; // inertial frame orientation
  1593. double inertia[3]; // diagonal inertia (in i-frame)
  1594. mjsOrientation ialt; // inertial frame alternative orientation
  1595. double fullinertia[6]; // non-axis-aligned inertia matrix
  1596. // other
  1597. mjtByte mocap; // is this a mocap body
  1598. double gravcomp; // gravity compensation
  1599. mjDoubleVec* userdata; // user data
  1600. mjtByte explicitinertial; // whether to save the body with explicit inertial clause
  1601. mjsPlugin plugin; // passive force plugin
  1602. mjString* info; // message appended to compiler errors
  1603. } mjsBody;
  1604. typedef struct mjsFrame_ { // frame specification
  1605. mjsElement* element; // element type
  1606. mjString* name; // name
  1607. mjString* childclass; // childclass name
  1608. double pos[3]; // position
  1609. double quat[4]; // orientation
  1610. mjsOrientation alt; // alternative orientation
  1611. mjString* info; // message appended to compiler errors
  1612. } mjsFrame;
  1613. typedef struct mjsJoint_ { // joint specification
  1614. mjsElement* element; // element type
  1615. mjString* name; // name
  1616. mjtJoint type; // joint type
  1617. // kinematics
  1618. double pos[3]; // anchor position
  1619. double axis[3]; // joint axis
  1620. double ref; // value at reference configuration: qpos0
  1621. int align; // align free joint with body com (mjtAlignFree)
  1622. // stiffness
  1623. double stiffness; // stiffness coefficient
  1624. double springref; // spring reference value: qpos_spring
  1625. double springdamper[2]; // timeconst, dampratio
  1626. // limits
  1627. int limited; // does joint have limits (mjtLimited)
  1628. double range[2]; // joint limits
  1629. double margin; // margin value for joint limit detection
  1630. mjtNum solref_limit[mjNREF]; // solver reference: joint limits
  1631. mjtNum solimp_limit[mjNIMP]; // solver impedance: joint limits
  1632. int actfrclimited; // are actuator forces on joint limited (mjtLimited)
  1633. double actfrcrange[2]; // actuator force limits
  1634. // dof properties
  1635. double armature; // armature inertia (mass for slider)
  1636. double damping; // damping coefficient
  1637. double frictionloss; // friction loss
  1638. mjtNum solref_friction[mjNREF]; // solver reference: dof friction
  1639. mjtNum solimp_friction[mjNIMP]; // solver impedance: dof friction
  1640. // other
  1641. int group; // group
  1642. mjtByte actgravcomp; // is gravcomp force applied via actuators
  1643. mjDoubleVec* userdata; // user data
  1644. mjString* info; // message appended to compiler errors
  1645. } mjsJoint;
  1646. typedef struct mjsGeom_ { // geom specification
  1647. mjsElement* element; // element type
  1648. mjString* name; // name
  1649. mjtGeom type; // geom type
  1650. // frame, size
  1651. double pos[3]; // position
  1652. double quat[4]; // orientation
  1653. mjsOrientation alt; // alternative orientation
  1654. double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
  1655. double size[3]; // type-specific size
  1656. // contact related
  1657. int contype; // contact type
  1658. int conaffinity; // contact affinity
  1659. int condim; // contact dimensionality
  1660. int priority; // contact priority
  1661. double friction[3]; // one-sided friction coefficients: slide, roll, spin
  1662. double solmix; // solver mixing for contact pairs
  1663. mjtNum solref[mjNREF]; // solver reference
  1664. mjtNum solimp[mjNIMP]; // solver impedance
  1665. double margin; // margin for contact detection
  1666. double gap; // include in solver if dist < margin-gap
  1667. // inertia inference
  1668. double mass; // used to compute density
  1669. double density; // used to compute mass and inertia from volume or surface
  1670. mjtGeomInertia typeinertia; // selects between surface and volume inertia
  1671. // fluid forces
  1672. mjtNum fluid_ellipsoid; // whether ellipsoid-fluid model is active
  1673. mjtNum fluid_coefs[5]; // ellipsoid-fluid interaction coefs
  1674. // visual
  1675. mjString* material; // name of material
  1676. float rgba[4]; // rgba when material is omitted
  1677. int group; // group
  1678. // other
  1679. mjString* hfieldname; // heightfield attached to geom
  1680. mjString* meshname; // mesh attached to geom
  1681. double fitscale; // scale mesh uniformly
  1682. mjDoubleVec* userdata; // user data
  1683. mjsPlugin plugin; // sdf plugin
  1684. mjString* info; // message appended to compiler errors
  1685. } mjsGeom;
  1686. typedef struct mjsSite_ { // site specification
  1687. mjsElement* element; // element type
  1688. mjString* name; // name
  1689. // frame, size
  1690. double pos[3]; // position
  1691. double quat[4]; // orientation
  1692. mjsOrientation alt; // alternative orientation
  1693. double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
  1694. double size[3]; // geom size
  1695. // visual
  1696. mjtGeom type; // geom type
  1697. mjString* material; // name of material
  1698. int group; // group
  1699. float rgba[4]; // rgba when material is omitted
  1700. // other
  1701. mjDoubleVec* userdata; // user data
  1702. mjString* info; // message appended to compiler errors
  1703. } mjsSite;
  1704. typedef struct mjsCamera_ { // camera specification
  1705. mjsElement* element; // element type
  1706. mjString* name; // name
  1707. // extrinsics
  1708. double pos[3]; // position
  1709. double quat[4]; // orientation
  1710. mjsOrientation alt; // alternative orientation
  1711. mjtCamLight mode; // tracking mode
  1712. mjString* targetbody; // target body for tracking/targeting
  1713. // intrinsics
  1714. int orthographic; // is camera orthographic
  1715. double fovy; // y-field of view
  1716. double ipd; // inter-pupilary distance
  1717. float intrinsic[4]; // camera intrinsics (length)
  1718. float sensor_size[2]; // sensor size (length)
  1719. float resolution[2]; // resolution (pixel)
  1720. float focal_length[2]; // focal length (length)
  1721. float focal_pixel[2]; // focal length (pixel)
  1722. float principal_length[2]; // principal point (length)
  1723. float principal_pixel[2]; // principal point (pixel)
  1724. // other
  1725. mjDoubleVec* userdata; // user data
  1726. mjString* info; // message appended to compiler errors
  1727. } mjsCamera;
  1728. typedef struct mjsLight_ { // light specification
  1729. mjsElement* element; // element type
  1730. mjString* name; // name
  1731. // frame
  1732. double pos[3]; // position
  1733. double dir[3]; // direction
  1734. mjtCamLight mode; // tracking mode
  1735. mjString* targetbody; // target body for targeting
  1736. // intrinsics
  1737. mjtByte active; // is light active
  1738. mjtByte directional; // is light directional or spot
  1739. mjtByte castshadow; // does light cast shadows
  1740. double bulbradius; // bulb radius, for soft shadows
  1741. float attenuation[3]; // OpenGL attenuation (quadratic model)
  1742. float cutoff; // OpenGL cutoff
  1743. float exponent; // OpenGL exponent
  1744. float ambient[3]; // ambient color
  1745. float diffuse[3]; // diffuse color
  1746. float specular[3]; // specular color
  1747. // other
  1748. mjString* info; // message appended to compiler errorsx
  1749. } mjsLight;
  1750. typedef struct mjsFlex_ { // flex specification
  1751. mjsElement* element; // element type
  1752. mjString* name; // name
  1753. // contact properties
  1754. int contype; // contact type
  1755. int conaffinity; // contact affinity
  1756. int condim; // contact dimensionality
  1757. int priority; // contact priority
  1758. double friction[3]; // one-sided friction coefficients: slide, roll, spin
  1759. double solmix; // solver mixing for contact pairs
  1760. mjtNum solref[mjNREF]; // solver reference
  1761. mjtNum solimp[mjNIMP]; // solver impedance
  1762. double margin; // margin for contact detection
  1763. double gap; // include in solver if dist<margin-gap
  1764. // other properties
  1765. int dim; // element dimensionality
  1766. double radius; // radius around primitive element
  1767. mjtByte internal; // enable internal collisions
  1768. mjtByte flatskin; // render flex skin with flat shading
  1769. int selfcollide; // mode for flex self colllision
  1770. int activelayers; // number of active element layers in 3D
  1771. int group; // group for visualizatioh
  1772. double edgestiffness; // edge stiffness
  1773. double edgedamping; // edge damping
  1774. float rgba[4]; // rgba when material is omitted
  1775. mjString* material; // name of material used for rendering
  1776. double young; // Young's modulus
  1777. double poisson; // Poisson's ratio
  1778. double damping; // Rayleigh's damping
  1779. double thickness; // thickness (2D only)
  1780. // mesh properties
  1781. mjStringVec* vertbody; // vertex body names
  1782. mjDoubleVec* vert; // vertex positions
  1783. mjIntVec* elem; // element vertex ids
  1784. mjFloatVec* texcoord; // vertex texture coordinates
  1785. // other
  1786. mjString* info; // message appended to compiler errors
  1787. } mjsFlex;
  1788. typedef struct mjsMesh_ { // mesh specification
  1789. mjsElement* element; // element type
  1790. mjString* name; // name
  1791. mjString* content_type; // content type of file
  1792. mjString* file; // mesh file
  1793. double refpos[3]; // reference position
  1794. double refquat[4]; // reference orientation
  1795. double scale[3]; // rescale mesh
  1796. mjtByte smoothnormal; // do not exclude large-angle faces from normals
  1797. int maxhullvert; // maximum vertex count for the convex hull
  1798. mjFloatVec* uservert; // user vertex data
  1799. mjFloatVec* usernormal; // user normal data
  1800. mjFloatVec* usertexcoord; // user texcoord data
  1801. mjIntVec* userface; // user vertex indices
  1802. mjIntVec* userfacenormal; // user normal indices
  1803. mjIntVec* userfacetexcoord; // user texcoord indices
  1804. mjsPlugin plugin; // sdf plugin
  1805. mjString* info; // message appended to compiler errors
  1806. } mjsMesh;
  1807. typedef struct mjsHField_ { // height field specification
  1808. mjsElement* element; // element type
  1809. mjString* name; // name
  1810. mjString* content_type; // content type of file
  1811. mjString* file; // file: (nrow, ncol, [elevation data])
  1812. double size[4]; // hfield size (ignore referencing geom size)
  1813. int nrow; // number of rows
  1814. int ncol; // number of columns
  1815. mjFloatVec* userdata; // user-provided elevation data
  1816. mjString* info; // message appended to compiler errors
  1817. } mjsHField;
  1818. typedef struct mjsSkin_ { // skin specification
  1819. mjsElement* element; // element type
  1820. mjString* name; // name
  1821. mjString* file; // skin file
  1822. mjString* material; // name of material used for rendering
  1823. float rgba[4]; // rgba when material is omitted
  1824. float inflate; // inflate in normal direction
  1825. int group; // group for visualization
  1826. // mesh
  1827. mjFloatVec* vert; // vertex positions
  1828. mjFloatVec* texcoord; // texture coordinates
  1829. mjIntVec* face; // faces
  1830. // skin
  1831. mjStringVec* bodyname; // body names
  1832. mjFloatVec* bindpos; // bind pos
  1833. mjFloatVec* bindquat; // bind quat
  1834. mjIntVecVec* vertid; // vertex ids
  1835. mjFloatVecVec* vertweight; // vertex weights
  1836. // other
  1837. mjString* info; // message appended to compiler errors
  1838. } mjsSkin;
  1839. typedef struct mjsTexture_ { // texture specification
  1840. mjsElement* element; // element type
  1841. mjString* name; // name
  1842. mjtTexture type; // texture type
  1843. // method 1: builtin
  1844. int builtin; // builtin type (mjtBuiltin)
  1845. int mark; // mark type (mjtMark)
  1846. double rgb1[3]; // first color for builtin
  1847. double rgb2[3]; // second color for builtin
  1848. double markrgb[3]; // mark color
  1849. double random; // probability of random dots
  1850. int height; // height in pixels (square for cube and skybox)
  1851. int width; // width in pixels
  1852. int nchannel; // number of channels
  1853. // method 2: single file
  1854. mjString* content_type; // content type of file
  1855. mjString* file; // png file to load; use for all sides of cube
  1856. int gridsize[2]; // size of grid for composite file; (1,1)-repeat
  1857. char gridlayout[13]; // row-major: L,R,F,B,U,D for faces; . for unused
  1858. // method 3: separate files
  1859. mjStringVec* cubefiles; // different file for each side of the cube
  1860. // method 4: from buffer read by user
  1861. mjByteVec* data; // texture data
  1862. // flip options
  1863. mjtByte hflip; // horizontal flip
  1864. mjtByte vflip; // vertical flip
  1865. // other
  1866. mjString* info; // message appended to compiler errors
  1867. } mjsTexture;
  1868. typedef struct mjsMaterial_ { // material specification
  1869. mjsElement* element; // element type
  1870. mjString* name; // name
  1871. mjStringVec* textures; // names of textures (empty: none)
  1872. mjtByte texuniform; // make texture cube uniform
  1873. float texrepeat[2]; // texture repetition for 2D mapping
  1874. float emission; // emission
  1875. float specular; // specular
  1876. float shininess; // shininess
  1877. float reflectance; // reflectance
  1878. float metallic; // metallic
  1879. float roughness; // roughness
  1880. float rgba[4]; // rgba
  1881. mjString* info; // message appended to compiler errors
  1882. } mjsMaterial;
  1883. typedef struct mjsPair_ { // pair specification
  1884. mjsElement* element; // element type
  1885. mjString* name; // name
  1886. mjString* geomname1; // name of geom 1
  1887. mjString* geomname2; // name of geom 2
  1888. // optional parameters: computed from geoms if not set by user
  1889. int condim; // contact dimensionality
  1890. mjtNum solref[mjNREF]; // solver reference, normal direction
  1891. mjtNum solreffriction[mjNREF]; // solver reference, frictional directions
  1892. mjtNum solimp[mjNIMP]; // solver impedance
  1893. double margin; // margin for contact detection
  1894. double gap; // include in solver if dist<margin-gap
  1895. double friction[5]; // full contact friction
  1896. mjString* info; // message appended to errors
  1897. } mjsPair;
  1898. typedef struct mjsExclude_ { // exclude specification
  1899. mjsElement* element; // element type
  1900. mjString* name; // name
  1901. mjString* bodyname1; // name of geom 1
  1902. mjString* bodyname2; // name of geom 2
  1903. mjString* info; // message appended to errors
  1904. } mjsExclude;
  1905. typedef struct mjsEquality_ { // equality specification
  1906. mjsElement* element; // element type
  1907. mjString* name; // name
  1908. mjtEq type; // constraint type
  1909. double data[mjNEQDATA]; // type-dependent data
  1910. mjtByte active; // is equality initially active
  1911. mjString* name1; // name of object 1
  1912. mjString* name2; // name of object 2
  1913. mjtObj objtype; // type of both objects
  1914. mjtNum solref[mjNREF]; // solver reference
  1915. mjtNum solimp[mjNIMP]; // solver impedance
  1916. mjString* info; // message appended to errors
  1917. } mjsEquality;
  1918. typedef struct mjsTendon_ { // tendon specification
  1919. mjsElement* element; // element type
  1920. mjString* name; // name
  1921. // stiffness, damping, friction
  1922. double stiffness; // stiffness coefficient
  1923. double springlength[2]; // spring resting length; {-1, -1}: use qpos_spring
  1924. double damping; // damping coefficient
  1925. double frictionloss; // friction loss
  1926. mjtNum solref_friction[mjNREF]; // solver reference: tendon friction
  1927. mjtNum solimp_friction[mjNIMP]; // solver impedance: tendon friction
  1928. // length range
  1929. int limited; // does tendon have limits (mjtLimited)
  1930. double range[2]; // length limits
  1931. double margin; // margin value for tendon limit detection
  1932. mjtNum solref_limit[mjNREF]; // solver reference: tendon limits
  1933. mjtNum solimp_limit[mjNIMP]; // solver impedance: tendon limits
  1934. // visual
  1935. mjString* material; // name of material for rendering
  1936. double width; // width for rendering
  1937. float rgba[4]; // rgba when material is omitted
  1938. int group; // group
  1939. // other
  1940. mjDoubleVec* userdata; // user data
  1941. mjString* info; // message appended to errors
  1942. } mjsTendon;
  1943. typedef struct mjsWrap_ { // wrapping object specification
  1944. mjsElement* element; // element type
  1945. mjString* info; // message appended to errors
  1946. } mjsWrap;
  1947. typedef struct mjsActuator_ { // actuator specification
  1948. mjsElement* element; // element type
  1949. mjString* name; // name
  1950. // gain, bias
  1951. mjtGain gaintype; // gain type
  1952. double gainprm[mjNGAIN]; // gain parameters
  1953. mjtBias biastype; // bias type
  1954. double biasprm[mjNGAIN]; // bias parameters
  1955. // activation state
  1956. mjtDyn dyntype; // dynamics type
  1957. double dynprm[mjNDYN]; // dynamics parameters
  1958. int actdim; // number of activation variables
  1959. mjtByte actearly; // apply next activations to qfrc
  1960. // transmission
  1961. mjtTrn trntype; // transmission type
  1962. double gear[6]; // length and transmitted force scaling
  1963. mjString* target; // name of transmission target
  1964. mjString* refsite; // reference site, for site transmission
  1965. mjString* slidersite; // site defining cylinder, for slider-crank
  1966. double cranklength; // crank length, for slider-crank
  1967. double lengthrange[2]; // transmission length range
  1968. double inheritrange; // automatic range setting for position and intvelocity
  1969. // input/output clamping
  1970. int ctrllimited; // are control limits defined (mjtLimited)
  1971. double ctrlrange[2]; // control range
  1972. int forcelimited; // are force limits defined (mjtLimited)
  1973. double forcerange[2]; // force range
  1974. int actlimited; // are activation limits defined (mjtLimited)
  1975. double actrange[2]; // activation range
  1976. // other
  1977. int group; // group
  1978. mjDoubleVec* userdata; // user data
  1979. mjsPlugin plugin; // actuator plugin
  1980. mjString* info; // message appended to compiler errors
  1981. } mjsActuator;
  1982. typedef struct mjsSensor_ { // sensor specification
  1983. mjsElement* element; // element type
  1984. mjString* name; // name
  1985. // sensor definition
  1986. mjtSensor type; // type of sensor
  1987. mjtObj objtype; // type of sensorized object
  1988. mjString* objname; // name of sensorized object
  1989. mjtObj reftype; // type of referenced object
  1990. mjString* refname; // name of referenced object
  1991. // user-defined sensors
  1992. mjtDataType datatype; // data type for sensor measurement
  1993. mjtStage needstage; // compute stage needed to simulate sensor
  1994. int dim; // number of scalar outputs
  1995. // output post-processing
  1996. double cutoff; // cutoff for real and positive datatypes
  1997. double noise; // noise stdev
  1998. // other
  1999. mjDoubleVec* userdata; // user data
  2000. mjsPlugin plugin; // sensor plugin
  2001. mjString* info; // message appended to compiler errors
  2002. } mjsSensor;
  2003. typedef struct mjsNumeric_ { // custom numeric field specification
  2004. mjsElement* element; // element type
  2005. mjString* name; // name
  2006. mjDoubleVec* data; // initialization data
  2007. int size; // array size, can be bigger than data size
  2008. mjString* info; // message appended to compiler errors
  2009. } mjsNumeric;
  2010. typedef struct mjsText_ { // custom text specification
  2011. mjsElement* element; // element type
  2012. mjString* name; // name
  2013. mjString* data; // text string
  2014. mjString* info; // message appended to compiler errors
  2015. } mjsText;
  2016. typedef struct mjsTuple_ { // tuple specification
  2017. mjsElement* element; // element type
  2018. mjString* name; // name
  2019. mjIntVec* objtype; // object types
  2020. mjStringVec* objname; // object names
  2021. mjDoubleVec* objprm; // object parameters
  2022. mjString* info; // message appended to compiler errors
  2023. } mjsTuple;
  2024. typedef struct mjsKey_ { // keyframe specification
  2025. mjsElement* element; // element type
  2026. mjString* name; // name
  2027. double time; // time
  2028. mjDoubleVec* qpos; // qpos
  2029. mjDoubleVec* qvel; // qvel
  2030. mjDoubleVec* act; // act
  2031. mjDoubleVec* mpos; // mocap pos
  2032. mjDoubleVec* mquat; // mocap quat
  2033. mjDoubleVec* ctrl; // ctrl
  2034. mjString* info; // message appended to compiler errors
  2035. } mjsKey;
  2036. typedef struct mjsDefault_ { // default specification
  2037. mjsElement* element; // element type
  2038. mjString* name; // class name
  2039. mjsJoint* joint; // joint defaults
  2040. mjsGeom* geom; // geom defaults
  2041. mjsSite* site; // site defaults
  2042. mjsCamera* camera; // camera defaults
  2043. mjsLight* light; // light defaults
  2044. mjsFlex* flex; // flex defaults
  2045. mjsMesh* mesh; // mesh defaults
  2046. mjsMaterial* material; // material defaults
  2047. mjsPair* pair; // pair defaults
  2048. mjsEquality* equality; // equality defaults
  2049. mjsTendon* tendon; // tendon defaults
  2050. mjsActuator* actuator; // actuator defaults
  2051. } mjsDefault;
  2052. typedef enum mjtTaskStatus_ { // status values for mjTask
  2053. mjTASK_NEW = 0, // newly created
  2054. mjTASK_QUEUED, // enqueued in a thread pool
  2055. mjTASK_COMPLETED // completed execution
  2056. } mjtTaskStatus;
  2057. struct mjThreadPool_ {
  2058. int nworker; // number of workers in the pool
  2059. };
  2060. typedef struct mjThreadPool_ mjThreadPool;
  2061. struct mjTask_ { // a task that can be executed by a thread pool.
  2062. mjfTask func; // pointer to the function that implements the task
  2063. void* args; // arguments to func
  2064. volatile int status; // status of the task
  2065. };
  2066. typedef struct mjTask_ mjTask;
  2067. typedef enum mjtButton_ { // mouse button
  2068. mjBUTTON_NONE = 0, // no button
  2069. mjBUTTON_LEFT, // left button
  2070. mjBUTTON_RIGHT, // right button
  2071. mjBUTTON_MIDDLE // middle button
  2072. } mjtButton;
  2073. typedef enum mjtEvent_ { // mouse and keyboard event type
  2074. mjEVENT_NONE = 0, // no event
  2075. mjEVENT_MOVE, // mouse move
  2076. mjEVENT_PRESS, // mouse button press
  2077. mjEVENT_RELEASE, // mouse button release
  2078. mjEVENT_SCROLL, // scroll
  2079. mjEVENT_KEY, // key press
  2080. mjEVENT_RESIZE, // resize
  2081. mjEVENT_REDRAW, // redraw
  2082. mjEVENT_FILESDROP // files drop
  2083. } mjtEvent;
  2084. typedef enum mjtItem_ { // UI item type
  2085. mjITEM_END = -2, // end of definition list (not an item)
  2086. mjITEM_SECTION = -1, // section (not an item)
  2087. mjITEM_SEPARATOR = 0, // separator
  2088. mjITEM_STATIC, // static text
  2089. mjITEM_BUTTON, // button
  2090. // the rest have data pointer
  2091. mjITEM_CHECKINT, // check box, int value
  2092. mjITEM_CHECKBYTE, // check box, mjtByte value
  2093. mjITEM_RADIO, // radio group
  2094. mjITEM_RADIOLINE, // radio group, single line
  2095. mjITEM_SELECT, // selection box
  2096. mjITEM_SLIDERINT, // slider, int value
  2097. mjITEM_SLIDERNUM, // slider, mjtNum value
  2098. mjITEM_EDITINT, // editable array, int values
  2099. mjITEM_EDITNUM, // editable array, mjtNum values
  2100. mjITEM_EDITFLOAT, // editable array, float values
  2101. mjITEM_EDITTXT, // editable text
  2102. mjNITEM // number of item types
  2103. } mjtItem;
  2104. typedef enum mjtSection_ { // UI section state
  2105. mjSECT_CLOSED = 0, // closed state (regular section)
  2106. mjSECT_OPEN, // open state (regular section)
  2107. mjSECT_FIXED // fixed section: always open, no title
  2108. } mjtSection;
  2109. struct mjuiState_ { // mouse and keyboard state
  2110. // constants set by user
  2111. int nrect; // number of rectangles used
  2112. mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window)
  2113. void* userdata; // pointer to user data (for callbacks)
  2114. // event type
  2115. int type; // (type mjtEvent)
  2116. // mouse buttons
  2117. int left; // is left button down
  2118. int right; // is right button down
  2119. int middle; // is middle button down
  2120. int doubleclick; // is last press a double click
  2121. int button; // which button was pressed (mjtButton)
  2122. double buttontime; // time of last button press
  2123. // mouse position
  2124. double x; // x position
  2125. double y; // y position
  2126. double dx; // x displacement
  2127. double dy; // y displacement
  2128. double sx; // x scroll
  2129. double sy; // y scroll
  2130. // keyboard
  2131. int control; // is control down
  2132. int shift; // is shift down
  2133. int alt; // is alt down
  2134. int key; // which key was pressed
  2135. double keytime; // time of last key press
  2136. // rectangle ownership and dragging
  2137. int mouserect; // which rectangle contains mouse
  2138. int dragrect; // which rectangle is dragged with mouse
  2139. int dragbutton; // which button started drag (mjtButton)
  2140. // files dropping (only valid when type == mjEVENT_FILESDROP)
  2141. int dropcount; // number of files dropped
  2142. const char** droppaths; // paths to files dropped
  2143. };
  2144. typedef struct mjuiState_ mjuiState;
  2145. struct mjuiThemeSpacing_ { // UI visualization theme spacing
  2146. int total; // total width
  2147. int scroll; // scrollbar width
  2148. int label; // label width
  2149. int section; // section gap
  2150. int cornersect; // corner radius for section
  2151. int cornersep; // corner radius for separator
  2152. int itemside; // item side gap
  2153. int itemmid; // item middle gap
  2154. int itemver; // item vertical gap
  2155. int texthor; // text horizontal gap
  2156. int textver; // text vertical gap
  2157. int linescroll; // number of pixels to scroll
  2158. int samples; // number of multisamples
  2159. };
  2160. typedef struct mjuiThemeSpacing_ mjuiThemeSpacing;
  2161. struct mjuiThemeColor_ { // UI visualization theme color
  2162. float master[3]; // master background
  2163. float thumb[3]; // scrollbar thumb
  2164. float secttitle[3]; // section title
  2165. float secttitle2[3]; // section title: bottom color
  2166. float secttitleuncheck[3]; // section title with unchecked box
  2167. float secttitleuncheck2[3]; // section title with unchecked box: bottom color
  2168. float secttitlecheck[3]; // section title with checked box
  2169. float secttitlecheck2[3]; // section title with checked box: bottom color
  2170. float sectfont[3]; // section font
  2171. float sectsymbol[3]; // section symbol
  2172. float sectpane[3]; // section pane
  2173. float separator[3]; // separator title
  2174. float separator2[3]; // separator title: bottom color
  2175. float shortcut[3]; // shortcut background
  2176. float fontactive[3]; // font active
  2177. float fontinactive[3]; // font inactive
  2178. float decorinactive[3]; // decor inactive
  2179. float decorinactive2[3]; // inactive slider color 2
  2180. float button[3]; // button
  2181. float check[3]; // check
  2182. float radio[3]; // radio
  2183. float select[3]; // select
  2184. float select2[3]; // select pane
  2185. float slider[3]; // slider
  2186. float slider2[3]; // slider color 2
  2187. float edit[3]; // edit
  2188. float edit2[3]; // edit invalid
  2189. float cursor[3]; // edit cursor
  2190. };
  2191. typedef struct mjuiThemeColor_ mjuiThemeColor;
  2192. struct mjuiItemSingle_ { // check and button-related
  2193. int modifier; // 0: none, 1: control, 2: shift; 4: alt
  2194. int shortcut; // shortcut key; 0: undefined
  2195. };
  2196. struct mjuiItemMulti_ { // static, radio and select-related
  2197. int nelem; // number of elements in group
  2198. char name[mjMAXUIMULTI][mjMAXUINAME]; // element names
  2199. };
  2200. struct mjuiItemSlider_ { // slider-related
  2201. double range[2]; // slider range
  2202. double divisions; // number of range divisions
  2203. };
  2204. struct mjuiItemEdit_ { // edit-related
  2205. int nelem; // number of elements in list
  2206. double range[mjMAXUIEDIT][2]; // element range (min>=max: ignore)
  2207. };
  2208. struct mjuiItem_ { // UI item
  2209. // common properties
  2210. int type; // type (mjtItem)
  2211. char name[mjMAXUINAME]; // name
  2212. int state; // 0: disable, 1: enable, 2+: use predicate
  2213. void *pdata; // data pointer (type-specific)
  2214. int sectionid; // id of section containing item
  2215. int itemid; // id of item within section
  2216. int userid; // user-supplied id (for event handling)
  2217. // type-specific properties
  2218. union {
  2219. struct mjuiItemSingle_ single; // check and button
  2220. struct mjuiItemMulti_ multi; // static, radio and select
  2221. struct mjuiItemSlider_ slider; // slider
  2222. struct mjuiItemEdit_ edit; // edit
  2223. };
  2224. // internal
  2225. mjrRect rect; // rectangle occupied by item
  2226. int skip; // item skipped due to closed separator
  2227. };
  2228. typedef struct mjuiItem_ mjuiItem;
  2229. struct mjuiSection_ { // UI section
  2230. // properties
  2231. char name[mjMAXUINAME]; // name
  2232. int state; // section state (mjtSection)
  2233. int modifier; // 0: none, 1: control, 2: shift; 4: alt
  2234. int shortcut; // shortcut key; 0: undefined
  2235. int checkbox; // 0: none, 1: unchecked, 2: checked
  2236. int nitem; // number of items in use
  2237. mjuiItem item[mjMAXUIITEM]; // preallocated array of items
  2238. // internal
  2239. mjrRect rtitle; // rectangle occupied by title
  2240. mjrRect rcontent; // rectangle occupied by content
  2241. int lastclick; // last mouse click over this section
  2242. };
  2243. typedef struct mjuiSection_ mjuiSection;
  2244. struct mjUI_ { // entire UI
  2245. // constants set by user
  2246. mjuiThemeSpacing spacing; // UI theme spacing
  2247. mjuiThemeColor color; // UI theme color
  2248. mjfItemEnable predicate; // callback to set item state programmatically
  2249. void* userdata; // pointer to user data (passed to predicate)
  2250. int rectid; // index of this ui rectangle in mjuiState
  2251. int auxid; // aux buffer index of this ui
  2252. int radiocol; // number of radio columns (0 defaults to 2)
  2253. // UI sizes (framebuffer units)
  2254. int width; // width
  2255. int height; // current heigth
  2256. int maxheight; // height when all sections open
  2257. int scroll; // scroll from top of UI
  2258. // mouse focus and count
  2259. int mousesect; // 0: none, -1: scroll, otherwise 1+section
  2260. int mouseitem; // item within section
  2261. int mousehelp; // help button down: print shortcuts
  2262. int mouseclicks; // number of mouse clicks over UI
  2263. int mousesectcheck; // 0: none, otherwise 1+section
  2264. // keyboard focus and edit
  2265. int editsect; // 0: none, otherwise 1+section
  2266. int edititem; // item within section
  2267. int editcursor; // cursor position
  2268. int editscroll; // horizontal scroll
  2269. char edittext[mjMAXUITEXT]; // current text
  2270. mjuiItem* editchanged; // pointer to changed edit in last mjui_event
  2271. // sections
  2272. int nsect; // number of sections in use
  2273. mjuiSection sect[mjMAXUISECT]; // preallocated array of sections
  2274. };
  2275. typedef struct mjUI_ mjUI;
  2276. struct mjuiDef_ { // table passed to mjui_add()
  2277. int type; // type (mjtItem); -1: section
  2278. char name[mjMAXUINAME]; // name
  2279. int state; // state
  2280. void* pdata; // pointer to data
  2281. char other[mjMAXUITEXT]; // string with type-specific properties
  2282. int otherint; // int with type-specific properties
  2283. };
  2284. typedef struct mjuiDef_ mjuiDef;
  2285. typedef enum mjtCatBit_ { // bitflags for mjvGeom category
  2286. mjCAT_STATIC = 1, // model elements in body 0
  2287. mjCAT_DYNAMIC = 2, // model elements in all other bodies
  2288. mjCAT_DECOR = 4, // decorative geoms
  2289. mjCAT_ALL = 7 // select all categories
  2290. } mjtCatBit;
  2291. typedef enum mjtMouse_ { // mouse interaction mode
  2292. mjMOUSE_NONE = 0, // no action
  2293. mjMOUSE_ROTATE_V, // rotate, vertical plane
  2294. mjMOUSE_ROTATE_H, // rotate, horizontal plane
  2295. mjMOUSE_MOVE_V, // move, vertical plane
  2296. mjMOUSE_MOVE_H, // move, horizontal plane
  2297. mjMOUSE_ZOOM, // zoom
  2298. mjMOUSE_SELECT // selection
  2299. } mjtMouse;
  2300. typedef enum mjtPertBit_ { // mouse perturbations
  2301. mjPERT_TRANSLATE = 1, // translation
  2302. mjPERT_ROTATE = 2 // rotation
  2303. } mjtPertBit;
  2304. typedef enum mjtCamera_ { // abstract camera type
  2305. mjCAMERA_FREE = 0, // free camera
  2306. mjCAMERA_TRACKING, // tracking camera; uses trackbodyid
  2307. mjCAMERA_FIXED, // fixed camera; uses fixedcamid
  2308. mjCAMERA_USER // user is responsible for setting OpenGL camera
  2309. } mjtCamera;
  2310. typedef enum mjtLabel_ { // object labeling
  2311. mjLABEL_NONE = 0, // nothing
  2312. mjLABEL_BODY, // body labels
  2313. mjLABEL_JOINT, // joint labels
  2314. mjLABEL_GEOM, // geom labels
  2315. mjLABEL_SITE, // site labels
  2316. mjLABEL_CAMERA, // camera labels
  2317. mjLABEL_LIGHT, // light labels
  2318. mjLABEL_TENDON, // tendon labels
  2319. mjLABEL_ACTUATOR, // actuator labels
  2320. mjLABEL_CONSTRAINT, // constraint labels
  2321. mjLABEL_FLEX, // flex labels
  2322. mjLABEL_SKIN, // skin labels
  2323. mjLABEL_SELECTION, // selected object
  2324. mjLABEL_SELPNT, // coordinates of selection point
  2325. mjLABEL_CONTACTPOINT, // contact information
  2326. mjLABEL_CONTACTFORCE, // magnitude of contact force
  2327. mjLABEL_ISLAND, // id of island
  2328. mjNLABEL // number of label types
  2329. } mjtLabel;
  2330. typedef enum mjtFrame_ { // frame visualization
  2331. mjFRAME_NONE = 0, // no frames
  2332. mjFRAME_BODY, // body frames
  2333. mjFRAME_GEOM, // geom frames
  2334. mjFRAME_SITE, // site frames
  2335. mjFRAME_CAMERA, // camera frames
  2336. mjFRAME_LIGHT, // light frames
  2337. mjFRAME_CONTACT, // contact frames
  2338. mjFRAME_WORLD, // world frame
  2339. mjNFRAME // number of visualization frames
  2340. } mjtFrame;
  2341. typedef enum mjtVisFlag_ { // flags enabling model element visualization
  2342. mjVIS_CONVEXHULL = 0, // mesh convex hull
  2343. mjVIS_TEXTURE, // textures
  2344. mjVIS_JOINT, // joints
  2345. mjVIS_CAMERA, // cameras
  2346. mjVIS_ACTUATOR, // actuators
  2347. mjVIS_ACTIVATION, // activations
  2348. mjVIS_LIGHT, // lights
  2349. mjVIS_TENDON, // tendons
  2350. mjVIS_RANGEFINDER, // rangefinder sensors
  2351. mjVIS_CONSTRAINT, // point constraints
  2352. mjVIS_INERTIA, // equivalent inertia boxes
  2353. mjVIS_SCLINERTIA, // scale equivalent inertia boxes with mass
  2354. mjVIS_PERTFORCE, // perturbation force
  2355. mjVIS_PERTOBJ, // perturbation object
  2356. mjVIS_CONTACTPOINT, // contact points
  2357. mjVIS_ISLAND, // constraint islands
  2358. mjVIS_CONTACTFORCE, // contact force
  2359. mjVIS_CONTACTSPLIT, // split contact force into normal and tangent
  2360. mjVIS_TRANSPARENT, // make dynamic geoms more transparent
  2361. mjVIS_AUTOCONNECT, // auto connect joints and body coms
  2362. mjVIS_COM, // center of mass
  2363. mjVIS_SELECT, // selection point
  2364. mjVIS_STATIC, // static bodies
  2365. mjVIS_SKIN, // skin
  2366. mjVIS_FLEXVERT, // flex vertices
  2367. mjVIS_FLEXEDGE, // flex edges
  2368. mjVIS_FLEXFACE, // flex element faces
  2369. mjVIS_FLEXSKIN, // flex smooth skin (disables the rest)
  2370. mjVIS_BODYBVH, // body bounding volume hierarchy
  2371. mjVIS_FLEXBVH, // flex bounding volume hierarchy
  2372. mjVIS_MESHBVH, // mesh bounding volume hierarchy
  2373. mjVIS_SDFITER, // iterations of SDF gradient descent
  2374. mjNVISFLAG // number of visualization flags
  2375. } mjtVisFlag;
  2376. typedef enum mjtRndFlag_ { // flags enabling rendering effects
  2377. mjRND_SHADOW = 0, // shadows
  2378. mjRND_WIREFRAME, // wireframe
  2379. mjRND_REFLECTION, // reflections
  2380. mjRND_ADDITIVE, // additive transparency
  2381. mjRND_SKYBOX, // skybox
  2382. mjRND_FOG, // fog
  2383. mjRND_HAZE, // haze
  2384. mjRND_SEGMENT, // segmentation with random color
  2385. mjRND_IDCOLOR, // segmentation with segid+1 color
  2386. mjRND_CULL_FACE, // cull backward faces
  2387. mjNRNDFLAG // number of rendering flags
  2388. } mjtRndFlag;
  2389. typedef enum mjtStereo_ { // type of stereo rendering
  2390. mjSTEREO_NONE = 0, // no stereo; use left eye only
  2391. mjSTEREO_QUADBUFFERED, // quad buffered; revert to side-by-side if no hardware support
  2392. mjSTEREO_SIDEBYSIDE // side-by-side
  2393. } mjtStereo;
  2394. struct mjvPerturb_ { // object selection and perturbation
  2395. int select; // selected body id; non-positive: none
  2396. int flexselect; // selected flex id; negative: none
  2397. int skinselect; // selected skin id; negative: none
  2398. int active; // perturbation bitmask (mjtPertBit)
  2399. int active2; // secondary perturbation bitmask (mjtPertBit)
  2400. mjtNum refpos[3]; // reference position for selected object
  2401. mjtNum refquat[4]; // reference orientation for selected object
  2402. mjtNum refselpos[3]; // reference position for selection point
  2403. mjtNum localpos[3]; // selection point in object coordinates
  2404. mjtNum localmass; // spatial inertia at selection point
  2405. mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb)
  2406. };
  2407. typedef struct mjvPerturb_ mjvPerturb;
  2408. struct mjvCamera_ { // abstract camera
  2409. // type and ids
  2410. int type; // camera type (mjtCamera)
  2411. int fixedcamid; // fixed camera id
  2412. int trackbodyid; // body id to track
  2413. // abstract camera pose specification
  2414. mjtNum lookat[3]; // lookat point
  2415. mjtNum distance; // distance to lookat point or tracked body
  2416. mjtNum azimuth; // camera azimuth (deg)
  2417. mjtNum elevation; // camera elevation (deg)
  2418. // orthographic / perspective
  2419. int orthographic; // 0: perspective; 1: orthographic
  2420. };
  2421. typedef struct mjvCamera_ mjvCamera;
  2422. struct mjvGLCamera_ { // OpenGL camera
  2423. // camera frame
  2424. float pos[3]; // position
  2425. float forward[3]; // forward direction
  2426. float up[3]; // up direction
  2427. // camera projection
  2428. float frustum_center; // hor. center (left,right set to match aspect)
  2429. float frustum_width; // width (not used for rendering)
  2430. float frustum_bottom; // bottom
  2431. float frustum_top; // top
  2432. float frustum_near; // near
  2433. float frustum_far; // far
  2434. // orthographic / perspective
  2435. int orthographic; // 0: perspective; 1: orthographic
  2436. };
  2437. typedef struct mjvGLCamera_ mjvGLCamera;
  2438. struct mjvGeom_ { // abstract geom
  2439. // type info
  2440. int type; // geom type (mjtGeom)
  2441. int dataid; // mesh, hfield or plane id; -1: none
  2442. int objtype; // mujoco object type; mjOBJ_UNKNOWN for decor
  2443. int objid; // mujoco object id; -1 for decor
  2444. int category; // visual category
  2445. int matid; // material id; -1: no textured material
  2446. int texcoord; // mesh or flex geom has texture coordinates
  2447. int segid; // segmentation id; -1: not shown
  2448. // spatial transform
  2449. float size[3]; // size parameters
  2450. float pos[3]; // Cartesian position
  2451. float mat[9]; // Cartesian orientation
  2452. // material properties
  2453. float rgba[4]; // color and transparency
  2454. float emission; // emission coef
  2455. float specular; // specular coef
  2456. float shininess; // shininess coef
  2457. float reflectance; // reflectance coef
  2458. char label[100]; // text label
  2459. // transparency rendering (set internally)
  2460. float camdist; // distance to camera (used by sorter)
  2461. float modelrbound; // geom rbound from model, 0 if not model geom
  2462. mjtByte transparent; // treat geom as transparent
  2463. };
  2464. typedef struct mjvGeom_ mjvGeom;
  2465. struct mjvLight_ { // OpenGL light
  2466. float pos[3]; // position rel. to body frame
  2467. float dir[3]; // direction rel. to body frame
  2468. float attenuation[3]; // OpenGL attenuation (quadratic model)
  2469. float cutoff; // OpenGL cutoff
  2470. float exponent; // OpenGL exponent
  2471. float ambient[3]; // ambient rgb (alpha=1)
  2472. float diffuse[3]; // diffuse rgb (alpha=1)
  2473. float specular[3]; // specular rgb (alpha=1)
  2474. mjtByte headlight; // headlight
  2475. mjtByte directional; // directional light
  2476. mjtByte castshadow; // does light cast shadows
  2477. float bulbradius; // bulb radius for soft shadows
  2478. };
  2479. typedef struct mjvLight_ mjvLight;
  2480. struct mjvOption_ { // abstract visualization options
  2481. int label; // what objects to label (mjtLabel)
  2482. int frame; // which frame to show (mjtFrame)
  2483. mjtByte geomgroup[mjNGROUP]; // geom visualization by group
  2484. mjtByte sitegroup[mjNGROUP]; // site visualization by group
  2485. mjtByte jointgroup[mjNGROUP]; // joint visualization by group
  2486. mjtByte tendongroup[mjNGROUP]; // tendon visualization by group
  2487. mjtByte actuatorgroup[mjNGROUP]; // actuator visualization by group
  2488. mjtByte flexgroup[mjNGROUP]; // flex visualization by group
  2489. mjtByte skingroup[mjNGROUP]; // skin visualization by group
  2490. mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag)
  2491. int bvh_depth; // depth of the bounding volume hierarchy to be visualized
  2492. int flex_layer; // element layer to be visualized for 3D flex
  2493. };
  2494. typedef struct mjvOption_ mjvOption;
  2495. struct mjvScene_ { // abstract scene passed to OpenGL renderer
  2496. // abstract geoms
  2497. int maxgeom; // size of allocated geom buffer
  2498. int ngeom; // number of geoms currently in buffer
  2499. mjvGeom* geoms; // buffer for geoms (ngeom)
  2500. int* geomorder; // buffer for ordering geoms by distance to camera (ngeom)
  2501. // flex data
  2502. int nflex; // number of flexes
  2503. int* flexedgeadr; // address of flex edges (nflex)
  2504. int* flexedgenum; // number of edges in flex (nflex)
  2505. int* flexvertadr; // address of flex vertices (nflex)
  2506. int* flexvertnum; // number of vertices in flex (nflex)
  2507. int* flexfaceadr; // address of flex faces (nflex)
  2508. int* flexfacenum; // number of flex faces allocated (nflex)
  2509. int* flexfaceused; // number of flex faces currently in use (nflex)
  2510. int* flexedge; // flex edge data (2*nflexedge)
  2511. float* flexvert; // flex vertices (3*nflexvert)
  2512. float* flexface; // flex faces vertices (9*sum(flexfacenum))
  2513. float* flexnormal; // flex face normals (9*sum(flexfacenum))
  2514. float* flextexcoord; // flex face texture coordinates (6*sum(flexfacenum))
  2515. mjtByte flexvertopt; // copy of mjVIS_FLEXVERT mjvOption flag
  2516. mjtByte flexedgeopt; // copy of mjVIS_FLEXEDGE mjvOption flag
  2517. mjtByte flexfaceopt; // copy of mjVIS_FLEXFACE mjvOption flag
  2518. mjtByte flexskinopt; // copy of mjVIS_FLEXSKIN mjvOption flag
  2519. // skin data
  2520. int nskin; // number of skins
  2521. int* skinfacenum; // number of faces in skin (nskin)
  2522. int* skinvertadr; // address of skin vertices (nskin)
  2523. int* skinvertnum; // number of vertices in skin (nskin)
  2524. float* skinvert; // skin vertex data (3*nskinvert)
  2525. float* skinnormal; // skin normal data (3*nskinvert)
  2526. // OpenGL lights
  2527. int nlight; // number of lights currently in buffer
  2528. mjvLight lights[mjMAXLIGHT]; // buffer for lights (nlight)
  2529. // OpenGL cameras
  2530. mjvGLCamera camera[2]; // left and right camera
  2531. // OpenGL model transformation
  2532. mjtByte enabletransform; // enable model transformation
  2533. float translate[3]; // model translation
  2534. float rotate[4]; // model quaternion rotation
  2535. float scale; // model scaling
  2536. // OpenGL rendering effects
  2537. int stereo; // stereoscopic rendering (mjtStereo)
  2538. mjtByte flags[mjNRNDFLAG]; // rendering flags (indexed by mjtRndFlag)
  2539. // framing
  2540. int framewidth; // frame pixel width; 0: disable framing
  2541. float framergb[3]; // frame color
  2542. };
  2543. typedef struct mjvScene_ mjvScene;
  2544. struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer
  2545. // enable flags
  2546. int flg_legend; // show legend
  2547. int flg_ticklabel[2]; // show grid tick labels (x,y)
  2548. int flg_extend; // automatically extend axis ranges to fit data
  2549. int flg_barplot; // isolated line segments (i.e. GL_LINES)
  2550. int flg_selection; // vertical selection line
  2551. int flg_symmetric; // symmetric y-axis
  2552. // style settings
  2553. float linewidth; // line width
  2554. float gridwidth; // grid line width
  2555. int gridsize[2]; // number of grid points in (x,y)
  2556. float gridrgb[3]; // grid line rgb
  2557. float figurergba[4]; // figure color and alpha
  2558. float panergba[4]; // pane color and alpha
  2559. float legendrgba[4]; // legend color and alpha
  2560. float textrgb[3]; // text color
  2561. float linergb[mjMAXLINE][3]; // line colors
  2562. float range[2][2]; // axis ranges; (min>=max) automatic
  2563. char xformat[20]; // x-tick label format for sprintf
  2564. char yformat[20]; // y-tick label format for sprintf
  2565. char minwidth[20]; // string used to determine min y-tick width
  2566. // text labels
  2567. char title[1000]; // figure title; subplots separated with 2+ spaces
  2568. char xlabel[100]; // x-axis label
  2569. char linename[mjMAXLINE][100]; // line names for legend
  2570. // dynamic settings
  2571. int legendoffset; // number of lines to offset legend
  2572. int subplot; // selected subplot (for title rendering)
  2573. int highlight[2]; // if point is in legend rect, highlight line
  2574. int highlightid; // if id>=0 and no point, highlight id
  2575. float selection; // selection line x-value
  2576. // line data
  2577. int linepnt[mjMAXLINE]; // number of points in line; (0) disable
  2578. float linedata[mjMAXLINE][2*mjMAXLINEPNT]; // line data (x,y)
  2579. // output from renderer
  2580. int xaxispixel[2]; // range of x-axis in pixels
  2581. int yaxispixel[2]; // range of y-axis in pixels
  2582. float xaxisdata[2]; // range of x-axis in data units
  2583. float yaxisdata[2]; // range of y-axis in data units
  2584. };
  2585. typedef struct mjvFigure_ mjvFigure;
  2586. struct mjvSceneState_ {
  2587. int nbuffer; // size of the buffer in bytes
  2588. void* buffer; // heap-allocated memory for all arrays in this struct
  2589. int maxgeom; // maximum number of mjvGeom supported by this state object
  2590. mjvScene scratch; // scratch space for vis geoms inserted by the user and plugins
  2591. // fields in mjModel that are necessary to re-render a scene
  2592. struct {
  2593. int nv;
  2594. int nu;
  2595. int na;
  2596. int nbody;
  2597. int nbvh;
  2598. int nbvhstatic;
  2599. int njnt;
  2600. int ngeom;
  2601. int nsite;
  2602. int ncam;
  2603. int nlight;
  2604. int nmesh;
  2605. int nskin;
  2606. int nflex;
  2607. int nflexvert;
  2608. int nflextexcoord;
  2609. int nskinvert;
  2610. int nskinface;
  2611. int nskinbone;
  2612. int nskinbonevert;
  2613. int nmat;
  2614. int neq;
  2615. int ntendon;
  2616. int ntree;
  2617. int nwrap;
  2618. int nsensor;
  2619. int nnames;
  2620. int npaths;
  2621. int nsensordata;
  2622. int narena;
  2623. mjOption opt;
  2624. mjVisual vis;
  2625. mjStatistic stat;
  2626. int* body_parentid;
  2627. int* body_rootid;
  2628. int* body_weldid;
  2629. int* body_mocapid;
  2630. int* body_jntnum;
  2631. int* body_jntadr;
  2632. int* body_dofnum;
  2633. int* body_dofadr;
  2634. int* body_geomnum;
  2635. int* body_geomadr;
  2636. mjtNum* body_iquat;
  2637. mjtNum* body_mass;
  2638. mjtNum* body_inertia;
  2639. int* body_bvhadr;
  2640. int* body_bvhnum;
  2641. int* bvh_depth;
  2642. int* bvh_child;
  2643. int* bvh_nodeid;
  2644. mjtNum* bvh_aabb;
  2645. int* jnt_type;
  2646. int* jnt_bodyid;
  2647. int* jnt_group;
  2648. int* geom_type;
  2649. int* geom_bodyid;
  2650. int* geom_contype;
  2651. int* geom_conaffinity;
  2652. int* geom_dataid;
  2653. int* geom_matid;
  2654. int* geom_group;
  2655. mjtNum* geom_size;
  2656. mjtNum* geom_aabb;
  2657. mjtNum* geom_rbound;
  2658. float* geom_rgba;
  2659. int* site_type;
  2660. int* site_bodyid;
  2661. int* site_matid;
  2662. int* site_group;
  2663. mjtNum* site_size;
  2664. float* site_rgba;
  2665. int* cam_orthographic;
  2666. mjtNum* cam_fovy;
  2667. mjtNum* cam_ipd;
  2668. int* cam_resolution;
  2669. float* cam_sensorsize;
  2670. float* cam_intrinsic;
  2671. mjtByte* light_directional;
  2672. mjtByte* light_castshadow;
  2673. float* light_bulbradius;
  2674. mjtByte* light_active;
  2675. float* light_attenuation;
  2676. float* light_cutoff;
  2677. float* light_exponent;
  2678. float* light_ambient;
  2679. float* light_diffuse;
  2680. float* light_specular;
  2681. mjtByte* flex_flatskin;
  2682. int* flex_dim;
  2683. int* flex_matid;
  2684. int* flex_group;
  2685. int* flex_vertadr;
  2686. int* flex_vertnum;
  2687. int* flex_elem;
  2688. int* flex_elemlayer;
  2689. int* flex_elemadr;
  2690. int* flex_elemnum;
  2691. int* flex_elemdataadr;
  2692. int* flex_shell;
  2693. int* flex_shellnum;
  2694. int* flex_shelldataadr;
  2695. int* flex_texcoordadr;
  2696. int* flex_bvhadr;
  2697. int* flex_bvhnum;
  2698. mjtNum* flex_radius;
  2699. float* flex_rgba;
  2700. int* hfield_pathadr;
  2701. int* mesh_bvhadr;
  2702. int* mesh_bvhnum;
  2703. int* mesh_texcoordadr;
  2704. int* mesh_graphadr;
  2705. int* mesh_pathadr;
  2706. int* skin_matid;
  2707. int* skin_group;
  2708. float* skin_rgba;
  2709. float* skin_inflate;
  2710. int* skin_vertadr;
  2711. int* skin_vertnum;
  2712. int* skin_texcoordadr;
  2713. int* skin_faceadr;
  2714. int* skin_facenum;
  2715. int* skin_boneadr;
  2716. int* skin_bonenum;
  2717. float* skin_vert;
  2718. int* skin_face;
  2719. int* skin_bonevertadr;
  2720. int* skin_bonevertnum;
  2721. float* skin_bonebindpos;
  2722. float* skin_bonebindquat;
  2723. int* skin_bonebodyid;
  2724. int* skin_bonevertid;
  2725. float* skin_bonevertweight;
  2726. int* skin_pathadr;
  2727. int* tex_pathadr;
  2728. int* mat_texid;
  2729. mjtByte* mat_texuniform;
  2730. float* mat_texrepeat;
  2731. float* mat_emission;
  2732. float* mat_specular;
  2733. float* mat_shininess;
  2734. float* mat_reflectance;
  2735. float* mat_metallic;
  2736. float* mat_roughness;
  2737. float* mat_rgba;
  2738. int* eq_type;
  2739. int* eq_obj1id;
  2740. int* eq_obj2id;
  2741. int* eq_objtype;
  2742. mjtNum* eq_data;
  2743. int* tendon_num;
  2744. int* tendon_matid;
  2745. int* tendon_group;
  2746. mjtByte* tendon_limited;
  2747. mjtNum* tendon_width;
  2748. mjtNum* tendon_range;
  2749. mjtNum* tendon_stiffness;
  2750. mjtNum* tendon_damping;
  2751. mjtNum* tendon_frictionloss;
  2752. mjtNum* tendon_lengthspring;
  2753. float* tendon_rgba;
  2754. int* actuator_trntype;
  2755. int* actuator_dyntype;
  2756. int* actuator_trnid;
  2757. int* actuator_actadr;
  2758. int* actuator_actnum;
  2759. int* actuator_group;
  2760. mjtByte* actuator_ctrllimited;
  2761. mjtByte* actuator_actlimited;
  2762. mjtNum* actuator_ctrlrange;
  2763. mjtNum* actuator_actrange;
  2764. mjtNum* actuator_cranklength;
  2765. int* sensor_type;
  2766. int* sensor_objid;
  2767. int* sensor_adr;
  2768. int* name_bodyadr;
  2769. int* name_jntadr;
  2770. int* name_geomadr;
  2771. int* name_siteadr;
  2772. int* name_camadr;
  2773. int* name_lightadr;
  2774. int* name_eqadr;
  2775. int* name_tendonadr;
  2776. int* name_actuatoradr;
  2777. char* names;
  2778. char* paths;
  2779. } model;
  2780. // fields in mjData that are necessary to re-render a scene
  2781. struct {
  2782. mjWarningStat warning[mjNWARNING];
  2783. int nefc;
  2784. int ncon;
  2785. int nisland;
  2786. mjtNum time;
  2787. mjtNum* act;
  2788. mjtNum* ctrl;
  2789. mjtNum* xfrc_applied;
  2790. mjtByte* eq_active;
  2791. mjtNum* sensordata;
  2792. mjtNum* xpos;
  2793. mjtNum* xquat;
  2794. mjtNum* xmat;
  2795. mjtNum* xipos;
  2796. mjtNum* ximat;
  2797. mjtNum* xanchor;
  2798. mjtNum* xaxis;
  2799. mjtNum* geom_xpos;
  2800. mjtNum* geom_xmat;
  2801. mjtNum* site_xpos;
  2802. mjtNum* site_xmat;
  2803. mjtNum* cam_xpos;
  2804. mjtNum* cam_xmat;
  2805. mjtNum* light_xpos;
  2806. mjtNum* light_xdir;
  2807. mjtNum* subtree_com;
  2808. int* ten_wrapadr;
  2809. int* ten_wrapnum;
  2810. int* wrap_obj;
  2811. mjtNum* ten_length;
  2812. mjtNum* wrap_xpos;
  2813. mjtNum* bvh_aabb_dyn;
  2814. mjtByte* bvh_active;
  2815. int* island_dofadr;
  2816. int* island_dofind;
  2817. int* dof_island;
  2818. int* efc_island;
  2819. int* tendon_efcadr;
  2820. mjtNum* flexvert_xpos;
  2821. mjContact* contact;
  2822. mjtNum* efc_force;
  2823. void* arena;
  2824. } data;
  2825. };
  2826. typedef struct mjvSceneState_ mjvSceneState;
  2827. //----------------------------- MJAPI FUNCTIONS --------------------------------
  2828. void mj_defaultVFS(mjVFS* vfs);
  2829. int mj_addFileVFS(mjVFS* vfs, const char* directory, const char* filename);
  2830. int mj_addBufferVFS(mjVFS* vfs, const char* name, const void* buffer, int nbuffer);
  2831. int mj_deleteFileVFS(mjVFS* vfs, const char* filename);
  2832. void mj_deleteVFS(mjVFS* vfs);
  2833. mjModel* mj_loadXML(const char* filename, const mjVFS* vfs, char* error, int error_sz);
  2834. mjSpec* mj_parseXML(const char* filename, const mjVFS* vfs, char* error, int error_sz);
  2835. mjSpec* mj_parseXMLString(const char* xml, const mjVFS* vfs, char* error, int error_sz);
  2836. mjModel* mj_compile(mjSpec* s, const mjVFS* vfs);
  2837. int mj_recompile(mjSpec* s, const mjVFS* vfs, mjModel* m, mjData* d);
  2838. int mj_saveLastXML(const char* filename, const mjModel* m, char* error, int error_sz);
  2839. void mj_freeLastXML(void);
  2840. int mj_saveXMLString(const mjSpec* s, char* xml, int xml_sz, char* error, int error_sz);
  2841. int mj_saveXML(const mjSpec* s, const char* filename, char* error, int error_sz);
  2842. void mj_step(const mjModel* m, mjData* d);
  2843. void mj_step1(const mjModel* m, mjData* d);
  2844. void mj_step2(const mjModel* m, mjData* d);
  2845. void mj_forward(const mjModel* m, mjData* d);
  2846. void mj_inverse(const mjModel* m, mjData* d);
  2847. void mj_forwardSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor);
  2848. void mj_inverseSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor);
  2849. void mj_defaultLROpt(mjLROpt* opt);
  2850. void mj_defaultSolRefImp(mjtNum* solref, mjtNum* solimp);
  2851. void mj_defaultOption(mjOption* opt);
  2852. void mj_defaultVisual(mjVisual* vis);
  2853. mjModel* mj_copyModel(mjModel* dest, const mjModel* src);
  2854. void mj_saveModel(const mjModel* m, const char* filename, void* buffer, int buffer_sz);
  2855. mjModel* mj_loadModel(const char* filename, const mjVFS* vfs);
  2856. void mj_deleteModel(mjModel* m);
  2857. int mj_sizeModel(const mjModel* m);
  2858. mjData* mj_makeData(const mjModel* m);
  2859. mjData* mj_copyData(mjData* dest, const mjModel* m, const mjData* src);
  2860. void mj_resetData(const mjModel* m, mjData* d);
  2861. void mj_resetDataDebug(const mjModel* m, mjData* d, unsigned char debug_value);
  2862. void mj_resetDataKeyframe(const mjModel* m, mjData* d, int key);
  2863. void mj_markStack(mjData* d);
  2864. void mj_freeStack(mjData* d);
  2865. void* mj_stackAllocByte(mjData* d, size_t bytes, size_t alignment);
  2866. mjtNum* mj_stackAllocNum(mjData* d, size_t size);
  2867. int* mj_stackAllocInt(mjData* d, size_t size);
  2868. void mj_deleteData(mjData* d);
  2869. void mj_resetCallbacks(void);
  2870. void mj_setConst(mjModel* m, mjData* d);
  2871. int mj_setLengthRange(mjModel* m, mjData* d, int index,
  2872. const mjLROpt* opt, char* error, int error_sz);
  2873. mjSpec* mj_makeSpec(void);
  2874. mjSpec* mj_copySpec(const mjSpec* s);
  2875. void mj_deleteSpec(mjSpec* s);
  2876. int mjs_activatePlugin(mjSpec* s, const char* name);
  2877. void mj_printFormattedModel(const mjModel* m, const char* filename, const char* float_format);
  2878. void mj_printModel(const mjModel* m, const char* filename);
  2879. void mj_printFormattedData(const mjModel* m, mjData* d, const char* filename,
  2880. const char* float_format);
  2881. void mj_printData(const mjModel* m, mjData* d, const char* filename);
  2882. void mju_printMat(const mjtNum* mat, int nr, int nc);
  2883. void mju_printMatSparse(const mjtNum* mat, int nr,
  2884. const int* rownnz, const int* rowadr, const int* colind);
  2885. int mj_printSchema(const char* filename, char* buffer, int buffer_sz,
  2886. int flg_html, int flg_pad);
  2887. void mj_fwdPosition(const mjModel* m, mjData* d);
  2888. void mj_fwdVelocity(const mjModel* m, mjData* d);
  2889. void mj_fwdActuation(const mjModel* m, mjData* d);
  2890. void mj_fwdAcceleration(const mjModel* m, mjData* d);
  2891. void mj_fwdConstraint(const mjModel* m, mjData* d);
  2892. void mj_Euler(const mjModel* m, mjData* d);
  2893. void mj_RungeKutta(const mjModel* m, mjData* d, int N);
  2894. void mj_implicit(const mjModel* m, mjData* d);
  2895. void mj_invPosition(const mjModel* m, mjData* d);
  2896. void mj_invVelocity(const mjModel* m, mjData* d);
  2897. void mj_invConstraint(const mjModel* m, mjData* d);
  2898. void mj_compareFwdInv(const mjModel* m, mjData* d);
  2899. void mj_sensorPos(const mjModel* m, mjData* d);
  2900. void mj_sensorVel(const mjModel* m, mjData* d);
  2901. void mj_sensorAcc(const mjModel* m, mjData* d);
  2902. void mj_energyPos(const mjModel* m, mjData* d);
  2903. void mj_energyVel(const mjModel* m, mjData* d);
  2904. void mj_checkPos(const mjModel* m, mjData* d);
  2905. void mj_checkVel(const mjModel* m, mjData* d);
  2906. void mj_checkAcc(const mjModel* m, mjData* d);
  2907. void mj_kinematics(const mjModel* m, mjData* d);
  2908. void mj_comPos(const mjModel* m, mjData* d);
  2909. void mj_camlight(const mjModel* m, mjData* d);
  2910. void mj_flex(const mjModel* m, mjData* d);
  2911. void mj_tendon(const mjModel* m, mjData* d);
  2912. void mj_transmission(const mjModel* m, mjData* d);
  2913. void mj_crb(const mjModel* m, mjData* d);
  2914. void mj_factorM(const mjModel* m, mjData* d);
  2915. void mj_solveM(const mjModel* m, mjData* d, mjtNum* x, const mjtNum* y, int n);
  2916. void mj_solveM2(const mjModel* m, mjData* d, mjtNum* x, const mjtNum* y, int n);
  2917. void mj_comVel(const mjModel* m, mjData* d);
  2918. void mj_passive(const mjModel* m, mjData* d);
  2919. void mj_subtreeVel(const mjModel* m, mjData* d);
  2920. void mj_rne(const mjModel* m, mjData* d, int flg_acc, mjtNum* result);
  2921. void mj_rnePostConstraint(const mjModel* m, mjData* d);
  2922. void mj_collision(const mjModel* m, mjData* d);
  2923. void mj_makeConstraint(const mjModel* m, mjData* d);
  2924. void mj_island(const mjModel* m, mjData* d);
  2925. void mj_projectConstraint(const mjModel* m, mjData* d);
  2926. void mj_referenceConstraint(const mjModel* m, mjData* d);
  2927. void mj_constraintUpdate(const mjModel* m, mjData* d, const mjtNum* jar,
  2928. mjtNum cost[1], int flg_coneHessian);
  2929. int mj_stateSize(const mjModel* m, unsigned int spec);
  2930. void mj_getState(const mjModel* m, const mjData* d, mjtNum* state, unsigned int spec);
  2931. void mj_setState(const mjModel* m, mjData* d, const mjtNum* state, unsigned int spec);
  2932. void mj_setKeyframe(mjModel* m, const mjData* d, int k);
  2933. int mj_addContact(const mjModel* m, mjData* d, const mjContact* con);
  2934. int mj_isPyramidal(const mjModel* m);
  2935. int mj_isSparse(const mjModel* m);
  2936. int mj_isDual(const mjModel* m);
  2937. void mj_mulJacVec(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec);
  2938. void mj_mulJacTVec(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec);
  2939. void mj_jac(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr,
  2940. const mjtNum point[3], int body);
  2941. void mj_jacBody(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int body);
  2942. void mj_jacBodyCom(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int body);
  2943. void mj_jacSubtreeCom(const mjModel* m, mjData* d, mjtNum* jacp, int body);
  2944. void mj_jacGeom(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int geom);
  2945. void mj_jacSite(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int site);
  2946. void mj_jacPointAxis(const mjModel* m, mjData* d, mjtNum* jacPoint, mjtNum* jacAxis,
  2947. const mjtNum point[3], const mjtNum axis[3], int body);
  2948. void mj_jacDot(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr,
  2949. const mjtNum point[3], int body);
  2950. void mj_angmomMat(const mjModel* m, mjData* d, mjtNum* mat, int body);
  2951. int mj_name2id(const mjModel* m, int type, const char* name);
  2952. const char* mj_id2name(const mjModel* m, int type, int id);
  2953. void mj_fullM(const mjModel* m, mjtNum* dst, const mjtNum* M);
  2954. void mj_mulM(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec);
  2955. void mj_mulM2(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec);
  2956. void mj_addM(const mjModel* m, mjData* d, mjtNum* dst, int* rownnz, int* rowadr, int* colind);
  2957. void mj_applyFT(const mjModel* m, mjData* d, const mjtNum force[3], const mjtNum torque[3],
  2958. const mjtNum point[3], int body, mjtNum* qfrc_target);
  2959. void mj_objectVelocity(const mjModel* m, const mjData* d,
  2960. int objtype, int objid, mjtNum res[6], int flg_local);
  2961. void mj_objectAcceleration(const mjModel* m, const mjData* d,
  2962. int objtype, int objid, mjtNum res[6], int flg_local);
  2963. mjtNum mj_geomDistance(const mjModel* m, const mjData* d, int geom1, int geom2,
  2964. mjtNum distmax, mjtNum fromto[6]);
  2965. void mj_contactForce(const mjModel* m, const mjData* d, int id, mjtNum result[6]);
  2966. void mj_differentiatePos(const mjModel* m, mjtNum* qvel, mjtNum dt,
  2967. const mjtNum* qpos1, const mjtNum* qpos2);
  2968. void mj_integratePos(const mjModel* m, mjtNum* qpos, const mjtNum* qvel, mjtNum dt);
  2969. void mj_normalizeQuat(const mjModel* m, mjtNum* qpos);
  2970. void mj_local2Global(mjData* d, mjtNum xpos[3], mjtNum xmat[9], const mjtNum pos[3],
  2971. const mjtNum quat[4], int body, mjtByte sameframe);
  2972. mjtNum mj_getTotalmass(const mjModel* m);
  2973. void mj_setTotalmass(mjModel* m, mjtNum newmass);
  2974. const char* mj_getPluginConfig(const mjModel* m, int plugin_id, const char* attrib);
  2975. void mj_loadPluginLibrary(const char* path);
  2976. void mj_loadAllPluginLibraries(const char* directory, mjfPluginLibraryLoadCallback callback);
  2977. int mj_version(void);
  2978. const char* mj_versionString(void);
  2979. void mj_multiRay(const mjModel* m, mjData* d, const mjtNum pnt[3], const mjtNum* vec,
  2980. const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude,
  2981. int* geomid, mjtNum* dist, int nray, mjtNum cutoff);
  2982. mjtNum mj_ray(const mjModel* m, const mjData* d, const mjtNum pnt[3], const mjtNum vec[3],
  2983. const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude,
  2984. int geomid[1]);
  2985. mjtNum mj_rayHfield(const mjModel* m, const mjData* d, int geomid,
  2986. const mjtNum pnt[3], const mjtNum vec[3]);
  2987. mjtNum mj_rayMesh(const mjModel* m, const mjData* d, int geomid,
  2988. const mjtNum pnt[3], const mjtNum vec[3]);
  2989. mjtNum mju_rayGeom(const mjtNum pos[3], const mjtNum mat[9], const mjtNum size[3],
  2990. const mjtNum pnt[3], const mjtNum vec[3], int geomtype);
  2991. mjtNum mju_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtByte flg_vert,
  2992. mjtByte flg_edge, mjtByte flg_face, mjtByte flg_skin, int flexid,
  2993. const mjtNum* pnt, const mjtNum* vec, int vertid[1]);
  2994. mjtNum mju_raySkin(int nface, int nvert, const int* face, const float* vert,
  2995. const mjtNum pnt[3], const mjtNum vec[3], int vertid[1]);
  2996. void mjv_defaultCamera(mjvCamera* cam);
  2997. void mjv_defaultFreeCamera(const mjModel* m, mjvCamera* cam);
  2998. void mjv_defaultPerturb(mjvPerturb* pert);
  2999. void mjv_room2model(mjtNum modelpos[3], mjtNum modelquat[4], const mjtNum roompos[3],
  3000. const mjtNum roomquat[4], const mjvScene* scn);
  3001. void mjv_model2room(mjtNum roompos[3], mjtNum roomquat[4], const mjtNum modelpos[3],
  3002. const mjtNum modelquat[4], const mjvScene* scn);
  3003. void mjv_cameraInModel(mjtNum headpos[3], mjtNum forward[3], mjtNum up[3],
  3004. const mjvScene* scn);
  3005. void mjv_cameraInRoom(mjtNum headpos[3], mjtNum forward[3], mjtNum up[3],
  3006. const mjvScene* scn);
  3007. mjtNum mjv_frustumHeight(const mjvScene* scn);
  3008. void mjv_alignToCamera(mjtNum res[3], const mjtNum vec[3], const mjtNum forward[3]);
  3009. void mjv_moveCamera(const mjModel* m, int action, mjtNum reldx, mjtNum reldy,
  3010. const mjvScene* scn, mjvCamera* cam);
  3011. void mjv_moveCameraFromState(const mjvSceneState* scnstate, int action,
  3012. mjtNum reldx, mjtNum reldy,
  3013. const mjvScene* scn, mjvCamera* cam);
  3014. void mjv_movePerturb(const mjModel* m, const mjData* d, int action, mjtNum reldx,
  3015. mjtNum reldy, const mjvScene* scn, mjvPerturb* pert);
  3016. void mjv_movePerturbFromState(const mjvSceneState* scnstate, int action,
  3017. mjtNum reldx, mjtNum reldy,
  3018. const mjvScene* scn, mjvPerturb* pert);
  3019. void mjv_moveModel(const mjModel* m, int action, mjtNum reldx, mjtNum reldy,
  3020. const mjtNum roomup[3], mjvScene* scn);
  3021. void mjv_initPerturb(const mjModel* m, mjData* d, const mjvScene* scn, mjvPerturb* pert);
  3022. void mjv_applyPerturbPose(const mjModel* m, mjData* d, const mjvPerturb* pert,
  3023. int flg_paused);
  3024. void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb* pert);
  3025. mjvGLCamera mjv_averageCamera(const mjvGLCamera* cam1, const mjvGLCamera* cam2);
  3026. int mjv_select(const mjModel* m, const mjData* d, const mjvOption* vopt,
  3027. mjtNum aspectratio, mjtNum relx, mjtNum rely,
  3028. const mjvScene* scn, mjtNum selpnt[3],
  3029. int geomid[1], int flexid[1], int skinid[1]);
  3030. void mjv_defaultOption(mjvOption* opt);
  3031. void mjv_defaultFigure(mjvFigure* fig);
  3032. void mjv_initGeom(mjvGeom* geom, int type, const mjtNum size[3],
  3033. const mjtNum pos[3], const mjtNum mat[9], const float rgba[4]);
  3034. void mjv_makeConnector(mjvGeom* geom, int type, mjtNum width,
  3035. mjtNum a0, mjtNum a1, mjtNum a2,
  3036. mjtNum b0, mjtNum b1, mjtNum b2);
  3037. void mjv_connector(mjvGeom* geom, int type, mjtNum width,
  3038. const mjtNum from[3], const mjtNum to[3]);
  3039. void mjv_defaultScene(mjvScene* scn);
  3040. void mjv_makeScene(const mjModel* m, mjvScene* scn, int maxgeom);
  3041. void mjv_freeScene(mjvScene* scn);
  3042. void mjv_updateScene(const mjModel* m, mjData* d, const mjvOption* opt,
  3043. const mjvPerturb* pert, mjvCamera* cam, int catmask, mjvScene* scn);
  3044. int mjv_updateSceneFromState(const mjvSceneState* scnstate, const mjvOption* opt,
  3045. const mjvPerturb* pert, mjvCamera* cam, int catmask,
  3046. mjvScene* scn);
  3047. void mjv_defaultSceneState(mjvSceneState* scnstate);
  3048. void mjv_makeSceneState(const mjModel* m, const mjData* d,
  3049. mjvSceneState* scnstate, int maxgeom);
  3050. void mjv_freeSceneState(mjvSceneState* scnstate);
  3051. void mjv_updateSceneState(const mjModel* m, mjData* d, const mjvOption* opt,
  3052. mjvSceneState* scnstate);
  3053. void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* opt,
  3054. const mjvPerturb* pert, int catmask, mjvScene* scn);
  3055. void mjv_makeLights(const mjModel* m, const mjData* d, mjvScene* scn);
  3056. void mjv_updateCamera(const mjModel* m, const mjData* d, mjvCamera* cam, mjvScene* scn);
  3057. void mjv_updateSkin(const mjModel* m, const mjData* d, mjvScene* scn);
  3058. void mjr_defaultContext(mjrContext* con);
  3059. void mjr_makeContext(const mjModel* m, mjrContext* con, int fontscale);
  3060. void mjr_changeFont(int fontscale, mjrContext* con);
  3061. void mjr_addAux(int index, int width, int height, int samples, mjrContext* con);
  3062. void mjr_freeContext(mjrContext* con);
  3063. void mjr_resizeOffscreen(int width, int height, mjrContext* con);
  3064. void mjr_uploadTexture(const mjModel* m, const mjrContext* con, int texid);
  3065. void mjr_uploadMesh(const mjModel* m, const mjrContext* con, int meshid);
  3066. void mjr_uploadHField(const mjModel* m, const mjrContext* con, int hfieldid);
  3067. void mjr_restoreBuffer(const mjrContext* con);
  3068. void mjr_setBuffer(int framebuffer, mjrContext* con);
  3069. void mjr_readPixels(unsigned char* rgb, float* depth,
  3070. mjrRect viewport, const mjrContext* con);
  3071. void mjr_drawPixels(const unsigned char* rgb, const float* depth,
  3072. mjrRect viewport, const mjrContext* con);
  3073. void mjr_blitBuffer(mjrRect src, mjrRect dst,
  3074. int flg_color, int flg_depth, const mjrContext* con);
  3075. void mjr_setAux(int index, const mjrContext* con);
  3076. void mjr_blitAux(int index, mjrRect src, int left, int bottom, const mjrContext* con);
  3077. void mjr_text(int font, const char* txt, const mjrContext* con,
  3078. float x, float y, float r, float g, float b);
  3079. void mjr_overlay(int font, int gridpos, mjrRect viewport,
  3080. const char* overlay, const char* overlay2, const mjrContext* con);
  3081. mjrRect mjr_maxViewport(const mjrContext* con);
  3082. void mjr_rectangle(mjrRect viewport, float r, float g, float b, float a);
  3083. void mjr_label(mjrRect viewport, int font, const char* txt,
  3084. float r, float g, float b, float a, float rt, float gt, float bt,
  3085. const mjrContext* con);
  3086. void mjr_figure(mjrRect viewport, mjvFigure* fig, const mjrContext* con);
  3087. void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con);
  3088. void mjr_finish(void);
  3089. int mjr_getError(void);
  3090. int mjr_findRect(int x, int y, int nrect, const mjrRect* rect);
  3091. mjuiThemeSpacing mjui_themeSpacing(int ind);
  3092. mjuiThemeColor mjui_themeColor(int ind);
  3093. void mjui_add(mjUI* ui, const mjuiDef* def);
  3094. void mjui_addToSection(mjUI* ui, int sect, const mjuiDef* def);
  3095. void mjui_resize(mjUI* ui, const mjrContext* con);
  3096. void mjui_update(int section, int item, const mjUI* ui,
  3097. const mjuiState* state, const mjrContext* con);
  3098. mjuiItem* mjui_event(mjUI* ui, mjuiState* state, const mjrContext* con);
  3099. void mjui_render(mjUI* ui, const mjuiState* state, const mjrContext* con);
  3100. void mju_error(const char* msg, ...) mjPRINTFLIKE(1, 2);
  3101. void mju_error_i(const char* msg, int i);
  3102. void mju_error_s(const char* msg, const char* text);
  3103. void mju_warning(const char* msg, ...) mjPRINTFLIKE(1, 2);
  3104. void mju_warning_i(const char* msg, int i);
  3105. void mju_warning_s(const char* msg, const char* text);
  3106. void mju_clearHandlers(void);
  3107. void* mju_malloc(size_t size);
  3108. void mju_free(void* ptr);
  3109. void mj_warning(mjData* d, int warning, int info);
  3110. void mju_writeLog(const char* type, const char* msg);
  3111. const char* mjs_getError(mjSpec* s);
  3112. int mjs_isWarning(mjSpec* s);
  3113. void mju_zero3(mjtNum res[3]);
  3114. void mju_copy3(mjtNum res[3], const mjtNum data[3]);
  3115. void mju_scl3(mjtNum res[3], const mjtNum vec[3], mjtNum scl);
  3116. void mju_add3(mjtNum res[3], const mjtNum vec1[3], const mjtNum vec2[3]);
  3117. void mju_sub3(mjtNum res[3], const mjtNum vec1[3], const mjtNum vec2[3]);
  3118. void mju_addTo3(mjtNum res[3], const mjtNum vec[3]);
  3119. void mju_subFrom3(mjtNum res[3], const mjtNum vec[3]);
  3120. void mju_addToScl3(mjtNum res[3], const mjtNum vec[3], mjtNum scl);
  3121. void mju_addScl3(mjtNum res[3], const mjtNum vec1[3], const mjtNum vec2[3], mjtNum scl);
  3122. mjtNum mju_normalize3(mjtNum vec[3]);
  3123. mjtNum mju_norm3(const mjtNum vec[3]);
  3124. mjtNum mju_dot3(const mjtNum vec1[3], const mjtNum vec2[3]);
  3125. mjtNum mju_dist3(const mjtNum pos1[3], const mjtNum pos2[3]);
  3126. void mju_mulMatVec3(mjtNum res[3], const mjtNum mat[9], const mjtNum vec[3]);
  3127. void mju_mulMatTVec3(mjtNum res[3], const mjtNum mat[9], const mjtNum vec[3]);
  3128. void mju_rotVecMat(mjtNum res[3], const mjtNum vec[3], const mjtNum mat[9]);
  3129. void mju_rotVecMatT(mjtNum res[3], const mjtNum vec[3], const mjtNum mat[9]);
  3130. void mju_cross(mjtNum res[3], const mjtNum a[3], const mjtNum b[3]);
  3131. void mju_zero4(mjtNum res[4]);
  3132. void mju_unit4(mjtNum res[4]);
  3133. void mju_copy4(mjtNum res[4], const mjtNum data[4]);
  3134. mjtNum mju_normalize4(mjtNum vec[4]);
  3135. void mju_zero(mjtNum* res, int n);
  3136. void mju_fill(mjtNum* res, mjtNum val, int n);
  3137. void mju_copy(mjtNum* res, const mjtNum* vec, int n);
  3138. mjtNum mju_sum(const mjtNum* vec, int n);
  3139. mjtNum mju_L1(const mjtNum* vec, int n);
  3140. void mju_scl(mjtNum* res, const mjtNum* vec, mjtNum scl, int n);
  3141. void mju_add(mjtNum* res, const mjtNum* vec1, const mjtNum* vec2, int n);
  3142. void mju_sub(mjtNum* res, const mjtNum* vec1, const mjtNum* vec2, int n);
  3143. void mju_addTo(mjtNum* res, const mjtNum* vec, int n);
  3144. void mju_subFrom(mjtNum* res, const mjtNum* vec, int n);
  3145. void mju_addToScl(mjtNum* res, const mjtNum* vec, mjtNum scl, int n);
  3146. void mju_addScl(mjtNum* res, const mjtNum* vec1, const mjtNum* vec2, mjtNum scl, int n);
  3147. mjtNum mju_normalize(mjtNum* res, int n);
  3148. mjtNum mju_norm(const mjtNum* res, int n);
  3149. mjtNum mju_dot(const mjtNum* vec1, const mjtNum* vec2, int n);
  3150. void mju_mulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int nr, int nc);
  3151. void mju_mulMatTVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int nr, int nc);
  3152. mjtNum mju_mulVecMatVec(const mjtNum* vec1, const mjtNum* mat, const mjtNum* vec2, int n);
  3153. void mju_transpose(mjtNum* res, const mjtNum* mat, int nr, int nc);
  3154. void mju_symmetrize(mjtNum* res, const mjtNum* mat, int n);
  3155. void mju_eye(mjtNum* mat, int n);
  3156. void mju_mulMatMat(mjtNum* res, const mjtNum* mat1, const mjtNum* mat2,
  3157. int r1, int c1, int c2);
  3158. void mju_mulMatMatT(mjtNum* res, const mjtNum* mat1, const mjtNum* mat2,
  3159. int r1, int c1, int r2);
  3160. void mju_mulMatTMat(mjtNum* res, const mjtNum* mat1, const mjtNum* mat2,
  3161. int r1, int c1, int c2);
  3162. void mju_sqrMatTD(mjtNum* res, const mjtNum* mat, const mjtNum* diag, int nr, int nc);
  3163. void mju_transformSpatial(mjtNum res[6], const mjtNum vec[6], int flg_force,
  3164. const mjtNum newpos[3], const mjtNum oldpos[3],
  3165. const mjtNum rotnew2old[9]);
  3166. void mju_rotVecQuat(mjtNum res[3], const mjtNum vec[3], const mjtNum quat[4]);
  3167. void mju_negQuat(mjtNum res[4], const mjtNum quat[4]);
  3168. void mju_mulQuat(mjtNum res[4], const mjtNum quat1[4], const mjtNum quat2[4]);
  3169. void mju_mulQuatAxis(mjtNum res[4], const mjtNum quat[4], const mjtNum axis[3]);
  3170. void mju_axisAngle2Quat(mjtNum res[4], const mjtNum axis[3], mjtNum angle);
  3171. void mju_quat2Vel(mjtNum res[3], const mjtNum quat[4], mjtNum dt);
  3172. void mju_subQuat(mjtNum res[3], const mjtNum qa[4], const mjtNum qb[4]);
  3173. void mju_quat2Mat(mjtNum res[9], const mjtNum quat[4]);
  3174. void mju_mat2Quat(mjtNum quat[4], const mjtNum mat[9]);
  3175. void mju_derivQuat(mjtNum res[4], const mjtNum quat[4], const mjtNum vel[3]);
  3176. void mju_quatIntegrate(mjtNum quat[4], const mjtNum vel[3], mjtNum scale);
  3177. void mju_quatZ2Vec(mjtNum quat[4], const mjtNum vec[3]);
  3178. void mju_euler2Quat(mjtNum quat[4], const mjtNum euler[3], const char* seq);
  3179. void mju_mulPose(mjtNum posres[3], mjtNum quatres[4],
  3180. const mjtNum pos1[3], const mjtNum quat1[4],
  3181. const mjtNum pos2[3], const mjtNum quat2[4]);
  3182. void mju_negPose(mjtNum posres[3], mjtNum quatres[4],
  3183. const mjtNum pos[3], const mjtNum quat[4]);
  3184. void mju_trnVecPose(mjtNum res[3], const mjtNum pos[3], const mjtNum quat[4],
  3185. const mjtNum vec[3]);
  3186. int mju_cholFactor(mjtNum* mat, int n, mjtNum mindiag);
  3187. void mju_cholSolve(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int n);
  3188. int mju_cholUpdate(mjtNum* mat, mjtNum* x, int n, int flg_plus);
  3189. mjtNum mju_cholFactorBand(mjtNum* mat, int ntotal, int nband, int ndense,
  3190. mjtNum diagadd, mjtNum diagmul);
  3191. void mju_cholSolveBand(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
  3192. int ntotal, int nband, int ndense);
  3193. void mju_band2Dense(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense,
  3194. mjtByte flg_sym);
  3195. void mju_dense2Band(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense);
  3196. void mju_bandMulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
  3197. int ntotal, int nband, int ndense, int nvec, mjtByte flg_sym);
  3198. int mju_bandDiag(int i, int ntotal, int nband, int ndense);
  3199. int mju_eig3(mjtNum eigval[3], mjtNum eigvec[9], mjtNum quat[4], const mjtNum mat[9]);
  3200. int mju_boxQP(mjtNum* res, mjtNum* R, int* index, const mjtNum* H, const mjtNum* g, int n,
  3201. const mjtNum* lower, const mjtNum* upper);
  3202. void mju_boxQPmalloc(mjtNum** res, mjtNum** R, int** index, mjtNum** H, mjtNum** g, int n,
  3203. mjtNum** lower, mjtNum** upper);
  3204. mjtNum mju_muscleGain(mjtNum len, mjtNum vel, const mjtNum lengthrange[2],
  3205. mjtNum acc0, const mjtNum prm[9]);
  3206. mjtNum mju_muscleBias(mjtNum len, const mjtNum lengthrange[2],
  3207. mjtNum acc0, const mjtNum prm[9]);
  3208. mjtNum mju_muscleDynamics(mjtNum ctrl, mjtNum act, const mjtNum prm[3]);
  3209. void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force, const mjtNum* mu, int dim);
  3210. void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid, const mjtNum* mu, int dim);
  3211. mjtNum mju_springDamper(mjtNum pos0, mjtNum vel0, mjtNum Kp, mjtNum Kv, mjtNum dt);
  3212. mjtNum mju_min(mjtNum a, mjtNum b);
  3213. mjtNum mju_max(mjtNum a, mjtNum b);
  3214. mjtNum mju_clip(mjtNum x, mjtNum min, mjtNum max);
  3215. mjtNum mju_sign(mjtNum x);
  3216. int mju_round(mjtNum x);
  3217. const char* mju_type2Str(int type);
  3218. int mju_str2Type(const char* str);
  3219. const char* mju_writeNumBytes(size_t nbytes);
  3220. const char* mju_warningText(int warning, size_t info);
  3221. int mju_isBad(mjtNum x);
  3222. int mju_isZero(mjtNum* vec, int n);
  3223. mjtNum mju_standardNormal(mjtNum* num2);
  3224. void mju_f2n(mjtNum* res, const float* vec, int n);
  3225. void mju_n2f(float* res, const mjtNum* vec, int n);
  3226. void mju_d2n(mjtNum* res, const double* vec, int n);
  3227. void mju_n2d(double* res, const mjtNum* vec, int n);
  3228. void mju_insertionSort(mjtNum* list, int n);
  3229. void mju_insertionSortInt(int* list, int n);
  3230. mjtNum mju_Halton(int index, int base);
  3231. char* mju_strncpy(char *dst, const char *src, int n);
  3232. mjtNum mju_sigmoid(mjtNum x);
  3233. void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered,
  3234. mjtNum* A, mjtNum* B, mjtNum* C, mjtNum* D);
  3235. void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_actuation,
  3236. mjtNum *DfDq, mjtNum *DfDv, mjtNum *DfDa,
  3237. mjtNum *DsDq, mjtNum *DsDv, mjtNum *DsDa,
  3238. mjtNum *DmDq);
  3239. void mjd_subQuat(const mjtNum qa[4], const mjtNum qb[4], mjtNum Da[9], mjtNum Db[9]);
  3240. void mjd_quatIntegrate(const mjtNum vel[3], mjtNum scale,
  3241. mjtNum Dquat[9], mjtNum Dvel[9], mjtNum Dscale[3]);
  3242. void mjp_defaultPlugin(mjpPlugin* plugin);
  3243. int mjp_registerPlugin(const mjpPlugin* plugin);
  3244. int mjp_pluginCount(void);
  3245. const mjpPlugin* mjp_getPlugin(const char* name, int* slot);
  3246. const mjpPlugin* mjp_getPluginAtSlot(int slot);
  3247. void mjp_defaultResourceProvider(mjpResourceProvider* provider);
  3248. int mjp_registerResourceProvider(const mjpResourceProvider* provider);
  3249. int mjp_resourceProviderCount(void);
  3250. const mjpResourceProvider* mjp_getResourceProvider(const char* resource_name);
  3251. const mjpResourceProvider* mjp_getResourceProviderAtSlot(int slot);
  3252. mjThreadPool* mju_threadPoolCreate(size_t number_of_threads);
  3253. void mju_bindThreadPool(mjData* d, void* thread_pool);
  3254. void mju_threadPoolEnqueue(mjThreadPool* thread_pool, mjTask* task);
  3255. void mju_threadPoolDestroy(mjThreadPool* thread_pool);
  3256. void mju_defaultTask(mjTask* task);
  3257. void mju_taskJoin(mjTask* task);
  3258. mjsBody* mjs_attachBody(mjsFrame* parent, const mjsBody* child,
  3259. const char* prefix, const char* suffix);
  3260. mjsFrame* mjs_attachFrame(mjsBody* parent, const mjsFrame* child,
  3261. const char* prefix, const char* suffix);
  3262. mjsBody* mjs_attachToSite(mjsSite* parent, const mjsBody* child,
  3263. const char* prefix, const char* suffix);
  3264. int mjs_detachBody(mjSpec* s, mjsBody* b);
  3265. mjsBody* mjs_addBody(mjsBody* body, mjsDefault* def);
  3266. mjsSite* mjs_addSite(mjsBody* body, mjsDefault* def);
  3267. mjsJoint* mjs_addJoint(mjsBody* body, mjsDefault* def);
  3268. mjsJoint* mjs_addFreeJoint(mjsBody* body);
  3269. mjsGeom* mjs_addGeom(mjsBody* body, mjsDefault* def);
  3270. mjsCamera* mjs_addCamera(mjsBody* body, mjsDefault* def);
  3271. mjsLight* mjs_addLight(mjsBody* body, mjsDefault* def);
  3272. mjsFrame* mjs_addFrame(mjsBody* body, mjsFrame* parentframe);
  3273. void mjs_delete(mjsElement* element);
  3274. mjsActuator* mjs_addActuator(mjSpec* s, mjsDefault* def);
  3275. mjsSensor* mjs_addSensor(mjSpec* s);
  3276. mjsFlex* mjs_addFlex(mjSpec* s);
  3277. mjsPair* mjs_addPair(mjSpec* s, mjsDefault* def);
  3278. mjsExclude* mjs_addExclude(mjSpec* s);
  3279. mjsEquality* mjs_addEquality(mjSpec* s, mjsDefault* def);
  3280. mjsTendon* mjs_addTendon(mjSpec* s, mjsDefault* def);
  3281. mjsWrap* mjs_wrapSite(mjsTendon* tendon, const char* name);
  3282. mjsWrap* mjs_wrapGeom(mjsTendon* tendon, const char* name, const char* sidesite);
  3283. mjsWrap* mjs_wrapJoint(mjsTendon* tendon, const char* name, double coef);
  3284. mjsWrap* mjs_wrapPulley(mjsTendon* tendon, double divisor);
  3285. mjsNumeric* mjs_addNumeric(mjSpec* s);
  3286. mjsText* mjs_addText(mjSpec* s);
  3287. mjsTuple* mjs_addTuple(mjSpec* s);
  3288. mjsKey* mjs_addKey(mjSpec* s);
  3289. mjsPlugin* mjs_addPlugin(mjSpec* s);
  3290. mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, const mjsDefault* parent);
  3291. mjsMesh* mjs_addMesh(mjSpec* s, mjsDefault* def);
  3292. mjsHField* mjs_addHField(mjSpec* s);
  3293. mjsSkin* mjs_addSkin(mjSpec* s);
  3294. mjsTexture* mjs_addTexture(mjSpec* s);
  3295. mjsMaterial* mjs_addMaterial(mjSpec* s, mjsDefault* def);
  3296. mjSpec* mjs_getSpec(mjsElement* element);
  3297. mjsBody* mjs_findBody(mjSpec* s, const char* name);
  3298. mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name);
  3299. mjsBody* mjs_findChild(mjsBody* body, const char* name);
  3300. mjsFrame* mjs_findFrame(mjSpec* s, const char* name);
  3301. mjsDefault* mjs_getDefault(mjsElement* element);
  3302. mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
  3303. mjsDefault* mjs_getSpecDefault(mjSpec* s);
  3304. int mjs_getId(mjsElement* element);
  3305. mjsElement* mjs_firstChild(mjsBody* body, mjtObj type, int recurse);
  3306. mjsElement* mjs_nextChild(mjsBody* body, mjsElement* child, int recurse);
  3307. mjsElement* mjs_firstElement(mjSpec* s, mjtObj type);
  3308. mjsElement* mjs_nextElement(mjSpec* s, mjsElement* element);
  3309. void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
  3310. void mjs_setString(mjString* dest, const char* text);
  3311. void mjs_setStringVec(mjStringVec* dest, const char* text);
  3312. mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
  3313. void mjs_appendString(mjStringVec* dest, const char* text);
  3314. void mjs_setInt(mjIntVec* dest, const int* array, int size);
  3315. void mjs_appendIntVec(mjIntVecVec* dest, const int* array, int size);
  3316. void mjs_setFloat(mjFloatVec* dest, const float* array, int size);
  3317. void mjs_appendFloatVec(mjFloatVecVec* dest, const float* array, int size);
  3318. void mjs_setDouble(mjDoubleVec* dest, const double* array, int size);
  3319. void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
  3320. const char* mjs_getString(const mjString* source);
  3321. const double* mjs_getDouble(const mjDoubleVec* source, int* size);
  3322. void mjs_setDefault(mjsElement* element, mjsDefault* def);
  3323. void mjs_setFrame(mjsElement* dest, mjsFrame* frame);
  3324. const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* sequence,
  3325. const mjsOrientation* orientation);
  3326. mjsFrame* mjs_bodyToFrame(mjsBody** body);
  3327. void mjs_defaultSpec(mjSpec* spec);
  3328. void mjs_defaultOrientation(mjsOrientation* orient);
  3329. void mjs_defaultBody(mjsBody* body);
  3330. void mjs_defaultFrame(mjsFrame* frame);
  3331. void mjs_defaultJoint(mjsJoint* joint);
  3332. void mjs_defaultGeom(mjsGeom* geom);
  3333. void mjs_defaultSite(mjsSite* site);
  3334. void mjs_defaultCamera(mjsCamera* camera);
  3335. void mjs_defaultLight(mjsLight* light);
  3336. void mjs_defaultFlex(mjsFlex* flex);
  3337. void mjs_defaultMesh(mjsMesh* mesh);
  3338. void mjs_defaultHField(mjsHField* hfield);
  3339. void mjs_defaultSkin(mjsSkin* skin);
  3340. void mjs_defaultTexture(mjsTexture* texture);
  3341. void mjs_defaultMaterial(mjsMaterial* material);
  3342. void mjs_defaultPair(mjsPair* pair);
  3343. void mjs_defaultEquality(mjsEquality* equality);
  3344. void mjs_defaultTendon(mjsTendon* tendon);
  3345. void mjs_defaultActuator(mjsActuator* actuator);
  3346. void mjs_defaultSensor(mjsSensor* sensor);
  3347. void mjs_defaultNumeric(mjsNumeric* numeric);
  3348. void mjs_defaultText(mjsText* text);
  3349. void mjs_defaultTuple(mjsTuple* tuple);
  3350. void mjs_defaultKey(mjsKey* key);
  3351. void mjs_defaultPlugin(mjsPlugin* plugin);
  3352. mjsBody* mjs_asBody(mjsElement* element);
  3353. mjsGeom* mjs_asGeom(mjsElement* element);
  3354. mjsJoint* mjs_asJoint(mjsElement* element);
  3355. mjsSite* mjs_asSite(mjsElement* element);
  3356. mjsCamera* mjs_asCamera(mjsElement* element);
  3357. mjsLight* mjs_asLight(mjsElement* element);
  3358. mjsFrame* mjs_asFrame(mjsElement* element);
  3359. mjsActuator* mjs_asActuator(mjsElement* element);
  3360. mjsSensor* mjs_asSensor(mjsElement* element);
  3361. mjsFlex* mjs_asFlex(mjsElement* element);
  3362. mjsPair* mjs_asPair(mjsElement* element);
  3363. mjsEquality* mjs_asEquality(mjsElement* element);
  3364. mjsExclude* mjs_asExclude(mjsElement* element);
  3365. mjsTendon* mjs_asTendon(mjsElement* element);
  3366. mjsNumeric* mjs_asNumeric(mjsElement* element);
  3367. mjsText* mjs_asText(mjsElement* element);
  3368. mjsTuple* mjs_asTuple(mjsElement* element);
  3369. mjsKey* mjs_asKey(mjsElement* element);
  3370. mjsMesh* mjs_asMesh(mjsElement* element);
  3371. mjsHField* mjs_asHField(mjsElement* element);
  3372. mjsSkin* mjs_asSkin(mjsElement* element);
  3373. mjsTexture* mjs_asTexture(mjsElement* element);
  3374. mjsMaterial* mjs_asMaterial(mjsElement* element);
  3375. mjsPlugin* mjs_asPlugin(mjsElement* element);
  3376. // NOLINTEND