Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int skipper = 0;
- private double[] apertureList = {90.0, 60.0, 40.0, 25.0, 15.0};
- private int aperture = 0;
- private int nextScannedAngle = 0;
- private int currentScanState = 0;
- // 0 - not found
- // 1 - found, scanning first half
- // 2 - found, scanning second half
- // 3 - found, last step middle
- // 4 - found, last step left
- // 5 - found, last step right
- private Scan pizzaScan() {
- skipper = (skipper + 1) % 5;
- if (skipper == 0) {
- setScanAperture(new Angle(apertureList[aperture], "d"));
- setScanDirection(new Angle(nextScannedAngle, "d"));
- return null;
- } else if (skipper == 1) {
- System.out.println(currentScanState + ", aperture: " + apertureList[aperture] + ", nextScannedAngle: " + nextScannedAngle % 360 + ", dtt: " + getLastScan().distanceToTarget);
- if (getLastScan().distanceToTarget != 0.0) {
- if (aperture < apertureList.length - 1) {
- currentScanState = 1;
- aperture++;
- nextScannedAngle -= apertureList[aperture - 1] / 4.0;
- } else if (aperture == apertureList.length - 1) {
- currentScanState = 3;
- }
- } else {
- if (currentScanState == 0) {
- nextScannedAngle += apertureList[aperture];
- } else if (currentScanState == 1) {
- nextScannedAngle += apertureList[aperture - 1] / 2.0;
- currentScanState = 2;
- } else if (currentScanState == 2) {
- currentScanState = 0;
- aperture = 0;
- } else if (currentScanState == 3) {
- currentScanState++;
- nextScannedAngle -= apertureList[aperture - 1];
- } else if (currentScanState == 4) {
- currentScanState++;
- nextScannedAngle += 2 * apertureList[aperture - 1];
- } else {
- currentScanState = 0;
- aperture = 0;
- }
- }
- } else {
- return null;
- }
- return aperture >= apertureList.length - 2 ? getLastScan() : null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement