blob: 7c99b81d653ff3d2fc80288660ba3138df9a6b21 [file] [log] [blame]
* Copyright (c) 2020-2021 Robert Bosch GmbH.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at
* SPDX-License-Identifier: EPL-2.0
* Contributors:
* Robert Bosch GmbH - initial API and implementation
package org.eclipse.app4mc.slg.ros2.generators
import java.util.HashSet
import java.util.List
import org.eclipse.app4mc.amalthea.model.StringObject
import org.eclipse.app4mc.amalthea.model.Tag
class RosTagGenerator {
static def String toCpp(Tag tag, String moduleName, HashSet<String> headers, List<String> declarations,
List<String> inits, List<String> calls, List<String> serviceCallbacks) '''
#include <chrono>
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
«FOR header : headers»
using namespace std::chrono_literals;
using std::placeholders::_1;
«FOR serviceCallback : serviceCallbacks»
class «moduleName» : public rclcpp::Node
«FOR declaration : declarations»
: Node("«moduleName.toLowerCase»")
«FOR init : inits»
«FOR call : calls»
int main(int argc, char * argv[])
setvbuf(stdout, NULL, _IONBF, BUFSIZ);
rclcpp::init(argc, argv);
«IF tag.customProperties.get('executor_type') !== null»
«IF (tag.customProperties.get('executor_type') as StringObject).value.equals('single_thread')»
rclcpp::executors::SingleThreadedExecutor executor;
rclcpp::executors::MultiThreadedExecutor executor;
rclcpp::executors::MultiThreadedExecutor executor;
auto node = std::make_shared<«moduleName»>();
return 0;