Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. class RobotControl
  4. {
  5. private Robot r;
  6. public static StringBuilder sb;
  7.  
  8. public RobotControl(Robot r)
  9. {
  10. this.r = r;
  11. if (Robot.assessment == true)
  12. {
  13.  
  14. r.speedUp(5);
  15. }
  16. }
  17.  
  18. public void control(int barHeights[], int blockHeights[]){ //B.H Arrays []
  19.  
  20. int h = 2; //B.H - I have declared some variables,that actually tells me the starting point of the actual robot. (How high is the robot when the program first starts, how far across the arm goes, how far down it goes to pick up object
  21. int w = 1;
  22. int d = 0;
  23. int i = 1;
  24. int currentBar = 0;
  25. int sourceHt = blockHeights[0] + blockHeights[1] + blockHeights[2] + blockHeights[3]; // B.H - To insert a break point, select the margin beside the line number (Little blue ball will be there if break point is active)
  26. // B.H - Line __ is how high it needs to go, it needs to go 12 high in order to pick up the top block/ they have hard coded it here as an example
  27. int targetCol1Ht = 0;
  28. int targetCol2Ht = 0;
  29. int blockHt = blockHeights[(blockHeights.length - i)];
  30. int clearence = 12;
  31. while (sourceHt > 0){
  32. while (h < clearence + 1)
  33. { // B.H - This bit of code is a loop, this will run this code more than once, code beside it will tell the program how many times to run... As long is less that 12 + 1 (so less than 13), i want it to go up
  34.  
  35. r.up();
  36.  
  37.  
  38. h++; // B.H - This adds 1 to the height, then itll repeat saying 3, moves up, then adds 1 to 4 untill it reaches 13
  39. }
  40. // B.H - once it hits 13, it drops out of the loop to the next code
  41.  
  42. int extendAmt = 10;
  43.  
  44. while (w < 10)
  45. {
  46.  
  47. r.extend(); //B.H - Next method is how far to move the arm across, so how many times it needs to move across to get to the pile of blocks stacked
  48. //Need: variable target height
  49. w++;
  50. }
  51.  
  52. while (h - d > sourceHt + 1)
  53. {
  54.  
  55. r.lower();
  56.  
  57.  
  58. d++;
  59. }
  60.  
  61.  
  62. r.pick();
  63.  
  64. sourceHt -= blockHt;
  65.  
  66. while (d > 0)
  67. {
  68. r.raise();
  69. d--;
  70. }
  71.  
  72. int contractAmt = 7;
  73. while (contractAmt - currentBar > 0)
  74. {
  75. r.contract();
  76. w--;
  77. contractAmt--;
  78. }
  79.  
  80. System.out.println(h);
  81. System.out.println(d);
  82. System.out.println(barHeights[0]);
  83.  
  84. while (h - 1 - d - blockHeights[0] - barHeights[0]> 0) //Change the blockHeights[0]<--- for the next few parts Error here: Work out actual height of block
  85. { //Include anoither variable that increments it
  86. r.lower();
  87. d++;
  88. }
  89.  
  90. r.drop();
  91. currentBar++;
  92. barHeights[currentBar] += blockHt;
  93.  
  94. while (d > 0)
  95. {
  96. r.raise();
  97. d--;
  98. }
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement