Skip to content

LoopNode : std::vector<T> | std::deque<T> #969

Open
@viprob-ai

Description

@viprob-ai

Hi @facontidavide

snippet

<LoopWaypointNode queue="{waypoints}" value="{wp}" if_empty="SKIPPED">
....
</>

Error

1746000290.487891654                bt_action_server   ERROR| Behavior Tree exception:The creation of the tree failed because the port [waypoints] was initially created with type [std::vector<geometry_msgs::msg::PoseStamped_<std::allocator<void> >, std::allocator<geometry_msgs::msg::PoseStamped_<std::allocator<void> > > >] and, later type [std::shared_ptr<std::deque<geometry_msgs::msg::PoseStamped_<std::allocator<void> >, std::allocator<geometry_msgs::msg::PoseStamped_<std::allocator<void> > > > >] was used somewhere else.

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 ?

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<geometry_msgs::msg::PoseStamped>>("vector_in"),
      BT::OutputPort<std::shared_ptr<std::deque<geometry_msgs::msg::PoseStamped>>>("queue_out")
    };
  }

  BT::NodeStatus tick() override
  {
    std::vector<geometry_msgs::msg::PoseStamped> input_vec;
    if (!getInput("vector_in", input_vec)) {
      return BT::NodeStatus::FAILURE;
    }

    auto q = std::make_shared<std::deque<geometry_msgs::msg::PoseStamped>>(input_vec.begin(), input_vec.end());
    setOutput("queue_out", q);
    return BT::NodeStatus::SUCCESS;
  }
};

Any Suggest to handle it in better way ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions