You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working with std::optional for enhanced flexibility in my Behavior Trees, specifically using it with InputPort to optionally accept parameters. Here is how I've set up my input port:
# node A
BT::InputPort<std::optional<double>>("param", std::nullopt, "description");
To connect this with an OutputPort that directly outputs a double, I've found that I need to use an intermediary node to convert a double to std::optional<double>, like so:
# node A
BT::InputPort<std::optional<double>>("param", std::nullopt, "description");
However, this approach, while functional, introduces additional complexity and overhead that I'd prefer to avoid. Ideally, I would like to define my OutputPort simply as:
# node B
BT::OutputPort<double>("param");
⬇️
# node A
BT::InputPort<std::optional<double>>("param", std::nullopt, "description");
But this leads to a type mismatch.
Is there a way to directly set an InputPort<std::optional<double>> with a value from an OutputPort<double> without requiring an intermediary node for conversion? I'm looking for a solution that would allow for a smoother integration between non-optional output ports and optional input ports, ideally directly within the framework's existing mechanisms.
Any suggestions, workarounds, or insights into how this might be achievable within the current BehaviorTree.CPP framework would be greatly appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello BehaviorTree.CPP Community,
I am currently working with
std::optional
for enhanced flexibility in my Behavior Trees, specifically using it withInputPort
to optionally accept parameters. Here is how I've set up my input port:To connect this with an
OutputPort
that directly outputs adouble
, I've found that I need to use an intermediary node to convert adouble
tostd::optional<double>
, like so:⬇️
⬇️
However, this approach, while functional, introduces additional complexity and overhead that I'd prefer to avoid. Ideally, I would like to define my
OutputPort
simply as:⬇️
But this leads to a type mismatch.
Is there a way to directly set an
InputPort<std::optional<double>>
with a value from anOutputPort<double>
without requiring an intermediary node for conversion? I'm looking for a solution that would allow for a smoother integration between non-optional output ports and optional input ports, ideally directly within the framework's existing mechanisms.Any suggestions, workarounds, or insights into how this might be achievable within the current BehaviorTree.CPP framework would be greatly appreciated.
Thank you for your guidance and support.
Beta Was this translation helpful? Give feedback.
All reactions