8000 Change SimCameraProperties to enable chaining of setters by ancientstraits · Pull Request #1731 · PhotonVision/photonvision · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Change SimCameraProperties to enable chaining of setters #1731

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

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

ancientstraits
Copy link
Contributor

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
@ancientstraits
Copy link
Contributor Author

When could my pull request be reviewed?

@mcm001 mcm001 merged commit a5d007e into PhotonVision:main Jan 28, 2025
36 checks passed
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.

2 participants
0