Implement rclcpp::is_initialized()#522
Implement rclcpp::is_initialized()#522wjwwood merged 2 commits intoros2:masterfrom chapulina:is_initialized
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.
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:
initshutdowninitEXPECT_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.
Sorry the previous comment was really two different questions, let me edit it real quick.
There was a problem hiding this comment.
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
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.
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.
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_initializedinstead ofisInitializedbecause that seemed to be the style throughout the utilitiesrcl_okwas already doing what was desired, sorclcpp::is_initializedis just a wrapper around that.