# IMU Overview

## Accelerometer

The accelerometer detects the instantaneous acceleration of the camera. The data provided by the accelerometer determines whether the camera is getting faster or slower, in any directions, with a precise value in meter per second squared (m/s²).

When an accelerometer is static, it is still measuring an acceleration of 9.8m/s² which corresponds to the force applied by the earth gravity. This force has always the same direction, from the camera to the center of the earth. The gravity allows to compute the camera’s absolute inclination and detect events like free falls.

## Gyroscope

A gyroscope measures the angular velocity of the camera in degrees per second (deg/s). When combined with the accelerometer, both sensors can estimate the orientation of the camera at a high frequency.

## Output Data

The following information is accessible from the camera sensor stack:

Output Data | Description | Units |
---|---|---|

Accelerometer |
||

linear_acceleration | 3x1 Vector for linear acceleration of the IMU given in m/s^{2}. Values are corrected from bias, scale and misalignment. |
m/s^{2} |

linear_acceleration_uncalibrated | 3x1 Vector for linear acceleration of the accelerometer, given in m/s^{2}. Values are not corrected from bias, scale nor misalignment. |
m/s^{2} |

linear_acceleration_covariance | 3x3 Covariance matrix for the uncalibrated linear acceleration of the accelerometer. | |

Gyroscope |
||

angular_velocity | 3x1 Vector for angular velocity of the gyroscope, given in deg/s. Values are corrected from bias, scale and misalignment. | deg/s |

angular_velocity_uncalibrated | 3x1 Vector for angular velocity of the gyroscope, given in deg/s. Values are not corrected from bias, scale nor misalignment. | deg/s |

angular_velocity_covariance | 3x3 Covariance matrix for the uncalibrated angular velocity of the gyroscope. | |

Orientation |
||

pose | IMU pose extracted from the fusion of the accelerometer and gyroscope measurements. Represented as a Transform. | |

pose_covariance | 3x3 Covariance matrix for pose orientation. |

## Using the API

Accessing the motion sensor data can be done through the `sl::SensorData`

class. This data is stored in the class `sl::SensorData::IMUData`

which amongst others contains the accelerometer and gyroscope values.

You can access the IMU data as follow:

```
sl::SensorsData::IMUData imu_data;
imu_data = sensor_data.imu;
```

```
imu_data = sl.SensorsData.IMUData()
imu_data = sensor_data.imu
```

### Accelerometer

Within the IMU, the accelerometer provides the linear acceleration of the sensor. It can be used to detect a variation of the camera speed or a sudden movement. As it also provides the gravity force, it can be used to detect a free fall or other events by estimating the inclination of the camera relative to the earth.

This values can be accessed with:

```
sl::float3 linear_acceleration;
linear_acceleration = imu_data.linear_acceleration
```

```
accel = sl.float3()
linear_acceleration = imu_data.linear_acceleration
```

To access the raw (uncalibrated) values, use `imu_data.linear_acceleration_uncalibrated`

.

### Gyroscope

Within the IMU, the gyroscope provides the angular velocity of the sensor. Therefore it can be used to detect a movement and track the relative orientation of the camera.

The gyroscope values can be accessed with:

```
sl::float3 angular_velocity;
angular_velocity = imu_data.angular_velocity
```

```
angular_velocity = sl.float3()
angular_velocity = imu_data.angular_velocity
```

To access the raw (uncalibrated) values, use `imu_data.angular_velocity_uncalibrated`

.

### Pose

One the key-reason of having the accelerometer and gyroscope in the camera it that their data can be fused to estimate the camera orientation. The accelerometer provides the gravity orientation, while the gyroscope estimates the rotations applied to the camera. Fused at high frequency, the combination of both sensors provides a robust orientation estimation.

The pose can be retrieved with `imu_data.pose`

.

## Code Example

For code example, check out the Getting Sensor Data tutorial.