Skip to content

Commit 599d323

Browse files
committed
pbio/drivebase: Fix curve direction for zero radius.
It is more intuitive to reverse the angle only for strictly negative radii. This way, a curve with zero radius behaves the same as the turn() method.
1 parent e8f67d5 commit 599d323

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
## [Unreleased]
66

77
### Changed
8-
- Renamed new `DCMotor.dc_settings()` method to `DCMotor.settings()`.
8+
- Renamed new `DCMotor.dc_settings()` method
9+
to `DCMotor.settings()` ([support#536]).
10+
11+
### Fixed
12+
- Fixed direction for `DriveBase.turn()` and `Drivebase.curve()` for some
13+
arguments ([support#535]).
14+
15+
[support#535]: https://github.com/pybricks/support/issues/535
16+
[support#536]: https://github.com/pybricks/support/issues/536
917

1018
## [3.1.0c1] - 2021-11-19
1119

lib/pbio/src/drivebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pbio_error_t pbio_drivebase_drive_curve(pbio_drivebase_t *db, int32_t radius, in
341341
} else {
342342
// In the normal case, angle_or_distance is interpreted as the angle,
343343
// signed by the radius. Arc length is computed accordingly.
344-
arc_angle = radius > 0 ? angle_or_distance : -angle_or_distance;
344+
arc_angle = radius < 0 ? -angle_or_distance : angle_or_distance;
345345
arc_length = (10 * abs(angle_or_distance) * radius) / 573;
346346
}
347347

0 commit comments

Comments
 (0)