Commit ed2a85fe authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Moved Adapter to ftl

parent 15d18b8e
Pipeline #116610 failed with stages
in 2 minutes and 50 seconds
package de.monticore.lang.monticar.generator.roscpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import java.util.Collections;
import java.util.Set;
public class DirectMsgConverter {
private String msgField;
private boolean isMsgToPort;
public DirectMsgConverter(String msgField, boolean isMsgToPort) {
this.isMsgToPort = isMsgToPort;
this.msgField = msgField;
}
public boolean isMsgToPort() {
return isMsgToPort;
}
public String getConversion(EMAPortSymbol portSymbol) {
return !isMsgToPort ? "." + msgField + " = component->" + NameHelper.getPortNameTargetLanguage(portSymbol) : "msg->" + msgField;
}
public boolean isPortToMsg() {
return !isMsgToPort();
}
public Set<String> getAdditionalIncludes() {
return Collections.emptySet();
}
}
package de.monticore.lang.monticar.generator.roscpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.FormatHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.PrinterHelper;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.*;
import de.monticore.lang.monticar.generator.roscpp.template.RosAdapterModel;
import de.monticore.lang.monticar.generator.roscpp.template.RosCppCMakeListsModel;
import de.monticore.lang.monticar.generator.roscpp.template.RosCppTemplates;
import de.monticore.lang.monticar.generator.roscpp.util.RosInterface;
import de.monticore.lang.monticar.generator.roscpp.util.RosPublisher;
import de.monticore.lang.monticar.generator.roscpp.util.RosSubscriber;
import de.monticore.lang.monticar.generator.rosmsg.util.FileContent;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
......@@ -12,6 +18,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class GeneratorRosCpp {
......@@ -61,19 +68,68 @@ public class GeneratorRosCpp {
private List<FileContent> generateRosAdapter(EMAComponentInstanceSymbol component) {
List<FileContent> res = new ArrayList<>();
FileContent adapter = new FileContent();
LanguageUnitRosCppAdapter languageUnitRosCppAdapter = new LanguageUnitRosCppAdapter(this.isRos2Mode());
Optional<AdapterBluePrint> bluePrintOpt = languageUnitRosCppAdapter.generateBluePrint(component);
if (TagHelper.rosConnectionsValid(component)) {
List<EMAPortSymbol> rosPorts = component.getPortInstanceList().stream()
.filter(EMAPortSymbol::isRosPort)
.collect(Collectors.toList());
List<RosSubscriber> rosSubscribers = rosPorts.stream()
.filter(EMAPortSymbol::isIncoming)
.map(RosSubscriber::new)
.collect(Collectors.toList());
List<RosPublisher> rosPublishers = rosPorts.stream()
.filter(EMAPortSymbol::isOutgoing)
.map(RosPublisher::new)
.collect(Collectors.toList());
List<RosInterface> rosInterfaces = new ArrayList<>();
rosInterfaces.addAll(rosSubscribers);
rosInterfaces.addAll(rosPublishers);
if (bluePrintOpt.isPresent()) {
bluePrintOpt.get().getAdapterFileContent(component, adapter);
if (generateCMake) {
res.addAll(LanguageUnitRosCMake.generateFiles(component, languageUnitRosCppAdapter.getRosInterfaces(), isRos2Mode()));
res.addAll(generateCMakeFiles(component, rosInterfaces, isRos2Mode()));
}
res.add(adapter);
RosAdapterModel model = new RosAdapterModel(ros2Mode, NameHelper.getComponentNameTargetLanguage(component.getFullName()));
model.addPublishers(rosPublishers);
model.addSubscribers(rosSubscribers);
model.addGenerics(GenericsHelper.getGenericsDefinition(component));
if(ros2Mode) {
rosSubscribers.forEach(s -> model.addInclude(s.getRos2Include()));
rosPublishers.forEach(s -> model.addInclude(s.getRos2Include()));
}else{
rosSubscribers.forEach(s -> model.addInclude(s.getRosInclude()));
rosPublishers.forEach(s -> model.addInclude(s.getRosInclude()));
}
String s = RosCppTemplates.generateRosAdapter(model);
res.add(new FileContent("RosAdapter_" + NameHelper.getComponentNameTargetLanguage(component.getFullName()) + ".h",s));
}
return res;
}
public List<FileContent> generateCMakeFiles(EMAComponentInstanceSymbol component, List<RosInterface> rosInterfaces, boolean ros2Mode) {
String compName = NameHelper.getComponentNameTargetLanguage(component.getFullName());
String name = NameHelper.getAdapterName(component);
RosCppCMakeListsModel model = new RosCppCMakeListsModel(name, compName);
List<String> allPackages = new ArrayList<>();
allPackages.add(ros2Mode ? "rclcpp" : "roscpp");
rosInterfaces.stream()
.map(RosInterface::getRosConnectionSymbol)
.map(RosConnectionSymbol::getTopicType)
.map(Optional::get)
.map(n -> n.split("/")[0])
.forEach(allPackages::add);
allPackages.forEach(model::addPackage);
List<FileContent> result = new ArrayList<>();
result.add(new FileContent("CMakeLists.txt", RosCppTemplates.generateRosCMakeLists(model)));
result.add(new FileContent(name + ".cpp","#include \"" + name + ".h\""));
return result;
}
}
package de.monticore.lang.monticar.generator.roscpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.template.RosCppCMakeListsModel;
import de.monticore.lang.monticar.generator.roscpp.template.RosCppTemplates;
import de.monticore.lang.monticar.generator.roscpp.util.RosInterface;
import de.monticore.lang.monticar.generator.rosmsg.util.FileContent;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class LanguageUnitRosCMake {
public static List<FileContent> generateFiles(EMAComponentInstanceSymbol component, List<RosInterface> rosInterfaces, boolean ros2Mode) {
String compName = NameHelper.getComponentNameTargetLanguage(component.getFullName());
String name = NameHelper.getAdapterName(component);
RosCppCMakeListsModel model = new RosCppCMakeListsModel(name, compName);
List<String> allPackages = new ArrayList<>();
allPackages.add(ros2Mode ? "rclcpp" : "roscpp");
rosInterfaces.stream()
.map(RosInterface::getRosConnectionSymbol)
.map(RosConnectionSymbol::getTopicType)
.map(Optional::get)
.map(n -> n.split("/")[0])
.forEach(allPackages::add);
allPackages.forEach(model::addPackage);
List<FileContent> result = new ArrayList<>();
result.add(new FileContent("CMakeLists.txt", RosCppTemplates.generateRosCMakeLists(model)));
result.add(new FileContent(name + ".cpp","#include \"" + name + ".h\""));
return result;
}
}
package de.monticore.lang.monticar.generator.roscpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.roscpp.converters.*;
import de.monticore.lang.monticar.generator.roscpp.helper.InitHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.monticar.generator.roscpp.instructions.CallMethodInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.*;
import de.monticore.lang.monticar.generator.rosmsg.RosMsg;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import java.util.*;
import java.util.stream.Collectors;
public class LanguageUnitRosCppAdapter {
private List<DirectMsgConverter> msgConverts = new ArrayList<>();
private List<String> additionalPackages = new ArrayList<>();
private Map<RosMsg, MCTypeReference<? extends MCTypeSymbol>> usedRosMsgs = new HashMap<>();
private boolean ros2Mode = false;
private List<RosInterface> interfaces;
public LanguageUnitRosCppAdapter(boolean ros2Mode) {
this.ros2Mode = ros2Mode;
}
public boolean isRos2Mode() {
return ros2Mode;
}
public void setRos2Mode(boolean ros2Mode) {
this.ros2Mode = ros2Mode;
}
public List<String> getAdditionalPackages() {
return additionalPackages;
}
public Optional<AdapterBluePrint> generateBluePrint(EMAComponentInstanceSymbol componentSymbol) {
AdapterBluePrint bluePrint = null;
if (TagHelper.rosConnectionsValid(componentSymbol)) {
String name = NameHelper.getAdapterName(componentSymbol);
bluePrint = new AdapterBluePrint(name, NameHelper.getComponentNameTargetLanguage(componentSymbol.getFullName()));
List<EMAPortSymbol> rosPorts = componentSymbol.getPortInstanceList().stream()
.filter(EMAPortSymbol::isRosPort)
.collect(Collectors.toList());
List<RosSubscriber> rosSubscribers = rosPorts.stream()
.filter(EMAPortSymbol::isIncoming)
.map(RosSubscriber::new)
.collect(Collectors.toList());
List<RosPublisher> rosPublishers = rosPorts.stream()
.filter(EMAPortSymbol::isOutgoing)
.map(RosPublisher::new)
.collect(Collectors.toList());
List<RosInterface> rosInterfaces = new ArrayList<>();
rosInterfaces.addAll(rosSubscribers);
rosInterfaces.addAll(rosPublishers);
interfaces = rosInterfaces;
SubscriberConverter subscriberConverter;
PublisherConverter publisherConverter;
if (ros2Mode) {
subscriberConverter = new Ros2SubscriberConverter();
publisherConverter = new Ros2PublisherConverter();
} else {
subscriberConverter = new RosSubscriberConverter();
publisherConverter = new RosPublisherConverter();
}
generateFields(componentSymbol, rosSubscribers, rosPublishers, bluePrint, subscriberConverter, publisherConverter);
generateCallbacks(rosSubscribers, bluePrint, subscriberConverter);
generateInit(name, rosSubscribers, rosPublishers, bluePrint, subscriberConverter, publisherConverter);
generatePublishMethods(rosPublishers, bluePrint, publisherConverter);
generateTick(rosPublishers, bluePrint);
generateIncludes(componentSymbol, rosInterfaces, bluePrint);
}
return Optional.ofNullable(bluePrint);
}
private void generateIncludes(EMAComponentInstanceSymbol componentSymbol, List<RosInterface> rosInterfaces, AdapterBluePrint bluePrint) {
List<String> topicTypes = rosInterfaces.stream()
.map(RosInterface::getRosConnectionSymbol)
.map(RosConnectionSymbol::getTopicType)
.map(Optional::get)
.peek(topicType -> additionalPackages.add(NameHelper.getPackageOfMsgType(topicType)))
.collect(Collectors.toList());
if (!isRos2Mode()) {
rosIncludes(componentSymbol, bluePrint, topicTypes);
}else{
ros2Includes(componentSymbol, bluePrint, topicTypes);
}
msgConverts.stream()
.map(DirectMsgConverter::getAdditionalIncludes)
.flatMap(Collection::stream)
.distinct()
.forEach(bluePrint::addAdditionalIncludeString);
}
private void rosIncludes(EMAComponentInstanceSymbol componentSymbol, AdapterBluePrint bluePrint, List<String> topicTypes) {
bluePrint.addAdditionalIncludeString("<ros/ros.h>");
String compName = NameHelper.getComponentNameTargetLanguage(componentSymbol.getFullName());
bluePrint.addAdditionalIncludeString("\"" + compName + ".h\"");
bluePrint.addAdditionalIncludeString("\"IAdapter_" + compName + ".h\"");
//Add each msg include exactly once
topicTypes.stream()
.map(type -> "<" + type + ".h>")
.forEach(bluePrint::addAdditionalIncludeString);
}
private void ros2Includes(EMAComponentInstanceSymbol componentSymbol, AdapterBluePrint bluePrint, List<String> topicTypes) {
bluePrint.addAdditionalIncludeString("<rclcpp/rclcpp.hpp>");
String compName = NameHelper.getComponentNameTargetLanguage(componentSymbol.getFullName());
bluePrint.addAdditionalIncludeString("\"" + compName + ".h\"");
bluePrint.addAdditionalIncludeString("\"IAdapter_" + compName + ".h\"");
//Add each msg include exactly once
topicTypes.stream()
.map(type -> {
if (ros2Mode) {
return NameHelper.msgTypeToSnakecase(NameHelper.addMsgToMsgType(type));
} else {
return type;
}
})
.map(type -> "<" + type + ".hpp>")
.forEach(bluePrint::addAdditionalIncludeString);
}
private void generatePublishMethods(List<RosPublisher> rosPublishers, AdapterBluePrint bluePrint, PublisherConverter publisherConverter) {
rosPublishers.stream()
.sorted(Comparator.comparing(a -> a.getPort().getName()))
.forEachOrdered(p -> publisherConverter.convertToPublishMethod(p, bluePrint));
}
public void generateInit(String classname, List<RosSubscriber> subscribers, List<RosPublisher> publishers, AdapterBluePrint bluePrint, SubscriberConverter subscriberConverter, PublisherConverter publisherConverter) {
Method initMethod = bluePrint.getInit();
InitHelper.getInitInstructions(classname,isRos2Mode()).forEach(initMethod::addInstruction);
//subs
subscribers.stream()
.sorted(Comparator.comparing(RosInterface::getNameInTargetLanguage))
.forEach(s -> subscriberConverter.convertToInit(s, classname, bluePrint));
publishers.stream()
.sorted(Comparator.comparing(RosInterface::getNameInTargetLanguage))
.forEach(p -> publisherConverter.convertToInit(p, bluePrint));
if(!isRos2Mode()) {
initMethod.addInstruction(new TargetCodeInstruction("ros::spin();"));
}else{
initMethod.addInstruction(new TargetCodeInstruction("rclcpp::spin(node_handle);"));
}
}
private void generateFields(EMAComponentInstanceSymbol symbol, List<RosSubscriber> rosSubscribers, List<RosPublisher> rosPublishers, AdapterBluePrint bluePrint, SubscriberConverter subscriberConverter, PublisherConverter publisherConverter) {
bluePrint.addDefineGenerics(symbol);
rosSubscribers.forEach(rosSubscriber -> subscriberConverter.convertToField(rosSubscriber, bluePrint));
rosPublishers.forEach(rosPublisher -> publisherConverter.convertToField(rosPublisher, bluePrint));
}
private void generateTick(List<RosPublisher> publishers, AdapterBluePrint bluePrint) {
Method tickMethod = bluePrint.getTick();
publishers.stream()
.map(RosPublisher::getMethodName)
.sorted()
.map(CallMethodInstruction::new)
.forEachOrdered(tickMethod::addInstruction);
}
private void generateCallbacks(List<RosSubscriber> rosSubscribers, AdapterBluePrint bluePrint, SubscriberConverter subscriberConverter) {
rosSubscribers.forEach(s -> subscriberConverter.convertToCallback(s, bluePrint));
}
public Map<RosMsg, MCTypeReference<? extends MCTypeSymbol>> getUsedRosMsgs() {
return usedRosMsgs;
}
public List<RosInterface> getRosInterfaces() {
return interfaces;
}
}
package de.monticore.lang.monticar.generator.roscpp.converters;
import de.monticore.lang.monticar.generator.roscpp.instructions.CreateTmpMsgInstruction;
import de.monticore.lang.monticar.generator.roscpp.instructions.SetMsgFieldInstruction;
import de.monticore.lang.monticar.generator.roscpp.instructions.SetStructMsgInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.monticar.generator.roscpp.util.Method;
import de.monticore.lang.monticar.generator.roscpp.util.RosPublisher;
import de.monticore.lang.monticar.generator.rosmsg.RosMsg;
public abstract class PublisherConverter {
public abstract void convertToField(RosPublisher rosPublisher, AdapterBluePrint bluePrint);
public abstract void convertToPublishMethod(RosPublisher rosPublisher, AdapterBluePrint bluePrint);
public abstract void convertToInit(RosPublisher rosPublisher, AdapterBluePrint bluePrint);
Method doConvertToPublishMethod(RosPublisher rosPublisher, RosMsg rosMsg, AdapterBluePrint bluePrint, String fullType) {
Method method = new Method(rosPublisher.getMethodName(), "void");
method.addInstruction(new CreateTmpMsgInstruction(fullType));
if (!rosPublisher.getRosConnectionSymbol().getMsgField().isPresent()) {
method.addInstruction(new SetStructMsgInstruction(rosPublisher.getPort(), rosMsg));
} else {
SetMsgFieldInstruction tmpInstr = new SetMsgFieldInstruction(rosPublisher.getPort(), rosPublisher.getMsgConverter());
method.addInstruction(tmpInstr);
}
bluePrint.addMethod(method);
return method;
}
}
package de.monticore.lang.monticar.generator.roscpp.converters;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.instructions.AdvertiseInstruction;
import de.monticore.lang.monticar.generator.roscpp.instructions.PublishInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.monticar.generator.roscpp.util.Method;
import de.monticore.lang.monticar.generator.roscpp.util.RosPublisher;
import de.monticore.lang.monticar.generator.roscpp.util.Variable;
public class Ros2PublisherConverter extends PublisherConverter {
@Override
public void convertToField(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
Variable field = new Variable();
field.setTypeNameTargetLanguage("rclcpp::Publisher<" + NameHelper.getFullRosType(rosPublisher.getRosConnectionSymbol()) + ">::SharedPtr");
field.setName(rosPublisher.getNameInTargetLanguage());
bluePrint.addVariable(field);
}
@Override
public void convertToPublishMethod(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
String fullRosType = NameHelper.getFullRos2Type(rosPublisher.getRosConnectionSymbol());
Method method = doConvertToPublishMethod(rosPublisher, rosPublisher.getRos2Msg(), bluePrint, fullRosType);
method.addInstruction(new PublishInstruction(rosPublisher.getNameInTargetLanguage(), true));
}
@Override
public void convertToInit(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
Method method = bluePrint.getInit();
method.addInstruction(new AdvertiseInstruction(rosPublisher.getNameInTargetLanguage(), rosPublisher.getTypeNameInTargetLanguage(), rosPublisher.getRosConnectionSymbol().getTopicName().get(), true));
}
}
package de.monticore.lang.monticar.generator.roscpp.converters;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.instructions.SubscribeInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.monticar.generator.roscpp.util.Method;
import de.monticore.lang.monticar.generator.roscpp.util.RosSubscriber;
import de.monticore.lang.monticar.generator.roscpp.util.Variable;
public class Ros2SubscriberConverter extends SubscriberConverter {
@Override
public void convertToField(RosSubscriber rosSubscriber, AdapterBluePrint bluePrint) {
Variable field = new Variable();
field.setTypeNameTargetLanguage("rclcpp::Subscription<" + NameHelper.getFullRos2Type(rosSubscriber.getRosConnectionSymbol()) + ">::SharedPtr");
field.setName(rosSubscriber.getNameInTargetLanguage());
bluePrint.addVariable(field);
}
@Override
public void convertToInit(RosSubscriber rosSubscriber, String className, AdapterBluePrint bluePrint) {
Method init = bluePrint.getInit();
init.addInstruction(new SubscribeInstruction(className, rosSubscriber.getNameInTargetLanguage(), rosSubscriber.getRosConnectionSymbol().getTopicName().get(), rosSubscriber.getMethodName(), true, rosSubscriber.getTypeNameInTargetLanguage()));
}
@Override
public void convertToCallback(RosSubscriber rosSubscriber, AdapterBluePrint bluePrint) {
RosConnectionSymbol rosCon = rosSubscriber.getRosConnectionSymbol();
String typeNameTargetLanguage = "const " + NameHelper.getFullRosType(rosCon) + "::SharedPtr";
doConvertToCallback(rosSubscriber, bluePrint, typeNameTargetLanguage);
}
}
package de.monticore.lang.monticar.generator.roscpp.converters;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.instructions.AdvertiseInstruction;
import de.monticore.lang.monticar.generator.roscpp.instructions.PublishInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.monticar.generator.roscpp.util.Method;
import de.monticore.lang.monticar.generator.roscpp.util.RosPublisher;
import de.monticore.lang.monticar.generator.roscpp.util.Variable;
public class RosPublisherConverter extends PublisherConverter {
@Override
public void convertToField(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
Variable field = new Variable();
field.setTypeNameTargetLanguage("ros::Publisher");
field.setName(rosPublisher.getNameInTargetLanguage());
bluePrint.addVariable(field);
}
@Override
public void convertToPublishMethod(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
String fullRosType = NameHelper.getFullRosType(rosPublisher.getRosConnectionSymbol());
Method method = doConvertToPublishMethod(rosPublisher, rosPublisher.getRosMsg(), bluePrint, fullRosType);
method.addInstruction(new PublishInstruction(rosPublisher.getNameInTargetLanguage(), false));
}
@Override
public void convertToInit(RosPublisher rosPublisher, AdapterBluePrint bluePrint) {
Method method = bluePrint.getInit();
method.addInstruction(new AdvertiseInstruction(rosPublisher.getNameInTargetLanguage(), rosPublisher.getTypeNameInTargetLanguage(), rosPublisher.getRosConnectionSymbol().getTopicName().get(), false));
}
}
package de.monticore.lang.monticar.generator.roscpp.converters;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.monticar.generator.roscpp.instructions.SubscribeInstruction;
import de.monticore.lang.monticar.generator.roscpp.util.AdapterBluePrint;
import de.monticore.lang.monticar.generator.roscpp.util.Method;
import de.monticore.lang.monticar.generator.roscpp.util.RosSubscriber;
import de.monticore.lang.monticar.generator.roscpp.util.Variable;
public class RosSubscriberConverter extends SubscriberConverter {
@Override
public void convertToField(RosSubscriber rosSubscriber, AdapterBluePrint bluePrint) {
Variable field = new Variable();
field.setTypeNameTargetLanguage("ros::Subscriber");
field.setName(rosSubscriber.getNameInTargetLanguage());
bluePrint.addVariable(field);
}
@Override
public void convertToInit(RosSubscriber rosSubscriber, String className, AdapterBluePrint bluePrint) {
Method init = bluePrint.getInit();
init.addInstruction(new SubscribeInstruction(className, rosSubscriber.getNameInTargetLanguage(), rosSubscriber.getRosConnectionSymbol().getTopicName().get(), rosSubscriber.getMethodName(), false, rosSubscriber.getTypeNameInTargetLanguage()));