generated from OakvilleDynamics/frc-robot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26e4ef6
commit c8cc656
Showing
13 changed files
with
347 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.Constants; | ||
import frc.robot.subsystems.Drivetrain; | ||
|
||
public class Drive extends CommandBase { | ||
|
||
// The subsystem the command runs on | ||
private final Drivetrain m_subDrivetrain; | ||
|
||
// The controller the command runs on | ||
private final Joystick m_driverController = | ||
new Joystick(Constants.ControllersConstants.driverControllerPort); | ||
|
||
/** | ||
* Creates a new Drive command. | ||
* | ||
* @param subsystem The subsystem used by this command. | ||
*/ | ||
public Drive(Drivetrain subsystem) { | ||
m_subDrivetrain = subsystem; | ||
addRequirements(subsystem); | ||
|
||
SmartDashboard.putData(subsystem); | ||
} | ||
|
||
/** Called when the command is initially scheduled. */ | ||
@Override | ||
public void initialize() { | ||
System.out.println("Drive initialized"); | ||
} | ||
|
||
/** Called every time the scheduler runs while the command is scheduled. */ | ||
@Override | ||
public void execute() { | ||
m_subDrivetrain.arcadeDrive(m_driverController.getX(), m_driverController.getY()); | ||
} | ||
|
||
/** Called once the command ends or is interrupted. */ | ||
@Override | ||
public void end(boolean interrupted) { | ||
m_subDrivetrain.arcadeDrive(0, 0); | ||
System.out.println("Drive ended"); | ||
} | ||
|
||
/** Returns true when the command should end. */ | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.Constants; | ||
import frc.robot.subsystems.Pneumatics; | ||
|
||
public class PistonControl extends CommandBase { | ||
|
||
private final Pneumatics m_subPneumatics; | ||
|
||
private final Joystick m_operatorJoystick = | ||
new Joystick(Constants.ControllersConstants.operatorControllerPort); | ||
|
||
/** Creates a new PistonControl. */ | ||
public PistonControl(Pneumatics subsystem) { | ||
m_subPneumatics = subsystem; | ||
addRequirements(subsystem); | ||
|
||
SmartDashboard.putData(subsystem); | ||
} | ||
|
||
/** Called when the command is initially scheduled. */ | ||
@Override | ||
public void initialize() { | ||
System.out.println("PistonControl initialized"); | ||
} | ||
|
||
/** Called every time the scheduler runs while the command is scheduled. */ | ||
@Override | ||
public void execute() { | ||
if (m_operatorJoystick.getRawButton(Constants.ControllersConstants.pistonButtonOpen)) { | ||
m_subPneumatics.open(); | ||
} else if (m_operatorJoystick.getRawButton(Constants.ControllersConstants.pistonButtonClose)) { | ||
m_subPneumatics.close(); | ||
} | ||
} | ||
|
||
/** Called once the command ends or is interrupted. */ | ||
@Override | ||
public void end(boolean interrupted) { | ||
System.out.println("PistonControl ended"); | ||
} | ||
|
||
/** Returns true when the command should end. */ | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkMaxLowLevel.MotorType; | ||
import edu.wpi.first.wpilibj.drive.DifferentialDrive; | ||
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class Drivetrain extends SubsystemBase { | ||
|
||
/** The motors on the right side of the drive. */ | ||
private CANSparkMax rightMotor1 = | ||
new CANSparkMax(Constants.DrivetrainConstants.rightMotor1, MotorType.kBrushed); | ||
|
||
private CANSparkMax rightMotor2 = | ||
new CANSparkMax(Constants.DrivetrainConstants.rightMotor2, MotorType.kBrushed); | ||
|
||
/** The motors on the left side of the drive. */ | ||
private CANSparkMax leftMotor1 = | ||
new CANSparkMax(Constants.DrivetrainConstants.leftMotor1, MotorType.kBrushed); | ||
|
||
private CANSparkMax leftMotor2 = | ||
new CANSparkMax(Constants.DrivetrainConstants.leftMotor2, MotorType.kBrushed); | ||
|
||
/** Configuration for the motor controllers to run together in a group. */ | ||
MotorControllerGroup rightMotors = new MotorControllerGroup(rightMotor1, rightMotor2); | ||
|
||
MotorControllerGroup leftMotors = new MotorControllerGroup(leftMotor1, leftMotor2); | ||
|
||
/** The robot's drive. */ | ||
private final DifferentialDrive drive = new DifferentialDrive(leftMotors, rightMotors); | ||
|
||
/** Creates a new Drivetrain subsystem. */ | ||
public Drivetrain() { | ||
System.out.println("Drivetrain initialized"); | ||
} | ||
|
||
/** | ||
* Arcade drive method for differential drive platform. The calculated values will be squared to | ||
* decrease sensitivity at low speeds. | ||
* | ||
* @param speed The robot's speed along the X axis [-1.0..1.0]. Forward is positive. | ||
* @param rotation The robot's rotation rate around the Z axis [-1.0..1.0]. Clockwise is positive. | ||
*/ | ||
public void arcadeDrive(double speed, double rotation) { | ||
drive.arcadeDrive(speed, rotation); | ||
} | ||
|
||
@Override | ||
/** | ||
* Periodic method for the drivetrain subsystem. This method will be called once per scheduler | ||
* run. | ||
*/ | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.