Commit b046691a authored by Svetlana's avatar Svetlana
Browse files

Application using jar of EMAM2Middleware (zero java code in application)

parent 65a5dcc4
#!/bin/bash
echo "Cleaning target directory..."
rm -rf target/*
echo "Generating code..."
java -cp embedded-montiarc-math-middleware-generator-0.0.9-SNAPSHOT-jar-with-dependencies.jar de.monticore.lang.monticar.generator.middleware.DistributedTargetGeneratorCli --models-dir=src/main/ --root-model=dp.mastercomponent --output-dir=target/Mastercomponent --generators=emadlcpp,roscpp --backend=MXNET
echo "Copying build and run scripts..."
cp -rf resources/scripts/* target/
chmod u+x target/*.sh
echo "Copying CNN weights..."
cp -rf resources/torcs target/torcs
chmod u+x resources/torcs/*.sh
cp -rf resources/dpnet target/model
echo "Building generated code..."
cd target
./build_all.sh
echo "Please start TORCS, configure race and run ./run_all.sh"
......@@ -4,7 +4,7 @@
#include <ml.h>
#include <highgui.h>
#include <cv.h>
#include <cv.hpp>
#include <ros/ros.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float32MultiArray.h>
......
......@@ -13,50 +13,50 @@ component Denormalizer {
Q newMinAngle = -0.5;
Q newRangeAngle = 0.5 - newMinAngle;
affordance.angle = (((normalizedPredictions(0) - oldMin) * newRangeAngle) / oldRange) + newMinAngle;
affordance.angle = (((normalizedPredictions(1) - oldMin) * newRangeAngle) / oldRange) + newMinAngle;
Q newMinMarkingL = -7;
Q newRangeMarkingL = -2.5 - newMinMarkingL;
affordance.toMarkingL = (((normalizedPredictions(1) - oldMin) * newRangeMarkingL) / oldRange) + newMinMarkingL;
affordance.toMarkingL = (((normalizedPredictions(2) - oldMin) * newRangeMarkingL) / oldRange) + newMinMarkingL;
Q newMinMarkingM = -2;
Q newRangeMarkingM = 3.5 - newMinMarkingM;
affordance.toMarkingM = (((normalizedPredictions(2) - oldMin) * newRangeMarkingM) / oldRange) + newMinMarkingM;
affordance.toMarkingM = (((normalizedPredictions(3) - oldMin) * newRangeMarkingM) / oldRange) + newMinMarkingM;
Q newMinMarkingR = 2.5;
Q newRangeMarkingR = newMinMarkingR - 7;
affordance.toMarkingR = (((normalizedPredictions(3) - oldMin) * newRangeMarkingR) / oldRange) + newMinMarkingR;
affordance.toMarkingR = (((normalizedPredictions(4) - 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;
affordance.distL = (((normalizedPredictions(5) - oldMin) * newRangeDist) / oldRange) + newMinDist;
affordance.distR = (((normalizedPredictions(6) - oldMin) * newRangeDist) / oldRange) + newMinDist;
Q newMinMarkingLL = -9.5;
Q newRangeMarkingLL = -4 - newMinMarkingLL;
affordance.toMarkingLL = (((normalizedPredictions(6) - oldMin) * newRangeMarkingLL) / oldRange) + newMinMarkingLL;
affordance.toMarkingLL = (((normalizedPredictions(7) - oldMin) * newRangeMarkingLL) / oldRange) + newMinMarkingLL;
Q newMinMarkingML = -5.5;
Q newRangeMarkingML = -0.5 - newMinMarkingML;
affordance.toMarkingML = (((normalizedPredictions(7) - oldMin) * newRangeMarkingML) / oldRange) + newMinMarkingML;
affordance.toMarkingML = (((normalizedPredictions(8) - oldMin) * newRangeMarkingML) / oldRange) + newMinMarkingML;
Q newMinMarkingMR = 0.5;
Q newRangeMarkingMR = 5.5 - newMinMarkingMR;
affordance.toMarkingMR = (((normalizedPredictions(8) - oldMin) * newRangeMarkingMR) / oldRange) + newMinMarkingMR;
affordance.toMarkingMR = (((normalizedPredictions(9) - oldMin) * newRangeMarkingMR) / oldRange) + newMinMarkingMR;
Q newMinMarkingRR = 4;
Q newRangeMarkingRR = 9.5 - newMinMarkingRR;
affordance.toMarkingRR = (((normalizedPredictions(9) - oldMin) * newRangeMarkingRR) / oldRange) + newMinMarkingRR;
affordance.toMarkingRR = (((normalizedPredictions(10) - 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;
affordance.distLL = (((normalizedPredictions(11) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
affordance.distMM = (((normalizedPredictions(12) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
affordance.distRR = (((normalizedPredictions(13) - oldMin) * newRangeDistLMR) / oldRange) + newMinDistLMR;
Q newMinFast = 0;
Q newRangeFast = 1 - newMinFast;
affordance.fast = (((normalizedPredictions(13) - oldMin) * newRangeFast) / oldRange) + newMinFast;
affordance.fast = (((normalizedPredictions(14) - oldMin) * newRangeFast) / oldRange) + newMinFast;
}
}
configuration Dpnet{
num_epoch : 100
batch_size : 64
context:cpu
normalize:true
eval_metric : mse
context : gpu
load_checkpoint : true
normalize : true
optimizer : sgd{
learning_rate : 0.01
learning_rate_decay : 0.9
......
......@@ -57,7 +57,7 @@ component DriverController {
desiredSpeed = 20; // 20m/s = 72 kmh
if (affordanceIn.fast != 1)
desiredSpeed = 20 - abs(steeringRecordIn(0) + steeringRecordIn(1) + steeringRecordIn(2) + steeringRecordIn(3) + steeringRecordIn(4)) * 4.5;
desiredSpeed = 20 - abs(steeringRecordIn(1) + steeringRecordIn(2) + steeringRecordIn(3) + steeringRecordIn(4) + steeringRecordIn(5)) * 4.5;
end
if (desiredSpeed < 10)
......@@ -88,4 +88,4 @@ component DriverController {
commandsOut(1) = 0; // accelCmd
end
}
}
\ No newline at end of file
}
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