Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Add files via upload #3

Open
wants to merge 2 commits 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
22 changes: 22 additions & 0 deletions Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
___ __ __ _ ____ ____ __ __ _ ____ ____
/ __)/ \ ( ( \/ ___)(_ _)/ _\ ( ( \(_ _)/ ___)
( (__( O )/ /\___ \ )( / \/ / )( \___ \
\___)\__/ \_)__)(____/ (__)\_/\_/\_)__) (__) (____/
*/
package frc.robot;

import edu.wpi.first.wpilibj.Joystick;

public class Constants {
public static Joystick leftDriveStick = new Joystick(0);
public static Joystick rightDriveStick = new Joystick(1);

final static public int driveSpeed = 1;
final static public int shooterMode = 0; // mode 0: low shooter | mode 1: high shooter

final static public double intakeSpeed = 1;

final static public double deadzone = 0.3;

}
19 changes: 19 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
_ _ __ __ __ _
( \/ ) / _\ ( )( ( \
/ \/ \/ \ )( / /
\_)(_/\_/\_/(__)\_)__)
*/

package frc.robot;

import edu.wpi.first.wpilibj.RobotBase;

public final class Main {
private Main() {
}

public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}
92 changes: 92 additions & 0 deletions Robot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* ____ __ ____ __ ____
( _ \ / \( _ \ / \(_ _)
) /( O )) _ (( O ) )(
(__\_) \__/(____/ \__/ (__)
*/

package frc.robot;

import frc.robot.OI;
// import frc.robot.commands.TankDrive;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.Limelight;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;


@Override
public void robotInit() {
OI oi = new OI();
m_robotContainer = new RobotContainer();

}


@Override
public void robotPeriodic() {
CommandScheduler.getInstance().run();
}


@Override
public void disabledInit() {
}

@Override
public void disabledPeriodic() {
}


@Override
public void autonomousInit() {
m_autonomousCommand = m_robotContainer.getAutonomousCommand();

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
}
}


@Override
public void autonomousPeriodic() {
}

@Override
public void teleopInit() {
SmartDashboard.putBoolean("Drive Mode", true);


if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}
}

@Override
public void teleopPeriodic() {

}

@Override
public void testInit() {
CommandScheduler.getInstance().cancelAll();
}


@Override
public void testPeriodic() {
}
}

76 changes: 76 additions & 0 deletions RobotContainer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
____ __ ____ __ ____ ___ __ __ _ ____ __ __ __ _ ____ ____
( _ \ / \( _ \ / \(_ _) / __)/ \ ( ( \(_ _)/ _\ ( )( ( \( __)( _ \
) /( O )) _ (( O ) )( ( (__( O )/ / )( / \ )( / / ) _) ) /
(__\_) \__/(____/ \__/ (__) \___)\__/ \_)__) (__)\_/\_/(__)\_)__)(____)(__\_)*/
package frc.robot;

import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
import frc.robot.commands.*;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.*;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.button.*;

public class RobotContainer {
/*
* OI
*/

public static Joystick rightJoy = new Joystick(0);
public static Joystick leftJoy = new Joystick(1);

/*
* Subsystems
*/

// public final static ShooterSubsystem m_ShooterSubsystem = new
// ShooterSubsystem();
public final static Limelight m_limelight = new Limelight("limelight");
// public final static IntakeSubsystem m_IntakeSubsystem = new
// IntakeSubsystem();
public final static DriveSubsystem m_driveSubsystem = new DriveSubsystem();
public final static DriveSubsystem m_driveSubsystemPID = new DrivePID();

/*
* Commands
*/

// private final AutoCommand m_autoCommand = new AutoCommand();

public RobotContainer() {
configureButtonBindings();
m_driveSubsystem.setDefaultCommand(new TankDrivePID());
}

public static Joystick getRightJoy() {
return rightJoy;
}

public static Joystick getLeftJoy() {
return leftJoy;
}

private void configureButtonBindings() {
GenericHID operatorGamepad = new Joystick(RobotMap.operatorGamepad);
Button shootButton = new JoystickButton(operatorGamepad, RobotMap.shootButton);
Button shooterUp = new JoystickButton(operatorGamepad, 1);
Button shooterDown = new JoystickButton(operatorGamepad, 2);
Button aimBot = new JoystickButton(operatorGamepad, 3);
Button rotatePanelButton = new JoystickButton(operatorGamepad, 5);
Button openIntake = new JoystickButton(operatorGamepad, 6);
Button closeIntake = new JoystickButton(operatorGamepad, 7);

// public GenericHID getRightJoystick(){ return operatorGamepad; }
// public double readRightForwardAxis() { return rightJoystick.getY();}

}

public Command getAutonomousCommand() {
return null;
}
}
29 changes: 29 additions & 0 deletions RobotMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* ____ __ ____ __ ____ _ _ __ ____
( _ \ / \( _ \ / \(_ _)( \/ ) / _\ ( _ \
) /( O )) _ (( O ) )( / \/ \/ \ ) __/
(__\_) \__/(____/ \__/ (__) \_)(_/\_/\_/(__) */

package frc.robot;

public class RobotMap {
public static int driverGamepad = 0;
public static int operatorGamepad = 2;
public static int leftStick = 0;
public static int rightStick = 0;
public static int shootButton = 7;
public static int intakeMotor = 0;
public static int shooterAngleMotor = 10;
public static int topMotor = 11;
public static int bottomMotor = 12;

public static class activatorSolenoid {
public static int forwardChannel = 0;
public static int reverseChannel = 0;
}

public static final int BALL_INTAKE_MOTOR = 7;
public static final int SOLENOID1_FORWARD_CHANNEL = 4;
public static final int SOLENOID1_REVERSE_CHANNEL = 5;
public static final int SOLENOID2_FORWARD_CHANNEL = 6;
public static final int SOLENOID2_REVERSE_CHANNEL = 7;
}
91 changes: 91 additions & 0 deletions commands/Aimbot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
__ __ _ _ ____ __ ____
/ _\ ( )( \/ )( _ \ / \(_ _)
/ \ )( / \/ \ ) _ (( O ) )(
\_/\_/(__)\_)(_/(____/ \__/ (__) */

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Robot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.RobotContainer;

public class Aimbot extends CommandBase {

public Aimbot() {
SmartDashboard.putNumber("constructed aimbot ", 1);
addRequirements(RobotContainer.m_limelight);
addRequirements(RobotContainer.m_driveSubsystem);

}

@Override
public void initialize() {
SmartDashboard.putNumber("Running Limelight - init", 1);
RobotContainer.m_limelight.setLED("on");
// RobotContainer.m_limelight.driverOnlyMode(false);

}

@Override
public void execute() {
// PID VALUES (MUST BE TUNED)
final double kPx = -.02f;
final double kPy = -.1f;
// minimum value to actually make the robot turn (at smaller values it may not
// turn due to friction)
final double min_aim_command = .16f;

// if a target is locked
if (RobotContainer.m_limelight.hasTarget()) {
SmartDashboard.putNumber("LIMELIGHT DISTANCE", RobotContainer.m_limelight.getDistance());
// grab data and add to smart dashboard
SmartDashboard.putBoolean("Limelight Target", true);
double tx = RobotContainer.m_limelight.getHorizontalOffset();
SmartDashboard.putNumber("Horizontal Offset", tx);
double ty = RobotContainer.m_limelight.getVerticalOffset();
SmartDashboard.putNumber("Vertical Offset", ty);
double distance = RobotContainer.m_limelight.getDistance();
SmartDashboard.putNumber("Limelight Distance", distance);

double x_adjust;
// on large angles, ignore the minimum aim value, on smaller angles add it to
// make sure the robot moves
if (Math.abs(tx) > 10.0) {
SmartDashboard.putNumber("applying x adjust", 0);
x_adjust = kPx * -tx;
} else {
SmartDashboard.putNumber("applying x adjust", 1);
if (kPx * -tx > 0) {
x_adjust = kPx * -tx + min_aim_command;
} else {
x_adjust = kPx * -tx - min_aim_command;
}
}
if (Math.abs(tx) < 1) {
x_adjust = 0;
SmartDashboard.putNumber("on target?", 1);
}
double y_adjust = kPy * -ty;
// double y_adjust = 0;
SmartDashboard.putNumber("Pivot Adjust Val", x_adjust);
SmartDashboard.putNumber("Drive Adjust Val", y_adjust);

// drive the robot based on these motor values
RobotContainer.m_driveSubsystem.drive(x_adjust + y_adjust, -(x_adjust - y_adjust));
// RobotContainer.m_driveSubsystem.drive(0,min_aim_command);

} else {
SmartDashboard.putBoolean("Limelight Target", false);
}

}

@Override
public boolean isFinished() {
// RobotContainer.m_limelight.setLED("off");
// RobotContainer.m_limelight.driverOnlyMode(true);
return true;
}
}
37 changes: 37 additions & 0 deletions commands/TankDrive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
__ __ __ _ __ _ ____ ____ __ _ _ ____
(_ _)/ _\ ( ( \( / )( \( _ \( )/ )( \( __)
)( / \/ / ) ( ) D ( ) / )( \ \/ / ) _)
(__)\_/\_/\_)__)(__\_)(____/(__\_)(__) \__/ (____)
*/

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants;
import frc.robot.RobotContainer;

public class TankDrive extends CommandBase {

public TankDrive() {
addRequirements(RobotContainer.m_driveSubsystem);
}

@Override
public void initialize() {
}

@Override
public void execute() {
RobotContainer.m_driveSubsystem.drive(RobotContainer.getLeftJoy().getY(), RobotContainer.getRightJoy().getY());
}

@Override
public void end(boolean interrupted) {
}

@Override
public boolean isFinished() {
return false;
}
}
Loading