Commit 94026348 authored by Svetlana's avatar Svetlana

Working ROS code generation

parent 9651ec32
File added
<component name="libraryTable">
<library name="Maven: de.monticore.lang:NumberUnit:0.0.10-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180211.010901-1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180310.011750-1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180211.010901-1-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180310.011750-1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180211.010901-1-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/NumberUnit/0.0.10-SNAPSHOT/NumberUnit-0.0.10-20180310.011750-1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: de.monticore.lang.monticar:common-monticar:0.0.10-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180210.010444-1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180214.010746-1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180210.010444-1-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180214.010746-1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180210.010444-1-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/de/monticore/lang/monticar/common-monticar/0.0.10-SNAPSHOT/common-monticar-0.0.10-20180214.010746-1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -76,5 +76,11 @@
<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.moticore.lang.monticar:embedded-montiarc-math-roscpp-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-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" />
</component>
</module>
\ No newline at end of file
......@@ -26,6 +26,16 @@
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>0.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.moticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-roscpp-generator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.moticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
- !de.monticar.lang.monticar.generator.python.RosTag
component: sp.add
subscriber:
- !de.monticar.lang.monticar.generator.python.RosInterface
ports:
a: clock.toSec()
b: clock.toSec()
topic: /clock
type: rosgraph_msgs/Clock
publisher:
- !de.monticar.lang.monticar.generator.python.RosInterface
ports:
c: data
topic: /echo
type: automated_driving_msgs/StampedFloat64
\ No newline at end of file
package sp;
component Add {
ports
in (0 m : 10 m) a,
in (0 m : 10 m) b,
out (0 m : 20 m) c;
implementation Math {
c = a + b;
}
}
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.symboltable.Scope;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab.createSymTab;
public class Experiments {
public static void main(String[] args) {
System.out.println("Experiments!");
Scope symtab = createSymTab("src/test/resources");
ExpandedComponentInstanceSymbol componentSymbol =
symtab.<ExpandedComponentInstanceSymbol>resolve(
"test.basicPortsLoop",
ExpandedComponentInstanceSymbol.KIND).orElse(null);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./output/cpp");
try {
List<File> files = generatorCPP.generateFiles(null, componentSymbol, symtab);
} catch (IOException e) {
e.printStackTrace();
}
}
}
package de.monticore.lang.monticar.generator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
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.DummyMiddlewareGenImpl;
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.roscpp.GeneratorRosCpp;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.YamlHelper;
import de.monticore.lang.monticar.generator.roscpp.tagging.RosToEmamTagSchema;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab.createSymTab;
public class Experiments {
public static void main(String[] args) {
System.out.println("Experiments!");
Scope scope = createSymTab("resources");
TaggingResolver symtab = new TaggingResolver(scope, Collections.singletonList("resources"));
TagMinMaxTagSchema.registerTagTypes(symtab);
TagTableTagSchema.registerTagTypes(symtab);
TagBreakpointsTagSchema.registerTagTypes(symtab);
TagExecutionOrderTagSchema.registerTagTypes(symtab);
TagInitTagSchema.registerTagTypes(symtab);
TagThresholdTagSchema.registerTagTypes(symtab);
TagDelayTagSchema.registerTagTypes(symtab);
RosToEmamTagSchema.registerTagTypes(symtab);
ExpandedComponentInstanceSymbol componentInstanceSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("sp.add", ExpandedComponentInstanceSymbol.KIND).orElse(null);
GeneratorRosCpp generatorRosCpp = new GeneratorRosCpp();
generatorRosCpp.setGenerationTargetPath("generated/");
try {
List<File> files = YamlHelper.generateFromFile("resources/config/add.yaml", symtab, generatorRosCpp);
} catch (IOException e) {
e.printStackTrace();
}
}
}
package a;
component Sub2 implements SuperComp{
port in (-oo:oo) in1,
out B out1;
}
package a;
component SuperComp{
port in (1:1:100) percentage;
}
\ No newline at end of file
package ba;
component Delay(Q(-oo:oo) value) {
port
in Q(-oo:oo) in1,
out Q(-oo:oo) out1;
implementation Math{
static Q lastVal = value;
out1 = lastVal;
lastVal = in1;
}
}
package ba;
component LookUp(Q(-oo:oo)^{1,n} lookupTable) {
ports
in N1 in1,
out (0:100) out1;
implementation Math{
out1 = lookupTable(in1);
}
}
package detection;
component EigenSolver<N1 n = 1,N1 targetEigenvectors = 1>{
ports in Q(-oo:oo)^{n,n} matrix,
out Q(-oo:oo)^{n,targetEigenvectors} eigenvectors;
implementation Math{
//calculate requested amount of eigenvectors if present
Q^{n,n} eigenVectors = eigvec(matrix);
Q counter = 1;
Q start = size(eigenVectors,2) - ( targetEigenvectors - 1 );
for i= start : size(eigenVectors,1)
eigenvectors(:,counter) = eigenVectors(:,i);
counter = counter + 1;
end
}
}
\ No newline at end of file
package detection;
component KMeansClustering<N1 n=1, N1 amountVectors=1, N1 maximumClusters=1>{
ports in Q(-oo:oo)^{n, amountVectors} vectors,
out Q(-oo:oo)^{n, 1} clusters;
implementation Math{
// construct the normalized matrix U from the obtained eigen vectors
Q^{n,amountVectors} UMatrix;
for i=1:size(vectors,1)
Q^{1,amountVectors} target= vectors(i,:) .^ 2;
Q amount = sqrt(sum(target));
UMatrix(i,:) = vectors(i,:) ./ amount;
end
clusters = kmeans(UMatrix, maximumClusters);
}
}
\ No newline at end of file
package detection;
component NormalizedLaplacian<N1 n = 1>{
ports in diag Q(-oo:oo)^{n,n} degree,
in Q(-oo:oo)^{n,n} W,
out Q(-oo:oo)^{n,n} nLaplacian;
implementation Math{
/*for i=1:size(degree,1)
for j=1:size(degree,2)
nLaplacian(i,j) = W(i,j) / (sqrt(degree(i,i)) * sqrt(degree(j,j)));
end
end*/
/*currently not working, this short notation will be automatically converted
* later on as it is equivalent to the expression below
*/
//nLaplacian = degree^(-0.5) * W * degree^(-0.5);
nLaplacian = sqrtm(inv(degree)) * W * sqrtm(inv(degree));
}
}
\ No newline at end of file
package detection;
component NormalizedLaplacianInstance{
ports in Q(-oo:oo)^{2500,2500} degree,
in Q(-oo:oo)^{2500,2500} W,
out Q(-oo:oo)^{2500,2500} nLaplacian;
instance NormalizedLaplacian<2500> normLaplaInst;
connect degree -> normLaplaInst.degree;
connect W -> normLaplaInst.W;
connect normLaplaInst.nLaplacian -> nLaplacian;
}
\ No newline at end of file