Commit 857ce5a5 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Adjust tests for ros2

parent 4ab43912
......@@ -9,6 +9,7 @@ import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.EmbeddedMontiArcMathLanguage;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.Utils;
import de.monticore.lang.monticar.enumlang._symboltable.EnumLangLanguage;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsLanguage;
......@@ -39,7 +40,9 @@ public class AbstractSymtabTest {
public static TaggingResolver createSymTabAndTaggingResolver(String... modelPath) {
Scope scope = createSymTab(modelPath);
return new TaggingResolver(scope, Arrays.asList(modelPath));
TaggingResolver taggingResolver = new TaggingResolver(scope, Arrays.asList(modelPath));
RosToEmamTagSchema.registerTagTypes(taggingResolver);
return taggingResolver;
}
public static Scope createSymTab(String... modelPath) {
......
......@@ -53,5 +53,54 @@ public class Ros2Test extends AbstractSymtabTest{
assertTrue(fileNames.contains("CMakeLists.txt"));
}
@Test
public void testBasicStructCompGeneration() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.structs.basicStructComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
GeneratorRosCpp generatorRosCpp = new GeneratorRosCpp();
generatorRosCpp.setGenerationTargetPath("./target/generated-sources-rclcpp/basicStructComp/");
generatorRosCpp.setGenerateCMake(true);
generatorRosCpp.setRos2Mode(true);
List<File> files = generatorRosCpp.generateFiles(componentInstanceSymbol, taggingResolver);
List<String> fileNames = files.stream()
.map(File::getName)
.collect(Collectors.toList());
assertTrue(fileNames.contains("CMakeLists.txt"));
assertTrue(fileNames.contains("generateMsgs.py"));
assertTrue(fileNames.contains("rclcpp_msg_gen.json"));
assertTrue(fileNames.contains("TestsStructsPosition.msg"));
}
@Test
public void testNestedStructCompGeneration() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.structs.nestedStructComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
GeneratorRosCpp generatorRosCpp = new GeneratorRosCpp();
generatorRosCpp.setGenerationTargetPath("./target/generated-sources-rclcpp/nestedStructComp/");
generatorRosCpp.setGenerateCMake(true);
generatorRosCpp.setRos2Mode(true);
List<File> files = generatorRosCpp.generateFiles(componentInstanceSymbol, taggingResolver);
List<String> fileNames = files.stream()
.map(File::getName)
.collect(Collectors.toList());
assertTrue(fileNames.contains("CMakeLists.txt"));
assertTrue(fileNames.contains("generateMsgs.py"));
assertTrue(fileNames.contains("rclcpp_msg_gen.json"));
assertTrue(fileNames.contains("TestsStructsPosition.msg"));
assertTrue(fileNames.contains("TestsStructsPositionWithDeltaTime.msg"));
}
}
cmake_minimum_required(VERSION 3.5)
project (RosAdapter_tests_msg_basicStructComp)
set (CMAKE_CXX_STANDARD 14)
set (AMENT_CMAKE_UNINSTALL_TARGET FALSE)
find_package(roscpp REQUIRED)
add_library(RosAdapter_tests_msg_basicStructComp RosAdapter_tests_msg_basicStructComp.cpp)
set_target_properties(RosAdapter_tests_msg_basicStructComp PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(RosAdapter_tests_msg_basicStructComp tests_msg_basicStructComp IAdapter_tests_msg_basicStructComp ${roscpp_LIBRARIES} ${struct_msgs_LIBRARIES})
target_include_directories(RosAdapter_tests_msg_basicStructComp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${roscpp_INCLUDE_DIRS} ${struct_msgs_INCLUDE_DIRS})
add_dependencies(RosAdapter_tests_msg_basicStructComp struct_msgs_generate_messages)
export(TARGETS RosAdapter_tests_msg_basicStructComp FILE RosAdapter_tests_msg_basicStructComp.cmake)
\ No newline at end of file
target_link_libraries(RosAdapter_tests_msg_basicStructComp tests_msg_basicStructComp IAdapter_tests_msg_basicStructComp ${roscpp_LIBRARIES})
target_include_directories(RosAdapter_tests_msg_basicStructComp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${roscpp_INCLUDE_DIRS})
export(TARGETS RosAdapter_tests_msg_basicStructComp FILE RosAdapter_tests_msg_basicStructComp.cmake)
# Generate .h files from .msg files
add_custom_target(gen_RosAdapter_tests_msg_basicStructComp_struct_msgs_tests_structs_BasicStruct ALL
COMMAND python /opt/ros/kinetic/lib/gencpp/gen_cpp.py ${CMAKE_CURRENT_SOURCE_DIR}/struct_msgs/tests_structs_BasicStruct.msg -Istruct_msgs:${CMAKE_CURRENT_SOURCE_DIR}/struct_msgs -p struct_msgs -o ${CMAKE_CURRENT_SOURCE_DIR}/struct_msgs -e /opt/ros/kinetic/share/gencpp/)
add_dependencies(RosAdapter_tests_msg_basicStructComp gen_RosAdapter_tests_msg_basicStructComp_struct_msgs_tests_structs_BasicStruct)
\ No newline at end of file
cmake_minimum_required(VERSION 3.5)
project (RosAdapter_tests_a_compA)
set (CMAKE_CXX_STANDARD 14)
set (AMENT_CMAKE_UNINSTALL_TARGET FALSE)
find_package(automated_driving_msgs REQUIRED)
find_package(roscpp REQUIRED)
......
cmake_minimum_required(VERSION 3.5)
project (RosAdapter_tests_a_compB)
set (CMAKE_CXX_STANDARD 14)
set (AMENT_CMAKE_UNINSTALL_TARGET FALSE)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
......
cmake_minimum_required(VERSION 3.5)
project (RosAdapter_test_instanceArrayComp_basicPorts_1_)
set (CMAKE_CXX_STANDARD 14)
set (AMENT_CMAKE_UNINSTALL_TARGET FALSE)
find_package(roscpp REQUIRED)
......
package test;
component BasicPorts{
ports in (-oo:oo) in1,in (-oo:oo) in2,
out (-oo:oo) out1,out (-oo:oo) out2;
ports in Q in1,in Q in2,
out Q out1,out Q out2;
connect in1 -> out2;
......
......@@ -2,7 +2,7 @@ package tests.structs;
conforms to de.monticore.lang.monticar.generator.roscpp.RosToEmamTagSchema;
tags Structs{
tag basicStructComp.posIn with RosConnection = {topic = (name1,package/type1), msgField = field1};
tag nestedStructComp.posWithDtIn with RosConnection = {topic = (name2,package/type2), msgField = field2};
tag arrayStructComp.trajectoryIn with RosConnection = {topic = (name3,package/type3), msgField = field3};
tag basicStructComp.posIn with RosConnection = {topic = (name1, struct_msgs/TestsStructsPosition)};
tag nestedStructComp.posWithDtIn with RosConnection = {topic = (name2, struct_msgs/msg/TestsStructsPositionWithDeltaTime)};
tag arrayStructComp.trajectoryIn with RosConnection = {topic = (name3, package/type3)};
}
\ No newline at end of file
Supports Markdown
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