-
Notifications
You must be signed in to change notification settings - Fork 436
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
Implement rclcpp::is_initialized() #522
Conversation
hmm that's where the naming will get confusing.. 👍 lgtm with green CI |
@mikaelarguedas that's why originally I had suggested that should be the semantic of I'm fine with having an |
Or the name in |
|
||
rclcpp::shutdown(); | ||
|
||
EXPECT_TRUE(rclcpp::is_initialized()); |
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 would expect is_initialized()
to be false after shutdown, is that not the expectation? I believe rcl_ok
should return false if you call rcl_shutdown
(maybe we're not doing that properly yet).
Also, what happens if you do:
init
shutdown
init
EXPECT_TRUE(rclcpp::is_initialized())
I'd then expect it to be true, but not before doing the second init
.
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.
Sorry the previous comment was really two different questions, let me edit it real quick.
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, it looks like we're not calling rcl_shutdown
ever, which until now hasn't had any consequence (none of our middlewares do anything on rcl_shutdown
/rmw_shutdown
):
rclcpp/rclcpp/src/rclcpp/utilities.cpp
Lines 270 to 288 in 8f2052d
void | |
rclcpp::shutdown() | |
{ | |
trigger_interrupt_guard_condition(SIGINT); | |
{ | |
std::lock_guard<std::mutex> lock(on_shutdown_mutex_); | |
for (auto & on_shutdown_callback : on_shutdown_callbacks_) { | |
on_shutdown_callback(); | |
} | |
} | |
} | |
void | |
rclcpp::on_shutdown(std::function<void(void)> callback) | |
{ | |
std::lock_guard<std::mutex> lock(on_shutdown_mutex_); | |
on_shutdown_callbacks_.push_back(callback); | |
} |
But now it means that rcl_ok()
's return value doesn't change when rclcpp::shutdown()
is used, despite that really being the intention:
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 added the last expectation just to make it clear that the current behaviour is that once initialized, there's no way back.
I don't think init
-> shutdown
-> init
works, I tried shutting down in the end of TestUtilities.init_with_args
and adding a new init
test after that but an exception is thrown.
I'm not sure what the consequences of calling rcl_shutdown
could be and whether it would be worth doing it on this PR. Whatcha think?
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 don't know, but I don't want to block this. I think it's clear more work needs to be done though (after merging this).
Btw, @chapulina should this be in review? or are you still working on it? |
Not working on it, unless the maintainers think the |
@mikaelarguedas said it lgth, and I don't want to block it. I'll just make a follow up issue. |
Fixed linter errors in f15da86 |
Thanks for the CI crash-course, @wjwwood ! |
I think this issue covers the improvements I talked about before (being able to do init-shutdown-init, etc.): #154 |
Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
Addresses #518.
is_initialized
instead ofisInitialized
because that seemed to be the style throughout the utilitiesrcl_ok
was already doing what was desired, sorclcpp::is_initialized
is just a wrapper around that.