Skip to content

Commit 22ae127

Browse files
committed
pbio/drivebase: Tweak defaults.
Adjusts default turn speed and acceleration for better results for most use cases.
1 parent f42fc45 commit 22ae127

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/pbio/src/drivebase.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ static pbio_error_t drivebase_adopt_settings(pbio_control_settings_t *s_distance
4747
// By default, heading control is the same as distance control
4848
*s_heading = *s_distance;
4949

50+
// Allow just slightly more torque for heading. While not technically
51+
// necessary under nominal circumstances, it gives the expected perceived
52+
// result of one wheel nearly stopping when you block the other.
53+
s_heading->max_torque *= 2;
54+
5055
return PBIO_SUCCESS;
5156
}
5257

pybricks/robotics/pb_type_drivebase.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ STATIC mp_obj_t robotics_DriveBase_make_new(const mp_obj_type_t *type, size_t n_
7171
pbio_control_settings_get_limits(&self->db->control_distance.settings, &straight_speed_limit, &straight_acceleration_limit, &_, &_);
7272
pbio_control_settings_get_limits(&self->db->control_heading.settings, &turn_rate_limit, &turn_acceleration_limit, &_, &_);
7373

74-
self->straight_speed = straight_speed_limit / 3;
75-
self->straight_acceleration = straight_acceleration_limit / 3;
76-
self->turn_rate = turn_rate_limit / 3;
77-
self->turn_acceleration = turn_acceleration_limit / 3;
74+
self->straight_speed = straight_speed_limit / 2;
75+
self->straight_acceleration = straight_acceleration_limit / 2;
76+
self->turn_rate = turn_rate_limit / 4;
77+
self->turn_acceleration = turn_acceleration_limit / 4;
7878

7979
return MP_OBJ_FROM_PTR(self);
8080
}

0 commit comments

Comments
 (0)