23template<
typename DynamicsType>
64 return params_.has_value();
92 template<
typename IntegratorType>
95 const bool& insertIntoHistory =
false,
96 const bool& calculateXddot =
false)
106 if (!DynamicsType::update(
xdot,
x, u, t0, tf, params_.value(), insertIntoHistory, calculateXddot))
110 if (!IntegratorType::integrate(
x,
xdot, tf, insertIntoHistory))
127 template<
typename IntegratorType>
131 const bool& insertIntoHistory =
false,
132 const bool& calculateXddot =
false)
144 double t_kp1 = t_k + dt_k;
145 if (!DynamicsType::update(
xdot,
x, u, t_k, t_kp1, params_.value(), insertIntoHistory, calculateXddot))
149 if (!IntegratorType::integrate(
x,
xdot, t_kp1, insertIntoHistory))
159 std::optional<ParamsType> params_;
237template<
typename IST,
typename SST,
typename SDST,
size_t d,
typename PT>
268 const bool& insertIntoHistory =
false,
269 const bool& calculateXddot =
false)
275 xdot_k.pose = x_k.twist;
276 xdot_k.twist = -params.
g + u_k / params.
m;
280 return xdot.
update(tf, xdot_k, insertIntoHistory);
284 return xdot.
update(tf, xdot_k, StateDotDotType::identity(), insertIntoHistory);
335 const bool& insertIntoHistory =
false,
336 const bool& calculateXddot =
false)
342 xdot_k.pose = x_k.twist;
343 xdot_k.twist = u_k / params.
J;
347 return xdot.
update(tf, xdot_k, insertIntoHistory);
351 return xdot.
update(tf, xdot_k, StateDotDotType::identity(), insertIntoHistory);
390 const bool& insertIntoHistory =
false,
391 const bool& calculateXddot =
false)
397 xdot_k.pose = x_k.twist;
398 xdot_k.twist = params.
J.inverse() * (-x_k.twist.cross(params.
J * x_k.twist) + u_k);
402 return xdot.
update(tf, xdot_k, insertIntoHistory);
406 return xdot.
update(tf, xdot_k, StateDotDotType::identity(), insertIntoHistory);
445 const bool& insertIntoHistory =
false,
446 const bool& calculateXddot =
false)
452 xdot_k.pose = x_k.twist;
453 xdot_k.twist.template block<2, 1>(0, 0) = -(x_k.pose.q().inverse() * params.
g) -
454 x_k.twist(2) * Matrix<T, 2, 1>(-x_k.twist(1), x_k.twist(0)) +
455 1.0 / params.
m * u_k.template block<2, 1>(0, 0);
456 xdot_k.twist(2) = u_k(2) / params.
J;
460 return xdot.
update(tf, xdot_k, insertIntoHistory);
464 return xdot.
update(tf, xdot_k, StateDotDotType::identity(), insertIntoHistory);
503 const bool& insertIntoHistory =
false,
504 const bool& calculateXddot =
false)
513 xdot_k.pose = x_k.twist;
514 xdot_k.twist.template block<3, 1>(0, 0) =
515 -(x_k.pose.q().inverse() * params.
g) -
516 x_k.twist.template block<3, 1>(3, 0).cross(x_k.twist.template block<3, 1>(0, 0)) +
517 1.0 / params.
m * u_k.template block<3, 1>(0, 0);
518 xdot_k.twist.template block<3, 1>(3, 0) =
520 (-x_k.twist.template block<3, 1>(3, 0).cross(params.
J * x_k.twist.template block<3, 1>(3, 0)) +
521 u_k.template block<3, 1>(3, 0));
525 return xdot.
update(tf, xdot_k, insertIntoHistory);
529 return xdot.
update(tf, xdot_k, StateDotDotType::identity(), insertIntoHistory);
534#define MAKE_MODEL(ModelBaseName, ModelDOF) \
535 template<typename T> \
536 using ModelBaseName##ModelDOF##Model = Model<ModelBaseName##Dynamics##ModelDOF<T>>; \
537 typedef ModelBaseName##ModelDOF##Model<double> ModelBaseName##ModelDOF##Modeld;
#define MAKE_MODEL(ModelBaseName, ModelDOF)
Definition Models.h:534
TranslationalDynamicsBase< ScalarSignal< T >, ScalarStateSignal< T >, ScalarStateSignal< T >, 1, RigidBodyParams1D > TranslationalDynamics1DOF
Definition Models.h:290
TranslationalDynamicsBase< Vector3Signal< T >, Vector3StateSignal< T >, Vector3StateSignal< T >, 3, RigidBodyParams3D > TranslationalDynamics3DOF
Definition Models.h:298
TranslationalDynamicsBase< Vector2Signal< T >, Vector2StateSignal< T >, Vector2StateSignal< T >, 2, RigidBodyParams2D > TranslationalDynamics2DOF
Definition Models.h:294
VectorSignal< T, 6 > Vector6Signal
Definition Signal.h:945
VectorSignal< T, 1 > Vector1Signal
Definition Signal.h:940
VectorSignal< T, 3 > Vector3Signal
Definition Signal.h:942
ManifoldStateSignal< T, SO3< T >, 4, 3 > SO3StateSignal
Definition State.h:387
VectorStateSignal< T, 6 > Vector6StateSignal
Definition State.h:381
ManifoldStateSignal< T, SE3< T >, 7, 6 > SE3StateSignal
Definition State.h:389
ManifoldStateSignal< T, SO2< T >, 2, 1 > SO2StateSignal
Definition State.h:386
Signal< T, ScalarStateSignalSpec< T >, ScalarStateSignalSpec< T > > ScalarStateSignal
Definition State.h:326
VectorStateSignal< T, 2 > Vector2StateSignal
Definition State.h:377
VectorStateSignal< T, 1 > Vector1StateSignal
Definition State.h:376
VectorStateSignal< T, 3 > Vector3StateSignal
Definition State.h:378
ManifoldStateSignal< T, SE2< T >, 4, 3 > SE2StateSignal
Definition State.h:388
Model()
Initialize a model with no parameters.
Definition Models.h:44
bool hasParams()
Definition Models.h:62
typename DynamicsType::StateSignalType StateSignalType
Definition Models.h:29
double t() const
Definition Models.h:79
void reset()
Zero out the model state and derivative variables and reset simulation time to zero.
Definition Models.h:70
typename DynamicsType::StateDotSignalType StateDotSignalType
Definition Models.h:28
void setParams(const ParamsType ¶ms)
Definition Models.h:54
StateDotSignalType xdot
Definition Models.h:39
StateSignalType x
Definition Models.h:35
bool simulate(const InputSignalType &u, const double &tf, const double &dt, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Definition Models.h:128
bool simulate(const InputSignalType &u, const double &tf, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Definition Models.h:93
typename DynamicsType::InputSignalType InputSignalType
Definition Models.h:27
typename DynamicsType::ParamsType ParamsType
Definition Models.h:30
typename VectorSignalSpec< T, d >::Type BaseType
Definition Signal.h:65
bool update(const double &_t, const BaseType &_x, bool insertHistory=false)
Update the signal with a new value at a given time, computing derivative automatically.
Definition Signal.h:270
typename VectorStateSignalSpec< T, d >::Type TangentType
Definition Signal.h:66
bool getTimeDelta(double &dt, const double &t0, const double &tf, const double &dt_max=std::numeric_limits< double >::max())
Definition Utils.h:11
Definition of the dynamics for planar motion of a mass that's allowed to rotate.
Definition Models.h:416
SE2StateSignal< T > StateSignalType
Definition Models.h:418
Vector3StateSignal< T > StateDotSignalType
Definition Models.h:419
Vector3Signal< T > InputSignalType
Definition Models.h:417
typename StateSignalType::BaseType StateType
Definition Models.h:422
typename StateDotSignalType::TangentType StateDotDotType
Definition Models.h:424
typename StateDotSignalType::BaseType StateDotType
Definition Models.h:423
typename InputSignalType::BaseType InputType
Definition Models.h:421
static bool update(StateDotSignalType &xdot, const StateSignalType &x, const InputSignalType &u, const double &t0, const double &tf, const ParamsType ¶ms, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Update a provided state time derivative given an input and time interval.
Definition Models.h:439
RigidBodyParams2D ParamsType
Definition Models.h:426
Definition of the dynamics for a 3D rigid body that can rotate about any axis.
Definition Models.h:474
typename StateDotSignalType::TangentType StateDotDotType
Definition Models.h:482
Vector6Signal< T > InputSignalType
Definition Models.h:475
typename StateDotSignalType::BaseType StateDotType
Definition Models.h:481
typename InputSignalType::BaseType InputType
Definition Models.h:479
RigidBodyParams3D ParamsType
Definition Models.h:484
SE3StateSignal< T > StateSignalType
Definition Models.h:476
typename StateSignalType::BaseType StateType
Definition Models.h:480
static bool update(StateDotSignalType &xdot, const StateSignalType &x, const InputSignalType &u, const double &t0, const double &tf, const ParamsType ¶ms, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Update a provided state time derivative given an input and time interval.
Definition Models.h:497
Vector6StateSignal< T > StateDotSignalType
Definition Models.h:477
Parameters for a 1D rigid body model.
Definition Models.h:168
double m
Model mass.
Definition Models.h:173
double g
Gravitational constant.
Definition Models.h:179
RigidBodyParams1D()
Definition Models.h:169
Parameters for a 2D rigid body model.
Definition Models.h:188
double m
Model mass.
Definition Models.h:193
RigidBodyParams2D()
Definition Models.h:189
double J
Moment of inertia.
Definition Models.h:199
Vector2d g
Gravitational vector.
Definition Models.h:205
Parameters for a 3D rigid body model.
Definition Models.h:214
Matrix3d J
Moment of inertia.
Definition Models.h:225
Vector3d g
Gravitational vector.
Definition Models.h:231
RigidBodyParams3D()
Definition Models.h:215
double m
Model mass.
Definition Models.h:219
Definition of the dynamics for planar rotation-only motion of a mass.
Definition Models.h:306
Vector1StateSignal< T > StateDotSignalType
Definition Models.h:309
RigidBodyParams2D ParamsType
Definition Models.h:316
static bool update(StateDotSignalType &xdot, const StateSignalType &x, const InputSignalType &u, const double &t0, const double &tf, const ParamsType ¶ms, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Update a provided state time derivative given an input and time interval.
Definition Models.h:329
typename StateDotSignalType::TangentType StateDotDotType
Definition Models.h:314
typename StateDotSignalType::BaseType StateDotType
Definition Models.h:313
Vector1Signal< T > InputSignalType
Definition Models.h:307
typename StateSignalType::BaseType StateType
Definition Models.h:312
SO2StateSignal< T > StateSignalType
Definition Models.h:308
typename InputSignalType::BaseType InputType
Definition Models.h:311
Definition of the dynamics for 3D rotation-only motion of a mass.
Definition Models.h:361
SO3StateSignal< T > StateSignalType
Definition Models.h:363
RigidBodyParams3D ParamsType
Definition Models.h:371
typename StateDotSignalType::BaseType StateDotType
Definition Models.h:368
Vector3StateSignal< T > StateDotSignalType
Definition Models.h:364
typename StateDotSignalType::TangentType StateDotDotType
Definition Models.h:369
Vector3Signal< T > InputSignalType
Definition Models.h:362
typename StateSignalType::BaseType StateType
Definition Models.h:367
typename InputSignalType::BaseType InputType
Definition Models.h:366
static bool update(StateDotSignalType &xdot, const StateSignalType &x, const InputSignalType &u, const double &t0, const double &tf, const ParamsType ¶ms, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Update a provided state time derivative given an input and time interval.
Definition Models.h:384
Base class for defining the dynamics for 1D, 2D, and 3D point masses.
Definition Models.h:239
SDST StateSignalType
Definition Models.h:242
typename StateDotSignalType::BaseType StateDotType
Definition Models.h:246
SST StateDotSignalType
Definition Models.h:241
static bool update(StateDotSignalType &xdot, const StateSignalType &x, const InputSignalType &u, const double &t0, const double &tf, const ParamsType ¶ms, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
Update a provided state time derivative given an input and time interval.
Definition Models.h:262
typename StateDotSignalType::TangentType StateDotDotType
Definition Models.h:247
PT ParamsType
Definition Models.h:249
typename StateSignalType::BaseType StateType
Definition Models.h:245
IST InputSignalType
Definition Models.h:240
typename InputSignalType::BaseType InputType
Definition Models.h:244