Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. private int skipper = 0;
  2.  
  3. private double[] apertureList = {90.0, 60.0, 40.0, 25.0, 15.0};
  4. private int aperture = 0;
  5. private int nextScannedAngle = 0;
  6. private int currentScanState = 0;
  7. // 0 - not found
  8. // 1 - found, scanning first half
  9. // 2 - found, scanning second half
  10. // 3 - found, last step middle
  11. // 4 - found, last step left
  12. // 5 - found, last step right
  13. private Scan pizzaScan() {
  14. skipper = (skipper + 1) % 5;
  15. if (skipper == 0) {
  16. setScanAperture(new Angle(apertureList[aperture], "d"));
  17. setScanDirection(new Angle(nextScannedAngle, "d"));
  18. return null;
  19. } else if (skipper == 1) {
  20. System.out.println(currentScanState + ", aperture: " + apertureList[aperture] + ", nextScannedAngle: " + nextScannedAngle % 360 + ", dtt: " + getLastScan().distanceToTarget);
  21. if (getLastScan().distanceToTarget != 0.0) {
  22. if (aperture < apertureList.length - 1) {
  23. currentScanState = 1;
  24. aperture++;
  25. nextScannedAngle -= apertureList[aperture - 1] / 4.0;
  26. } else if (aperture == apertureList.length - 1) {
  27. currentScanState = 3;
  28. }
  29. } else {
  30. if (currentScanState == 0) {
  31. nextScannedAngle += apertureList[aperture];
  32. } else if (currentScanState == 1) {
  33. nextScannedAngle += apertureList[aperture - 1] / 2.0;
  34. currentScanState = 2;
  35. } else if (currentScanState == 2) {
  36. currentScanState = 0;
  37. aperture = 0;
  38. } else if (currentScanState == 3) {
  39. currentScanState++;
  40. nextScannedAngle -= apertureList[aperture - 1];
  41. } else if (currentScanState == 4) {
  42. currentScanState++;
  43. nextScannedAngle += 2 * apertureList[aperture - 1];
  44. } else {
  45. currentScanState = 0;
  46. aperture = 0;
  47. }
  48. }
  49. } else {
  50. return null;
  51. }
  52.  
  53.  
  54. return aperture >= apertureList.length - 2 ? getLastScan() : null;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement