File kernel/src/modelingTools/NewtonEulerDS.hpp¶
Go to the source code of this file
Typedefs
-
typedef void (*FInt_NE)(double t, double *q, double *v, double *f, unsigned int size_z, double *z)¶
Pointer to function for plug-in.
-
typedef void (*FExt_NE)(double t, double *f, unsigned int size_z, double *z)¶
Functions
-
void computeExtForceAtPos(SP::SiconosVector q, bool isMextExpressedInInertialFrame, SP::SiconosVector force, bool forceAbsRef, SP::SiconosVector pos, bool posAbsRef, SP::SiconosVector fExt, SP::SiconosVector mExt, bool accumulate)¶
Compute the force and moment vectors applied to a body with state q from a force vector at a given position.
-
class NewtonEulerDS : public SecondOrderDS
- #include <>
NewtonEuler non linear dynamical systems.
The equations of motion in the Newton-Euler formalism can be stated as
\[\begin{split} \left\{\begin{array}{rcl} M \dot v + F_{int}(q,v, \Omega, t)&=& F_{ext}(t), \\ I \dot \Omega + \Omega \wedge I\Omega + M_{int}(q,v, \Omega, t) &=& M_{ext}(t), \\ \dot q &=& T(q) [ v, \Omega] \\ \dot R &=& R \tilde \Omega,\quad R^{-1}=R^T,\quad \det(R)=1 . \end{array}\right. \end{split}\]with
\( x_G,v_G \) position and velocity of the center of mass expressed in a inertial frame of reference (world frame)
\( \Omega \) angular velocity vector expressed in the body-fixed frame (frame attached to the object)
\( R \) rotation matrix form the inertial frame to the body-fixed frame \( R^{-1}=R^T, \det(R)=1 \), i.e \( R\in SO^+(3) \)
\( M=m\,I_{3\times 3} \) diagonal mass matrix with \( m \in \mathbb{R} \) the scalar mass
\( I \) constant inertia matrix
\( F_{ext} \) and \( M_{ext} \) are the external applied forces and moment
In the current implementation, \( R \) is parametrized by a unit quaternion.
Public Functions
-
NewtonEulerDS(SP::SiconosVector position, SP::SiconosVector twist, double mass, SP::SiconosMatrix inertia)
constructor from a minimum set of data
- Parameters
position – initial coordinates of this DynamicalSystem
twist – initial twist of this DynamicalSystem
mass – the mass
inertia – the inertia matrix
-
virtual ~NewtonEulerDS()
destructor
-
virtual void resetToInitialState() override
reset the state to the initial state
-
virtual void initRhs(double time) override
allocate (if needed) and compute rhs and its jacobian.
- Parameters
time – of initialization
-
virtual void initializeNonSmoothInput(unsigned int level) override
set nonsmooth input to zero
- Parameters
level – input-level to be initialized.
-
virtual void computeRhs(double time) override
update right-hand side for the current state
- Parameters
time – of interest
-
virtual void computeJacobianRhsx(double time) override
update \( \nabla_x rhs \) for the current state
- Parameters
time – of interest
-
virtual void resetAllNonSmoothParts() override
reset non-smooth part of the rhs (i.e.
p), for all ‘levels’
-
virtual void resetNonSmoothPart(unsigned int level) override
set nonsmooth part of the rhs (i.e.
p) to zero for a given level
- Parameters
level –
-
inline virtual SP::SiconosVector forces() const override
get forces
- Returns
pointer on a SiconosVector
-
inline virtual SP::SiconosMatrix jacobianqForces() const override
get JacobianqForces
- Returns
pointer on a SiconosMatrix
-
inline virtual SP::SiconosMatrix jacobianvForces() const override
get JacobianvForces
- Returns
pointer on a SiconosMatrix
-
inline virtual unsigned int getqDim() const
Returns dimension of vector q.
-
inline virtual SP::SiconosVector q() const override
get q (pointer link)
- Returns
pointer on a SiconosVector
-
virtual void setQ(const SiconosVector &newValue) override
set value of generalized coordinates vector (copy)
- Parameters
newValue –
-
virtual void setQPtr(SP::SiconosVector newPtr) override
set value of generalized coordinates vector (pointer link)
- Parameters
newPtr –
-
virtual void setQ0(const SiconosVector &newValue) override
set initial state (copy)
- Parameters
newValue –
-
virtual void setQ0Ptr(SP::SiconosVector newPtr) override
set initial state (pointer link)
- Parameters
newPtr –
-
inline SP::SiconosVector twist() const
get twist
- Returns
pointer on a SiconosVector
-
inline virtual SP::SiconosVector velocity() const override
get twist
- Returns
pointer on a SiconosVector this accessor is left to get a uniform access to velocity. This should be removed with MechanicalDS class
-
inline virtual SP::SiconosVector velocity0() const override
get initial velocity (pointer)
- Returns
pointer on a SiconosVector
-
virtual void setVelocity(const SiconosVector &newValue) override
set velocity (copy)
- Parameters
newValue –
-
virtual void setVelocityPtr(SP::SiconosVector newPtr) override
set velocity (pointer link)
- Parameters
newPtr –
-
virtual void setVelocity0(const SiconosVector &newValue) override
set initial velocity (copy)
- Parameters
newValue –
-
virtual void setVelocity0Ptr(SP::SiconosVector newPtr) override
set initial velocity (pointer link)
- Parameters
newPtr –
-
inline virtual SP::SiconosVector acceleration() const override
get acceleration (pointer link)
- Returns
pointer on a SiconosVector
-
inline virtual void computeMass() override
default function to compute the mass
-
inline virtual void computeMass(SP::SiconosVector position) override
function to compute the mass
- Parameters
position – value used to evaluate the mass matrix
-
SP::SiconosVector linearVelocity(bool absoluteRef) const
Get the linear velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters
absoluteRef – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
- Returns
A SiconosVector of size 3 containing the linear velocity of this dynamical system.
-
void linearVelocity(bool absoluteRef, SiconosVector &v) const
Fill a SiconosVector with the linear velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters
absoluteRef – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
v – A SiconosVector of size 3 to receive the linear velocity.
-
SP::SiconosVector angularVelocity(bool absoluteRef) const
Get the angular velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters
absoluteRef – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
- Returns
A SiconosVector of size 3 containing the angular velocity of this dynamical system.
-
void angularVelocity(bool absoluteRef, SiconosVector &w) const
Fill a SiconosVector with the angular velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters
absoluteRef – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
w – A SiconosVector of size 3 to receive the angular velocity.
-
inline double scalarMass() const
get mass value
- Returns
a double
-
inline void setScalarMass(double mass)
Modify the scalar mass.
-
inline SP::SiconosMatrix inertia()
- Returns
the inertia matrix
-
inline void setInertia(SP::SiconosMatrix newInertia)
Modify the inertia matrix (pointer link)
- Parameters
newInertia – the new inertia matrix
-
void setInertia(double ix, double iy, double iz)
Modify the inertia matrix.
- Parameters
ix – x component
iy – y component
iz – z component
-
void updateMassMatrix()
to be called after scalar mass or inertia matrix have changed
-
inline SP::SiconosVector fExt() const
get fExt
- Returns
pointer on a plugged vector
-
inline void setFExtPtr(SP::SiconosVector newPtr)
set fExt to pointer newPtr
- Parameters
newPtr – a SP to a Simple vector
-
inline void setMExtPtr(SP::SiconosVector newPtr)
set mExt to pointer newPtr
- Parameters
newPtr – a SP to a Simple vector
-
inline SP::SiconosVector mGyr() const
get mGyr
- Returns
pointer on a plugged vector
-
inline virtual const SiconosMemory &qMemory() override
get all the values of the state vector q stored in memory
- Returns
a memory
-
inline const SiconosMemory &twistMemory()
get all the values of the state vector twist stored in memory
- Returns
a memory
-
inline virtual const SiconosMemory &velocityMemory() override
get all the values of the state vector twist stored in memory
- Returns
a memory
-
virtual void initMemory(unsigned int steps) override
initialize the SiconosMemory objects with a positive size.
- Parameters
steps – the size of the SiconosMemory (i)
-
virtual void swapInMemory() override
push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory,
- Todo:
Modify the function swapIn Memory with the new Object Memory
-
inline virtual const SiconosMemory &forcesMemory() override
get forces in memory buff
- Returns
pointer on a SiconosMemory
-
inline const SiconosMemory &dotqMemory()¶
-
double computeKineticEnergy()
To compute the kinetic energy.
-
virtual void display(bool brief = true) const override
print the data to the screen
-
inline void setIsMextExpressedInInertialFrame(bool value)¶
-
inline void setNullifyMGyr(bool value)¶
-
virtual void normalizeq()¶
-
virtual void init_inverse_mass() override
Allocate memory for the lu factorization of the mass of the system.
Useful for some integrators with system inversion involving the mass
-
virtual void update_inverse_mass() override
Update the content of the lu factorization of the mass of the system, if required.
-
inline void setComputeJacobianFIntqByFD(bool value)¶
-
inline void setComputeJacobianFIntvByFD(bool value)¶
-
inline void setComputeJacobianMIntqByFD(bool value)¶
-
inline void setComputeJacobianMIntvByFD(bool value)¶
-
inline void setComputeFExtFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute _fExt
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
inline void setComputeMExtFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute _mExt
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
inline void setComputeFExtFunction(FExt_NE fct)
set a specified function to compute _fExt
- Parameters
fct – a pointer on the plugin function
-
inline void setComputeMExtFunction(FExt_NE fct)
set a specified function to compute _mExt
- Parameters
fct – a pointer on the plugin function
-
inline void setComputeFIntFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute _fInt
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
inline void setComputeMIntFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute _mInt
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
inline void setComputeFIntFunction(FInt_NE fct)
set a specified function to compute _fInt
- Parameters
fct – a pointer on the plugin function
-
inline void setComputeMIntFunction(FInt_NE fct)
set a specified function to compute _mInt
- Parameters
fct – a pointer on the plugin function
-
void setComputeJacobianFIntqFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters
pluginPath – std::string : the complete path to the plugin
functionName – std::string : the name of the function to use in this plugin
-
void setComputeJacobianFIntvFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
void setComputeJacobianFIntqFunction(FInt_NE fct)
set a specified function to compute jacobian following q of the FInt
- Parameters
fct – a pointer on the plugin function
-
void setComputeJacobianFIntvFunction(FInt_NE fct)
set a specified function to compute jacobian following v of the FInt
- Parameters
fct – a pointer on the plugin function
-
void setComputeJacobianMIntqFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
void setComputeJacobianMIntvFunction(const std::string &pluginPath, const std::string &functionName)
allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.
- Parameters
pluginPath – the complete path to the plugin
functionName – the name of the function to use in this plugin
-
void setComputeJacobianMIntqFunction(FInt_NE fct)
set a specified function to compute jacobian following q of the FInt
- Parameters
fct – a pointer on the plugin function
-
void setComputeJacobianMIntvFunction(FInt_NE fct)
set a specified function to compute jacobian following v of the FInt
- Parameters
fct – a pointer on the plugin function
-
virtual void computeFExt(double time)
function to compute the external forces
- Parameters
time – the current time
-
virtual void computeFExt(double time, SP::SiconosVector fExt)
default function to compute the external forces
- Parameters
time – the current time
fExt – the computed external force (in-out param)
-
virtual void computeMExt(double time, SP::SiconosVector mExt)
function to compute the external moments The external moments are expressed by default in the body frame, since the Euler equation for Omega is written in the body—fixed frame.
Nevertheless, if _isMextExpressedInInertialFrame) is set to true, we assume that the external moment is given in the inertial frame and we perform the rotation afterwards
- Parameters
time – the current time
mExt – the computed external moment (in-out param)
-
virtual void computeMExt(double time)¶
-
void addExtForceAtPos(SP::SiconosVector force, bool forceAbsRef, SP::SiconosVector pos = SP::SiconosVector(), bool posAbsRef = false)
Adds a force/torque impulse to a body’s FExt and MExt vectors in either absolute (inertial) or relative (body) frame.
Modifies contents of _fExt and _mExt! Therefore these must have been set as constant vectors using setFExtPtr and setMExtPtr prior to calling this function. Adjustments to _mExt will take into account the value of _isMextExpressedInInertialFrame.
- Parameters
force – A force vector to be added.
forceAbsRef – If true, force is in inertial frame, otherwise it is in body frame.
pos – A position at which force should be applied. If nullptr, the center of mass is assumed.
posAbsRef – If true, pos is in inertial frame, otherwise it is in body frame.
-
void computeFInt(double time, SP::SiconosVector q, SP::SiconosVector v)
default function to compute the internal forces
- Parameters
time – the current time function to compute the internal forces
time – the current time
q –
v –
-
virtual void computeFInt(double time, SP::SiconosVector q, SP::SiconosVector v, SP::SiconosVector fInt)
default function to compute the internal forces
- Parameters
time – the current time
q –
v –
fInt – the computed internal force vector
-
void computeMInt(double time, SP::SiconosVector q, SP::SiconosVector v)
default function to compute the internal moments
- Parameters
time – the current time
q –
v –
-
virtual void computeMInt(double time, SP::SiconosVector q, SP::SiconosVector v, SP::SiconosVector mInt)
default function to compute the internal moments
- Parameters
time – the current time
q –
v –
mInt – the computed internal moment vector
-
inline virtual void updatePlugins(double time) override
default function to update the plugins functions using a new time:
- Parameters
time – the current time
-
virtual void init_forces() override
Allocate memory for forces and its jacobian.
-
virtual void computeForces(double time)
Default function to compute forces.
- Parameters
time – double, the current time
-
virtual void computeForces(double time, SP::SiconosVector q, SP::SiconosVector twist) override
function to compute forces with some specific values for q and twist (ie not those of the current state).
- Parameters
time – double : the current time
q – SP::SiconosVector: pointers on q
twist – SP::SiconosVector: pointers on twist
-
virtual void computeJacobianqForces(double time) override
Default function to compute the jacobian w.r.t.
q of forces
- Parameters
time – double, the current time
-
virtual void computeJacobianvForces(double time) override
Default function to compute the jacobian w.r.t.
v of forces
- Parameters
time – double, the current time
-
virtual void computeMGyr(SP::SiconosVector twist)
function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).
- Parameters
twist – SP::SiconosVector: pointers on twist vector
-
virtual void computeMGyr(SP::SiconosVector twist, SP::SiconosVector mGyr)
function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).
- Parameters
twist – pointer to twist vector
mGyr – pointer to gyroscopic forces
-
virtual void computeJacobianMGyrtwist(double time)
Default function to compute the jacobian following q of mGyr.
- Parameters
time – the current time
-
virtual void computeJacobianMGyrtwistByFD(double time, SP::SiconosVector q, SP::SiconosVector twist)
Default function to compute the jacobian following q of mGyr by forward finite difference.
- Parameters
time – the current time
q – current state
twist – pointer to twist vector
-
void computeJacobianFIntq(double time)
To compute the jacobian w.r.t q of the internal forces.
- Parameters
time – double : the current time
-
void computeJacobianFIntv(double time)
To compute the jacobian w.r.t v of the internal forces.
- Parameters
time – double : the current time
-
virtual void computeJacobianFIntq(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t q of the internal forces.
- Parameters
time – double
position – SP::SiconosVector
twist – SP::SiconosVector
-
void computeJacobianFIntqByFD(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t q of the internal forces by forward finite difference.
- Parameters
time – double
position – SP::SiconosVector
twist – SP::SiconosVector
-
virtual void computeJacobianFIntv(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t.
v of the internal forces
- Parameters
time – double: the current time
position – SP::SiconosVector
twist – SP::SiconosVector
-
void computeJacobianFIntvByFD(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t v of the internal forces by forward finite difference.
- Parameters
time – double
position – SP::SiconosVector
twist – SP::SiconosVector
-
virtual void computeJacobianMIntq(double time)
To compute the jacobian w.r.t q of the internal forces.
- Parameters
time – double : the current time
-
virtual void computeJacobianMIntv(double time)
To compute the jacobian w.r.t v of the internal forces.
- Parameters
time – double : the current time
-
virtual void computeJacobianMIntq(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t q of the internal forces.
- Parameters
time – double : the current time,
position – SP::SiconosVector
twist – SP::SiconosVector
-
void computeJacobianMIntqByFD(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t q of the internal moments by forward finite difference.
- Parameters
time – double
position – SP::SiconosVector
twist – SP::SiconosVector
-
virtual void computeJacobianMIntv(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t.
v of the internal forces
- Parameters
time – double: the current time
position – SP::SiconosVector
twist – SP::SiconosVector
-
void computeJacobianMIntvByFD(double time, SP::SiconosVector position, SP::SiconosVector twist)
To compute the jacobian w.r.t v of the internal moments by forward finite difference.
- Parameters
time – double
position – SP::SiconosVector
twist – SP::SiconosVector
-
virtual void computeT()¶
-
virtual void computeTdot()¶
-
ACCEPT_STD_VISITORS()¶
Protected Types
Protected Functions
-
ACCEPT_SERIALIZATION(NewtonEulerDS)¶
-
void _init()¶
Common code for constructors should be replaced in C++11 by delegating constructors.
-
NewtonEulerDS()¶
Default constructor.
-
virtual void _zeroPlugin() override¶
build all _plugin…
Protected Attributes
-
SP::SiconosVector _twist¶
_twist contains the twist of the Newton Euler dynamical system.
_twist[0:2] : \( v_G \in \RR^3 \) velocity of the center of mass in the inertial frame of reference (world frame). _twist[3:5] : \( \Omega\in\RR^3 \) angular velocity expressed in the body-fixed frame
-
SP::SiconosVector _q¶
_q contains the representation of the system In the current implementation, we have _q[0:2] : the coordinates of the center of mass expressed in the inertial frame of reference (world frame) _q[3:6] : an unit quaternion representing the orientation of the solid.
This unit quaternion encodes the rotation mapping from the inertial frame of reference to the body-fixed frame
-
unsigned int _qDim¶
Dimension of _q, is not necessary equal to _ndof.
In our case, _qDim = 7 and _ndof =6
-
SiconosMemory _twistMemory¶
Memory vectors that stores the values within the time—step.
-
SiconosMemory _qMemory¶
-
SiconosMemory _forcesMemory¶
-
SiconosMemory _dotqMemory¶
-
double _scalarMass¶
Scalar mass of the system.
-
SP::SimpleMatrix _T¶
Matrix depending on the parametrization of the orientation \( v = T(q) \dot q \).
-
bool _hasConstantFExt¶
boolean if _fext is constant (set thanks to setFExtPtr for instance) false by default
-
bool _hasConstantMExt¶
boolean if _mext is constant (set thanks to setMExtPtr for instance) false by default
-
bool _isMextExpressedInInertialFrame¶
if true, we assume that mExt is given in inertial frame (default false)
-
SP::SiconosVector _mInt¶
external moment expressed in the body-fixed frame
internal moment of the forces
-
bool _nullifyMGyr¶
if true, we set the gyroscopic forces equal to 0 (default false)
-
bool _computeJacobianFIntqByFD¶
If true, we compute the missing Jacobian by forward finite difference.
-
bool _computeJacobianFInttwistByFD¶
If true, we compute the missing Jacobian by forward finite difference.
-
bool _computeJacobianMIntqByFD¶
If true, we compute the missing Jacobian by forward finite difference.
-
bool _computeJacobianMInttwistByFD¶
If true, we compute the missing Jacobian by forward finite difference.
-
double _epsilonFD¶
value of the step in finite difference
-
SP::PluggedObject _pluginMExt¶
Plugin to compute the external moment expressed in the inertial frame
-
SP::PluggedObject _pluginJacqFInt¶
The following code is commented because the jacobian of _mInt and _fInt are not yet used by the numerical scheme.
Will be needed by a fully implicit scheme for instance. NewtonEulerDS plug-in to compute \( \nabla_qF_{Int}(\dot q, q, t) \), id = “jacobianFIntq”
- Param time
: current time
- Param sizeOfq
: size of vector q
- Param q
: pointer to the first element of q
- Param twist
: pointer to the first element of twist
- Param jacob
[inout] : pointer to the first element of the jacobian
- Param size
of vector z
- Param z
[inout] : a vector of user-defined parameters
-
SP::PluggedObject _pluginJactwistFInt¶
NewtonEulerDS plug-in to compute \( \nabla_{\dot q}F_{Int}(\dot q, q, t) \), id = “jacobianFIntTwist”.
- Param time
: current time
- Param sizeOfq
: size of vector q
- Param q
: pointer to the first element of q
- Param twist
: pointer to the first element of twist
- Param jacob
[inout] : pointer to the first element of the jacobian
- Param size
of vector z
- Param z
[inout] : a vector of user-defined parameters
-
SP::PluggedObject _pluginJacqMInt¶
NewtonEulerDS plug-in to compute \( \nabla_qM_{Int}(\dot q, q, t) \), id = “jacobianMInttwist”.
- Param time
: current time
- Param sizeOfq
: size of vector q
- Param q
: pointer to the first element of q
- Param twist
: pointer to the first element of twist
- Param jacob
[inout] : pointer to the first element of the jacobian
- Param size
of vector z
- Param z
[inout] : a vector of user-defined parameters
-
SP::PluggedObject _pluginJactwistMInt¶
NewtonEulerDS plug-in to compute \( \nabla_{\dot q}M_{Int}(\dot q, q, t) \), id = “jacobianMInttwist”.
- Param time
: current time
- Param sizeOfq
: size of vector q
- Param q
: pointer to the first element of q
- Param twist
: pointer to the first element of twist
- Param jacob
[inout] : pointer to the first element of the jacobian
- Param size
of vector z
- Param z
[inout] : a vector of user-defined parameters
-
VectorOfSMatrices _rhsMatrices¶
A container of matrices to save matrices that are involed in first order from of NewtonEulerDS system values (jacobianXBloc10, jacobianXBloc11, zeroMatrix, idMatrix) No get-set functions at the time.
Only used as a protected member.