Skip to content

Commit 8809277

Browse files
committed
pybricks.common.IMU: Relax default stationary thresholds.
This makes sure that the defaults work better in noisier conditions. Fixes pybricks/support#1105
1 parent 9d1327c commit 8809277

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@
1010
is a tuple of `(name, num_values, data_type)` tuples for each available mode.
1111
- Added `pybricks.tools.read_input_byte()` function ([support#1102]).
1212

13+
### Changed
14+
- Relaxed thesholds that define when the IMU is stationary, to make the
15+
defaults work better in noisier conditions ([support#1105]).
16+
1317
### Fixed
1418
- Fixed Technic (Extra) Large motors not working ([support#1131]) on all hubs.
1519
- Fixed Powered Up Light not working ([support#1131]) on all hubs.
1620
- Fixed UART sensors not working on Technic Hub ([support#1137]).
1721
- Fixed incorrect number of ports on City Hub ([support#1131]).
1822

1923
[support#1054]: https://github.com/pybricks/support/issues/1054
24+
[support#1105]: https://github.com/pybricks/support/issues/1105
2025
[support#1131]: https://github.com/pybricks/support/issues/1131
2126
[support#1137]: https://github.com/pybricks/support/issues/1137
2227

lib/pbio/drv/imu/imu_lsm6ds3tr_c_stm32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ static PT_THREAD(pbdrv_imu_lsm6ds3tr_c_stm32_init(struct pt *pt)) {
228228
imu_dev->config.gyro_scale = lsm6ds3tr_c_from_fs2000dps_to_mdps(1) / 1000.0f;
229229

230230
// default noise thresholds, can be changed during runtime
231-
imu_dev->config.gyro_stationary_threshold = 20; // 1.4 deg/s
232-
imu_dev->config.accel_stationary_threshold = 100; // 240 mm/s^2, or approx 2.5^ of gravity
231+
imu_dev->config.gyro_stationary_threshold = 71; // 5 deg/s
232+
imu_dev->config.accel_stationary_threshold = 1044; // 2500 mm/s^2, or approx 25% of gravity
233233

234234
// Configure INT1 to trigger when new gyro data is ready.
235235
PT_SPAWN(pt, &child, lsm6ds3tr_c_pin_int1_route_set(&child, ctx, (lsm6ds3tr_c_int1_route_t) {

pybricks/common/pb_type_imu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ mp_obj_t pb_type_IMU_obj_new(mp_obj_t top_side_axis_in, mp_obj_t front_side_axis
249249
pbio_imu_set_base_orientation(&front_side_axis, &top_side_axis);
250250

251251
// Default noise thresholds.
252-
pbio_imu_set_stationary_thresholds(1.5f, 250.0f);
252+
pbio_imu_set_stationary_thresholds(5.0f, 2500.0f);
253253

254254
// Return singleton instance.
255255
return MP_OBJ_FROM_PTR(&singleton_imu_obj);

0 commit comments

Comments
 (0)