Botsingdetectie.java 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package boebot;
  2. public class Botsingdetectie{
  3. private IrDetectie irL;
  4. private IrDetectie irR;
  5. private VsDetectie vsR;
  6. private VsDetectie vsL;
  7. private boolean IrDetectL;
  8. private boolean IrDetectR;
  9. private boolean VsDetectL;
  10. private boolean VsDetectR;
  11. public Botsingdetectie(){
  12. //irL = new IrDetectie(8, 9);
  13. //irR = new IrDetectie(2, 0);
  14. vsL = new VsDetectie(14);
  15. vsR = new VsDetectie(15);
  16. }
  17. public boolean detectEdge(){
  18. // IrDetectL = irL.detect();
  19. // IrDetectR = irR.detect();
  20. // if(!IrDetectL || !IrDetectR){
  21. // return true;
  22. // }else{
  23. return false;
  24. }
  25. public int detectObject(){
  26. VsDetectL = vsL.detect();
  27. VsDetectR = vsR.detect();
  28. if(VsDetectL && VsDetectR)
  29. {
  30. return 3;
  31. }
  32. else if(VsDetectL)
  33. {
  34. return 1;
  35. }
  36. else if(VsDetectR)
  37. {
  38. return 2;
  39. }
  40. else {
  41. return 0;
  42. }
  43. }
  44. }