Basicshape: GoToPosition

This function moves the basic shape to a specified position.

The movement starts at an initial speed, an optional acceleration or deceleration takes place, it travels at the specified speed, then an optional deceleration to zero (reaching zero at the end of the motion) occurs.

It can take an optional callback function, that is given the object, its position at the time of the callback, and the speed at the time of the callback. The callback function can be called periodically, by specifying the period via an integer value (representing milliseconds), or with an array of integers. If given an array of integers, the callback is called for each value in the array, N milliseconds before the motion completes where N is a member of the array.

Any acceleration or deceleration value will be treated as infinite if it is less than or equal to zero. Note that this means that deceleration must be given as a positive value.

Function

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray, xAcc, xDec, yAcc, yDec, zAcc, zDec);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed, xAcc, xDec, yAcc, yDec, zAcc, zDec, initX, initY, initZ);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, xAcc, xDec, yAcc, yDec, zAcc, zDec, initX, initY, initZ);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval, xAcc, xDec, yAcc, yDec, zAcc, zDec, initX, initY, initZ);

void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray, xAcc, xDec, yAcc, yDec, zAcc, zDec, initX, initY, initZ);

Parameters

Name Type Description
x Number The X coordinate of the target position
y Number The Y coordinate of the target position
z Number The Z coordinate of the target position
xSpeed Number The speed along the X axis
ySpeed Number The speed along the Y axis
zSpeed Number The speed along the Z axis
CallbackFunction Number Callback function will be called
CallbackInterval Number Interval in milliseconds when callback function is called
intOffsetArray Array Array of integer values in milliseconds. The callback function is called when equipment reaches any of those offset.
xAcc Number Acceleration of X axis
xDec Number Deceleration of X axis
yAcc Number Acceleration of Y axis
yDec Number Deceleration of Y axis
zAcc Number Acceleration of Z axis
zDec Number Deceleration of Z axis
initX Number The speed that the X axis starts moving at.
initY Number The speed that the Y axis starts moving at.
initZ Number The speed that the Z axis starts moving at.

Return Value

None

Example

function OnSimulationStart()
{
    InitAnimation();
    StartAnimation(); 
}

function InitAnimation()
{
    //-- get basic shapes
    _basicShape1 = GetComponentByNameAndType("BasicShape1", "Basic Shape");
    _basicShape1.X = 0.0
    _basicShape1.Y = 0.0

    _basicShape2 = GetComponentByNameAndType("BasicShape2", "Basic Shape");
    _basicShape2.X = 2.0
    _basicShape2.Y = 0.0

    _basicShape3 = GetComponentByNameAndType("BasicShape3", "Basic Shape");
    _basicShape3.X = 4.0
    _basicShape3.Y = 0.0

    _basicShape4 = GetComponentByNameAndType("BasicShape4", "Basic Shape");
    _basicShape4.X = 6.0
    _basicShape4.Y = 0.0

    _basicShape5 = GetComponentByNameAndType("BasicShape5", "Basic Shape");
    _basicShape5.X = 8.0
    _basicShape5.Y = 0.0

    _basicShape6 = GetComponentByNameAndType("BasicShape6", "Basic Shape");
    _basicShape6.X = 10.0
    _basicShape6.Y = 0.0

    _basicShape7 = GetComponentByNameAndType("BasicShape7", "Basic Shape");
    _basicShape7.X = 12.0
    _basicShape7.Y = 0.0

    _basicShape8 = GetComponentByNameAndType("BasicShape8", "Basic Shape");
    _basicShape8.X = 14.0
    _basicShape8.Y = 0.0
}

function StartAnimation()
{
    SubscribeToEvent("OnArrivePosition", _basicShape7.Name, "Basic Shape", "OnArrivePosition_callbackFromEvent");
    Move();
}

function OnArrivePosition_callback(sender, x, y, z, speedX, speedY, speedZ)
{
    LogDebug("-> OnArrivePosition_callback " + sender.Name + " Arrived x=" + x + " y=" + y + " z=" + z + ` Speed x=${speedX} y=${speedY} z=${speedZ}`);
}

function OnArrivePosition_callbackFromEvent(sender, x, y, z, speedX, speedY, speedZ)
{
    LogDebug("-> OnArrivePosition_callbackFromEvent " + sender.Name + " Arrived x=" + x + " y=" + y + " z=" + z + ` Speed x=${speedX} y=${speedY} z=${speedZ}`)
}

function Move()
{
    //-- Default
    _basicShape1.GoToPosition(0, 0, 5, 0, 0, 1);

    //-- Default with Acceleration deceleration
    _basicShape2.GoToPosition(2, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0.5, 0.5); 

    //-- With callback
    _basicShape3.GoToPosition(4, 0, 5, 0, 0, 1, OnArrivePosition_callback);

    //-- With callback and Acceleration deceleration
    _basicShape4.GoToPosition(6, 0, 5, 0, 0, 1, OnArrivePosition_callback, 0, 0, 0, 0, 0.5, 0.5); 

    //-- with callback, interval
    _basicShape5.GoToPosition(8, 0, 5, 0, 0, 1, OnArrivePosition_callback, 500);

    //-- With callback ,interval and Acceleration deceleration
    _basicShape6.GoToPosition(10, 0, 5, 0, 0, 1, OnArrivePosition_callback, 500, 0, 0, 0, 0, 0.5, 0.5);

    //-- With callback, offset
    _basicShape7.GoToPosition(12, 0, 5, 0, 0, 1, OnArrivePosition_callback, [3000,2000,1000,500]);

    //-- With callback, offset and acceleration deceleration
    _basicShape8.GoToPosition(14, 0, 5, 0, 0, 1, OnArrivePosition_callback, [3000,2000,1000,500], 0, 0, 0, 0, 0.5, 0.5); 
}