Skip to content

Commit ae17160

Browse files
committed
pbio/control: Use measured position for hold after run_time.
Under load, the reference angle can be far ahead of the measured angle. If we try to hold that (unreachable) angle, the run_time command never completes. Fixes: pybricks/support#903
1 parent 761ba6a commit ae17160

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
### Fixed
88
- Fixed some objects do not implement `__hash__` ([support#876]).
9+
- Fixed `Motor.run_time` not completing under load ([support#903]).
910

1011
[support#876]: https://github.com/pybricks/support/issues/876
12+
[support#903]: https://github.com/pybricks/support/issues/903
1113

1214
## [3.2.1] - 2022-12-26
1315

lib/pbio/src/control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void pbio_control_update(pbio_control_t *ctl, uint32_t time_now, pbio_control_st
223223
// a stationary endpoint, convert it to a stationary angle
224224
// based command and hold it.
225225
if (pbio_control_type_is_time(ctl) && ref_end.speed == 0) {
226-
int32_t target = pbio_control_settings_ctl_to_app_long(&ctl->settings, &ref->position);
226+
int32_t target = pbio_control_settings_ctl_to_app_long(&ctl->settings, &state->position);
227227
pbio_control_start_position_control_hold(ctl, time_now, target);
228228
}
229229
break;

0 commit comments

Comments
 (0)