Skip to content

Commit

Permalink
pybricks.common.IMU: Relax default stationary thresholds.
Browse files Browse the repository at this point in the history
This makes sure that the defaults work better in noisier conditions.

Fixes pybricks/support#1105
  • Loading branch information
laurensvalk committed Jul 7, 2023
1 parent 9d1327c commit 8809277
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
is a tuple of `(name, num_values, data_type)` tuples for each available mode.
- Added `pybricks.tools.read_input_byte()` function ([support#1102]).

### Changed
- Relaxed thesholds that define when the IMU is stationary, to make the
defaults work better in noisier conditions ([support#1105]).

### Fixed
- Fixed Technic (Extra) Large motors not working ([support#1131]) on all hubs.
- Fixed Powered Up Light not working ([support#1131]) on all hubs.
- Fixed UART sensors not working on Technic Hub ([support#1137]).
- Fixed incorrect number of ports on City Hub ([support#1131]).

[support#1054]: https://github.com/pybricks/support/issues/1054
[support#1105]: https://github.com/pybricks/support/issues/1105
[support#1131]: https://github.com/pybricks/support/issues/1131
[support#1137]: https://github.com/pybricks/support/issues/1137

Expand Down
4 changes: 2 additions & 2 deletions lib/pbio/drv/imu/imu_lsm6ds3tr_c_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ static PT_THREAD(pbdrv_imu_lsm6ds3tr_c_stm32_init(struct pt *pt)) {
imu_dev->config.gyro_scale = lsm6ds3tr_c_from_fs2000dps_to_mdps(1) / 1000.0f;

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

// Configure INT1 to trigger when new gyro data is ready.
PT_SPAWN(pt, &child, lsm6ds3tr_c_pin_int1_route_set(&child, ctx, (lsm6ds3tr_c_int1_route_t) {
Expand Down
2 changes: 1 addition & 1 deletion pybricks/common/pb_type_imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
pbio_imu_set_base_orientation(&front_side_axis, &top_side_axis);

// Default noise thresholds.
pbio_imu_set_stationary_thresholds(1.5f, 250.0f);
pbio_imu_set_stationary_thresholds(5.0f, 2500.0f);

// Return singleton instance.
return MP_OBJ_FROM_PTR(&singleton_imu_obj);
Expand Down

0 comments on commit 8809277

Please sign in to comment.