msVectorToAngles (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.50.00


This function will take the applied values and calculate the angles of the axis relative to acceleration forces.

 

When mode is ABSOLUTE (see msAccEnable) and not moving, the angles returned will represent the tilt of each axis relative to the earth surface.

 

 

Input:

X : FLOAT

The acceleration force measured on the X-axis.

 

Y : FLOAT

The acceleration force measured on the Y-axis.

 

Z : FLOAT

The acceleration force measured on the Z-axis.

 

Output:

Roll : FLOAT

Angle of the X-axis relative to acceleration forces in 0.01 degrees.

 

Pitch : FLOAT

Angle of the Y-axis relative to acceleration forces in 0.01 degrees.

 

Yaw : FLOAT

Angle of the Z-axis  relative to acceleration forces in 0.01 degrees.

 

Returns: INT

1

-

Success.

0

-

This function is not supported.

 

Declaration:

FUNCTION msVectorToAngles : INT;
VAR_INPUT
  X       : FLOAT;
  Y       : FLOAT;
  Z       : FLOAT;
  Roll    : ACCESS FLOAT;
  Pitch   : ACCESS FLOAT;
  Yaw     : ACCESS FLOAT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  val   : msDataSet;
  roll  : FLOAT;
  pitch : FLOAT;
  yaw   : FLOAT;
END_VAR;
 
msOpen();
msAccEnable(enable := TRUE, mode := 2);
 
BEGIN
msRead(data := val);
msVectorToAngles(x := val.AccX, y := val.AccY, z := val.AccZ, roll := roll, pitch := pitch, yaw := yaw);
 ...
END;
END_PROGRAM;