Skip to content

11/2/23 [master] - Post CCC Additions/Fixes #7

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
125 changes: 112 additions & 13 deletions .Glass/glass.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,139 @@
{
"NetworkTables": {
"Persistent Values": {
"open": false
},
"Retained Values": {
"open": false
},
"Transitory Values": {
"open": false
},
"retained": {
"SmartDashboard": {
"Auton Chooser": {
"Rotation PID": {
"open": true
},
"open": true
}
},
"transitory": {
"LiveWindow": {
"AngledElevator": {
"open": true
},
"Claw": {
"open": true
},
"Drivetrain": {
"open": true
},
"Ungrouped": {
"open": true
}
},
"SmartDashboard": {
"Auton Chooser": {
"open": true
}
},
"datatable": {
"Align Pitch": {
"open": true
},
"Drivetrain": {
"open": true
},
"Elevator": {
"open": true
},
"Swerve Module": {
"open": true
},
"SwervePositionController": {
"open": true
},
"open": true
}
},
"types": {
"/FMSInfo": "FMSInfo",
"/LiveWindow/AngledElevator": "Subsystem",
"/LiveWindow/AngledElevator/Limit Switch": "Digital Input",
"/LiveWindow/Claw": "Subsystem",
"/LiveWindow/Drivetrain": "Subsystem",
"/LiveWindow/Ungrouped/DigitalInput[0]": "Digital Input",
"/LiveWindow/Ungrouped/PIDController[1]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[2]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[3]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[4]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[5]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[6]": "PIDController",
"/LiveWindow/Ungrouped/Scheduler": "Scheduler",
"/SmartDashboard/Auton Chooser": "String Chooser"
"/SmartDashboard/AngledElevator": "Subsystem",
"/SmartDashboard/Auton Chooser": "String Chooser",
"/SmartDashboard/Field": "Field2d",
"/SmartDashboard/Rotation PID": "String Chooser",
"/SmartDashboard/test controller": "PIDController"
},
"windows": {
"/LiveWindow/AngledElevator": {
"window": {
"visible": true
}
},
"/LiveWindow/Claw": {
"window": {
"visible": true
}
},
"/LiveWindow/Drivetrain": {
"window": {
"visible": true
}
},
"/SmartDashboard/AngledElevator": {
"window": {
"visible": true
}
},
"/SmartDashboard/Auton Chooser": {
"window": {
"visible": true
}
}
}
},
"NetworkTables Settings": {
"mode": "Client (NT4)",
"serverTeam": "1072"
}
"serverTeam": "10.10.72.2"
},
"Plots": {
"Plot <0>": {
"plots": [
{
"height": 0,
"series": [
{
"color": [
0.2980392277240753,
0.44705885648727417,
0.6901960968971252,
1.0
],
"id": "NT:/SmartDashboard/test controller/p"
},
{
"color": [
0.8666667342185974,
0.5176470875740051,
0.32156863808631897,
1.0
],
"id": "NT:/SmartDashboard/kP"
}
]
}
]
},
"Plot <1>": {
"plots": [
{
"height": 0
}
]
}
},
"enterKey": 345
}
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import frc.robot.commands.claw.ToggleClaw;
import frc.robot.commands.drivetrain.AlignPitch;
import frc.robot.commands.elevator.MoveToPosition;
import frc.robot.commands.elevator.SoftZero;
import frc.robot.commands.elevator.ZeroElevator;
import frc.robot.subsystems.Drivetrain;
import harkerrobolib.joysticks.XboxGamepad;
Expand Down Expand Up @@ -63,6 +64,7 @@ private void initBindings() {
//operator.getRightDPadButton().debounce(0.13, DebounceType.kRising).onTrue(new ToggleClaw());
operator.getRightDPadButton().onTrue(new ToggleClaw());
operator.getRightBumper().onTrue(new ZeroElevator());
operator.getLeftBumper().onTrue(new SoftZero());
// set A button on OPERATOR controller to set Elevator to POSITION LOW
operator.getButtonX().whileTrue(new MoveToPosition(RobotMap.AngledElevator.POSITIONS[3]));
operator.getButtonY().whileTrue(new MoveToPosition(RobotMap.AngledElevator.POSITIONS[2]));
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import frc.robot.commands.claw.ToggleClaw;
import frc.robot.commands.drivetrain.SwerveManual;
import frc.robot.commands.elevator.ElevatorManual;
import frc.robot.commands.elevator.ZeroElevator;
import frc.robot.subsystems.AngledElevator;
import frc.robot.subsystems.Claw;
import frc.robot.subsystems.Drivetrain;
import frc.robot.util.CameraPoseEstimation;
import frc.robot.util.Telemetry;

/**
* The VM is configured to automatically run this class, and to call the
Expand All @@ -40,6 +42,7 @@ public class Robot extends TimedRobot {

private SendableChooser<String> autonChooser;
private PowerDistribution powerDistribution;
private Telemetry telemetry;

/**
* This function is run when the robot is first started up and should be used
Expand All @@ -62,11 +65,16 @@ public void robotInit() {
autonChooser.addOption("Bottom Path", "Bottom Path");
autonChooser.addOption("Top Path", "Top Path");
autonChooser.addOption("No auton", "No auton");
autonChooser.addOption("Bottom Path Middle", "Bottom Path Middle");
autonChooser.addOption("Top Path Middle", "Top Path Middle");
SmartDashboard.putData("Auton Chooser", autonChooser);
CameraPoseEstimation.getInstance().getCamera().setDriverMode(true);
AngledElevator.getInstance().resetEncoders();

// rio voltage and current

telemetry = new Telemetry();

powerDistribution = new PowerDistribution();
}

Expand All @@ -77,11 +85,6 @@ public void robotPeriodic() {

SmartDashboard.putString("Current Auton:", autonChooser.getSelected());

// double pdhVoltage = powerDistribution.getVoltage();
// double pdhCurrent = powerDistribution.getCurrent(20);
// SmartDashboard.putNumber("pdh voltage", pdhVoltage);
// SmartDashboard.putNumber("rio current", pdhCurrent);

// SmartDashboard.putNumber("kP",);
// SmartDashboard.putNumber("kI",
// Drivetrain.getInstance().thetaController.getI());
Expand All @@ -91,6 +94,8 @@ public void robotPeriodic() {
// SmartDashboard.putData(Drivetrain.getInstance());
// SmartDashboard.putData(Claw.getInstance());



NetworkTableInstance.getDefault().flushLocal();
NetworkTableInstance.getDefault().flush();
}
Expand Down Expand Up @@ -139,6 +144,16 @@ public void autonomousInit() {
.setPose(Trajectories.apply(new Pose2d(1.91, 2.75, Rotation2d.fromDegrees(180))));
Autons.noAuton.schedule();
break;
case "Bottom Path Middle":
Drivetrain.getInstance()
.setPose(Trajectories.apply(new Pose2d(1.91, 1.09, Rotation2d.fromDegrees(180))));
Autons.bottomPathMid.schedule();
break;
case "Top Path Middle":
Drivetrain.getInstance()
.setPose(Trajectories.apply(new Pose2d(1.91, 4.44, Rotation2d.fromDegrees(180))));
Autons.topPathMid.schedule();
break;
default:
Drivetrain.getInstance()
.setPose(Trajectories.apply(new Pose2d(1.91, 2.75, Rotation2d.fromDegrees(180))));
Expand All @@ -159,11 +174,12 @@ public void teleopInit() {
Autons.middleAndCross.cancel();
Autons.noAuton.cancel();
Drivetrain.getInstance().setYaw(180);
new ZeroElevator();
}

@Override
public void teleopPeriodic() {

telemetry.putButtons();
}

@Override
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ public static final class Claw {

public static final class AngledElevator {
public static final double kP = 0.12; // Based on RoboCode2023; TUNE
public static final double kG = 0.087; // Based on RoboCode2023; TUNE
public static final double kG = 0.073; // Based on RoboCode2023; TUNE

public static final double MAX_ERROR = 100;
public static final double MAX_ERROR = 500;

public static final double CRUISE_VELOCITY = 7447; // NEEDS TO BE TUNED (based on RoboCode2023)
public static final double CRUISE_ACCELERATION = 4447; // NEEDS TO BE TUNED (based on RoboCode2023)
public static final double CRUISE_ACCELERATION = 4447; // NEEDS TO BE TUNED (based on RoboCode2023) 4447

public static final int MASTER_ID = 15; // Left Motor
public static final int FOLLOWER_ID = 14; // Right Motor
Expand All @@ -158,15 +158,16 @@ public static final class AngledElevator {
public static final boolean FOLLOWER_INVERTED = false; // TODO

// Thresholds for soft-limits
public static final double FORWARD_LIMIT = 41000;
public static final double FORWARD_LIMIT = 45500;
public static final double REVERSE_LIMIT = 0;

// Time for the motor to go from neutral to full
public static final double RAMP_TIME = 0.01;


// POSITIONS: Low, Middle, High, Human Player (HP)
public static double[] POSITIONS = {
10018, 27000, 41000, 28750
10018, 27000, 45000, 31000
};

// HORIZONTAL Offsets: Middle, High, Human Player (HP)
Expand Down
Loading