正在查找标签…
视觉系统已开启。
正在加载相机图像…
正在加载实拍图像…
正在加载实拍图像…
正在加载图像帧…
// PhotonLib:每台相机使用一个位姿估计器
PhotonCamera camera = new PhotonCamera("front");
PhotonPoseEstimator estimator = new PhotonPoseEstimator(
AprilTagFieldLayout.loadField(AprilTagFields.kDefaultField), robotToCamera);
// 每个控制周期执行
for (var result : camera.getAllUnreadResults()) {
var est = estimator.estimateCoprocMultiTagPose(result);
if (est.isEmpty()) est = estimator.estimateLowestAmbiguityPose(result);
est.ifPresent(e -> {
int n = e.targetsUsed.size();
double d = e.targetsUsed.stream()
.mapToDouble(t -> t.getBestCameraToTarget().getTranslation().getNorm())
.average().orElse(10);
double xy = 0.01 * d * d / n;
poseEstimator.addVisionMeasurement(
e.estimatedPose.toPose2d(), e.timestampSeconds, VecBuilder.fill(xy, xy, 9999999));
});
}// LimelightHelpers:使用 MegaTag2
// 每个控制周期先发送陀螺仪航向角(单位:度),再读取位姿
LimelightHelpers.SetRobotOrientation("limelight",
poseEstimator.getEstimatedPosition().getRotation().getDegrees(), 0, 0, 0, 0, 0);
LimelightHelpers.PoseEstimate mt2 =
LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2("limelight");
if (mt2 != null && mt2.tagCount > 0 && Math.abs(gyroRateDegPerSec) < 360) {
double xy = 0.01 * mt2.avgTagDist * mt2.avgTagDist / mt2.tagCount;
poseEstimator.addVisionMeasurement(mt2.pose, mt2.timestampSeconds, VecBuilder.fill(xy, xy, 9999999));
}1. 为什么机器人不能在整场比赛中只靠轮式里程计定位?
2. 图像中标签的每个方格宽约 1.5 个像素,会发生什么?
3. 机器人停稳时能看到标签,高速行驶时却会丢失。首先应调整哪项相机设置?
4. 用于 AprilTag 检测的相机为什么常用全局快门?
5. 相机标定后,你又重新调整了镜头焦点。接下来应该怎么做?
6. 为什么用画面中的两个或更多标签估计位姿,比只用一个标签好?
7. 在位姿求解中使用陀螺仪航向(MegaTag2 或约束求解),可以解决什么问题?
8. 向 addVisionMeasurement 提交每个视觉位姿时,还应提供什么?
9. 即使机器人静止、标签也很近,检测仍时有时无。首先应该怎么做?