Skip to content

Commit

Permalink
extmod/modrobotics: set drivebase defaults
Browse files Browse the repository at this point in the history
Define them as a function of the underlying motors.
  • Loading branch information
laurensvalk committed Apr 21, 2020
1 parent 21d7d2a commit abdcfca
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions extmod/modrobotics.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ STATIC mp_obj_t robotics_DriveBase_make_new(const mp_obj_type_t *type, size_t n_
self->heading_control = builtins_Control_obj_make_new(&self->db->control_heading);
self->distance_control = builtins_Control_obj_make_new(&self->db->control_distance);

// Set defaults for drivebase
self->straight_speed = 100;
self->straight_acceleration = 200;
self->turn_rate = 90;
self->turn_acceleration = 180;
// Get defaults for drivebase as 1/3 of maximum for the underlying motors
int32_t straight_speed_limit, straight_acceleration_limit, turn_rate_limit, turn_acceleration_limit, _;
pbio_control_settings_get_limits(&self->db->control_distance.settings, &straight_speed_limit, &straight_acceleration_limit, &_);
pbio_control_settings_get_limits(&self->db->control_heading.settings, &turn_rate_limit, &turn_acceleration_limit, &_);

self->straight_speed = straight_speed_limit/3;
self->straight_acceleration = straight_acceleration_limit/3;
self->turn_rate = turn_rate_limit/3;
self->turn_acceleration = turn_acceleration_limit/3;

return MP_OBJ_FROM_PTR(self);
}
Expand Down

0 comments on commit abdcfca

Please sign in to comment.