# SimpleRhythms#

Collection of class templates for linear and bilinear rhythm drivers. These are for example used to create the spine rhythms in the AMMR.

```
#include "<AMMR_TOOLS>\ModelUtilities/Rhythms/SimpleRhythms.any"`
```

## #RhythmDriverLinear#

Creates a linear rhythm between the degrees of freedom (DOF) of a kinematic measure. The rhythm is defined by
a `RhythmCoefficients`

vector which defines the relative movement of the DOFs.

In the example below the rhythm constrains two DOFs of the arm to move in a 1:4 ratio.

Example

```
RhythmDriverLinear Rhythm = {
RhythmCoefficients = {0.2, 0.8};
Measures.Input = {
AnyJoint& ref1 = Main.HumanModel.BodyModel.Interface.Arm.Right.ShoulderElevation;
AnyJoint& ref2 = Main.HumanModel.BodyModel.Interface.Arm.Right.GHElevation;
};
```

Full signature

```
RhythmDriverLinear <ObjectName>(
RELATIVE_TO_DOF=1,
) = {
Measures.Input = {
AnyKinMeaure MyMeasure = <...>; (1..Inf)
};
};
```

Arguments

- __CLASS__:
`AnyKinMotion`

- RELATIVE_TO_DOF:
Specifies which kinematic input measure is used in the implementation of the rhythm. By default (RELATIVE_TO_DOF=1) the first measure is used as the reference for the rest. I.e. all other measures are linked to some ratio of the first measure in the underlying matrix defining the rhythm. It is also possible to set this value to -1, in which case the rhythm is implemented implicitly, i.e. all kinematic measures are linked together as in a chain. Note, that implicit implementation prevents the any of the RhythmCoefficients to be zero. (Default: 1)

Expected members

```
Measures.Input = {
AnyKinMeaure MyMeasure = <...>; (1..Inf)
};
```

A number of AnyKinMeasures that are used to define the rhythm

Optional initialization members

##
`RhythmCoefficients = ones(1,Measures.Input.nDim)[0];`

- class type:
`AnyVector`

The Coefficient which defines the relative weights of the kinematic measures in the Rhythm. The default value is a vector of ones.

##
`Measures.Input.r = #default;`

- class type:
`MeasureOrganize`

A number of AnyKinMeasures that are used to define the rhythm AnyKinMeaure MyMeasure = <…>; (1..Inf)

## #_RhythmDriverFunInterpol#

This helper class template used by the `RhythmDriverBiLinear`

class
to implement the interpolation function used in the rhythm.

Full signature

```
_RhythmDriverFunInterpol <ObjectName> = {};
```

Arguments

- __CLASS__:
`AnyFunInterpol`

## #RhythmDriverBiLinear#

Creates a bi-linear rhythm between a number of input kinematic measures where the
RhythmCoefficients can be different between the positive and negative values of
the input measures. The rhythm is similar to simple `RhythmDriverLinear`

template
but is defined by two sets of RhythmCoefficients.

`RhythmCoefficients`

: for positive values of the input measures`RhythmCoefficientsNegative`

: for negative values of the input measures`TransitionInterval`

: The interval over which the transition between the two sets of RhythmCoefficients is performed.

The RhythmCoefficients are defined as a vector of coefficients for each kinematic measure. The relative ratio between the coefficients defines the rhythm. If the coefficients sum to 1, then the coefficients can be interpreted as the relative fraction of the kinematic measures in the rhythm.

Full signature

```
RhythmDriverBiLinear <ObjectName>(
NDIM=<required>,
RELATIVE_TO_DOF=1,
) = {
Measures.Input = {
AnyKinMeasure MyMeasure = <...>; (1..Inf)
};
RhythmCoefficients = <Required>;
RhythmCoefficientsNegative = <Required>;
};
```

Arguments

- __CLASS__:
`AnyKinEq`

- NDIM:
The number of kinematic measures used in the implementation of the rhythm. Due to the implementation it of this class template it is necessary to specify this value explicitly. (Required)

- RELATIVE_TO_DOF:
Specifies which kinematic input measure is used in the implementation of the rhythm. By default (RELATIVE_TO_DOF=1) the first measure is used as the reference for the rest. I.e. all other measures are linked to some ratio of the first measure in the underlying matrix defining the rhythm. It is also possible to set this value to -1, in which case the rhythm is implemented implicitly, i.e. all kinematic measures are linked together as in a chain. Note, that implicit implementation prevents the any of the RhythmCoefficients to be zero. (Default: 1)

Expected members

```
Measures.Input = {
AnyKinMeasure MyMeasure = <...>; (1..Inf)
};
```

A number of AnyKinMeasures that are used to define the rhythm

Required initialization members

```
RhythmCoefficients = <Required>;
```

- class type:
`AnyVector`

The coefficient which defines the relative weights of the kinematic measures in the Rhythm for positive inputs.

```
RhythmCoefficientsNegative = <Required>;
```

- class type:
`AnyVector`

The coefficient which defines the relative weights of the kinematic measures in the Rhythm for negative inputs.

Optional initialization members

##
`TransitionInterval = 0.1;`

- class type:
`AnyVar`

The interval over which the transition between the two sets of RhythmCoefficients is performed.

##
`Measures.Input.r = #default;`

- class type:
`MeasureOrganize`

A number of AnyKinMeasures that are used to define the rhythm AnyKinMeasure MyMeasure = <…>; (1..Inf)