Skip to content

Commit

Permalink
AP_InertialSensor: fixed orientation of batch sampled data
Browse files Browse the repository at this point in the history
we need to rotate the data so that FFT displays match the configured
orientation
  • Loading branch information
tridge authored and andyp1per committed Oct 17, 2023
1 parent 76d12ed commit 2f933cc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,23 +662,32 @@ void AP_InertialSensor_Backend::_notify_new_delta_velocity(uint8_t instance, con
}


void AP_InertialSensor_Backend::_notify_new_accel_sensor_rate_sample(uint8_t instance, const Vector3f &accel)
void AP_InertialSensor_Backend::_notify_new_accel_sensor_rate_sample(uint8_t instance, const Vector3f &_accel)
{
#if AP_INERTIALSENSOR_BATCHSAMPLER_ENABLED
if (!_imu.batchsampler.doing_sensor_rate_logging()) {
return;
}

// get batch sampling in correct orientation
Vector3f accel = _accel;
accel.rotate(_imu._accel_orientation[instance]);

_imu.batchsampler.sample(instance, AP_InertialSensor::IMU_SENSOR_TYPE_ACCEL, AP_HAL::micros64(), accel);
#endif
}

void AP_InertialSensor_Backend::_notify_new_gyro_sensor_rate_sample(uint8_t instance, const Vector3f &gyro)
void AP_InertialSensor_Backend::_notify_new_gyro_sensor_rate_sample(uint8_t instance, const Vector3f &_gyro)
{
#if AP_INERTIALSENSOR_BATCHSAMPLER_ENABLED
if (!_imu.batchsampler.doing_sensor_rate_logging()) {
return;
}

// get batch sampling in correct orientation
Vector3f gyro = _gyro;
gyro.rotate(_imu._gyro_orientation[instance]);

_imu.batchsampler.sample(instance, AP_InertialSensor::IMU_SENSOR_TYPE_GYRO, AP_HAL::micros64(), gyro);
#endif
}
Expand Down

0 comments on commit 2f933cc

Please sign in to comment.