@@ -131,13 +131,13 @@ static pbio_error_t pbio_drivebase_get_state_control(pbio_drivebase_t *db, pbio_
131131 return err ;
132132 }
133133
134- // Take sum to get distance state
134+ // Take average to get distance state
135135 pbio_angle_avg (& state_left .position , & state_right .position , & state_distance -> position );
136136 pbio_angle_avg (& state_left .position_estimate , & state_right .position_estimate , & state_distance -> position_estimate );
137137 state_distance -> speed_estimate = (state_left .speed_estimate + state_right .speed_estimate ) / 2 ;
138138 state_distance -> speed = (state_left .speed + state_right .speed ) / 2 ;
139139
140- // Take difference to get heading state, which is implemented as
140+ // Take average difference to get heading state, which is implemented as:
141141 // (left - right) / 2 = (left + right) / 2 - right = avg - right.
142142 pbio_angle_diff (& state_distance -> position , & state_right .position , & state_heading -> position );
143143 pbio_angle_diff (& state_distance -> position_estimate , & state_right .position_estimate , & state_heading -> position_estimate );
@@ -378,19 +378,19 @@ static pbio_error_t pbio_drivebase_update(pbio_drivebase_t *db) {
378378 // Get reference and torque signals
379379 pbio_trajectory_reference_t ref_distance ;
380380 pbio_trajectory_reference_t ref_heading ;
381- int32_t sum_torque , dif_torque ;
382- pbio_dcmotor_actuation_t sum_actuation , dif_actuation ;
383- pbio_control_update (& db -> control_distance , time_now , & state_distance , & ref_distance , & sum_actuation , & sum_torque );
384- pbio_control_update (& db -> control_heading , time_now , & state_heading , & ref_heading , & dif_actuation , & dif_torque );
381+ int32_t distance_torque , heading_torque ;
382+ pbio_dcmotor_actuation_t distance_actuation , heading_actuation ;
383+ pbio_control_update (& db -> control_distance , time_now , & state_distance , & ref_distance , & distance_actuation , & distance_torque );
384+ pbio_control_update (& db -> control_heading , time_now , & state_heading , & ref_heading , & heading_actuation , & heading_torque );
385385
386386 // If either controller coasts, coast both, thereby also stopping control.
387- if (sum_actuation == PBIO_DCMOTOR_ACTUATION_COAST ||
388- dif_actuation == PBIO_DCMOTOR_ACTUATION_COAST ) {
387+ if (distance_actuation == PBIO_DCMOTOR_ACTUATION_COAST ||
388+ heading_actuation == PBIO_DCMOTOR_ACTUATION_COAST ) {
389389 return pbio_drivebase_stop (db , PBIO_CONTROL_ON_COMPLETION_COAST );
390390 }
391391 // If either controller brakes, brake both, thereby also stopping control.
392- if (sum_actuation == PBIO_DCMOTOR_ACTUATION_BRAKE ||
393- dif_actuation == PBIO_DCMOTOR_ACTUATION_BRAKE ) {
392+ if (distance_actuation == PBIO_DCMOTOR_ACTUATION_BRAKE ||
393+ heading_actuation == PBIO_DCMOTOR_ACTUATION_BRAKE ) {
394394 return pbio_drivebase_stop (db , PBIO_CONTROL_ON_COMPLETION_BRAKE );
395395 }
396396
@@ -405,14 +405,14 @@ static pbio_error_t pbio_drivebase_update(pbio_drivebase_t *db) {
405405
406406 // The left servo drives at a torque and speed of sum + dif
407407 int32_t feed_forward_left = pbio_observer_get_feedforward_torque (db -> left -> observer .model , ref_distance .speed + ref_heading .speed , ref_distance .acceleration + ref_heading .acceleration );
408- err = pbio_servo_actuate (db -> left , sum_actuation , sum_torque + dif_torque + feed_forward_left );
408+ err = pbio_servo_actuate (db -> left , distance_actuation , distance_torque + heading_torque + feed_forward_left );
409409 if (err != PBIO_SUCCESS ) {
410410 return err ;
411411 }
412412
413413 // The right servo drives at a torque and speed of sum - dif
414414 int32_t feed_forward_right = pbio_observer_get_feedforward_torque (db -> right -> observer .model , ref_distance .speed - ref_heading .speed , ref_distance .acceleration - ref_heading .acceleration );
415- return pbio_servo_actuate (db -> right , dif_actuation , sum_torque - dif_torque + feed_forward_right );
415+ return pbio_servo_actuate (db -> right , heading_actuation , distance_torque - heading_torque + feed_forward_right );
416416}
417417
418418/**
0 commit comments