Skip to content

Commit

Permalink
here eng my b
Browse files Browse the repository at this point in the history
  • Loading branch information
samanthanguyen23 committed Nov 29, 2023
1 parent 5a1a91a commit 111de82
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/java/frc/robot/Subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@
// the WPILib BSD license file in the root directory of this project.

package frc.robot.Subsystems;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
import com.ctre.phoenix.motorcontrol.can.TalonFX;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.Elevator;

// import frc.robot.Constants.Elevator;
import java.util.Timer;

import edu.wpi.first.wpilibj2.command.SubsystemBase;

// private PIDController controller;

public class ElevatorSubsystem extends SubsystemBase {
Expand All @@ -29,6 +18,7 @@ public class ElevatorSubsystem extends SubsystemBase {
private PIDController controller;
private double targetHeight;
private double motorPower;
private double currentHeight;



Expand All @@ -51,14 +41,23 @@ public void setTargetHeight(double targetHeight){




@Override
public void periodic() {
// This method will be called once per scheduler run
motorPower = controller.calculate(targetHeight);

leftMotor.set(TalonFXControlMode.PercentOutput, motorPower);
currentHeight = ticksToInches(-leftMotor.getSelectedSensorPosition());
}


public boolean nearTargetHeight() {

public boolean nearTargetHeight(){
if(targetHeight -0.5 <= currentHeight && currentHeight <= targetHeight +0.5){
return true;
}
return false;
}
}

}

0 comments on commit 111de82

Please sign in to comment.