Commit 05c709ac authored by Svetlana's avatar Svetlana

Fixes in Denormalizer.

parent 2c4d88aa
......@@ -3,21 +3,22 @@ import dp.subcomponents.*;
component Mastercomponent {
ports
in Q(0:255)^{3, 210, 280} imageIn,
in Z(0:255)^{3, 210, 280} imageIn,
in Q(0 m/s:0.1 m/s:100 m/s) speedIn,
out Q(-1:1)^{3} commandsOut;
instance Dpnet dpnet;
instance DriverController driverController;
instance Unnormalizer unnorm;
instance KFMastercomponent kfm;
instance Denormalizer denorm;
//instance KFMastercomponent kfm;
instance SteeringBuffer steeringBuffer;
connect imageIn -> dpnet.data;
connect dpnet.predictions -> unnorm.normalizedPredictions;
connect dpnet.predictions -> denorm.normalizedPredictions;
connect unnorm.affordance -> kfm.affordanceIn;
connect kfm.affordanceSmoothed -> driverController.affordanceIn;
//connect denorm.affordance -> kfm.affordanceIn;
//connect kfm.affordanceSmoothed -> driverController.affordanceIn;
connect denorm.affordance -> driverController.affordanceIn;
connect steeringBuffer.outputBuffer -> driverController.steeringRecordIn;
connect speedIn -> driverController.speedIn;
......
package dp.subcomponents;
import changeRange;
component Denormalizer {
ports in Q^{14} normalizedPredictions,
out Affordance affordance;
implementation Math {
function changeRange(oldMin, oldMax, newMin, newMax, oldValue){
(((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin
}
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));
}
}
......@@ -2,7 +2,7 @@
package dp.subcomponents;
component Dpnet{
ports in Q(0:255)^{3, 210, 280} data,
ports in Z(0:255)^{3, 210, 280} data,
out Q(-oo:oo)^{14} predictions;
implementation CNN {
......
package dp.subcomponents;
component Unnormalizer {
ports in Q^{14} normalizedPredictions,
out Affordance affordance;
implementation Math {
Q oldMin = 0.1;
Q oldMax = 0.9;
Q oldRange = oldMax - oldMin;
Q newMin = -0.5;
Q newMax = 0.5;
Q newRange = newMax - newMin;
affordance.angle = (((normalizedPredictions(0) - oldMin) * newRange) / oldRange) + newMin;
newMin = -7;
newMax = -2.5;
newRange = newMax - newMin;
affordance.toMarkingL = (((normalizedPredictions(1) - oldMin) * newRange) / oldRange) + newMin;
newMin = -2;
newMax = 3.5;
newRange = newMax - newMin;
affordance.toMarkingM = (((normalizedPredictions(2) - oldMin) * newRange) / oldRange) + newMin;
newMin = 2.5;
newMax = 7;
newRange = newMax - newMin;
affordance.toMarkingR = (((normalizedPredictions(3) - oldMin) * newRange) / oldRange) + newMin;
newMin = 0;
newMax = 75;
newRange = newMax - newMin;
affordance.distL = (((normalizedPredictions(4) - oldMin) * newRange) / oldRange) + newMin;
affordance.distR = (((normalizedPredictions(5) - oldMin) * newRange) / oldRange) + newMin;
newMin = -9.5;
newMax = -4;
newRange = newMax - newMin;
affordance.toMarkingLL = (((normalizedPredictions(6) - oldMin) * newRange) / oldRange) + newMin;
newMin = -5.5;
newMax = -0.5;
newRange = newMax - newMin;
affordance.toMarkingML = (((normalizedPredictions(7) - oldMin) * newRange) / oldRange) + newMin;
newMin = 0.5;
newMax = 5.5;
newRange = newMax - newMin;
affordance.toMarkingMR = (((normalizedPredictions(8) - oldMin) * newRange) / oldRange) + newMin;
newMin = 4;
newMax = 9.5;
newRange = newMax - newMin;
affordance.toMarkingRR = (((normalizedPredictions(9) - oldMin) * newRange) / oldRange) + newMin;
newMin = 0;
newMax = 75;
newRange = newMax - newMin;
affordance.distLL = (((normalizedPredictions(10) - oldMin) * newRange) / oldRange) + newMin;
affordance.distMM = (((normalizedPredictions(11) - oldMin) * newRange) / oldRange) + newMin;
affordance.distRR = (((normalizedPredictions(12) - oldMin) * newRange) / oldRange) + newMin;
newMin = 0;
newMax = 1;
newRange = newMax - newMin;
affordance.fast = (((normalizedPredictions(13) - oldMin) * newRange) / oldRange) + newMin;
}
}
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