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

Change SimCameraProperties to enable chaining of setters #1731

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ancientstraits
Copy link

With this change, the setters of SimCameraProperties return that SimCameraProperties object, enabling chaining. This means that instead of doing:

SimCameraProperties camProps = new SimCameraProperties();
camProps.setCalibration(640, 480, Rotation2d.fromDegrees(100));
camProps.setCalibError(0.25, 0.08);
camProps.setFPS(45);
camProps.setAvgLatencyMs(25);
camProps.setLatencyStdDevMs(5);

We can do:

SimCameraProperties camProps = new SimCameraProperties()
    .setCalibration(640, 480, Rotation2d.fromDegrees(100))
    .setCalibError(0.25, 0.08).setFPS(45)
    .setAvgLatencyMs(25).setLatencyStdDevMs(5);

And this does not disrupt the code for people who are doing it the first way, so doing it both ways is easy. The changes to the code are very simple, as they only make the setters return this;, and change their return type from void to SimCameraProperties.

@ancientstraits ancientstraits requested a review from a team as a code owner January 15, 2025 15:21
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.

1 participant