Skip to content

Commit

Permalink
Add out-of-the-box mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
richiksc committed Dec 19, 2018
1 parent 972411c commit ef5a9c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ protected void logPowerInfo(double startTime) {
* proportions between values.
*/
protected void scaleWheelValues() {
valuesAbs.mapFrom(values, new WheelValues.Mapper() {
@Override
public double apply(double val) {
return Math.abs(val);
}
});
valuesAbs.mapFrom(values, WheelValues.Mapper.ABS);

final double maxAbs = valuesAbs.max();
if (maxAbs > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ public class WheelValues {
private double br;

public interface Mapper {
Mapper ABS = new Mapper() {
@Override
public double apply(double val) {
return Math.abs(val);
}
};
Mapper SIGMOID = new Mapper() {
@Override
public double apply(double val) {
return val / (1 + Math.abs(val));
}
};
double apply(double val);
}

Expand Down

0 comments on commit ef5a9c8

Please sign in to comment.