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

C++ SysIdRoutine Mechanism does not support null log function #6507

Closed
bhall-ctre opened this issue Apr 10, 2024 · 0 comments · Fixed by #6508
Closed

C++ SysIdRoutine Mechanism does not support null log function #6507

bhall-ctre opened this issue Apr 10, 2024 · 0 comments · Fixed by #6508

Comments

@bhall-ctre
Copy link
Contributor

bhall-ctre commented Apr 10, 2024

Describe the bug
In the Java version of SysIdRoutine.Mechanism, you can pass in null for the log parameter in the constructor. However, the C++ version is not a std::optional, and passing in nullptr or {} causes a crash.

To Reproduce
Steps to reproduce the behavior:

  1. Create a C++ SysIdRoutine where the log parameter for Mechanism is nullptr or {}
  2. Try running any SysIdRoutine command

Expected behavior
To match the behavior in Java, and following the convention of the Config class, the C++ Mechanism log parameter should be a std::optional, and passing in std::nullopt should not cause a crash. Alternatively, the Config class should be modified not to take a std::optional<std::function> recordState, and both should just accept a (potentially null) std::function.

The temporary workaround is to pass in an empty single-parameter lambda: [](auto) {}.

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 a pull request may close this issue.

1 participant