Utility Functions
package com.seattlesolvers.solverslib.solverslib.util;
Last updated
import com.seattlesolvers.solverslib.util.LUT;
LUT<Double, Double> speeds = new LUT<Double, Double>()
{{
add(5.0, 1.0);
add(4.0, 0.9);
add(3.0, 0.75);
add(2.0, 0.5);
add(1.0, 0.2);
}};
double distance = odometry.getPose().getTranslation().getDistance(new Translation2d(5, 10));
shooter.set(speeds.getClosest(distance));import com.seattlesolvers.solverslib.util.InterpLUT;
//Init the Look up table
InterpLUT lut = new InterpLUT();
//Adding each val with a key
lut.add(1.1, 0.2);
lut.add(2.7, .5);
lut.add(3.6, 0.75);
lut.add(4.1, 0.9);
lut.add(5, 1);
//generating final equation
lut.createLUT();
double distance = odometry.getPose().getTranslation().getDistance(new Translation2d(5, 10));
shooter.set(lut.get(distance));
//getting the velo required and passing it to the shooter.import com.seattlesolvers.solverslib.util;
double ValueToClamp;
double LowestPossibleValue;
double HighestPossibleValue;
double OutputVal = clamp(ValueToClamp,
LowestPossibleValue,
HighestPossibleValue);import com.seattlesolvers.solverslib.util;
int ValueToClamp;
int LowestPossibleValue;
int HighestPossibleValue;
int OutputVal = clamp(ValueToClamp,
LowestPossibleValue,
HighestPossibleValue);