![]() |
nRF Connect SDK API 3.3.99
|
| int accel_to_angle_calc | ( | struct accel_to_angle_ctx * | ctx, |
| const struct sensor_value | vals[3], | ||
| struct accel_to_angle_pr_data * | pr ) |
#include <include/accel_to_angle/accel_to_angle.h>
Calculate pitch and roll angles from accelerometer data.
The function calculates pitch and roll angles from accelerometer data. The accelerometer data is provided as an array the size of ACCEL_TO_ANGLE_AXIS_NUM. The order of the axes in the array is X, Y, Z. The calculated pitch and roll angles are stored in the provided accel_to_angle_pr_data struct.
The provided accel_to_angle_pr_data structure can be NULL. In this case, the function will only update the internal state of the context instance, and the calculated pitch and roll angles will not be returned to the caller.
If a filter is set in the accel_to_angle_ctx context, it is applied to the accelerometer data before calculating the rotation. Otherwise, the raw accelerometer data is used.
| [in] | ctx | Pointer to the accel_to_angle_ctx context. |
| [in] | vals | Array of sensor values containing accelerometer data for X, Y, Z axes. |
| [out] | pr | Pointer to the structure with pitch and roll data where the calculated rotation (in degrees) is stored. This can be NULL if the calculated rotation is not needed. |
| 0 | If the operation was successful. Otherwise, a (negative) error code is returned. |