Skip to content

Commit

Permalink
fix the antigrav code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixmix00 committed Sep 14, 2023
1 parent ed5d4d0 commit 65ee961
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import java.*;
package com.team766.controllers;

import java.util.*;

public class CanSparkMaxSmartMotionRotationalPIDController extends ExtendableCanSparkMaxSmartMotionPIDController {

Expand All @@ -17,7 +19,7 @@ private double euToDegrees(final double eu) {
}

public void runPIDs(){
updateAntigrav(antiGravK * Math.sin(euToDegrees(mc.getSensorPosition())));
updateAntigrav(antiGravK * Math.sin(euToDegrees(getHallSensorPosition())));
run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public ExtendableCanSparkMaxSmartMotionPIDController(final String configName, fi
private double absToEu(final double abs) {
return encoderUnitsPerOneAbsolute * abs;
}

/*
* This is a method to get the hall sensor position from the motorcontroller, so we can use it in the antigravity calculations in the subclass.
* @return the value of the hall sensor position
* @author Max Spier - 9/13/2023
*/
protected double getHallSensorPosition(){
return mc.getSensorPosition();
}

/*
* Method to change all PIDF values at once
Expand Down

0 comments on commit 65ee961

Please sign in to comment.