Skip to content

Commit

Permalink
added command that can be used to get new lerp points and print the c…
Browse files Browse the repository at this point in the history
…ode to use for those lerp points
  • Loading branch information
PGgit08 committed Apr 1, 2024
1 parent 441e1a5 commit 9a3f66f
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/main/java/frc/robot/commands/auto/AutonShoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
import frc.robot.commands.intake.FeedActuate;
import frc.robot.commands.shooter.SpinShooter;
import frc.robot.subsystems.ElevatorSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.LEDSubsystem;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.subsystems.SwerveDriveSubsystem;
import frc.robot.subsystems.IntakeSubsystem.FeedMode;
Expand Down
77 changes: 77 additions & 0 deletions src/main/java/frc/robot/commands/auto/SaveLerpPoints.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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.auto;

import java.util.ArrayList;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.ElevatorSubsystem;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.utils.UtilFuncs;

public class SaveLerpPoints extends Command {
private final ShooterSubsystem _shooter;
private final ElevatorSubsystem _elevator;

private ArrayList<double[]> shooterPoints = new ArrayList<>();
private ArrayList<double[]> elevatorPoints = new ArrayList<>();

private final String SHOOTER_LERP_NAME = "SHOOTER_DISTANCE_ANGLE";
private final String ELEVATOR_LERP_NAME = "ELEVATOR_DISTANCE_HEIGHT";

/** Creates a new SaveLerpPoints. */
public SaveLerpPoints(
ShooterSubsystem shooter,
ElevatorSubsystem elevator
) {
_shooter = shooter;
_elevator = elevator;

addRequirements(_shooter, _elevator);
}

private void showLine(String className, double[] point) {
System.out.println(className + ".put(" + Double.toString(point[0]) + ", " + Double.toString(point[1]) + ");");
}

/**
* Creates the code that can be copied into Constants.java for lerp points.
*/
public void showCode() {
for (double[] point : shooterPoints) {
showLine(SHOOTER_LERP_NAME, point);
}

for (double[] point : elevatorPoints) {
showLine(ELEVATOR_LERP_NAME, point);
}
}

// Called when the command is initially scheduled.
@Override
public void initialize() {
double shotDistance = UtilFuncs.ShotVector().getNorm();

double[] shooterLerp = {shotDistance, _shooter.getAngle()};
double[] elevatorLerp = {shotDistance, _elevator.getHeight()};

shooterPoints.add(shooterLerp);
elevatorPoints.add(elevatorLerp);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}

// 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 true;
}
}

0 comments on commit 9a3f66f

Please sign in to comment.