Microbot drives

This commit is contained in:
McGrathMaggie
2024-11-10 18:02:54 -07:00
parent 8179b2d33a
commit c8760ab3fa
5 changed files with 105 additions and 2 deletions
+17
View File
@@ -11,7 +11,12 @@ import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler; import edu.wpi.first.wpilibj2.command.CommandScheduler;
<<<<<<< Updated upstream
import frc4388.utility.DeferredBlock; import frc4388.utility.DeferredBlock;
=======
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.utility.RobotGyro;
>>>>>>> Stashed changes
import frc4388.utility.RobotTime; import frc4388.utility.RobotTime;
/** /**
@@ -36,8 +41,11 @@ public class Robot extends TimedRobot {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our // Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard. // autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer(); m_robotContainer = new RobotContainer();
<<<<<<< Updated upstream
SmartDashboard.putData("AutoPlayback Chooser", m_robotContainer.chooser); SmartDashboard.putData("AutoPlayback Chooser", m_robotContainer.chooser);
=======
>>>>>>> Stashed changes
} }
/** /**
@@ -115,14 +123,23 @@ public class Robot extends TimedRobot {
m_robotContainer.m_robotSwerveDrive.resetGyro(); m_robotContainer.m_robotSwerveDrive.resetGyro();
m_robotTime.startMatchTime(); m_robotTime.startMatchTime();
<<<<<<< Updated upstream
m_robotContainer.m_robotMap.restart_motor_tests(); m_robotContainer.m_robotMap.restart_motor_tests();
=======
>>>>>>> Stashed changes
} }
/** /**
* This function is called periodically during operator control. * This function is called periodically during operator control.
*/ */
@Override @Override
<<<<<<< Updated upstream
public void teleopPeriodic() {} public void teleopPeriodic() {}
=======
public void teleopPeriodic() {
}
>>>>>>> Stashed changes
/** /**
* This function is called periodically during test mode. * This function is called periodically during test mode.
@@ -23,6 +23,7 @@ import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.JoystickButton; import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.POVButton; import edu.wpi.first.wpilibj2.command.button.POVButton;
import frc4388.robot.Constants.*; import frc4388.robot.Constants.*;
<<<<<<< Updated upstream
import frc4388.robot.subsystems.Arm; import frc4388.robot.subsystems.Arm;
import frc4388.robot.subsystems.Claw; import frc4388.robot.subsystems.Claw;
import frc4388.robot.subsystems.Limelight; import frc4388.robot.subsystems.Limelight;
@@ -37,6 +38,14 @@ import frc4388.robot.commands.Placement.LimeAlign;
import frc4388.robot.commands.Swerve.RotateToAngle; import frc4388.robot.commands.Swerve.RotateToAngle;
import frc4388.utility.controller.DeadbandedXboxController; import frc4388.utility.controller.DeadbandedXboxController;
import frc4388.utility.controller.XboxController; import frc4388.utility.controller.XboxController;
=======
import frc4388.robot.subsystems.LED;
import frc4388.robot.subsystems.Microbot;
import frc4388.utility.LEDPatterns;
import frc4388.utility.RobotGyro;
import frc4388.utility.controller.IHandController;
import frc4388.utility.controller.XboxController;
>>>>>>> Stashed changes
/** /**
* This class is where the bulk of the robot should be declared. Since * This class is where the bulk of the robot should be declared. Since
@@ -50,6 +59,7 @@ public class RobotContainer {
public final RobotMap m_robotMap = new RobotMap(); public final RobotMap m_robotMap = new RobotMap();
/* Subsystems */ /* Subsystems */
<<<<<<< Updated upstream
public final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.leftFront, public final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.leftFront,
m_robotMap.rightFront, m_robotMap.rightFront,
m_robotMap.leftBack, m_robotMap.leftBack,
@@ -61,6 +71,10 @@ public class RobotContainer {
public final Claw m_robotClaw = new Claw(m_robotMap.leftClaw, m_robotMap.rightClaw, m_robotMap.spinnyspin); public final Claw m_robotClaw = new Claw(m_robotMap.leftClaw, m_robotMap.rightClaw, m_robotMap.spinnyspin);
public final Limelight m_robotLimeLight = new Limelight(); public final Limelight m_robotLimeLight = new Limelight();
=======
private final LED m_robotLED = new LED(m_robotMap.LEDController);
private final Microbot microbot = new Microbot(m_robotMap.frontLeft, m_robotMap.backLeft, m_robotMap.frontRight, m_robotMap.backRight);
>>>>>>> Stashed changes
/* Controllers */ /* Controllers */
private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID);
@@ -165,13 +179,17 @@ public class RobotContainer {
armToHome.asProxy() armToHome.asProxy()
); );
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
/** /**
* The container for the robot. Contains subsystems, OI devices, and commands. * The container for the robot. Contains subsystems, OI devices, and commands.
*/ */
public RobotContainer() { public RobotContainer() {
configureButtonBindings(); configureButtonBindings();
<<<<<<< Updated upstream
// * Default Commands // * Default Commands
m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> { m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> {
m_robotSwerveDrive.driveWithInput(getDeadbandedDriverController().getLeft(), m_robotSwerveDrive.driveWithInput(getDeadbandedDriverController().getLeft(),
@@ -212,6 +230,14 @@ public class RobotContainer {
private static class TapState { private static class TapState {
public boolean gearTapped = true; public boolean gearTapped = true;
public long gearTime = 0; public long gearTime = 0;
=======
/* Default Commands */
// drives the robot with a two-axis input from the driver controller
// continually sends updates to the Blinkin LED controller to keep the lights on
m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED(), m_robotLED));
microbot.setDefaultCommand(new RunCommand(() -> microbot.drive(m_driverXbox.getLeftYAxis(), m_driverXbox.getRightYAxis())));
>>>>>>> Stashed changes
} }
/** /**
+21
View File
@@ -30,6 +30,7 @@ import frc4388.utility.RobotGyro;
* testing and modularization. * testing and modularization.
*/ */
public class RobotMap { public class RobotMap {
<<<<<<< Updated upstream
private WPI_Pigeon2 m_pigeon2 = new WPI_Pigeon2(14); private WPI_Pigeon2 m_pigeon2 = new WPI_Pigeon2(14);
public RobotGyro gyro = new RobotGyro(m_pigeon2); public RobotGyro gyro = new RobotGyro(m_pigeon2);
@@ -49,6 +50,26 @@ public class RobotMap {
} catch (IllegalArgumentException | IllegalAccessException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
=======
public TalonSRX frontLeft = new TalonSRX(20);
public TalonSRX backLeft = new TalonSRX(21);
public TalonSRX backRight = new TalonSRX(23);
public TalonSRX frontRight = new TalonSRX(22);
public RobotMap() {
configureLEDMotorControllers();
configureDriveMotorControllers();
frontRight.configFactoryDefault();
frontLeft.configFactoryDefault();
backLeft.configFactoryDefault();
backRight.configFactoryDefault();
frontLeft.setInverted(true);
backLeft.setInverted(true);
>>>>>>> Stashed changes
} }
} }
@@ -0,0 +1,39 @@
// 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 frc4388.robot.subsystems;
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Microbot extends SubsystemBase {
/** Creates a new Microbot. */
TalonSRX frontLeft;
TalonSRX backLeft;
TalonSRX frontRight;
TalonSRX backRight;
public Microbot(TalonSRX frontLeft, TalonSRX backLeft, TalonSRX frontRight, TalonSRX backRight) {
this.frontLeft = frontLeft;
this.backLeft = backLeft;
this.frontRight = backRight;
this.backRight = backRight;
}
public void drive(double leftOutput, double rightOutput) {
frontLeft.set(ControlMode.PercentOutput, leftOutput);
backLeft.set(ControlMode.PercentOutput, leftOutput);
frontRight.set(ControlMode.PercentOutput, rightOutput);
backRight.set(ControlMode.PercentOutput, rightOutput);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}
@@ -13,8 +13,8 @@ public class XboxController implements IHandController
public static final int LEFT_Y_AXIS = 1; public static final int LEFT_Y_AXIS = 1;
public static final int LEFT_TRIGGER_AXIS = 2; public static final int LEFT_TRIGGER_AXIS = 2;
public static final int RIGHT_TRIGGER_AXIS = 3; public static final int RIGHT_TRIGGER_AXIS = 3;
public static final int RIGHT_X_AXIS = 4; public static final int RIGHT_X_AXIS = 2;
public static final int RIGHT_Y_AXIS = 5; public static final int RIGHT_Y_AXIS = 3;
public static final int LEFT_RIGHT_DPAD_AXIS = 6; public static final int LEFT_RIGHT_DPAD_AXIS = 6;
public static final int TOP_BOTTOM_DPAD_AXIS = 6; public static final int TOP_BOTTOM_DPAD_AXIS = 6;