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

Add support for logging service. #2122

Merged
merged 6 commits into from
Apr 18, 2023
Merged

Conversation

llapx
Copy link
Contributor

@llapx llapx commented Mar 8, 2023

No description provided.

@llapx
Copy link
Contributor Author

llapx commented Mar 8, 2023

#ros2/rcl_interfaces#154

@llapx
Copy link
Contributor Author

llapx commented Mar 8, 2023

Rebased to the latest rolling.

@fujitatomoya fujitatomoya self-requested a review March 14, 2023 05:02
@fujitatomoya fujitatomoya self-assigned this Mar 14, 2023
@fujitatomoya fujitatomoya added the enhancement New feature or request label Mar 14, 2023
@Barry-Xu-2018
Copy link
Collaborator

This PR depend on #2122

@Barry-Xu-2018
Copy link
Collaborator

Barry-Xu-2018 commented Mar 21, 2023

There is another way to avoid changing the existing interface of NodeBase.
Create a new class NodeBuiltinExecutor. It is initialized at Node construct. start_parameter_services​, start_parameter_event_publisher​, use_clock_thread and enable_log_service​​​ in node options are handled in this class. That is, all builitin pubisher, service, etc are located in class NodeBuiltinExecutor. Node option control if it is created.
Of course, this leads to big change. So maybe this design is better to be implemented in refactor action instead of implementing this PR.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@llapx thanks for working on this, 1st review completed.

rclcpp/include/rclcpp/node.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/node_interfaces/node_base.hpp Outdated Show resolved Hide resolved
rclcpp/src/rclcpp/node.cpp Outdated Show resolved Hide resolved
rclcpp/src/rclcpp/node.cpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/node_options.hpp Outdated Show resolved Hide resolved
rclcpp/src/rclcpp/time_source.cpp Outdated Show resolved Hide resolved
rclcpp/src/rclcpp/node_interfaces/node_base.cpp Outdated Show resolved Hide resolved
rclcpp/src/rclcpp/node_interfaces/node_logging.cpp Outdated Show resolved Hide resolved
rclcpp/test/rclcpp/test_logging_service.cpp Outdated Show resolved Hide resolved
rclcpp/test/rclcpp/test_logging_service.cpp Outdated Show resolved Hide resolved
@fujitatomoya
Copy link
Collaborator

@clalancette @mjcarroll @wjwwood @alsora @gbiggs @iuhilnehc-ynos

I would like to have opinion and comments on the followings(only applies to rclcpp).

  • currently time source (/clock subscription) has SingleThreadedExecutor if ROS time is enabled. and that executor is dedicated to time source. But this PR tries to share the executor between time source and logging level service this PR adds. i think that keep the dedicated executor for time source would be necessary for user experience, and probably add one more SingleThreadedExecutor for logger level service? Or user can configure if they want to have dedicated executor for time source? what do you think?
  • via logger level service, user might want to know the effective logger level as well? (Or, either rcutils_logging_get_logger_effective_level or rcutils_logging_get_logger_level?) i am inclined to take rcutils_logging_get_logger_level, since this is actual level of the logger in the hash map, so that user can figure out what level should be applied for based on their requirement.

thanks,

@fujitatomoya
Copy link
Collaborator

@Barry-Xu-2018 since we have not received the response to #2122 (comment), probably we can keep the current implementation with this PR, which is sharing single threaded executor within time source and logging level service if enabled. what do you think?

@iuhilnehc-ynos please chime in if you have comments on this.

thanks,

@Barry-Xu-2018
Copy link
Collaborator

Barry-Xu-2018 commented Apr 4, 2023

@fujitatomoya

since we have not received the response to #2122 (comment), probably we can keep the current implementation with this PR, which is sharing single threaded executor within time source and logging level service if enabled. what do you think?

Yes. But I refactor code to avoid many changes on existing interface.
Barry-Xu-2018#3
For the first version (f4199fe6613734f4b64934ac654e6176a1c75ee8), I used NodeBuiltinExecutor to launch logger service and clock thread. But find time_source has problem for some case.
After discussing with @iuhilnehc-ynos, we think we should use NodeBuiltinExecutor only for logger service (Otherwise, there are many changes for time_source).
We can create new PR to refactor time_source to use NodeBuiltinExecutor.
What do you think ?

About the second point, we incline to use rcutils_logging_get_logger_level.

@Barry-Xu-2018
Copy link
Collaborator

0074d6d introduce a new class NodeBuiltinExecutor.
NodeBuiltinExecutor take charge of running all internal(built-In) services, subscription, etc.
Now only logger service is launched.
I don't want to have too many changes in this PR which isn't related to logger service.
Next, clock thread and related work in time source will be moved to this class.

@fujitatomoya
Copy link
Collaborator

@Barry-Xu-2018 @iuhilnehc-ynos

We had a quick discussion on this today.

in addition to #2122 (comment), we can just rely on user thread to spin just like parameter services ParameterService do. This can be good enough to handle the logging services in the node. I did not think we had discuss on this before, but sounds good enough to me. what do you think?

in case of handling these services with internal thread just like time source, SingleThreadedExecutor can be shared with time source, so that we can avoid the situation to extra thread in the node.

CC: @wjwwood @alsora

@fujitatomoya
Copy link
Collaborator

in addition to #2122 (comment), we can just rely on user thread to spin just like parameter services ParameterService do. This can be good enough to handle the logging services in the node. I did not think we had discuss on this before, but sounds good enough to me. what do you think?

besides, this is the current implementation of ros2/rclpy#1102

@Barry-Xu-2018
Copy link
Collaborator

in addition to #2122 (comment), we can just rely on user thread to spin just like parameter services ParameterService do. This can be good enough to handle the logging services in the node. I did not think we had discuss on this before, but sounds good enough to me. what do you think?

Yes. We can put logger service in user thread like parameter services.
From our previous consideration, we want to move all internal services (such as parameter service, clock service, log service, etc) from user thread to internal thread. So we created NodeBuiltinExecutor.
Of course, it's not appropriate to include such changes for this purpose in this PR.

@fujitatomoya
Copy link
Collaborator

Of course, it's not appropriate to include such changes for this purpose in this PR.

I think this can be handles as different issue and PRs, but currently i see that user thread could be most appropriate.

@Barry-Xu-2018
Copy link
Collaborator

I updated codes.
@fujitatomoya @iuhilnehc-ynos please review again.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

lgtm

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@Barry-Xu-2018
Copy link
Collaborator

Rebase was done.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

Lgtm, I was iffy about the service interface being passed separately from the constructor but on reflection I think that's actually for the best since the feature is optional.

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

llapx and others added 6 commits April 17, 2023 20:29
Signed-off-by: Lei Liu <Lei.Liu.AP@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
@clalancette
Copy link
Contributor

This needed a rebase, which I've done now. I think it also needs an updated .repos file, which I've also made. Here's another CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor

(also, Rpr is going to fail since we haven't released rcl_interfaces yet; we'll do that tomorrow)

@clalancette
Copy link
Contributor

@fujitatomoya @llapx @Barry-Xu-2018 So unfortunately it looks like something is going on with Windows here. In particular, some of the tests are crashing that didn't crash in the nightlies, and didn't seem to crash with the other code that went in today. I honestly don't know what is going on here, but I don't think we should put this in like it is. Can you please take a look and try to see what is happening?

@Barry-Xu-2018
Copy link
Collaborator

@clalancette Okay. I will check failed test cases.

@fujitatomoya
Copy link
Collaborator

actually there are 5 test failure, all of them looks not related to our PRs, but hard to guarantee that at this very last moment.
@Barry-Xu-2018 any thoughts?

starting windows CI again:

  • Windows Build Status

@Barry-Xu-2018
Copy link
Collaborator

@fujitatomoya
Yeah. These failed tests are all the program died or did not respond.
The logger service isn't enabled, change of this PR should not affect test result.
So I suspect it's an issue with the CI system. We have to run it again.

@fujitatomoya
Copy link
Collaborator

@clalancette @Yadunund

in our opinion, that is so unlikely those are related to our PR, since our code is not even enabled. (builtin logging level service is opt-in.)
so I would say that we can merge this, and we will be there if anything happens to our code as we do.

on the other hand, we understand that you do not take this at very last moment unless CI is all green. (CI windows has been restarted, but will not be completed in time.)

@clalancette clalancette merged commit 3610b68 into ros2:rolling Apr 18, 2023
Barry-Xu-2018 pushed a commit to Barry-Xu-2018/rclcpp that referenced this pull request Jan 12, 2024
* Add support for logging service.

* Update to not modify interfaces and not change time_source

* Use unique_ptr for NodeBuiltinExecutorImpl

* Use user thread to run logger service

* Update code for lifecycle_node

Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Lei Liu <Lei.Liu.AP@sony.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants