first commit
This commit is contained in:
15
src/main/java/frc/robot/Main.java
Normal file
15
src/main/java/frc/robot/Main.java
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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;
|
||||
|
||||
import edu.wpi.first.wpilibj.RobotBase;
|
||||
|
||||
public final class Main {
|
||||
private Main() {}
|
||||
|
||||
public static void main(String... args) {
|
||||
RobotBase.startRobot(Robot::new);
|
||||
}
|
||||
}
|
||||
72
src/main/java/frc/robot/Robot.java
Normal file
72
src/main/java/frc/robot/Robot.java
Normal file
@@ -0,0 +1,72 @@
|
||||
// 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;
|
||||
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.CommandScheduler;
|
||||
|
||||
public class Robot extends TimedRobot {
|
||||
private Command m_autonomousCommand;
|
||||
|
||||
private final RobotContainer m_robotContainer;
|
||||
|
||||
public Robot() {
|
||||
m_robotContainer = new RobotContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void robotPeriodic() {
|
||||
CommandScheduler.getInstance().run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disabledInit() {}
|
||||
|
||||
@Override
|
||||
public void disabledPeriodic() {}
|
||||
|
||||
@Override
|
||||
public void disabledExit() {}
|
||||
|
||||
@Override
|
||||
public void autonomousInit() {
|
||||
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand != null) {
|
||||
m_autonomousCommand.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autonomousPeriodic() {}
|
||||
|
||||
@Override
|
||||
public void autonomousExit() {}
|
||||
|
||||
@Override
|
||||
public void teleopInit() {
|
||||
if (m_autonomousCommand != null) {
|
||||
m_autonomousCommand.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {}
|
||||
|
||||
@Override
|
||||
public void teleopExit() {}
|
||||
|
||||
@Override
|
||||
public void testInit() {
|
||||
CommandScheduler.getInstance().cancelAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testPeriodic() {}
|
||||
|
||||
@Override
|
||||
public void testExit() {}
|
||||
}
|
||||
33
src/main/java/frc/robot/RobotContainer.java
Normal file
33
src/main/java/frc/robot/RobotContainer.java
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import frc.robot.constants.ArmConstants;
|
||||
import frc.robot.constants.IOConstants;
|
||||
import frc.robot.subsystems.Arm;
|
||||
|
||||
public class RobotContainer {
|
||||
CommandXboxController driver;
|
||||
|
||||
Arm arm;
|
||||
|
||||
public RobotContainer() {
|
||||
arm = new Arm();
|
||||
driver = new CommandXboxController(IOConstants.kDriverID0);
|
||||
configureBindings();
|
||||
}
|
||||
|
||||
private void configureBindings() {
|
||||
}
|
||||
|
||||
public Command getAutonomousCommand() {
|
||||
return Commands.print("No autonomous command configured");
|
||||
}
|
||||
}
|
||||
5
src/main/java/frc/robot/constants/ArmConstants.java
Normal file
5
src/main/java/frc/robot/constants/ArmConstants.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class ArmConstants {
|
||||
public static final int kArmMotorID1 = 1;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class DriveTrainConstants {
|
||||
public static final int kmotorLeftFtID2 = 2;
|
||||
public static final int kmotorRightFtID3 = 3;
|
||||
public static final int kmotorLeftBkID4 = 4;
|
||||
public static final int kmotorRightBkID5 = 5;
|
||||
}
|
||||
5
src/main/java/frc/robot/constants/IOConstants.java
Normal file
5
src/main/java/frc/robot/constants/IOConstants.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class IOConstants {
|
||||
public static final int kDriverID0 = 0;
|
||||
}
|
||||
21
src/main/java/frc/robot/subsystems/Arm.java
Normal file
21
src/main/java/frc/robot/subsystems/Arm.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package frc.robot.subsystems;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.constants.ArmConstants;
|
||||
|
||||
public class Arm extends SubsystemBase {
|
||||
private WPI_TalonSRX motor;
|
||||
|
||||
public Arm() {
|
||||
motor = new WPI_TalonSRX(ArmConstants.kArmMotorID1);
|
||||
}
|
||||
|
||||
public Command runArmMotor(double speed) {
|
||||
return run(() -> {
|
||||
motor.set(speed);
|
||||
});
|
||||
}
|
||||
}
|
||||
44
src/main/java/frc/robot/subsystems/DriveTrain.java
Normal file
44
src/main/java/frc/robot/subsystems/DriveTrain.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package frc.robot.subsystems;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
import com.ctre.phoenix6.controls.Follower;
|
||||
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.constants.DriveTrainConstants;
|
||||
|
||||
|
||||
public class DriveTrain extends SubsystemBase {
|
||||
private WPI_TalonSRX motorLeftFt;
|
||||
private WPI_TalonSRX motorRightFt;
|
||||
private WPI_TalonSRX motorLeftBk;
|
||||
private WPI_TalonSRX motorRightBk;
|
||||
|
||||
private DifferentialDrive drive;
|
||||
public DriveTrain() {
|
||||
motorLeftFt = new WPI_TalonSRX(DriveTrainConstants.kmotorLeftFtID2);
|
||||
motorRightFt = new WPI_TalonSRX(DriveTrainConstants.kmotorRightFtID3);
|
||||
motorLeftBk = new WPI_TalonSRX(DriveTrainConstants.kmotorLeftBkID4);
|
||||
motorRightBk = new WPI_TalonSRX(DriveTrainConstants.kmotorRightBkID5);
|
||||
|
||||
motorLeftBk.follow(motorLeftFt);
|
||||
motorRightBk.follow(motorRightFt);
|
||||
|
||||
drive = new DifferentialDrive(motorLeftFt, motorRightFt);
|
||||
}
|
||||
public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
|
||||
return run(() -> {
|
||||
//makes car like steering possible
|
||||
drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble());
|
||||
});
|
||||
}
|
||||
|
||||
public Command driveTank(DoubleSupplier leftSpeed, DoubleSupplier rightSpeed) {
|
||||
return run(() -> {
|
||||
//makes tank steering possible
|
||||
drive.tankDrive(leftSpeed.getAsDouble(), rightSpeed.getAsDouble());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user