mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 07:28:29 -04:00
448efc70a3
This converts the MPU6000 driver to a frontend/backend structure, and disables all other drivers. They will be progressively re-enabled as each is converted
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#include <AP_HAL.h>
|
|
#include "AP_InertialSensor.h"
|
|
#include "AP_InertialSensor_Backend.h"
|
|
|
|
AP_InertialSensor_Backend::AP_InertialSensor_Backend(AP_InertialSensor &imu, Vector3f &gyro, Vector3f &accel) :
|
|
_imu(imu),
|
|
_gyro(gyro),
|
|
_accel(accel)
|
|
{}
|
|
|
|
/*
|
|
rotate gyro vector and add the gyro offset
|
|
*/
|
|
void AP_InertialSensor_Backend::_rotate_and_offset_gyro(uint8_t instance, uint32_t now)
|
|
{
|
|
_imu._gyro[instance].rotate(_imu._board_orientation);
|
|
_imu._gyro[instance] -= _imu._gyro_offset[instance];
|
|
_imu._last_gyro_sample_time_usec[instance] = now;
|
|
}
|
|
|
|
/*
|
|
rotate accel vector, scale and add the accel offset
|
|
*/
|
|
void AP_InertialSensor_Backend::_rotate_and_offset_accel(uint8_t instance, uint32_t now)
|
|
{
|
|
_imu._accel[instance].rotate(_imu._board_orientation);
|
|
|
|
const Vector3f &accel_scale = _imu._accel_scale[instance].get();
|
|
_imu._accel[instance].x *= accel_scale.x;
|
|
_imu._accel[instance].y *= accel_scale.y;
|
|
_imu._accel[instance].z *= accel_scale.z;
|
|
_imu._accel[instance] -= _imu._accel_offset[instance];
|
|
_imu._last_accel_sample_time_usec[instance] = now;
|
|
}
|