Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
1bde0e5
drivetrain
matt-mekha Feb 27, 2021
d6b0964
Merge branch 'mekhas-branch' of github.com:awtybots/FRC-2021 into mek…
matt-mekha Feb 27, 2021
d61f1fe
updated to botplus v0.3.1, simplified drive control functions
matt-mekha Feb 27, 2021
44e354c
intake, indexer, implemented botplus v0.3.2
matt-mekha Feb 27, 2021
c4b1f47
format
matt-mekha Feb 27, 2021
a116cfe
botplus 0.4.0
matt-mekha Feb 27, 2021
95ee33b
v0.4.1
matt-mekha Feb 27, 2021
a129155
botplus 4.1
matt-mekha Feb 27, 2021
0980e4f
botplus unix friendly logging jar
matt-mekha Feb 27, 2021
38a45b6
botplus v5 (simpler drive, added pid)
matt-mekha Feb 28, 2021
2332948
pid tuning
matt-mekha Feb 28, 2021
a9808f4
no homework
matt-mekha Mar 2, 2021
b3e7ea6
fix
matt-mekha Mar 2, 2021
8496323
added auton driving commands
matt-mekha Mar 2, 2021
d4c942d
saturday march 6
matt-mekha Mar 6, 2021
2851e1a
auto aim and auto shoot
matt-mekha Apr 7, 2021
679d222
uncomment code
matt-mekha Apr 7, 2021
f615242
Merge pull request #4 from awtybots/saturday-march-6
matt-mekha Apr 7, 2021
27bde76
formatting
matt-mekha Apr 7, 2021
3b9a564
removed verifyGoogleJavaFormat task that causes builds to fail
AlexDvorak Apr 14, 2021
0925414
update botplus library to v0.5.2
AlexDvorak Apr 14, 2021
1691cd7
pretty
matt-mekha May 21, 2021
16b033d
spindexer
matt-mekha May 21, 2021
6bdfbff
turret subsystem
matt-mekha May 21, 2021
9b23199
compressor and LED code
matt-mekha May 21, 2021
8f80c34
adjustable hood subsystem
matt-mekha May 21, 2021
df0b33a
auto aim using turret
matt-mekha May 21, 2021
946554d
adjustable hood used in autoshoot command
matt-mekha May 21, 2021
74a4ce2
diagnostics
matt-mekha May 21, 2021
45baef4
turret should be ready before shooting
matt-mekha May 21, 2021
6f9adfb
googleJavaFormat
AlexDvorak May 22, 2021
9178366
botplus v0.5.2 in build.gradle, git pre-commit hook
AlexDvorak May 22, 2021
aba0054
actual height of inner port
AlexDvorak May 23, 2021
659750b
LED alliance color fix
matt-mekha May 24, 2021
61b025f
fixed some ids
matt-mekha Jun 5, 2021
4ab3610
shooter pid last year numbers
matt-mekha Jun 5, 2021
61e3020
tuesday, june 8 (turret, shooter)
matt-mekha Jun 9, 2021
4df25cd
turret good
matt-mekha Jun 9, 2021
ac7d803
spindexer, adjustable hood
matt-mekha Jun 10, 2021
9cc078d
efficient CAN
matt-mekha Jun 10, 2021
94f2a3c
better controller util
matt-mekha Jun 10, 2021
43da768
servo
matt-mekha Jun 10, 2021
ca51ffb
tuned adjustable hood
matt-mekha Jun 10, 2021
c9086fe
auto shoot
matt-mekha Jun 10, 2021
a10d17b
update spindexer speeds and backoff time
matt-mekha Jun 10, 2021
65f2f67
prevent autoshoot from using tower subsystem
matt-mekha Jun 11, 2021
db858f1
adjustments and bug fixes
matt-mekha Jun 11, 2021
f17984b
Merge
matt-mekha Jun 11, 2021
d921def
auton
matt-mekha Jun 12, 2021
87c4570
tune drive and drive forward option
matt-mekha Jun 12, 2021
4f47fb5
reasonable max vel for auton
matt-mekha Jun 12, 2021
7fa1d64
drive curve, cleaner drive code
matt-mekha Jun 12, 2021
3e820c1
preventive measures for adjustable hood's suicide ideation
matt-mekha Jun 12, 2021
d7ce10f
shooter timer
matt-mekha Jun 12, 2021
5f2122e
turret optional
matt-mekha Jun 12, 2021
d29e87d
indexer tower backup, refactored singletons
matt-mekha Jun 12, 2021
ec52325
reset turret
matt-mekha Jun 12, 2021
11e97b5
reverse tower command
matt-mekha Jun 12, 2021
ac0eb89
semi consistent tower and spindexer
matt-mekha Jun 12, 2021
0508e9d
indexer tower only one motor
matt-mekha Jun 12, 2021
0f55ce5
controller diagrams
matt-mekha Jun 12, 2021
9ad7c22
c
matt-mekha Jun 12, 2021
0eaf746
spindexer might not exist
matt-mekha Jun 13, 2021
8bea55f
climber
matt-mekha Jun 13, 2021
dbd63b1
fixed auton drive bug and added safe drive forward
matt-mekha Jun 13, 2021
6839a50
drive forward time
matt-mekha Jun 13, 2021
9ecb957
brake climb
matt-mekha Jun 13, 2021
a5cd60b
reverse climber
matt-mekha Jun 13, 2021
a8c3e9c
working climber + diagnostics
matt-mekha Jun 13, 2021
e79a869
turret range smaller
matt-mekha Jun 14, 2021
9e6d997
new tower
matt-mekha Jun 14, 2021
dad8f39
rename hood angle to hoodLaunchAngle + extra goodies
AlexDvorak Jun 14, 2021
ef7f088
cleanup
matt-mekha Jun 14, 2021
192edd2
stage formatted files in pre-commit, use inches in distances
AlexDvorak Jun 14, 2021
51a71c7
Merge branch 'mekhas-branch' of https://github.com/awtybots/FRC-2021 …
matt-mekha Jun 14, 2021
6b2a7d0
pre comp cleanup
matt-mekha Jun 14, 2021
98e17f9
no more test mode
matt-mekha Jun 14, 2021
01f9973
repackage teleop automagic commands
AlexDvorak Jun 14, 2021
4fa8bb7
ignore tool
AlexDvorak Jun 14, 2021
7b9d2a2
detailed controls documents
matt-mekha Jun 15, 2021
28fb52b
Merge branch 'mekhas-branch' of https://github.com/awtybots/FRC-2021 …
matt-mekha Jun 15, 2021
c9b5dce
reverse logic fixed
matt-mekha Jun 15, 2021
b5cd19c
safe auton with shooting
matt-mekha Jun 15, 2021
1742e23
run indexer while shooting
matt-mekha Jun 15, 2021
8fcdc83
shoot 3 and drive forward time default auton
matt-mekha Jun 15, 2021
031fc31
make pdf of controls not lie (invert tower motor)
matt-mekha Jun 15, 2021
0d8cebb
increase min output to 7% of drive
matt-mekha Jun 15, 2021
d7c8350
Merge branch 'mekhas-branch' of https://github.com/awtybots/FRC-2021 …
matt-mekha Jun 15, 2021
80e6437
cleanup invert indexer, invert climber
matt-mekha Jun 15, 2021
173bbd2
ignore turret for now, pass time to drive through command constructor
matt-mekha Jun 15, 2021
f594afd
tuune manual presets
matt-mekha Jun 15, 2021
2116696
who knows
matt-mekha Jun 15, 2021
9a5e49c
lowr auton rpm
matt-mekha Jun 15, 2021
0e9b536
fixed potentially fatal NullPointerException
matt-mekha Jun 15, 2021
79e55d1
Merge branch 'mekhas-branch' of https://github.com/awtybots/FRC-2021 …
matt-mekha Jun 15, 2021
dcf57b7
no PID driving, slower ramp
matt-mekha Jun 16, 2021
205d9c9
dumb hood reset
matt-mekha Jun 16, 2021
0bff82e
restore autoshoot
matt-mekha Jun 16, 2021
7d5f902
remove LEDs bc not plugged in
matt-mekha Jun 16, 2021
6e238e2
adjust rpm for close shot
matt-mekha Jun 16, 2021
0c4c228
disable adjustable hood completely
matt-mekha Jun 16, 2021
d73ee31
decrease auton layup shot rpm
matt-mekha Jun 16, 2021
06ec82e
Merge branch 'mekhas-branch' of https://github.com/awtybots/FRC-2021 …
matt-mekha Jun 16, 2021
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
5 changes: 4 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh
exit 0
exec 1>&2
chmod +x gradlew
echo "Formatting code before commit..."
exec ./gradlew -q syncGitHooks format
./gradlew -q syncGitHooks format
[[ $? != 0 ]] && exit 1 # exit if formatter failed
exec git add -A ./src/main/java/frc/robot
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ gradle-app.setting
.settings/
bin/
imgui.ini
update_with_main.zsh
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true,
"**/*~": true
"**/*~": true,

"WPILib-License.md": true
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
simulation wpi.deps.sim.gui(wpi.platforms.desktop, false)
simulation wpi.deps.sim.driverstation(wpi.platforms.desktop, false)

implementation files('libs/botplus-v0.5.2.jar')
implementation files('libs/botplus-v0.6.3.jar')

// Websocket extensions require additional configuration.
// simulation wpi.deps.sim.ws_server(wpi.platforms.desktop, false)
Expand Down
Binary file added docs/Controls.pdf
Binary file not shown.
Binary file added docs/Controls.pub
Binary file not shown.
Binary file added libs/botplus-v0.6.3-sources.jar
Binary file not shown.
Binary file renamed libs/botplus-v0.5.2.jar → libs/botplus-v0.6.3.jar
Binary file not shown.
102 changes: 79 additions & 23 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,105 @@
package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.commands.auton.sequences.*;
import frc.robot.commands.teleop.*;
import frc.robot.commands.teleop.automatic.*;
import frc.robot.subsystems.*;
import org.awtybots.frc.botplus.CompetitionBot;
import org.awtybots.frc.botplus.commands.Controller;
import org.awtybots.frc.botplus.sensors.vision.Limelight;

public class Robot extends TimedRobot {
public class Robot extends CompetitionBot {

public static Limelight limelight =
new Limelight(
RobotMap.Dimensions.limelightMountingHeight, RobotMap.Dimensions.limelightMountingAngle);
public static PowerDistributionPanel pdp = new PowerDistributionPanel();

private Compressor compressor = new Compressor();

@Override
public void robotInit() {}
public void robotInit() {
super.robotInit();
compressor.setClosedLoopControl(true);
}

/**
* This runs after the mode specific periodic functions, but before LiveWindow and SmartDashboard
* integrated updating.
*/
@Override
public void robotPeriodic() {
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
// commands, running already-scheduled commands, removing finished or interrupted commands,
// and running subsystem periodic() methods.
CommandScheduler.getInstance().run();
}

@Override
public void disabledInit() {}
public boolean isTestMode() {
return false;
}

@Override
public void disabledPeriodic() {}
public void addAutonOptions() {
addAutonDefault("Drive Forward Time and Shoot 3", new DriveForwardTimeAndShoot3(0.75));
// addAutonOption("Shoot 3 and Drive Forward Time", new Shoot3AndDriveForwardTime(1.5));
// addAutonOption("Shoot 3 from the Line", new Shoot3FromLine());
// addAutonOption("Drive Forward Time", new DriveForwardTime(1.5));
}

@Override
public void autonomousInit() {}
public void teleopInit() {
super.teleopInit();
Robot.limelight.setDriverMode(true);
}

@Override
public void autonomousPeriodic() {}
public void teleopPeriodic() {
super.teleopPeriodic();
}

@Override
public void teleopInit() {}
public void disabledInit() {
super.disabledInit();
Robot.limelight.setDriverMode(true);
}

@Override
public void teleopPeriodic() {}
public void bindIO() {
Controller controller1 = new Controller(0);
Controller controller2 = new Controller(1);

@Override
public void testInit() {
CommandScheduler.getInstance().cancelAll();
}
controller1.streamAnalogInputTo(new TeleopDrive());
controller1.getTrgL().whenHeld(new ToggleIntakeMotorOnly());
controller1.getTrgR().whenHeld(new ToggleIntake());
controller1.getBtnA().whenHeld(new ToggleClimber(ToggleClimber.Forward));
controller1.getBtnBack().whenHeld(new ToggleClimber(ToggleClimber.Reverse));

/** This function is called periodically during test mode. */
@Override
public void testPeriodic() {}
// controller1.getBtnX().whenHeld(new ManualHoodRun(true));
// controller1.getBtnB().whenHeld(new ManualHoodRun(false));

controller2.getBtnA().whenHeld(new ManualShootingPreset(4000.0, 76, false)); // against wall
controller2.getBtnX().whenHeld(new ManualShootingPreset(5000.0, 58, true)); // mid range?
controller2.getBtnB().whenHeld(new ManualShootingPreset(5700.0, 57, true)); // long range
// controller2
// .getBtnY()
// .whenHeld(
// new AutoAimUsingTurret()
// .alongWith(new AutoShoot())); // fancy pants shot w/limelight, turret, physics
// math

controller2.getBtnBack().whenPressed(new ResetHoodDumb());
// new ResetTurret() // hood all the way back, turret dead center
// .alongWith(new SetHoodLaunchAngle(AdjustableHoodSubsystem.maxLaunchAngle)));
// controller2.getBtnStart().whenHeld(new AutoAimUsingTurret());
// controller2.getDpadLeft().whenPressed( // manually move turret left 10 degrees
// new InstantCommand(() -> TurretSubsystem.getInstance().setRelativeGoalAngle(-10),
// TurretSubsystem.getInstance()
// ));
// controller2.getDpadRight().whenPressed( // manually move turret right 10 degrees
// new InstantCommand(() -> TurretSubsystem.getInstance().setRelativeGoalAngle(10),
// TurretSubsystem.getInstance()
// ));
controller2.getBmpL().whenHeld(new ReverseTower());
controller2.getBmpR().whenHeld(new ToggleTower());
controller2.getTrgL().whenHeld(new ReverseIndexer());
controller2.getTrgR().whenHeld(new ToggleIndexer());
}
}
72 changes: 72 additions & 0 deletions src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package frc.robot;

public abstract class RobotMap {
public abstract static class CAN {
public static final int leftDrive1 = 13;
public static final int leftDrive2 = 14;
public static final int rightDrive1 = 11;
public static final int rightDrive2 = 12;

public static final int intake = 5;
// public static final int spindexer = 7; // rip
public static final int tower = 9;

public static final int turret = 8;
public static final int adjustableHood = 10;
public static final int shooter = 15;

public static final int indexerL = 7;
public static final int indexerR = 6;

public static final int climber = 16;
}

public abstract static class PDP {
public static final int spindexer = 4;
public static final int tower = 13;
public static final int adjustableHood = 12;
public static final int climber = 2;
}

public abstract static class PCM {
public static final int intakeFwd = 5;
public static final int intakeRev = 4;
}

public abstract static class DIO {
public static final int allianceColorLEDs = 0;
public static final int towerLimitSwitch = 1;
}

public abstract static class LimelightPipelines {
public static final int powerPort = 0;
}

public abstract static class Dimensions {
public static final double limelightMountingAngle = 23; // degrees TODO doublecheck
public static final double limelightMountingHeight = feetInchesMeters(20.9); // TODO doublecheck

public static final double powerPortHeight = feetInchesMeters(8, 2.25);
public static final double powerPortVisionTargetOffset =
feetInchesMeters(8.5); // distance between center of vision target and center of goal

public static final double trackWidth =
feetInchesMeters(26.755); // distance between the left and right wheels, meters

public static final double climberWinchCircumference =
3; // this one is actually in inches believe it or not
}

public static double feetInchesMeters(int feet, double inches) {
inches += feet * 12.0;
double centimeters = inches * 2.54;
double meters = centimeters / 100.0;
return meters;
}

public static double feetInchesMeters(double inches) {
double centimeters = inches * 2.54;
double meters = centimeters / 100.0;
return meters;
}
}
30 changes: 0 additions & 30 deletions src/main/java/frc/robot/commands/ExampleCommand.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/java/frc/robot/commands/auton/DriveCurve.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package frc.robot.commands.auton;

import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.RobotMap;

public class DriveCurve extends SequentialCommandGroup {

/**
* a smooth arc path for the robot to follow
*
* @param arcRadius radius of arc drawn by path of robot
* @param degrees degrees of circle to make arc from (positive means curve right)
*/
public DriveCurve(double arcRadius, double degrees) {
double radians = Math.toRadians(degrees);

double centerArcLength = arcRadius * radians;
double differentialArcLength = (RobotMap.Dimensions.trackWidth * 0.5) * radians;

double leftArcLength = centerArcLength + differentialArcLength;
double rightArcLength = centerArcLength - differentialArcLength;

addCommands(new DriveDistance(leftArcLength, rightArcLength));
}
}
58 changes: 58 additions & 0 deletions src/main/java/frc/robot/commands/auton/DriveDistance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package frc.robot.commands.auton;

import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.DrivetrainSubsystem;

public class DriveDistance extends CommandBase {
private static final double gapTime = 0.5;

private DriveSideDistance driveSideDistanceL;
private DriveSideDistance driveSideDistanceR;

private double plannedTime;
private Timer timer;

public DriveDistance(double distance) {
this(distance, distance);
}

public DriveDistance(double distanceL, double distanceR) {
addRequirements(DrivetrainSubsystem.getInstance());
driveSideDistanceL = new DriveSideDistance(distanceL);
driveSideDistanceR = new DriveSideDistance(distanceR);

if (driveSideDistanceL.plannedTime < driveSideDistanceR.plannedTime) {
plannedTime = driveSideDistanceR.plannedTime;
driveSideDistanceL.replanSlower(plannedTime);
} else {
plannedTime = driveSideDistanceL.plannedTime;
driveSideDistanceR.replanSlower(plannedTime);
}

timer = new Timer();
}

@Override
public void initialize() {
timer.start();
}

public void execute() {
double currentTime = timer.get();
double velocityL = driveSideDistanceL.tick(currentTime);
double velocityR = driveSideDistanceR.tick(currentTime);
DrivetrainSubsystem.getInstance().setMotorVelocityOutput(velocityL, velocityR);
}

@Override
public void end(boolean interrupted) {
if (interrupted) DrivetrainSubsystem.getInstance().kill();
else DrivetrainSubsystem.getInstance().softStop();
}

@Override
public boolean isFinished() {
return timer.get() > plannedTime + gapTime;
}
}
Loading