Skip to content

Commit

Permalink
update code to find find the encoder value based on the calculated angle
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry-Lachance committed Feb 6, 2024
1 parent 80c13d0 commit 926d829
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/frc/robot/commands/SetShooterAngleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class SetShooterAngleCommand extends PIDCommand {
public SetShooterAngleCommand(AngleShooter angleShooter, Limelight limelight) {
super(
// The controller that the command will use
new PIDController(0, 0, 0),
new PIDController(0, 0, 0),//TODO change value
// This should return the measurement
() -> angleShooter.getEncoderValue(),
// This should return the setpoint (can also be a constant)
() ->
((limelight.calculateShooterAngle()
* 8.57)), // TODO adjust 8.57 based on gearbox and encoder
((limelight.calculateShooterAngle()*(angleShooter.getEncoderMax()-angleShooter.getEncoderMin()))/30)+angleShooter.getEncoderMin()//un produit croiser pour calculer les valeur d'encoder basee sur l'angle calculer
,
// This uses the output
output -> {
angleShooter.setPower(output);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/subsystems/AngleShooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ public AngleShooter() {

public double getEncoderValue() {

return shooterAngleEncoder.getAbsolutePosition() - encoderMin;
return shooterAngleEncoder.getAbsolutePosition();
}
public double getEncoderMax(){
return encoderMax;
}
public double getEncoderMin(){
return encoderMin;
}
public void setPower(double power) {
shooterAngle.set(power);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/Limelight.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public double calculateShooterAngle() {
if (ty.getDouble(0) < 1234
&& ty.getDouble(0) > -1234
&& tx.getDouble(0) <= 90) { // TODO change range
return Math.atan(62.6 / tx.getDouble(0));
return Math.atan(62.6 / tx.getDouble(0));//TODO check if relative to the field or camera
} else {
return 30;
}
Expand Down

0 comments on commit 926d829

Please sign in to comment.