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

Create a timer that does not get triggered as soon as it is initialized. #1980

Closed
Voldivh opened this issue Aug 3, 2022 · 2 comments
Closed
Assignees

Comments

@Voldivh
Copy link
Contributor

Voldivh commented Aug 3, 2022

Feature request

Feature description

Create a timer that does not get's triggered at the moment of initialization. There are several ways to create a timer which executes periodically a callback, I would like to have some control over when the timer starts the countdown. At the moment, the workaround is to create the timer, then cancel it and reset it at the moment I would like it to begin, but, in the time between the timer is created and canceled, the callback may be executed.

Implementation considerations

A way I thought for this feature is to add another argument to the GenericTimer class such as start_on_initialization, this argument can be used as a flag in order to start or not the timer. We could give the argument a default value of true that way, all the implementations so far would't have to be modified and the users could choose the behavior that works best for the application. In order to start the clock in the cases where the argument is false, it is possible to use the reset function and set the flag to false or create a new function start() that modifies the flag and starts the clock.

@Voldivh
Copy link
Contributor Author

Voldivh commented Aug 10, 2022

An implementation example that solves this issue can be found in the following forks:

The solution presented before modifies the rcl_timer_init arguments implementing an autostart flag. This is later used by the rclcpp API to give access to the user to select if the timer will start on initialization or not.

@fujitatomoya
Copy link
Collaborator

I will go ahead to close this since #2005 has been merged.

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

No branches or pull requests

3 participants