-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add cout bt logs #4449
Closed
Closed
Add cout bt logs #4449
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,8 @@ class NavigatorBase | |
const std::vector<std::string> & plugin_lib_names, | ||
const FeedbackUtils & feedback_utils, | ||
nav2_core::NavigatorMuxer * plugin_muxer, | ||
std::shared_ptr<nav2_util::OdomSmoother> odom_smoother) = 0; | ||
std::shared_ptr<nav2_util::OdomSmoother> odom_smoother, | ||
std::shared_ptr<BT::StdCoutLogger> logger_cout_) = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not the abstract logger so folks could pass in any logger they want (or have option in the higher level node to select the logger type they prefer)? |
||
|
||
/** | ||
* @brief Activation of the navigator's backend BT and actions | ||
|
@@ -190,13 +191,19 @@ class BehaviorTreeNavigator : public NavigatorBase | |
const std::vector<std::string> & plugin_lib_names, | ||
const FeedbackUtils & feedback_utils, | ||
nav2_core::NavigatorMuxer * plugin_muxer, | ||
std::shared_ptr<nav2_util::OdomSmoother> odom_smoother) final | ||
std::shared_ptr<nav2_util::OdomSmoother> odom_smoother, | ||
std::shared_ptr<BT::StdCoutLogger> logger_cout) final | ||
{ | ||
auto node = parent_node.lock(); | ||
logger_ = node->get_logger(); | ||
clock_ = node->get_clock(); | ||
feedback_utils_ = feedback_utils; | ||
plugin_muxer_ = plugin_muxer; | ||
logger_cout_ = logger_cout; | ||
if (!node->has_parameter("enable_cout_logger")) { | ||
node->declare_parameter("enable_cout_logger", false); | ||
} | ||
enable_cout_logger_ = node->get_parameter("enable_cout_logger").as_bool(); | ||
|
||
// get the default behavior tree for this navigator | ||
std::string default_bt_xml_filename = getDefaultBTFilepath(parent_node); | ||
|
@@ -296,7 +303,10 @@ class BehaviorTreeNavigator : public NavigatorBase | |
} | ||
|
||
bool goal_accepted = goalReceived(goal); | ||
|
||
logger_cout_.reset(); | ||
logger_cout_ = std::make_shared<BT::StdCoutLogger>(bt_action_server_->getTree()); | ||
logger_cout_->enableTransitionToIdle(false); | ||
logger_cout_->setEnabled(enable_cout_logger_); | ||
if (goal_accepted) { | ||
plugin_muxer_->startNavigating(getName()); | ||
} | ||
|
@@ -313,6 +323,7 @@ class BehaviorTreeNavigator : public NavigatorBase | |
{ | ||
plugin_muxer_->stopNavigating(getName()); | ||
goalCompleted(result, final_bt_status); | ||
logger_cout_.reset(); | ||
} | ||
|
||
/** | ||
|
@@ -371,6 +382,8 @@ class BehaviorTreeNavigator : public NavigatorBase | |
rclcpp::Clock::SharedPtr clock_; | ||
FeedbackUtils feedback_utils_; | ||
NavigatorMuxer * plugin_muxer_; | ||
std::shared_ptr<BT::StdCoutLogger> logger_cout_; | ||
bool enable_cout_logger_; | ||
}; | ||
|
||
} // namespace nav2_core | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is
logger_cout_
made? Shouldn't this be created in the BT Navigator to be passed onto the navigator base to share? I'm not sure why we're passing in a nullptr and its unused in the BT Navigator level unless (1) we're creating it here for all N instances to share or (2) we're keeping the logger object here to use somewhere.(1) would mean we should be instantiating it above and then passing it in to share. Move the parameter logic here too.
(2) would mean we can remove modifying the
on_configure
API / storing the logger object at this high level, because its unused and breaks ABI (since its unused here anyway). That would make this fully a feature of the plugins and not of the BT Navigator instance itself.The mixing is weird unless it would be used at a higher level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I know its weird to pass a nullptr but I got to this point to statisfy:
tree_
which is only availableBehaviorTreeNavigator
and not inBTNavigator
It's possible that I missed another obvious way of implementing though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@facontidavide this is the second time that the singleton nature of the loggers has caused us problems in Nav2. We actually removed live Groot monitoring because of it.
Would it be possible to allow multiple loggers in BT.CPP to allow for this? If we’re running into this every couple of years, I bet others are too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, it is ok to remove the singleton constraint. Let me work on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: BehaviorTree/BehaviorTree.CPP@ced041b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that creating your own logger is trivial and boring. StdCout is only 30 lines of code. Are you sure that you don't want to create your own, maybe one that use
RCLCPP_INFO
instead ofstd::cout
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave that to @tonynajjar , but I agree that doing an RCLCPP log would be better so it enters the
.ros/logs
entries. That would probably need to live here I guess since ROS shouldn't bleed into BT.CPP.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly!