Botsingdetectie.java 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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(7);
  15. vsR = new VsDetectie(5);
  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. }
  26. public int detectObject(){
  27. VsDetectL = vsL.detect();
  28. VsDetectR = vsR.detect();
  29. if(VsDetectL && VsDetectR)
  30. {
  31. return 3;
  32. }
  33. else if(VsDetectL)
  34. {
  35. return 1;
  36. }
  37. else if(VsDetectR)
  38. {
  39. return 2;
  40. }
  41. else {
  42. return 0;
  43. }
  44. }
  45. }