[RST-10642] Allow the optimizer to remain disabled at startup #374
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of automatically starting all of the plugins during construction, we should allow the optimizer to remain in the offline state until someone calls
start()
. Therobot_localization
package supported this feature with adisabled_at_startup
flag. This PR only affects the operation of the fixed-lag smoother. The batch optimizer is missing most of this functionality.Note: There is a subtle API change here. The base Optimizer class no longer starts the plugins during construction. This PR patches the BatchOptimizer is start the plugins during its constructor instead. But if there exists a 3rd party optimizer derived from the base Optimizer class, that 3rd party class will potentially break. I considered placing the plugin startup check inside the base Optimizer class. That would prevent this breakage and it would mean both the Fixed-lag Smoother and Batch Optimizer would benefit from the
disabled_at_startup
flag. However, I feel this reduces the flexibility of the derived Optimizer classes. Allowing the derived classes to have control over when the plugins are started and stopped feels better. Derived classes can implement additional logic and bookkeeping, handle any locks required, etc at the same time the plugins change state.But feel free to disagree with me.