Commit 8a147557 authored by Svetlana's avatar Svetlana

Fixed denormalizer component

parent 67cb5814
package dp.subcomponents;
function Q newValue = ChangeRange(Q oldMin, Q oldMax, Q newMin, Q newMax, Q oldValue)
Q oldRange = oldMax - oldMin;
Q newRange = newMax - newMin;
newValue = (((oldValue - oldMin) * newRange) / oldRange) + newMin;
end
\ No newline at end of file
package dp.subcomponents;
import dp.subcomponents.*;
import ChangeRange;
component Denormalizer {
ports in Q^{14} normalizedPredictions,
out Affordance affordance;
implementation Math {
Q oldMin = 0.1;
Q oldMax = 0.9;
affordance.angle = ChangeRange(oldMin, oldMax, -0.5, 0.5, normalizedPredictions(0));
affordance.toMarkingL = ChangeRange(oldMin, oldMax, -7, -2.5, normalizedPredictions(1));
affordance.toMarkingM = ChangeRange(oldMin, oldMax, -2, 3.5, normalizedPredictions(2));
affordance.toMarkingR = ChangeRange(oldMin, oldMax, 2.5, 7, normalizedPredictions(3));
affordance.distL = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(4));
affordance.distR = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(5));
affordance.toMarkingLL = ChangeRange(oldMin, oldMax, -9.5, -4, normalizedPredictions(6));
affordance.toMarkingML = ChangeRange(oldMin, oldMax, -5.5, -0.5, normalizedPredictions(7));
affordance.toMarkingMR = ChangeRange(oldMin, oldMax, 0.5, 5.5, normalizedPredictions(8));
affordance.toMarkingRR = ChangeRange(oldMin, oldMax, 4, 9.5, normalizedPredictions(9));
affordance.distLL = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(10));
affordance.distMM = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(11));
affordance.distRR = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(12));
affordance.fast = ChangeRange(oldMin, oldMax, 0, 1, normalizedPredictions(13));
}
out Affordance affordance;
implementation Math {
Q oldMin = 0.1;
Q oldMax = 0.9;
Q oldRange = oldMax - oldMin;
Q newMinAngle = -0.5;
Q newRangeAngle = 0.5 - newMinAngle;
affordance.angle = (((normalizedPredictions(0) - oldMin) * newRangeAngle) / oldRange) + newMinAngle;
Q newMinMarkingL = -7;
Q newRangeMarkingL = -2.5 - newMinMarkingL;
affordance.toMarkingL = (((normalizedPredictions(1) - oldMin) * newRangeMarkingL) / oldRange) + newMinMarkingL;
Q newMinMarkingM = -2;
Q newRangeMarkingM = 3.5 - newMinMarkingM;
affordance.toMarkingM = (((normalizedPredictions(2) - oldMin) * newRangeMarkingM) / oldRange) + newMinMarkingM;
Q newMinMarkingR = 2.5;
Q newRangeMarkingR = newMinMarkingR - 7;
affordance.toMarkingR = (((normalizedPredictions(3) - oldMin) * newRangeMarkingR) / oldRange) + newMinMarkingR;
Q newMinDist = 0;
Q newRangeDist = 75 - newMinDist;
affordance.distL = (((normalizedPredictions(4) - oldMin) * newRangeDist) / oldRange) + newMinDist;
affordance.distR = (((normalizedPredictions(5) - oldMin) * newRangeDist) / oldRange) + newMinDist;
Q newMinMarkingLL = -9.5;
Q newRangeMarkingLL = -4 - newMinMarkingLL;
affordance.toMarkingLL = (((normalizedPredictions(6) - oldMin) * newRangeMarkingLL) / oldRange) + newMinMarkingLL;
Q newMinMarkingML = -5.5;
Q newRangeMarkingML = -0.5 - newMinMarkingML;
affordance.toMarkingML = (((normalizedPredictions(7) - oldMin) * newRangeMarkingML) / oldRange) + newMinMarkingML;
Q newMinMarkingMR = 0.5;
Q newRangeMarkingMR = 5.5 - newMinMarkingMR;
affordance.toMarkingMR = (((normalizedPredictions(8) - oldMin) * newRangeMarkingMR) / oldRange) + newMinMarkingMR;
Q newMinMarkingRR = 4;
Q newRangeMarkingRR = 9.5 - newMinMarkingRR;
affordance.toMarkingRR = (((normalizedPredictions(9) - oldMin) * newRangeMarkingRR) / oldRange) + newMinMarkingRR;
Q newMinDistLMR = 0;
Q newRangeDistLMR = 75 - newMinDistLMR;
affordance.distLL = (((normalizedPredictions(10) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
affordance.distMM = (((normalizedPredictions(11) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
affordance.distRR = (((normalizedPredictions(12) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
Q newMinFast = 0;
Q newRangeFast = 1 - newMinFast;
affordance.fast = (((normalizedPredictions(13) - oldMin) * newRangeFast) / oldRange) + newMinFast;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment