Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggles to drive set and print for autonomous #36

Closed
ssejrog opened this issue Jan 6, 2022 · 1 comment
Closed

Add toggles to drive set and print for autonomous #36

ssejrog opened this issue Jan 6, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ssejrog
Copy link
Member

ssejrog commented Jan 6, 2022

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
When debugging, sometimes you don't want the drive motors to move, but you want the PID to calculate. Also when debugging something else, sometimes you don't want the drive prints to print.

Describe the solution you'd like

A new function should toggle the drive motors off in autonomous, and another for disabling the autonomous prints.

@ssejrog ssejrog added the enhancement New feature or request label Jan 6, 2022
@ssejrog ssejrog self-assigned this Jan 6, 2022
@ssejrog
Copy link
Member Author

ssejrog commented Jan 6, 2022

Two new functions were added, chassis.toggle_auto_drive(bool toggle) and chassis.toggle_auto_print(bool toggle), where true enables and false disables. These are both defaulted to true.

This example would run drive PID to move 24 inches, but the motors wouldn't move. This can be useful for debugging.

void autonomous() {
  chassis.reset_gyro(); // Reset gyro position to 0
  chassis.reset_drive_sensor(); // Reset drive sensors to 0
  chassis.set_drive_brake(MOTOR_BRAKE_HOLD); // Set motors to hold.  This helps autonomous consistency. 

  chassis.toggle_auto_drive(false);
  
  chassis.set_drive_pid(24, 110);
  while (true) {
    printf(" Left Error: %f  Right Error: %f", chassis.leftPID.error, chassis.rightPID.error);
  }
}

This example runs the drive but doesn't print anything. This can be useful for debugging other subsystems to avoid clutter in terminal.

void autonomous() {
  chassis.reset_gyro(); // Reset gyro position to 0
  chassis.reset_drive_sensor(); // Reset drive sensors to 0
  chassis.set_drive_brake(MOTOR_BRAKE_HOLD); // Set motors to hold.  This helps autonomous consistency. 

  chassis.toggle_auto_print(false);
  
  chassis.set_drive_pid(24, 110);
  chassis.wait_drive();
}

@ssejrog ssejrog closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant