Add Camera Extrinsic Calibration Command#244
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a camera extrinsic calibration command to the VisionSubsystem and refactors the vision processing from a periodic() method to a command-based architecture. The calibration feature allows operators to automatically determine camera-to-robot transforms by collecting samples of camera-to-target transforms and averaging them.
Key changes:
- Refactored periodic vision processing into a command that is set as the default command
- Added cameraCalibrationCommand() that collects transform samples and computes camera extrinsics
- Moved and refactored preFilter() and postFilter() methods to the end of the class
- Removed TrigSolve-based pose estimation and related logging functionality
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I think this behavior could be achieved in a util class in the lib rather then in the subsystem as this isn't really specific to the subsystem impl |
|
Yes it is, its a command that relies on internal data the rest of the program shouldn't have access to. In my mind there's no good reason to separate this from the robot code when its actual wanted behavior is slightly different for each robot. |
|
What would be the behavior that is robot/season dependent? |
|
Which cameras are calibrated together, for example. It's far from impossible to put it in lib, I just don't see a good reason to. |
|
I think that its a lot of clutter for the vision subsystem for non-operations code (i.e. isn't used at comp or on the field), and it really is a utility in scope. Also I disagree with making the periodic into a command, it breaks the design pattern we have for everything else and can be risky depending on the command scheduler to handle it |
|
I can see the argument for why it would be in robot, but I agree that it makes more sense in lib. Ideally we run this once per season (if at all, assuming individual corrections are insufficient) and never touch it again |
Just to be clear, making the main functionality the default command is no different than periodic, they are both scheduled by the CommandScheduler in pretty much the same way. The difference is that it allows me to run other commands under other circumstances. We never need to schedule the default command, as it is automatically scheduled any time any other command that requires |
|
Is that better than "no?" |
|
yes, this sounds reasonable |
| / result.getTargets().size()) | ||
| * camera.getProperties().stdDevFactor(); | ||
| double linearStdDev = LINEAR_STDDEV_BASELINE * stdDevFactor; | ||
| double angularStdDev = ANGULAR_STDDEV_BASELINE * stdDevFactor; |
There was a problem hiding this comment.
this should probably be accomplished via a private helper method at some point because we will likely want to look into increasing the sophistication of this process
| continue; | ||
| } | ||
|
|
||
| result.getTargets().forEach(target -> { |
There was a problem hiding this comment.
do we want to enforce a tag ID filter to prevent a sloppy calibration scenario in which another tag is visible in frame?
| if (samples.get(camera).size() >= SAMPLE_COUNT) { | ||
| return; | ||
| } | ||
| samples.get(camera) |
There was a problem hiding this comment.
since we're calibrating from a known transform, do we want outlier rejection built into the sample collection to account for environmental fluctuations (blur, occlusion, etc.)? implemented via ambiguity cutoff. essentially translates to a Z-score rejection in statistics
| * @param robotCenterTransform known transform from the calibration target to the robot center | ||
| * when the robot is positioned at the calibration point | ||
| */ | ||
| public Command cameraCalibrationCommand( |
There was a problem hiding this comment.
hate to say it but if we end up using this multiple times per season and it lives here it may want to have a unit test for it
…hub.com/WHS-FRC-3467/W8-Library into 111-camera-translation-calibration-tool
Resolves #111