Description
Sequence function: y = sequence_of_functions(f1(y), f2(y), f3(y))
All other function types can be inserted into this.
#include <ChFunctionSequence.h>
Public Member Functions | |
ChFunctionSequence (const ChFunctionSequence &other) | |
virtual ChFunctionSequence * | Clone () const override |
"Virtual" copy constructor (covariant return type). | |
virtual Type | GetType () const override |
Return the unique function type identifier. | |
virtual double | GetVal (double x) const override |
Return the function output for input x. More... | |
virtual double | GetDer (double x) const override |
Return the first derivative of the function. More... | |
virtual double | GetDer2 (double x) const override |
Return the second derivative of the function. More... | |
void | SetStartArg (double start) |
The sequence of functions starts at this x value. | |
double | GetStartArg () const |
The sequence of functions starts at this x value. | |
std::list< ChFseqNode > & | GetFunctions () |
Access the list of the sub-functions. | |
void | Setup () |
Scans all the seq.of functions and setup the timings and continuity offsets, to satisfy all constraints. More... | |
bool | InsertFunct (std::shared_ptr< ChFunction > myfx, double duration, double weight=1, bool c0=false, bool c1=false, bool c2=false, int position=-1) |
Insert function after the fx with defined "position" index in list. More... | |
bool | RemoveFunct (int index) |
Remove and deletes function with defined "position", and returns true. More... | |
std::shared_ptr< ChFunction > | GetFunction (int index) |
Returns the ChFunction with given "index". More... | |
ChFseqNode * | GetNode (int index) |
As above, but returns the function node (containing function pointer, function duration, continuity flags with previous node, etc.) | |
double | GetWidth (int index) |
As above, but returning duration. More... | |
virtual double | GetWeight (double x) const override |
Return the weight of the function. More... | |
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::ChFunction | |
ChFunction (const ChFunction &other) | |
virtual double | GetDer3 (double x) const |
Return the third derivative of the function. More... | |
virtual double | GetDerN (double x, int der_order) const |
Return the Nth derivative of the function (up to 3rd derivative). More... | |
virtual void | Update (double x) |
Update the function at the provided value of its argument. | |
virtual double | GetMax (double xmin, double xmax, double sampling_step, int der_order) const |
Estimate the maximum of the function (or its der_order derivative) in the range [xmin, xmax]. More... | |
virtual double | GetMin (double xmin, double xmax, double sampling_step, int der_order) const |
Estimate the minimum of the function (or its der_order derivative) in the range [xmin, xmax]. More... | |
virtual double | GetMean (double xmin, double xmax, double sampling_step, int der_order) const |
Estimate the mean of the function (or its der_order derivative) in the range [xmin, xmax]. More... | |
virtual double | GetSquaredMean (double xmin, double xmax, double sampling_step, int der_order) const |
Estimate the squared mean of the function (or its der_order derivative) in the range [xmin, xmax]. More... | |
virtual double | GetIntegral (double xmin, double xmax, double sampling_step, int der_order) const |
Estimate the integral of the function (or its der_order derivative) over the range [xmin, xmax]. More... | |
virtual double | GetPositiveAccelerationCoeff () const |
Compute the positive acceleration coefficient. More... | |
virtual double | GetNegativeAccelerationCoeff () const |
Compute the negative acceleration coefficient. More... | |
virtual double | GetVelocityCoefficient () const |
Compute the velocity coefficient. More... | |
virtual void | OutputToASCIIFile (std::ostream &file, double xmin, double xmax, int samples, char delimiter) |
Store X-Y pairs to an ASCII File. More... | |
virtual ChMatrixDynamic | SampleUpToDerN (double xmin, double xmax, double step, int derN=0) |
Sample function on given interval [xmin, xmax], up to derN derivative (0 being the function ouput itself). More... | |
double | operator() (double arg) const |
Alias operator of the GetVal function. | |
Protected Attributes | |
std::list< ChFseqNode > | m_functions |
the list of sub functions | |
double | m_start |
start time for sequence | |
Additional Inherited Members | |
Public Types inherited from chrono::ChFunction | |
enum | Type { BSPLINE, CONSTANT, CONSTACC, CONSTJERK, CUSTOM, CYCLOIDAL, DERIVATIVE, FILLET3, INTEGRAL, INTERP, LAMBDA, MIRROR, OPERATOR, POLY, POLY23, POLY345, RAMP, REPEAT, SEQUENCE, SINE, SINE_STEP } |
Enumeration of function types. | |
Member Function Documentation
◆ GetDer()
|
overridevirtual |
Return the first derivative of the function.
Default implementation computes a numerical differentiation. Inherited classes may override this method with a more efficient implementation (e.g. analytical solution).
Reimplemented from chrono::ChFunction.
◆ GetDer2()
|
overridevirtual |
Return the second derivative of the function.
Default implementation computes a numerical differentiation. Inherited classes may override this method with a more efficient implementation (e.g. analytical solution).
Reimplemented from chrono::ChFunction.
◆ GetFunction()
std::shared_ptr< ChFunction > chrono::ChFunctionSequence::GetFunction | ( | int | index | ) |
Returns the ChFunction with given "index".
- If index = 0, returns always head (beginning),
- If index = -1 returns tail (end).
- If index > max number of current nodes, returns tail fx anyway.
◆ GetVal()
|
overridevirtual |
Return the function output for input x.
Must be overridden by specialized classes.
Implements chrono::ChFunction.
◆ GetWeight()
|
overridevirtual |
Return the weight of the function.
(useful for applications where you need to mix different weighted ChFunctions)
Reimplemented from chrono::ChFunction.
◆ GetWidth()
double chrono::ChFunctionSequence::GetWidth | ( | int | index | ) |
As above, but returning duration.
(return value is reference, so it can be also changed later, but remember Setup() for the ChFunctionSequence after you modified this return value by reference TO DO). If no function, returns 0.
◆ InsertFunct()
bool chrono::ChFunctionSequence::InsertFunct | ( | std::shared_ptr< ChFunction > | myfx, |
double | duration, | ||
double | weight = 1 , |
||
bool | c0 = false , |
||
bool | c1 = false , |
||
bool | c2 = false , |
||
int | position = -1 |
||
) |
Insert function after the fx with defined "position" index in list.
- If index is higher than available objects, it simply goes to the end.
- If index = 0 insert at the beginning,
- If index = -1 insert at the end. Inserted functions will be deleted automatically when this object will be deleted. The fx segment has its own 'weight': use 1.0 for default, or different weights if you want that GetWeight() will give different results depending on the "x" parameter. Set c0=true if you want to force C0 continuity with previous function (an offset will be implicitly added to the function, as y=f(x)+Offset). Same for C1 and C2 continuity, using c1 and c2 flags.
- Parameters
-
myfx the function to insert duration duration of the time segment for this function weight optional weight scalar c0 impose continuity to previous f() by offsetting/slanting c1 impose continuity to previous f() by offsetting/slanting c2 impose continuity to previous f() by offsetting/slanting position position index, 0,1,2,3.. (if -1 insert at the end)
◆ RemoveFunct()
bool chrono::ChFunctionSequence::RemoveFunct | ( | int | index | ) |
Remove and deletes function with defined "position", and returns true.
- If index = 0, removes always head (beginning),
- If index = -1 removes tail (end).
- If index > max number of current nodes, removes tail anyway, but returns false.
◆ Setup()
void chrono::ChFunctionSequence::Setup | ( | ) |
Scans all the seq.of functions and setup the timings and continuity offsets, to satisfy all constraints.
This must be called whenever a new function is inserted, or its timing and continuity constraints are changed.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono/functions/ChFunctionSequence.h
- /builds/uwsbel/chrono/src/chrono/functions/ChFunctionSequence.cpp