Commit bd4cf7b0 authored by Svetlana Pavlitskaya's avatar Svetlana Pavlitskaya
Browse files

minor changes in TorcsEMAMGenerator

parent ce6b2506
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
1. Run Generator in src/main/java 1. Run Generator in src/main/java
2. Start TORCS, choose 'Quick Race', go to 'Configure', select some map and choose 'chenyi' as the only driver. Start race. 2. Start TORCS, choose 'Quick Race', go to 'Configure', select some map and choose 'chenyi' as the only driver. Start race.
3. Change to target/generated-sources-torcs-dl directory and run `build_all.sh` to compile generated code * To set specific screen resolution go to torcs config folder (e.g. ./torcs/config) and edit screen.xml. Our toolchain uses 280x210.
4. Change to target/generated-sources-torcs-dl directory and run `run_all.sh` to start ROS and all the ROS nodes including TORCS connectors. This will open a separate console for each ROS node. 3. Go to target/generated-sources-torcs-dl and run `build_all.sh` to compile generated code
4. Go to target/generated-sources-torcs-dl and run `run_all.sh` to start ROS and ROS node including TORCS connectors. This will open a separate console for each ROS node
and another console for ROS core. and another console for ROS core.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:common-monticar:0.0.11-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc:0.0.11c-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.7.1" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:Tagging:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:struct:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:enum:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-logging:1.7.7" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-utilities:1.7.7" level="project" />
<orderEntry type="library" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.10" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-runtime:4.5.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.9" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.18.2-GA" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr4:4.5.1" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-grammar:4.5.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-emf-runtime:4.5.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare.match:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.emf:org.eclipse.emf.compare.diff:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf:ecore:2.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:runtime:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse:osgi:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:common:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:jobs:3.4.100" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:registry:3.4.100" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:preferences:3.2.300" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.core:contenttype:3.4.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.equinox:app:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf.ecore:xmi:2.5.0" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.eclipse.emf:common:2.5.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.0" level="project" />
<orderEntry type="library" name="Maven: de.se_rwth.commons:se-commons-groovy:1.7.7" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.3.7" level="project" />
<orderEntry type="library" name="Maven: jline:jline:2.12" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:NumberUnit:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:common-monticar:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" />
<orderEntry type="library" name="Maven: org.jscience:jscience:4.3.1" level="project" />
<orderEntry type="library" name="Maven: org.javolution:javolution:5.2.3" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-math-generator:0.0.6-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-math:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:math:0.0.10-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: it.unibo.alice.tuprolog:tuprolog:3.2.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.6.2" level="project" />
<orderEntry type="library" name="Maven: montiarc.verification:montiarc-execution-order:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:tagging:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:tagging:grammars:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:montiarc-fe:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:cd4analysis:1.3.9" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:montiarc-fe:grammars:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:common:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore:javaDSL:grammars:4.3.8" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang:SIUnit:0.0.3-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: montiarc.languages:common:grammars:4.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore:javaDSL:4.3.8" level="project" />
<orderEntry type="library" name="Maven: de.monticore:monticore-grammar:grammars:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.23" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-math-roscpp-generator:0.0.1c-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-math-rosmsg-generator:0.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware.yamlbeans:yamlbeans:1.12" level="project" />
<orderEntry type="library" name="Maven: de.moticore.lang.monticar:embedded-montiarc-math-middleware-generator:0.0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.jgrapht:jgrapht-core:1.1.0" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-deeplearning:0.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:cnn-arch:0.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:cnn-train:0.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: de.monticore.lang.monticar:embedded-montiarc-behaviour:0.0.11-SNAPSHOT" level="project" />
</component>
</module>
\ No newline at end of file
...@@ -3,19 +3,9 @@ package de.monticore.lang.monticar.torcs_dl; ...@@ -3,19 +3,9 @@ package de.monticore.lang.monticar.torcs_dl;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.RosToEmamTagSchema; import de.monticore.lang.embeddedmontiarc.tagging.RosToEmamTagSchema;
import de.monticore.lang.monticar.generator.middleware.MiddlewareGenerator; import de.monticore.lang.monticar.generator.middleware.MiddlewareGenerator;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl; import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl;
import de.monticore.lang.monticar.generator.order.nfp.TagBreakpointsTagSchema.TagBreakpointsTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagDelayTagSchema.TagDelayTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagExecutionOrderTagSchema.TagExecutionOrderTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagInitTagSchema.TagInitTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagMinMaxTagSchema.TagMinMaxTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagTableTagSchema.TagTableTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagThresholdTagSchema.TagThresholdTagSchema;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper; import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver; import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
...@@ -23,7 +13,6 @@ import java.io.IOException; ...@@ -23,7 +13,6 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.Arrays;
public class Generator { public class Generator {
...@@ -34,85 +23,42 @@ public class Generator { ...@@ -34,85 +23,42 @@ public class Generator {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Starting code generation..."); System.out.println("Starting code generation...");
// generateForEmamComponent("Imagepreprocessing"); TaggingResolver taggingResolver = de.monticore.lang.monticar.emadl.generator.AbstractSymtab.createSymTabAndTaggingResolver(MODELS_PATH);
// generateForEmamComponent("Safetycontroller");
// generateForEmamComponent("Drivercontroller");
//// generateForEmamComponent("Featureextraction");
// generateForEmadlComponent("Featureextraction");
generateForEmadlComponent("Mastercomponent");
try {
Files.copy(Paths.get(RESOURCES_PATH+"scripts/build_all.sh"), Paths.get(TARGET_PATH_GENERATED+"build_all.sh"), StandardCopyOption.REPLACE_EXISTING);
Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"build_all.sh");
Files.copy(Paths.get(RESOURCES_PATH+"scripts/run_all.sh"), Paths.get(TARGET_PATH_GENERATED+"run_all.sh"), StandardCopyOption.REPLACE_EXISTING);
Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"run_all.sh");
FileUtils.copyDirectory(new File(RESOURCES_PATH+"torcs"), new File(TARGET_PATH_GENERATED+"torcs"));
Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"torcs/build.sh");
Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"torcs/run_all.sh");
FileUtils.copyDirectory(new File(RESOURCES_PATH+"dpnet"), new File(TARGET_PATH_GENERATED+"model/dpnet"));
} catch (IOException e) {
System.err.println("Failed to copy build and start scripts.");
e.printStackTrace();
}
}
private static void generateForEmamComponent(String componentName) {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver( MODELS_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver); RosToEmamTagSchema.registerTagTypes(taggingResolver);
try { try {
System.out.println("Generating for " + componentName); System.out.println("Code generation for Mastercomponent");
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("dp."+componentName.toLowerCase(), ExpandedComponentInstanceSymbol.KIND).orElse(null); ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("dp."+ "Mastercomponent".toLowerCase(), ExpandedComponentInstanceSymbol.KIND).orElse(null);
assert componentInstanceSymbol != null;
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol); TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
MiddlewareGenerator middlewareGenerator = new MiddlewareGenerator(); MiddlewareGenerator middlewareGenerator = new MiddlewareGenerator();
middlewareGenerator.add(new CPPGenImpl(), "cpp"); middlewareGenerator.add(new EMADLGeneratorImpl(MODELS_PATH), "cpp");
middlewareGenerator.add(new RosCppGenImpl(), "roscpp"); middlewareGenerator.add(new RosCppGenImpl(), "roscpp");
middlewareGenerator.setGenerationTargetPath(TARGET_PATH_GENERATED +componentName); middlewareGenerator.setGenerationTargetPath(TARGET_PATH_GENERATED + "Mastercomponent");
middlewareGenerator.generate(componentInstanceSymbol, taggingResolver); middlewareGenerator.generate(componentInstanceSymbol, taggingResolver);
} catch (IOException e) { } catch (IOException e1) {
System.err.println("Failed to generate sources. Sorry."); System.err.println("Failed to generate sources. Sorry.");
e.printStackTrace(); e1.printStackTrace();
} }
}
private static void generateForEmadlComponent(String componentName) {
TaggingResolver taggingResolver = de.monticore.lang.monticar.emadl.generator.AbstractSymtab.createSymTabAndTaggingResolver(MODELS_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
try { try {
System.out.println("Generating for " + componentName); Files.copy(Paths.get(RESOURCES_PATH+"scripts/build_all.sh"), Paths.get(TARGET_PATH_GENERATED+"build_all.sh"), StandardCopyOption.REPLACE_EXISTING);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("dp."+componentName.toLowerCase(), ExpandedComponentInstanceSymbol.KIND).orElse(null); Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"build_all.sh");
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol); Files.copy(Paths.get(RESOURCES_PATH+"scripts/run_all.sh"), Paths.get(TARGET_PATH_GENERATED+"run_all.sh"), StandardCopyOption.REPLACE_EXISTING);
Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"run_all.sh");
MiddlewareGenerator middlewareGenerator = new MiddlewareGenerator(); FileUtils.copyDirectory(new File(RESOURCES_PATH+"torcs"), new File(TARGET_PATH_GENERATED+"torcs"));
middlewareGenerator.add(new EMADLGeneratorImpl(MODELS_PATH), "cpp"); Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"torcs/build.sh");
middlewareGenerator.add(new RosCppGenImpl(), "roscpp"); Runtime.getRuntime().exec("chmod u+x "+TARGET_PATH_GENERATED+"torcs/run_all.sh");
middlewareGenerator.setGenerationTargetPath(TARGET_PATH_GENERATED +componentName);
middlewareGenerator.generate(componentInstanceSymbol, taggingResolver); FileUtils.copyDirectory(new File(RESOURCES_PATH+"dpnet"), new File(TARGET_PATH_GENERATED+"model/dpnet"));
} catch (IOException e) { } catch (IOException e) {
System.err.println("Failed to generate sources. Sorry."); System.err.println("Failed to copy build and start scripts.");
e.printStackTrace(); e.printStackTrace();
} }
} }
public static TaggingResolver createSymTabAndTaggingResolver( String... modelPath) {
Scope scope = AbstractSymtab.createSymTab(modelPath);
TaggingResolver tagging = new TaggingResolver(scope, Arrays.asList(modelPath));
TagMinMaxTagSchema.registerTagTypes(tagging);
TagTableTagSchema.registerTagTypes(tagging);
TagBreakpointsTagSchema.registerTagTypes(tagging);
TagExecutionOrderTagSchema.registerTagTypes(tagging);
TagInitTagSchema.registerTagTypes(tagging);
TagThresholdTagSchema.registerTagTypes(tagging);
TagDelayTagSchema.registerTagTypes(tagging);
return tagging;
}
} }
...@@ -2,7 +2,7 @@ package dp.subcomponents; ...@@ -2,7 +2,7 @@ package dp.subcomponents;
component Imagepreprocessing { component Imagepreprocessing {
ports ports
in Z(0:255)^{3, 240, 320} imageIn, in Z(0:255)^{3, 210, 280} imageIn,
out Z(0:255)^{3, 210, 280} imageOut; out Z(0:255)^{3, 210, 280} imageOut;
implementation Math { implementation Math {
......
%!/bin/bash %!/bin/bash
echo "Building DriverController" echo "Building Mastercomponent"
cd Drivercontroller cd Mastercomponent
mkdir -p build
cd build
cmake ..
make -j
cd ../..
echo "Building SafetyController"
cd Safetycontroller
mkdir -p build
cd build
cmake ..
make -j
cd ../..
echo "Building FeatureExtraction"
cd Featureextraction
mkdir -p build
cd build
cmake ..
make -j
cd ../..
echo "Building ImagePreprocessing"
cd Imagepreprocessing
mkdir -p build mkdir -p build
cd build cd build
cmake .. cmake ..
...@@ -39,5 +15,3 @@ cd torcs ...@@ -39,5 +15,3 @@ cd torcs
echo echo
echo "Well done!" echo "Well done!"
echo "Run ./run_all.sh to run all." echo "Run ./run_all.sh to run all."
...@@ -9,11 +9,4 @@ xterm -T TORCSDriver -e torcs/src/driver/build/driver & ...@@ -9,11 +9,4 @@ xterm -T TORCSDriver -e torcs/src/driver/build/driver &
xterm -T TORCSCamera -e torcs/src/camera/build/camera & xterm -T TORCSCamera -e torcs/src/camera/build/camera &
xterm -T DriverController -e Drivercontroller/build/coordinator/Coordinator_dp_drivercontroller & xterm -T Mastercomponent -e Mastercomponent/build/coordinator/Coordinator_dp_mastercomponent &
\ No newline at end of file
xterm -T SafetyController -e Safetycontroller/build/coordinator/Coordinator_dp_safetycontroller &
xterm -T FeatureExtraction -e Featureextraction/build/coordinator/Coordinator_dp_featureextraction &
xterm -T ImagePreprocessing -e Imagepreprocessing/build/coordinator/Coordinator_dp_imagepreprocessing &
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