Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADIS16470: Publish data only when there are no failures #853

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions src/drivers/imu/analog_devices/adis16470/ADIS16470.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ void ADIS16470::RunImpl()
ScheduleDelayed(SAMPLE_INTERVAL_US * 2);
}

int16_t accel_x;
int16_t accel_y;
int16_t accel_z;

int16_t gyro_x;
int16_t gyro_y;
int16_t gyro_z;

bool success = false;

struct BurstRead {
Expand Down Expand Up @@ -302,26 +310,23 @@ void ADIS16470::RunImpl()
_px4_gyro.set_temperature(temperature);


int16_t accel_x = buffer.X_ACCL_OUT;
int16_t accel_y = buffer.Y_ACCL_OUT;
int16_t accel_z = buffer.Z_ACCL_OUT;
accel_x = buffer.X_ACCL_OUT;
accel_y = buffer.Y_ACCL_OUT;
accel_z = buffer.Z_ACCL_OUT;

// sensor's frame is +x forward, +y left, +z up
// flip y & z to publish right handed with z down (x forward, y right, z down)
accel_y = (accel_y == INT16_MIN) ? INT16_MAX : -accel_y;
accel_z = (accel_z == INT16_MIN) ? INT16_MAX : -accel_z;

_px4_accel.update(timestamp_sample, accel_x, accel_y, accel_z);

gyro_x = buffer.X_GYRO_OUT;
gyro_y = buffer.Y_GYRO_OUT;
gyro_z = buffer.Z_GYRO_OUT;

int16_t gyro_x = buffer.X_GYRO_OUT;
int16_t gyro_y = buffer.Y_GYRO_OUT;
int16_t gyro_z = buffer.Z_GYRO_OUT;
// sensor's frame is +x forward, +y left, +z up
// flip y & z to publish right handed with z down (x forward, y right, z down)
gyro_y = (gyro_y == INT16_MIN) ? INT16_MAX : -gyro_y;
gyro_z = (gyro_z == INT16_MIN) ? INT16_MAX : -gyro_z;
_px4_gyro.update(timestamp_sample, gyro_x, gyro_y, gyro_z);

success = true;

Expand Down Expand Up @@ -353,7 +358,16 @@ void ADIS16470::RunImpl()
// register check failed, force reset
perf_count(_bad_register_perf);
Reset();
return;
}

}

if (success) {
// Publish data if there was no errors

_px4_accel.update(timestamp_sample, accel_x, accel_y, accel_z);
_px4_gyro.update(timestamp_sample, gyro_x, gyro_y, gyro_z);
}
}

Expand Down
Loading