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

Basic Timer implementation #440

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

agalbachicar
Copy link
Contributor

@agalbachicar agalbachicar commented Nov 29, 2024

Description

This is a basic Timer implementation. It is heavily based on what other client libraries do, i.e. use RCL bindings and provide a safe API against the bindings.

Details

It is by no means a final version but it is a good first approach to something close to the final version. We will happily change everything you tell us to change :)

It is important to look at the TimerCallback type trait definition.

We tried to keep mutable and non-mutable functions within Timer but then when integrating it against WaitSet, Node and Executor we had to make it all "non-mutable".

This has been done in collaboration (peer programming) with @tulku , @JesusSilvaUtrera, @jballoffet 🎊

How to test it?

  • Add end to end example -> fbb8629

We wrote an end to end example, we will soon add it so it can be show how to do it.
We introduced some unit tests, we can certainly extend them as soon as we define the final API.

Notes

We observed some non-trivial delays in the callback execution. Certainly the overhead between the bindings and what we are doing is non-negligible. We would appreciate some input here.

Identified discussion points

  • i64 for durations, shall we use proper Duration types?
  • Using the Clock::with_source() makes the test in Timer crash with SIGSEGV. See the comment and test in timer.rs.

agalbachicar and others added 18 commits November 28, 2024 19:52
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
* Added timer_period_ns

* Adds Timer::is_ready().

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>

* Added comments to avoid warnings

* Added the getter for rcl_clock_t

---------

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Co-authored-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
* Added timer_period_ns

* Adds Timer::is_ready().

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>

* Added comments to avoid warnings

* Added the getter for rcl_clock_t

* WIP add create_timer to node

* Cleaning some stuff

---------

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Co-authored-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
@jhdcs
Copy link
Collaborator

jhdcs commented Nov 29, 2024

In reference to your discussion points, I think that having timers use Duration would be valuable.

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
- Adds documentation.
- Removes the no-callback constructor.
- Removes vertical space.

Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
@mxgrey
Copy link
Collaborator

mxgrey commented Dec 2, 2024

For visibility, I've opened agalbachicar#5 which targets this PR and addresses most of the feedback that I expect the working group will have for this PR.

I recommend that others hold off on reviewing this until agalbachicar#5 gets settled because any reviews in the meantime will likely become outdated soon.

@agalbachicar separately from the PR that I opened, you'll need to merge the latest main branch into your PR branch in order for the CI to pass.

@agalbachicar
Copy link
Contributor Author

And also here, thanks a lot for such a feedback, @mxgrey ! I'll review it with my peers and get back as soon as possible.

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.

4 participants