Repository navigation
Replies: 1 comment
|
Your understanding is mostly right. Point by point (BT.CPP 4.x): 1. One node per capability: yes. Make each driver call a small node of the right type: 2. Pass the driver/logger/config through the constructor, not the blackboard. auto driver = std::make_shared<RobotDriver>();
factory.registerNodeType<MoveToPose>("MoveToPose", driver);
factory.registerNodeType<IsEnabled>("IsEnabled", driver);
class MoveToPose : public BT::StatefulActionNode {
public:
MoveToPose(const std::string& n, const BT::NodeConfig& c, std::shared_ptr<RobotDriver> d)
: StatefulActionNode(n, c), drv_(std::move(d)) {}
static BT::PortsList providedPorts() { return { BT::InputPort<Pose>("goal") }; }
...
};Keep ports for the data that changes while the tree runs (goals, results). Keep the constructor for dependencies. 3. Yes. 4. For a fixed set of 4 slots, the simplest way is a reusable subtree with port remapping, instanced 4 times: struct Slot { Pose pick, place; };
factory.registerNodeType<BT::LoopNode<Slot>>("LoopSlot");
factory.registerNodeType<SplitSlot>("SplitSlot"); // Sync action: input slot -> outputs pick, place<LoopSlot queue="{slots}" value="{slot}">
<Sequence>
<SplitSlot slot="{slot}" pick="{pick}" place="{place}"/>
<SubTree ID="PickPlace" pick="{pick}" place="{place}"/>
</Sequence>
</LoopSlot>auto slots = std::make_shared<std::deque<Slot>>(/* 4 slots */);
tree.rootBlackboard()->set("slots", slots);
tree.tickWhileRunning();I built this against 4.11.0 with a fake async driver. It runs pick/place for the 4 slots in order and returns SUCCESS. Only |
Uh oh!
There was an error while loading. Please reload this page.
If there is a better place to ask this, please tell me! I just wanted to make sure my understanding of how behavior trees should be structured.
If i have a robot driver that is threadsafe and async, I think this fits the requirements of BTs well (non blocking). But should i create a new node class for each function like is_enabled, move_to_pose, set_velocity_limit? AFAICT this is the recommended way through inheritance.
Related to this, how do i pass the robot driver object to the node class? Should I instantiate it and do the setup before setting up the BT and then just save it on the blackboard and use input ports? Same for stuff like the logger object or any config that i need for the implementation.
For setting the desired pose, i.e. requesting a movement, this is my current approach: i define an action in the XML file, and set desired_pose="{desired_pose}" which then needs to be updated on the blackboard before the movement by another node. Is that correct?
Assuming that is true, I have a tree with a few subtrees, lets assume its just a pick and place task but with 4 slots so 4 different pick and place poses. Is the proper way of doing it to just write the BT with desired_pose="{pick_pose}", desired_pose="{place_pose}", and then have a node before that update all required variables on the blackboard by popping elements off a queue that was initialized at startup?
All reactions