Skip to content

Commit

Permalink
[#502] made simpler test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilok1 committed Apr 2, 2024
1 parent 0faddb1 commit f860b47
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import frc.robot.command.PointAtPoint;
import frc.robot.command.PointAtTag;
import frc.robot.command.SetPointClimb;
import frc.robot.command.SimpleFacingTest;
import frc.robot.command.Sing;
import frc.robot.command.SmartClimb;
import frc.robot.command.SmartCollect;
Expand Down Expand Up @@ -238,7 +239,10 @@ protected void configureButtonBindings() {
// .whileTrue(new PointAtPoint(DrivetrainConstants.SPEAKER_POSE, drivetrain, driver));
// new Trigger(driver::getLeftBumper)
// .whileTrue(new ComboPoint(DrivetrainConstants.SPEAKER_POSE, drivetrain, driver, limelights));
new Trigger(driver::getLeftBumper).whileTrue(new FacingTest(DrivetrainConstants.SPEAKER_POSE, drivetrain, driver));

// new Trigger(driver::getLeftBumper).whileTrue(new FacingTest(DrivetrainConstants.SPEAKER_POSE, drivetrain, driver)); //TODO: delete

new Trigger(driver::getLeftBumper).whileTrue(new SimpleFacingTest(drivetrain, driver));

// new Trigger(driver::getYButton)
// .whileTrue(new MoveToPose(AutonomousConstants.TARGET_POSE, drivetrain));
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/frc/robot/command/SimpleFacingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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.command;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Swerve;

public class SimpleFacingTest extends Command {
/** Creates a new SimpleFacingTest. */

private Swerve drivetrain;
private XboxController driver;
private Rotation2d targetHeading;

public SimpleFacingTest(Swerve drivetrain, XboxController driver) {
// Use addRequirements() here to declare subsystem dependencies.
this.drivetrain = drivetrain;
this.driver = driver;
addRequirements(drivetrain);
}

// Called when the command is initially scheduled.
@Override
public void initialize() {
targetHeading = new Rotation2d(0d);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
drivetrain.setFieldFacing(-driver.getLeftY(), -driver.getLeftX(), targetHeading);
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

0 comments on commit f860b47

Please sign in to comment.