-
Notifications
You must be signed in to change notification settings - Fork 724
LoopNode : std::vector<T> | std::deque<T> #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just ran into the same issue and was tempted to write a similar vector-to-queue converter node but came here to see if there are better solutions. Anything so far? |
Btw, if this is needed for multiple types, a template can be pretty handy: #include <behaviortree_cpp/action_node.h>
#include <behaviortree_cpp/bt_factory.h>
template <typename T>
class VectorToQueueNode : public BT::SyncActionNode {
public:
VectorToQueueNode(const std::string& name, const BT::NodeConfig& config) : BT::SyncActionNode(name, config) {}
static BT::PortsList providedPorts() {
return {
BT::InputPort<std::vector<T>>("vector"),
BT::OutputPort<std::shared_ptr<std::deque<T>>>("queue"),
};
}
BT::NodeStatus tick() override {
std::vector<T> vec;
if (!getInput("vector", vec)) {
return BT::NodeStatus::FAILURE;
}
auto queue = std::make_shared<std::deque<T>>(vec.cbegin(), vec.cend());
setOutput("queue", queue);
return BT::NodeStatus::SUCCESS;
}
};
BT_REGISTER_NODES(factory) {
factory.registerNodeType<VectorToQueueNode<std::string>>("VectorToQueueString");
factory.registerNodeType<VectorToQueueNode<bool>>("VectorToQueueBool");
factory.registerNodeType<VectorToQueueNode<int>>("VectorToQueueInt");
factory.registerNodeType<VectorToQueueNode<double>>("VectorToQueueDouble");
} |
Yeah , i also landed up with the template class as it seemed the more logical thing given in cases where you might also need to refill or initiate the
|
Hi @facontidavide
snippet
Error
As my upstream node return it in
std::vector<T>
I cant Loop through it using
LoopNode<T>
Do i have to always write a overhead wrapper ?
Any Suggest to handle it in better way ?
The text was updated successfully, but these errors were encountered: