Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/com/team766/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import com.team766.robot.mechanisms.Drive;

/**
/*
* This class is the glue that binds the controls on the physical operator
* interface to the code that allow control of the robot.
*/
*/

public class OI extends Procedure {
private JoystickReader leftJoystick;
private JoystickReader rightJoystick;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void run(Context context) {
context.takeOwnership(Robot.grabber);
context.takeOwnership(Robot.storage);
context.takeOwnership(Robot.gyro);
context.takeOwnership(Robot.voltageController);

CameraServer.startAutomaticCapture();

Expand All @@ -79,6 +81,9 @@ public void run(Context context) {
// SmartDashboard.putString("Alliance", "NULLLLLLLLL");
// }

Robot.voltageController.displayPower();
Robot.voltageController.powerWarning();
Robot.voltageController.currentWarning();

if (controlPanel.getButtonPressed(InputConstants.RESET_GYRO)) {
Robot.gyro.resetGyro();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/team766/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Robot {
public static Grabber grabber;
public static Arms arms;
public static Gyro gyro;
public static VoltageController voltageController;

public static void robotInit() {
// Initialize mechanisms here
Expand All @@ -19,5 +20,6 @@ public static void robotInit() {
grabber = new Grabber();
arms = new Arms();
gyro = new Gyro();
voltageController = new VoltageController();
}
}
49 changes: 49 additions & 0 deletions src/main/java/com/team766/robot/mechanisms/VoltageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.team766.robot.mechanisms;

import com.team766.framework.Mechanism;
import edu.wpi.first.wpilibj.PowerDistribution;
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class VoltageController extends Mechanism {
private double voltage;
private String voltageReport;
private PowerDistribution powerDist;
private double current;
private String currentReport;

public VoltageController(){
powerDist = new PowerDistribution(1, ModuleType.kRev);
voltage = powerDist.getVoltage();
current = powerDist.getTotalCurrent();
}

public void powerWarning(){
voltage = powerDist.getVoltage();
if(voltage <= 8.5){
voltageReport = "VOLTAGE TOO LOW!!!";
} else {
voltageReport = "voltage is normal :-)";
}
SmartDashboard.putString("Voltage Warning", voltageReport);
}

public void currentWarning(){
current = powerDist.getTotalCurrent();
if(current >= 140.0){
currentReport = "WARNING!!! USING TOO MUCH POWER!";
} else {
currentReport = "power levels are safe :-)";
}
SmartDashboard.putString("Power Warning", currentReport);
}

public void displayPower(){
voltage = powerDist.getVoltage();
current = powerDist.getTotalCurrent();
SmartDashboard.putNumber("Voltage", voltage);
SmartDashboard.putNumber("Total Current", current);
}


}