@@ -290,6 +290,12 @@ class MJScene : public DynamicObject
290
290
* task typically compute and apply forces and torques on the system
291
291
* that depend on the simulation time or the state of the multi-body.
292
292
*
293
+ * Models in this task should contribute to computing ``f`` in:
294
+ *
295
+ * dx = f(t,x) dt
296
+ *
297
+ * where ``x`` represents the state of this dynamic object.
298
+ *
293
299
* @warning `SysModel` added to the dynamics task should be memoryless.
294
300
* That is, any output message computed should depend strictly on
295
301
* input messages and the current time/states. It should save values
@@ -303,6 +309,23 @@ class MJScene : public DynamicObject
303
309
*/
304
310
void AddModelToDynamicsTask (SysModel* model, int32_t priority = -1 );
305
311
312
+ /* * @brief Adds a model to the diffusion dynamics task.
313
+ *
314
+ * This task and function are only relevant when the dynamics of
315
+ * the system are stochastic.
316
+ *
317
+ * Similar to ``AddModelToDynamicsTask``, except that models in this
318
+ * task contribute to computing ``g`` in:
319
+ *
320
+ * dx = f(t,x)dt + g(t,x)dW
321
+ *
322
+ * where ``x`` is the state of the system, ``f`` represents the
323
+ * drift term of the dynamics (classic time derivative), and
324
+ * ``g`` is the diffusion term of the dynamics (which evaluates
325
+ * the impact of the random 'noise' ``W`` on the dynamics).
326
+ */
327
+ void AddModelToDiffusionDynamicsTask (SysModel* model, int32_t priority = -1 );
328
+
306
329
/* *
307
330
* @brief Adds forward kinematics to the dynamics task.
308
331
*
@@ -334,6 +357,17 @@ class MJScene : public DynamicObject
334
357
*/
335
358
void AddFwdKinematicsToDynamicsTask (int32_t priority);
336
359
360
+ /* *
361
+ * @brief Adds forward kinematics to the diffusion dynamics task.
362
+ *
363
+ * See ``AddModelToDiffusionDynamicsTask`` and ``AddFwdKinematicsToDynamicsTask``.
364
+ *
365
+ * By default, the diffusion dynamics task has no forward kinematics
366
+ * model, so one must be added if the diffusion term depends on the
367
+ * forward kinematics of the multibody.
368
+ */
369
+ void AddFwdKinematicsToDiffusionDynamicsTask (int32_t priority);
370
+
337
371
/* *
338
372
* @brief Calls `SelfInit` on all system models in the dynamics task.
339
373
*/
@@ -367,11 +401,30 @@ class MJScene : public DynamicObject
367
401
* joints... These information is translated, through MuJoCo, into
368
402
* first derivatives of the joint states and the mass of bodies.
369
403
*
404
+ * Computes ``f`` in:
405
+ *
406
+ * dx = f(t,x) dt
407
+ *
408
+ * where ``x`` represents the current state of the dynamics.
409
+ *
370
410
* @param t The current simulation time in seconds.
371
411
* @param timeStep The integration time step.
372
412
*/
373
413
void equationsOfMotion (double t, double timeStep) override ;
374
414
415
+ /* *
416
+ * @brief Computes the diffusion of the dynamics of the system.
417
+ *
418
+ * Only relevant for systems with stochastic dynamics.
419
+ *
420
+ * Computes ``g`` in:
421
+ *
422
+ * dx = f(t,x) dt + g(t,x)dW
423
+ *
424
+ * where ``x`` represents the current state of the dynamics.
425
+ */
426
+ void equationsOfMotionDiffusion (double t, double timeStep) override ;
427
+
375
428
/* *
376
429
* @brief Prepares the system before actual integration.
377
430
*
@@ -558,6 +611,7 @@ class MJScene : public DynamicObject
558
611
bool forwardKinematicsStale = true ; // /< Flag indicating stale forward kinematics.
559
612
560
613
SysModelTask dynamicsTask; // /< Task managing models involved in the dynamics of this scene.
614
+ SysModelTask dynamicsDiffusionTask; // /< Task managing models involved in the diffusion stochastic dynamics of this scene.
561
615
std::vector<std::unique_ptr<SysModel>> ownedSysModel; // /< System models that should be cleared on this scene destruction.
562
616
563
617
MJQPosStateData* qposState; // /< Position state data.
0 commit comments