Advertisement
xDefo

programma 15.22

May 2nd, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. void closeClaw(){
  2. moveMotorTarget(claw,claw_PositionClose,-claw_Velocity);
  3. sleep(500);
  4. }
  5. void liftClaw(){
  6. moveMotorTarget(clawLifter,clawLifter_PositionUp,clawLifter_Velocity);
  7. sleep(500);
  8. }
  9. void fallClaw(){
  10. moveMotorTarget(clawLifter,clawLifter_PositionDown,-clawLifter_Velocity);
  11. sleep(500);
  12. }
  13. void inizialize(){ //alza la pinza e la apre
  14. liftClaw();
  15. openClaw();
  16. }
  17. void liftObject(){
  18. movement(0,0);
  19. fallClaw();
  20. closeClaw();
  21. //liftClaw();
  22.  
  23. }
  24. void releaseObject(){
  25. movement(0,0);
  26. fallClaw();
  27. openClaw();
  28. liftClaw();
  29. }
  30. void turn( char a){
  31. resetGyro(gyroscope);
  32. switch (a)
  33. {
  34. case 'L':
  35. resetGyro(gyroscope);
  36. while (getGyroDegrees(gyroscope)<89)
  37. {
  38. motor[motorA]=10;
  39. motor[motorB]=-10;
  40. wait1Msec(1);
  41. }
  42. break;
  43. case 'R' :
  44. resetGyro(gyroscope);
  45. while (getGyroDegrees(gyroscope)>-89 )
  46. {
  47. motor[motorA]=-10;
  48. motor[motorB]=10;
  49. wait1Msec(1);
  50. }
  51. break;
  52.  
  53. }
  54. }
  55. void dropObject(){
  56. movement(-10,-10);
  57. sleep(500);
  58. turn('R');
  59. while(!objectDetected(Object_distance))
  60. {
  61. moveForward(10);
  62. }
  63. movement(0,0);
  64. openClaw();
  65. }
  66. void routine()// Funzione cerca oggetto è afferra
  67. {
  68. while(!objectDetectedLeft(20)) //Mentre il LeftSensor non rileva oggetti va avanti
  69. {
  70. movement(moveforwardVelocity,moveforwardVelocity);
  71. }
  72. movement(0,0);//spegnimento motori
  73. turn('L');//gira a sinistra di 90°
  74. movement(0,0);//spegnimento motori
  75. while(!objectDetectedFront(Object_distance))//Mentre la distanza è maggiore di Object_distance va avanti
  76. {
  77. movement(10,10);
  78. if(objectDetected(Object_distance))
  79. {
  80. liftObject();
  81. }
  82. }
  83. }
  84. void Program(){
  85.  
  86. inizialize();
  87. routine();
  88.  
  89.  
  90.  
  91. //dropObject();
  92.  
  93. }
  94.  
  95. task main(){
  96. Program();
  97. //closeClaw();
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement