# new Ayva(configopt)
Create a new instance of Ayva with the specified configuration.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
Object |
<optional> |
|
name |
String |
<optional> |
the name of this configuration |
defaultAxis |
String |
<optional> |
the default axis to command when no axis is specified |
axes |
Array.<Object> |
<optional> |
an array of axis configurations (see Ayva#configureAxis) |
Members
# static defaultConfiguration
Return a copy of the default configuration.
Methods
# static blendMotion(firstProvider, secondProvider, factor)
Creates a value provider that is a blend of the two value providers passed. The factor is the multiplier for the values generated by the second provider. The first provider's values will be multiplied by 1 - factor.
Parameters:
Name | Type | Description |
---|---|---|
firstProvider |
function | |
secondProvider |
function | |
factor |
Number | value between 0 and 1 |
# static linearMotion(from, to, phaseopt, eccopt, bpmopt, shiftopt)
Eccentric Parametric Oscillatory Linear Motion™
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
from |
Number | the start of the range of motion |
|
to |
Number | the end of the range of motion |
|
phase |
Number |
<optional> |
the phase of the motion in multiples of π/2 |
ecc |
Number |
<optional> |
the eccentricity of the motion |
bpm |
Number |
<optional> |
beats per minute |
shift |
Number |
<optional> |
additional phase shift of the motion in radians |
the value provider
# static linearMotion(params)
Eccentric Parametric Oscillatory Linear Motion™
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | the parameters of the motion. |
the value provider
# static map(value, inMin, inMax, outMinopt, outMaxopt)
Maps a value from one range to another. The default target range is [0, 1]. Does not constrain values to within the range.
This function is analagous to the map() function in the arduino's math library:
https://www.arduino.cc/reference/en/language/functions/math/map/
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Number | |||
inMin |
Number | |||
inMax |
Number | |||
outMin |
Number |
<optional> |
0 | |
outMax |
Number |
<optional> |
1 |
# static parabolicMotion(from, to, phaseopt, eccopt, bpmopt, shiftopt)
Eccentric Parametric Oscillatory Parabolic Motion™
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
from |
Number | the start of the range of motion |
|
to |
Number | the end of the range of motion |
|
phase |
Number |
<optional> |
the phase of the motion in multiples of π/2 |
ecc |
Number |
<optional> |
the eccentricity of the motion |
bpm |
Number |
<optional> |
beats per minute |
shift |
Number |
<optional> |
additional phase shift of the motion in radians |
the value provider
# static parabolicMotion(params)
Eccentric Parametric Oscillatory Parabolic Motion™
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | the parameters of the motion. |
the value provider
# static ramp(fn)
Convert the function provided into a ramp function.
Parameters:
Name | Type | Description |
---|---|---|
fn |
function |
the new ramp function
# static RAMP_COS()
Value provider that generates motion towards a target position that resembles part of a cos wave (0 - 180 degrees).
# static RAMP_LINEAR()
Value provider that generates motion towards a target position with constant velocity.
# static RAMP_NEGATIVE_PARABOLIC()
Value provider that generates motion towards a target position in the shape of the first half of an upside down parabola. This creates the effect of "launching" towards the target position.
# static RAMP_PARABOLIC()
Value provider that generates motion towards a target position in the shape of the latter half of a parabola. This creates the effect of "falling" towards the target position.
# static tempestMotion(from, to, phaseopt, eccopt, bpmopt, shiftopt)
Creates a value provider that generates oscillatory motion. The formula is:
cos(θ + phase·π/2 + ecc·sin(θ + phase·π/2))
The result is translated and scaled to fit the range and beats per minute specified. This formula was created by Tempest MAx—loosely based on orbital motion calculations. Hence, tempestMotion.
See this graph of the function where you can adjust the parameters to see how they affect the motion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
from |
Number | the start of the range of motion |
|
to |
Number | the end of the range of motion |
|
phase |
Number |
<optional> |
the phase of the wave in multiples of π/2 |
ecc |
Number |
<optional> |
the eccentricity of the wave |
bpm |
Number |
<optional> |
beats per minute |
shift |
Number |
<optional> |
additional phase shift of the wave in radians |
the value provider.
Example
// Note: These examples use Move Builders from the Motion API.
// Simple up/down stroke for 10 seconds.
ayva.$.stroke(Ayva.tempestMotion(1, 0), 10).execute();
// ... out of phase with a little eccentricity.
ayva.$.stroke(Ayva.tempestMotion(1, 0, 1, 0.2), 10).execute();
// ... at 30 BPM.
ayva.$.stroke(Ayva.tempestMotion(1, 0, 1, 0.2, 30), 10).execute();
# static tempestMotion(params)
Creates a value provider that generates oscillatory motion. The formula is:
cos(θ + phase·π/2 + ecc·sin(θ + phase·π/2))
The result is translated and scaled to fit the range and beats per minute specified. This formula was created by Tempest MAx—loosely based on orbital motion calculations. Hence, tempestMotion.
See this graph of the function where you can adjust the parameters to see how they affect the motion.
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | the parameters of the motion. |
the value provider.
Example
// Note: These examples use Move Builders from the Motion API.
// Simple up/down stroke for 10 seconds.
ayva.$.stroke(Ayva.tempestMotion({ from: 1, to: 0}), 10).execute();
// ... out of phase with a little eccentricity.
ayva.$.stroke(Ayva.tempestMotion({ from: 1, to: 0, phase: 1, ecc: 0.2 }), 10).execute();
// ... at 30 BPM.
ayva.$.stroke(Ayva.tempestMotion({ from: 1, to: 0, phase: 1, ecc: 0.2, bpm: 30 }), 10).execute();
# addOutput(…output)
Registers a new output. Ayva outputs commands to all connected outputs. More than one output can be specified.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
output |
function | Object |
<repeatable> |
a function or an object with a write() method. |
# addOutputDevice(…device)
Registers a new output device. Ayva outputs commands to all connected devices. More than one device can be specified.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
device |
Object |
<repeatable> |
a function or an object with a write method. |
- Deprecated:
- since version 0.13.0. Use addOutput() instead.
# configureAxis(axisConfig)
Configures a new axis. If an axis with the same name has already been configured, it will be overridden.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
axisConfig |
Object | axis configuration object |
||
name |
String | the machine name of this axis (such as L0, R0, etc...) |
||
type |
String | linear, rotation, or auxiliary |
||
alias |
String |
<optional> |
an alias used to refer to this axis |
|
max |
Number |
<optional> |
1 | specifies maximum value for this axis |
min |
Number |
<optional> |
0 | specifies minimum value for this axis |
Example
const ayva = new Ayva();
ayva.configureAxis({
name: 'L0',
type: 'linear',
alias: 'stroke',
max: 0.9,
min: 0.3,
});
# defaultConfiguration()
Setup this Ayva instance with the default configuration (a six axis stroker).
the instance of Ayva
Example
const ayva = new Ayva().defaultConfiguration();
# async do(behavior)
Perform the specified behavior until it completes or is explicitly stopped. If another behavior is running, it will be stopped.
For full details on how to use this method, see the Behavior API tutorial.
Parameters:
Name | Type | Description |
---|---|---|
behavior |
GeneratorBehavior | function | Object | the behavior to perform. |
# getAxis(name) → {Object}
Fetch an immutable object containing the properties for an axis.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the name or alias of the axis to get. |
axisConfig - an immutable object of axis properties.
# getOutputDevices()
Return a list of all output devices.
- Deprecated:
- since version 0.13.0. Use getOutput() instead.
# async home(speedopt) → {Promise}
Moves all axes to their default positions.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
speed |
Number |
<optional> |
0.5 | optional speed of the movement. |
A promise that resolves when the movements are finished.
# move(…movements) → {Promise}
Performs movements along one or more axes. This is a powerful method that can synchronize axis movement while allowing for fine control over position, speed, or move duration. For full details on how to use this method, see the Motion API tutorial.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
movements |
Object |
<repeatable> |
a promise that resolves with the boolean value true when all movements have finished, or false if the move was cancelled.
Example
ayva.move({
axis: 'stroke',
to: 0,
speed: 1,
},{
axis: 'twist',
to: 0.5,
duration: 1,
});
# ready() → {Promise}
Wait until ayva is not doing anything (neither moving nor sleeping).
a promise that resolves when there are no more moves or sleeps queued.
# removeOutput(output)
Remove the specified output.
Parameters:
Name | Type | Description |
---|---|---|
output |
Object | the output to remove. |
# removeOutputDevice(device)
Remove the specified device.
Parameters:
Name | Type | Description |
---|---|---|
device |
Object | the device to remove. |
- Deprecated:
- since version 0.13.0. Use removeOutput() instead.
# setValues(axisValueMap)
Live update axis values.
Parameters:
Name | Type | Description |
---|---|---|
axisValueMap |
Object | axis to value map |
# sleep(seconds) → {Promise}
Asynchronously sleep for the specified number of seconds (or until stop() is called).
Parameters:
Name | Type | Description |
---|---|---|
seconds |
Number |
a Promise that resolves with the value true if the time elapses. false if the sleep is cancelled.
# stop()
Cancels all running or pending movements, clears the current behavior (if any), and cancels any sleeps.
# updateLimits(axis, from, to)
Update the limits for the specified axis.
Parameters:
Name | Type | Description |
---|---|---|
axis |
String | |
from |
Number | value between 0 and 1 |
to |
Number | value between 0 and 1 |