From 8b5184e09a4d99ecb0ba00cbc2df1ddcaea6fcd0 Mon Sep 17 00:00:00 2001 From: Erick Kramer Date: Thu, 22 Jun 2023 18:48:10 +0200 Subject: [PATCH] Allow using reserve keywords in action definition The original version of the action bridge fails to compile when reserve keywords like `goal`, `result`, or `feedback` are used as attributes in an action definition. This change is a hacky work around to this, where `_type` is added to the `type.lower()` usages while filling out the template for the `ActionFactory::translate_` method. Signed-off-by: Erick Kramer --- resource/interface_factories.cpp.em | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/resource/interface_factories.cpp.em b/resource/interface_factories.cpp.em index ae155e28..1a98deb1 100644 --- a/resource/interface_factories.cpp.em +++ b/resource/interface_factories.cpp.em @@ -403,27 +403,27 @@ void ActionFactory_@(frm_)_@(to_)< @(action["ros2_package"])::action::@(action["ros2_name"]) >::translate_@(type.lower())_@(frm)_to_@(to)( @[ if type == "Goal"]@ - @(const_1)ROS@(frm)@(type) &@(type.lower())@(frm), - @(const_2)ROS@(to)@(type) &@(type.lower())@(to)) + @(const_1)ROS@(frm)@(type) &@(type.lower())_type@(frm), + @(const_2)ROS@(to)@(type) &@(type.lower())_type@(to)) @[ else]@ - @(const_1)ROS@(to)@(type) &@(type.lower())@(to), - @(const_2)ROS@(frm)@(type) &@(type.lower())@(frm)) + @(const_1)ROS@(to)@(type) &@(type.lower())_type@(to), + @(const_2)ROS@(frm)@(type) &@(type.lower())_type@(frm)) @[ end if]@ { @[ for field in action["fields"][type.lower()]]@ @[ if field["array"]]@ @(type.lower())@(to).@(field["ros" + to]["name"]).resize(@(type.lower())@(frm).@(field["ros" + frm]["name"]).size()); - auto @(field["ros" + frm]["name"])@(frm)_it = @(type.lower())@(frm).@(field["ros" + frm]["name"]).begin(); - auto @(field["ros" + to]["name"])@(to)_it = @(type.lower())@(to).@(field["ros" + to]["name"]).begin(); + auto @(field["ros" + frm]["name"])@(frm)_it = @(type.lower())_type@(frm).@(field["ros" + frm]["name"]).begin(); + auto @(field["ros" + to]["name"])@(to)_it = @(type.lower())_type@(to).@(field["ros" + to]["name"]).begin(); while ( - @(field["ros" + frm]["name"])@(frm)_it != @(type.lower())@(frm).@(field["ros" + frm]["name"]).end() && - @(field["ros" + to]["name"])@(to)_it != @(type.lower())@(to).@(field["ros" + to]["name"]).end() + @(field["ros" + frm]["name"])@(frm)_it != @(type.lower())_type@(frm).@(field["ros" + frm]["name"]).end() && + @(field["ros" + to]["name"])@(to)_it != @(type.lower())_type@(to).@(field["ros" + to]["name"]).end() ) { auto & @(field["ros" + frm]["name"])@(frm) = *(@(field["ros" + frm]["name"])@(frm)_it++); auto & @(field["ros" + to]["name"])@(to) = *(@(field["ros" + to]["name"])@(to)_it++); @[ else]@ - auto & @(field["ros" + frm]["name"])@(frm) = @(type.lower())@(frm).@(field["ros" + frm]["name"]); - auto & @(field["ros" + to]["name"])@(to) = @(type.lower())@(to).@(field["ros" + to]["name"]); + auto & @(field["ros" + frm]["name"])@(frm) = @(type.lower())_type@(frm).@(field["ros" + frm]["name"]); + auto & @(field["ros" + to]["name"])@(to) = @(type.lower())_type@(to).@(field["ros" + to]["name"]); @[ end if]@ @[ if field["basic"]]@ @[ if field["ros2"]["type"].startswith("builtin_interfaces") ]@