Skip to content

Commit

Permalink
fix template
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Deshpande <harshavardhan.deshpande@ipa.fraunhofer.de>
  • Loading branch information
hsd-dev committed Jun 4, 2020
1 parent e85e73d commit 3a0b59c
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions resource/interface_factories.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ from ros1_bridge import camel_case_to_lower_case_underscore

// include ROS 1 actions
@[for action in mapped_actions]@
#include <@(action["ros1_package"])/@(action["ros1_name"]).h>
#include <@(action["ros1_package"])/@(action["ros1_name"])Action.h>
@[end for]@

// include ROS 2 actions
Expand Down Expand Up @@ -119,26 +119,24 @@ get_action_factory_@(ros2_package_name)__@(interface_type)__@(interface.message_
@[end if]@
@[for action in mapped_actions]@
if (
(
ros_id == "ros1" &&
package_name == "@(action["ros1_package"])" &&
action_name == "@(action["ros1_name"])"
) {
return std::unique_ptr<ActionFactoryInterface>(new ActionFactory_2_1<
@(action["ros1_package"])::@(action["ros1_name"]),
@(action["ros2_package"])::srv::@(action["ros2_name"])
>);
}
else if
ros_id == "ros1" &&
package_name == "@(action["ros1_package"])" &&
action_name == "@(action["ros1_name"])"
) {
return std::unique_ptr<ActionFactoryInterface>(new ActionFactory_2_1<
@(action["ros1_package"])::@(action["ros1_name"])Action,
@(action["ros2_package"])::action::@(action["ros2_name"])
>);
}
else if
(
ros_id == "ros2" &&
package_name == "@(action["ros2_package"])" &&
action_name == "action/@(action["ros2_name"])"
)
) {
return std::unique_ptr<ActionFactoryInterface>(new ActionFactory_1_2<
@(action["ros1_package"])::@(action["ros1_name"]),
@(action["ros2_package"])::srv::@(action["ros2_name"])
@(action["ros1_package"])::@(action["ros1_name"])Action,
@(action["ros2_package"])::action::@(action["ros2_name"])
>);
}
@[end for]@
Expand Down Expand Up @@ -357,16 +355,29 @@ void ServiceFactory<
@[ for frm, to in [("1", "2"), ("2", "1")]]@
@[ for type in ["Goal", "Result", "Feedback"]]@
template <>
void ActionFactory_@(frm)_@(to)<
@[ if type == "Goal"]@
@{
frm_, to_ = frm, to
const_1 = "const "
const_2 = ""
}@
@[ else]@
@{
frm_, to_ = to, frm
const_1 = ""
const_2 = "const "
}@
@[ end if]@
void ActionFactory_@(frm_)_@(to_)<
@(action["ros1_package"])::@(action["ros1_name"])Action,
@(action["ros2_package"])::action::@(action["ros2_name"])
>::translate_@(type.lower())_@(frm)_to_@(to)(
@[ if type == "Goal"]@
const ROS@(frm)Goal &@(type.lower())@(frm),
ROS@(to)Goal &@(type.lower())@(to))
@(const_1)ROS@(frm)@(type) &@(type.lower())@(frm),
@(const_2)ROS@(to)@(type) &@(type.lower())@(to))
@[ else]@
const ROS@(to)Goal &@(type.lower())@(to),
ROS@(frm)Goal &@(type.lower())@(frm))
@(const_1)ROS@(to)@(type) &@(type.lower())@(to),
@(const_2)ROS@(frm)@(type) &@(type.lower())@(frm))
@[ end if]@
{
@[ for field in action["fields"][type.lower()]]@
Expand All @@ -385,9 +396,13 @@ void ActionFactory_@(frm)_@(to)<
auto & @(field["ros" + to]["name"])@(to) = @(type.lower())@(to).@(field["ros" + to]["name"]);
@[ end if]@
@[ if field["basic"]]@
@[ if field["ros2"]["type"].startswith("builtin_interfaces") ]@
ros1_bridge::convert_@(frm)_to_@(to)(@(field["ros" + frm]["name"])@(frm), @(field["ros" + to]["name"])@(to));
@[ else]@
@(field["ros" + to]["name"])@(to) = @(field["ros" + frm]["name"])@(frm);
@[ end if]@
@[ else]@
Factory<@(field["ros" + frm]["cpptype"]),@(field["ros" + to]["cpptype"])>::convert_@(frm)_to_@(to)(@(field["ros" + frm]["name"])@(frm), @(field["ros" + to]["name"])@(to));
Factory<@(field["ros1"]["cpptype"]),@(field["ros2"]["cpptype"])>::convert_@(frm)_to_@(to)(@(field["ros" + frm]["name"])@(frm), @(field["ros" + to]["name"])@(to));
@[end if]@
@[ if field["array"]]@
}
Expand Down

0 comments on commit 3a0b59c

Please sign in to comment.