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've been using this code as a reference and I ran into a small problem. I think that the Parallel behaviour will not reset states correctly for behaviours that terminate (that succeed or fail).
The resetting is left to Behaviour::tick(), which updates the status of the behaviour. But the Parallel behaviour will not tick behaviours that were previously terminated.
One fix is to have Parallel implement onInitialize and reset the children's state there (or tick them, though this wont interact well with the Repeat decorator).
The text was updated successfully, but these errors were encountered:
class Parallel : public Behavior {
public:
// Other members and methods...
void onInitialize() override {
// Reset or reinitialize the state of all child behaviors
for (auto& child : children) {
if (child->getStatus() == BH_SUCCESS || child->getStatus() == BH_FAILURE) {
child->reset(); // Reset the child behavior if it has terminated
}
}
}
Status update() override {
// Implementation of the parallel behavior's update logic...
}
// Other members and methods...
};
class Behavior {
public:
// Other members and methods...
virtual void onInitialize() {
// Default implementation of onInitialize, if any
}
void reset() {
status = BH_INVALID;
onInitialize();
}
// Other members and methods...
};
// Other necessary code...
Hey!
I've been using this code as a reference and I ran into a small problem. I think that the
Parallel
behaviour will not reset states correctly for behaviours that terminate (that succeed or fail).The resetting is left to
Behaviour::tick()
, which updates the status of the behaviour. But theParallel
behaviour will not tick behaviours that were previously terminated.One fix is to have
Parallel
implementonInitialize
and reset the children's state there (or tick them, though this wont interact well with the Repeat decorator).The text was updated successfully, but these errors were encountered: