mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 00:37:59 -06:00
change
This commit is contained in:
@@ -18,6 +18,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||
import frc4388.robot.Constants.*;
|
||||
import frc4388.robot.commands.AutoBalance;
|
||||
import frc4388.robot.commands.DriveWithInput;
|
||||
import frc4388.robot.subsystems.LED;
|
||||
import frc4388.robot.subsystems.SwerveDrive;
|
||||
@@ -115,6 +116,8 @@ public class RobotContainer {
|
||||
|
||||
// new JoystickButton(getDriverJoystick(), XboxController.Y_BUTTON)
|
||||
// .onTrue()
|
||||
new JoystickButton(getDriverJoystick(), XboxController.Y_BUTTON)
|
||||
.onTrue(new AutoBalance(m_robotMap.gyro, m_robotSwerveDrive));
|
||||
|
||||
//New interupt button
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.X_BUTTON)
|
||||
|
||||
@@ -23,8 +23,8 @@ import frc4388.utility.RobotGyro;
|
||||
* testing and modularization.
|
||||
*/
|
||||
public class RobotMap {
|
||||
// private WPI_Pigeon2 m_pigeon2 = new WPI_Pigeon2(14);
|
||||
// public RobotGyro gyro = new RobotGyro(m_pigeon2);
|
||||
private WPI_Pigeon2 m_pigeon2 = new WPI_Pigeon2(14);
|
||||
public RobotGyro gyro = new RobotGyro(m_pigeon2);
|
||||
|
||||
|
||||
public SwerveModule leftFront;
|
||||
|
||||
@@ -5,37 +5,42 @@
|
||||
package frc4388.robot.commands;
|
||||
|
||||
import edu.wpi.first.math.MathUtil;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import frc4388.robot.Robot;
|
||||
import frc4388.robot.subsystems.SwerveDrive;
|
||||
import frc4388.utility.RobotGyro;
|
||||
|
||||
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||
// information, see:
|
||||
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
|
||||
public class AutoBalance extends PelvicInflammatoryDisease {
|
||||
Robot.MicroBot bot;
|
||||
RobotGyro gyro;
|
||||
SwerveDrive drive;
|
||||
|
||||
/** Creates a new AutoBalanceTF2. */
|
||||
public AutoBalance(Robot.MicroBot bot) {
|
||||
public AutoBalance(RobotGyro gyro, SwerveDrive drive) {
|
||||
super(.7, .1, 15, 0);
|
||||
addRequirements(bot);
|
||||
this.bot = bot;
|
||||
addRequirements(drive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getError() {
|
||||
return bot.gyro.getPitch();
|
||||
var pitch = gyro.getPitch();
|
||||
SmartDashboard.putNumber("pitch", pitch);
|
||||
return pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runWithOutput(double output) {
|
||||
double out2 = MathUtil.clamp(output / 40, -.5, .5);
|
||||
if (Math.abs(bot.gyro.getPitch()) < 3) out2 = 0;
|
||||
bot.setOutput(out2);
|
||||
if (Math.abs(gyro.getPitch()) < 3) out2 = 0;
|
||||
drive.drive(out2, 0, 0, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
this.bot.gyro.reset();
|
||||
this.gyro.reset();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
|
||||
Reference in New Issue
Block a user