Description
A motion function p=f(s) where p(t) is an externally-provided sample, as a ZERO_ORDER_HOLD (zero order hold) of FIRST_ORDER_HOLD (first order).
You must keep the setpoint p updated via multiple calls to SetSetpoint(), for example calling SetSetpoint() at each timestep in the simulation loop. It is assumed that one will later evaluate GetPos(), GetLinVel() etc. in close vicinity of the setpoint (old setpoints are not saved), preferably ecactly at the same s, but in vicinity of s there will be extrapolation (after last s) and interpolation (before last s) according to: If in ZERO_ORDER_HOLD mode: value p will persist indefinitely until next call, derivative p_ds and p_dsds will be zero. If in FIRST_ORDER_HOLD mode: value p will interpolate linearly from the previous value, derivative p_ds will be constant, p_dsds will be zero. If in SOH mode: value p will interpolate quadratically, derivative p_ds will be linear, p_dsds will be constant. Default: uses FIRST_ORDER_HOLD mode. Use SetMode() to change it.
#include <ChFunctionPositionSetpoint.h>
Public Types | |
enum | eChSetpointMode { ZERO_ORDER_HOLD, FIRST_ORDER_HOLD, SOH, OVERRIDE } |
Type of setpoint interpolation/extrapolation - zero order hold, first order hold, etc. More... | |
Public Member Functions | |
ChFunctionPositionSetpoint (const ChFunctionPositionSetpoint &other) | |
virtual ChFunctionPositionSetpoint * | Clone () const override |
"Virtual" copy constructor. | |
void | SetMode (eChSetpointMode mmode) |
Sets the extrapolation/interpolation mode. | |
eChSetpointMode | GetMode () |
Gets the extrapolation/interpolation mode. | |
void | Reset (double ms=0) |
Use this to go back to s=0 (the SetSetpoint() function works only if called at increasing s values) | |
virtual void | SetSetpoint (ChVector3d p_setpoint, double s) |
Set the setpoint, and compute its derivatives (speed, acceleration) automatically by backward differentiation (only if s is called at increasing small steps, most often s is time). More... | |
virtual void | SetSetpointAndDerivatives (ChVector3d p_setpoint, ChVector3d p_setpoint_ds, ChVector3d p_setpoint_dsds) |
Set the setpoint, and also its derivatives. More... | |
virtual ChVector3d | GetPos (double s) const override |
Return the position imposed by the function, at s. | |
virtual ChVector3d | GetLinVel (double s) const override |
Return the linear velocity imposed by the function, at s. | |
virtual ChVector3d | GetLinAcc (double s) const override |
Return the linear acceleration imposed the function, at s. | |
virtual void | ArchiveOut (ChArchiveOut &archive_out) override |
Method to allow serialization of transient data to archives. | |
virtual void | ArchiveIn (ChArchiveIn &archive_in) override |
Method to allow de-serialization of transient data from archives. | |
Public Member Functions inherited from chrono::ChFunctionPosition | |
ChFunctionPosition (const ChFunctionPosition &other) | |
virtual void | Update (double t) |
Update could be implemented by children classes, ex. to launch callbacks. | |
Member Enumeration Documentation
◆ eChSetpointMode
Type of setpoint interpolation/extrapolation - zero order hold, first order hold, etc.
Enumerator | |
---|---|
ZERO_ORDER_HOLD | Zero Order Hold: p constant, p_ds = p_dsds = 0 in neighbour of setpoint s. |
FIRST_ORDER_HOLD | First Order Hold: p linear, p_ds constant, p_dsds = 0 in neighbour of setpoint s. |
SOH | First Order Hold: p parabolic, p_ds linear, p_dsds constant in neighbour of setpoint s. |
OVERRIDE | p, p_ds, p_dsds are set via SetSetpointAndDerivatives() and will be considered constant in GetVal(s) regardless of s until next SetSetpointAndDerivatives() |
Member Function Documentation
◆ SetSetpoint()
|
virtual |
Set the setpoint, and compute its derivatives (speed, acceleration) automatically by backward differentiation (only if s is called at increasing small steps, most often s is time).
Note: each time must be called with increasing s so that internally it add sthe 'new' setpoint and scrolls the previous samples for computing extrapolation/interpolation, but if called multiple times with exactly the same s value, the buffer of past samples is not scrolled: it just recompute setpoint and derivatives according to the 'updated' setpoint. If in ZERO_ORDER_HOLD mode: value p will persist indefinitely until next call, derivative p_ds and p_dsds will be zero. If in FIRST_ORDER_HOLD mode: value p will interpolate linearly from the previous value, derivative p_ds will be constant, p_dsds will be zero. If in SOH mode: value p will interpolate quadratically, derivative p_ds will be linear, p_dsds will be constant.
◆ SetSetpointAndDerivatives()
|
inlinevirtual |
Set the setpoint, and also its derivatives.
Moreover, changes the mode to eChSetpointMode::OVERRIDE, so all values will persist indefinitely until next call, that is multiple calls to GetPos(s) GetLinVel() etc. will give same results (non interpolated) regardless of s.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono/functions/ChFunctionPositionSetpoint.h
- /builds/uwsbel/chrono/src/chrono/functions/ChFunctionPositionSetpoint.cpp