Skip to content
Snippets Groups Projects
Commit 75bb3e9b authored by Beat Küng's avatar Beat Küng Committed by Daniel Agar
Browse files

bmi055: add support for IMU_GYRO_CUTOFF and IMU_ACCEL_CUTOFF

parent ba6ef193
No related branches found
No related tags found
No related merge requests found
......@@ -118,11 +118,13 @@ BMI055_accel::init()
_accel_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_accel_s));
if (_accel_reports == nullptr) {
goto out;
return -ENOMEM;
}
if (reset() != OK) {
goto out;
ret = reset();
if (ret != OK) {
return ret;
}
/* Initialize offsets and scales */
......@@ -135,6 +137,16 @@ BMI055_accel::init()
_accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH);
param_t accel_cut_ph = param_find("IMU_ACCEL_CUTOFF");
float accel_cut = BMI055_ACCEL_DEFAULT_DRIVER_FILTER_FREQ;
if (accel_cut_ph != PARAM_INVALID && (param_get(accel_cut_ph, &accel_cut) == PX4_OK)) {
_accel_filter_x.set_cutoff_frequency(BMI055_ACCEL_DEFAULT_RATE, accel_cut);
_accel_filter_y.set_cutoff_frequency(BMI055_ACCEL_DEFAULT_RATE, accel_cut);
_accel_filter_z.set_cutoff_frequency(BMI055_ACCEL_DEFAULT_RATE, accel_cut);
}
measure();
/* advertise sensor topic, measure manually to initialize valid report */
......@@ -149,7 +161,6 @@ BMI055_accel::init()
warnx("ADVERT FAIL");
}
out:
return ret;
}
......
......@@ -117,11 +117,13 @@ BMI055_gyro::init()
_gyro_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_gyro_s));
if (_gyro_reports == nullptr) {
goto out;
return -ENOMEM;
}
if (reset() != OK) {
goto out;
ret = reset();
if (ret != OK) {
return ret;
}
/* Initialize offsets and scales */
......@@ -132,11 +134,14 @@ BMI055_gyro::init()
_gyro_scale.z_offset = 0;
_gyro_scale.z_scale = 1.0f;
param_t gyro_cut_ph = param_find("IMU_GYRO_CUTOFF");
float gyro_cut = BMI055_GYRO_DEFAULT_DRIVER_FILTER_FREQ;
/* if probe/setup failed, bail now */
if (ret != OK) {
DEVICE_DEBUG("gyro init failed");
return ret;
if (gyro_cut_ph != PARAM_INVALID && (param_get(gyro_cut_ph, &gyro_cut) == PX4_OK)) {
_gyro_filter_x.set_cutoff_frequency(BMI055_GYRO_DEFAULT_RATE, gyro_cut);
_gyro_filter_y.set_cutoff_frequency(BMI055_GYRO_DEFAULT_RATE, gyro_cut);
_gyro_filter_z.set_cutoff_frequency(BMI055_GYRO_DEFAULT_RATE, gyro_cut);
}
_gyro_class_instance = register_class_devname(GYRO_BASE_DEVICE_PATH);
......@@ -154,7 +159,6 @@ BMI055_gyro::init()
warnx("ADVERT FAIL");
}
out:
return ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment