Main Content

linaccel

Linear acceleration from accelerometer reading

Since R2023b

Description

acc = linaccel(orientations,accReadings) returns the linear accelerations of the accelerometer in the north-east-down (NED) reference frame based on the accelerometer readings and its orientations.

example

acc = linaccel(___,RF) specifies the reference frame as the "NED" (north-east-down) or the "ENU" (east-north-up) reference frame.

Examples

collapse all

Assume that the accelerometer measurement frame is exactly aligned with the local NED frame and define its orientation in quaternions.

quat0 = ones(1,"quaternion")
quat0 = quaternion
     1 + 0i + 0j + 0k

Obtain the linear acceleration using the linaccel function the acceleration reading of 0. As expected, the linear acceleration vector contains only the gravitational acceleration.

acc0 = linaccel(quat0,zeros(1,3));
disp(acc0)
         0         0    9.8100

Next, obtain the linear acceleration with the reading of [1 1 1] m/s2.

acc1 = linaccel(quat0,ones(1,3));
disp(acc1)
   -1.0000   -1.0000    8.8100

Finally, create a vector of random quaternions and some random accelerometer readings. Obtain the corresponding linear accelerations.

rng(2023) % For repeatable results
quats = randrot(10,1);
accReadings = randn(10,3);
linearAccs = linaccel(quats,accReadings)
linearAccs = 10×3

   -1.1666    1.3727   10.5044
   -0.6536    0.8999    9.6202
   -0.1499   -1.2073   11.3756
    1.7606   -0.1023    8.4418
   -0.4588   -0.2137   10.0868
    0.5909   -0.4882    9.5781
   -1.8862    0.7566   10.3921
   -0.8211   -0.1111   10.3667
   -1.4470    1.7535    8.9106
   -0.6821   -1.0202    9.4492

Input Arguments

collapse all

Orientations of the accelerometer with respect to the reference frame, specified as an N-by-1 vector of quaternion objects or a 3-by-3-by-N array of rotation matrices. N is the total number of orientations.

Accelerometer readings, specified as an N-by-3 real-valued matrix in m/s2. The number of readings N must be the same as the number of orientations in orientations.

Tip

The function assumes that the accelerometer readings do not contain the gravitational acceleration.

Reference frame, specified as "NED" for the north-east-down frame or "ENU" for the east-north-up frame.

Data Types: string | char

Output Arguments

collapse all

Linear accelerations, returned as a N-by-3 real-valued matrix. N is the total number of accelerometer readings specified in accReadings. Each row of the matrix is a linear acceleration vector.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2023b