Skip to content
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

Meta PR: try inheritance instead of callbacks #6

Merged
merged 4 commits into from
May 1, 2024

Conversation

facontidavide
Copy link
Collaborator

What about this?

@@ -41,9 +41,13 @@ ActionServerBT::ActionServerBT(const rclcpp::NodeOptions& options, const UserCal

// register the users Plugins and BehaviorTree.xml files into the factory
register_behavior_trees(params_, factory_, node_);
registerNodesIntoFactory(factory_);

// No one "own" this blackboard
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want this to persist, by default

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would a user go about clearing the global blackboard? Seems like some runs they could want values to persist but others should start clean. Should we consider adding an option to the Action goal?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also leads into the feature of the user waning to clear and ImportBlackboardFromJSON. Another nice addition to the Action goal would be the ability to specify a path to a JSON file that should be loaded before running the tree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can still access it and clean it in onTreeCreated.

I would use that callback to do all this initialization and let the user take care of it, instead of tryingto figure out all the potential things they may want to do

Copy link
Owner

@MarqRazz MarqRazz May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I was thinking about that as an option too but it could lead to a few situations. Let's say they offer a service to set the blackboard. What would stop them from mutating the BB while the tree is running? Does BT.CPP have guards to protect from reading and writing BB variables at the same time?

Copy link
Owner

@MarqRazz MarqRazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how clean this ended up, great work @facontidavide!

action_server_bt/src/action_server_bt.cpp Outdated Show resolved Hide resolved
action_server_bt/src/action_server_bt.cpp Outdated Show resolved Hide resolved
@@ -41,9 +41,13 @@ ActionServerBT::ActionServerBT(const rclcpp::NodeOptions& options, const UserCal

// register the users Plugins and BehaviorTree.xml files into the factory
register_behavior_trees(params_, factory_, node_);
registerNodesIntoFactory(factory_);

// No one "own" this blackboard
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would a user go about clearing the global blackboard? Seems like some runs they could want values to persist but others should start clean. Should we consider adding an option to the Action goal?

@facontidavide
Copy link
Collaborator Author

How would a user go about clearing the global blackboard?

I just removed the method clear in 4.6.0 and maybe that was an error (I will restore it in 4.6.1):

Brute force cleanup

static auto clean_bb = BT::Blackboard::create();
clean_bb->cloneInto(*global_blackboard);

RCLCPP_ERROR(kLogger, action_result->error_message.c_str());
tree.haltTree();
goal_handle->canceled(action_result);
abort_action(status, "Action Server canceling and halting Behavior Tree");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this should return goal_handle->canceled(). If we move this statement out of the lambda we can support both canceled and aborted.

Copy link
Owner

@MarqRazz MarqRazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we fix the return on cancel I think this is good to go.

@MarqRazz MarqRazz merged commit 72358cb into user_callback May 1, 2024
1 check passed
@MarqRazz MarqRazz deleted the inheritance branch May 2, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants