Peihsun Yeh
/
ECE4180FinalV4
CarlsenBot working
notes.h@0:cdd566529530, 2013-05-01 (annotated)
- Committer:
- pyeh9
- Date:
- Wed May 01 16:00:53 2013 +0000
- Revision:
- 0:cdd566529530
CarlsenBot Working commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pyeh9 | 0:cdd566529530 | 1 | /* |
pyeh9 | 0:cdd566529530 | 2 | while(motor_x1.ticks < pos){ |
pyeh9 | 0:cdd566529530 | 3 | spd = (((float)pos-(float)motor_x1.ticks))/pos; |
pyeh9 | 0:cdd566529530 | 4 | spd*=0.6; |
pyeh9 | 0:cdd566529530 | 5 | if(spd < 0.2) spd = 0.2 |
pyeh9 | 0:cdd566529530 | 6 | ; |
pyeh9 | 0:cdd566529530 | 7 | motor_x1.speed(spd); |
pyeh9 | 0:cdd566529530 | 8 | motor_x2.speed(spd); |
pyeh9 | 0:cdd566529530 | 9 | pc.printf("Ticks: %d, speed: %f\n", motor_x1.ticks, spd); |
pyeh9 | 0:cdd566529530 | 10 | wait(0.001); |
pyeh9 | 0:cdd566529530 | 11 | motor_x1.speed(0); |
pyeh9 | 0:cdd566529530 | 12 | } |
pyeh9 | 0:cdd566529530 | 13 | */ |
pyeh9 | 0:cdd566529530 | 14 | /* |
pyeh9 | 0:cdd566529530 | 15 | wait(0.5); |
pyeh9 | 0:cdd566529530 | 16 | while(motor_x1.ticks != pos){ |
pyeh9 | 0:cdd566529530 | 17 | if(motor_x1.ticks > pos) spd = -0.2; |
pyeh9 | 0:cdd566529530 | 18 | else spd = 0.2; |
pyeh9 | 0:cdd566529530 | 19 | motor_x1.speed(spd); |
pyeh9 | 0:cdd566529530 | 20 | motor_x2.speed(spd); |
pyeh9 | 0:cdd566529530 | 21 | pc.printf("Ticks: %d, speed: %f\n", motor_x1.ticks, spd); |
pyeh9 | 0:cdd566529530 | 22 | wait(0.01); |
pyeh9 | 0:cdd566529530 | 23 | motor_x1.speed(0); |
pyeh9 | 0:cdd566529530 | 24 | motor_x2.speed(0); |
pyeh9 | 0:cdd566529530 | 25 | } |
pyeh9 | 0:cdd566529530 | 26 | */ |
pyeh9 | 0:cdd566529530 | 27 | |
pyeh9 | 0:cdd566529530 | 28 | //something here |
pyeh9 | 0:cdd566529530 | 29 | |
pyeh9 | 0:cdd566529530 | 30 | /* |
pyeh9 | 0:cdd566529530 | 31 | //set coordinates given for testing (numOfSquares for testing only) |
pyeh9 | 0:cdd566529530 | 32 | numOfSquaresX = 1; |
pyeh9 | 0:cdd566529530 | 33 | numOfSquaresY = 1; |
pyeh9 | 0:cdd566529530 | 34 | |
pyeh9 | 0:cdd566529530 | 35 | //when actually recieveing data, change numOfSquares to srcX |
pyeh9 | 0:cdd566529530 | 36 | sourceX = numOfSquaresX * 210 - clawLocationX; |
pyeh9 | 0:cdd566529530 | 37 | sourceY = numOfSquaresY * 181 - clawLocationY; |
pyeh9 | 0:cdd566529530 | 38 | |
pyeh9 | 0:cdd566529530 | 39 | moveX(sourceX); |
pyeh9 | 0:cdd566529530 | 40 | moveY(sourceY); |
pyeh9 | 0:cdd566529530 | 41 | wait(1); |
pyeh9 | 0:cdd566529530 | 42 | claw = OPEN; |
pyeh9 | 0:cdd566529530 | 43 | wait(1); |
pyeh9 | 0:cdd566529530 | 44 | moveZ(0.49); |
pyeh9 | 0:cdd566529530 | 45 | claw = CLOSE; |
pyeh9 | 0:cdd566529530 | 46 | wait(1); |
pyeh9 | 0:cdd566529530 | 47 | moveZ(0.36); |
pyeh9 | 0:cdd566529530 | 48 | |
pyeh9 | 0:cdd566529530 | 49 | //need to set clawLocation here |
pyeh9 | 0:cdd566529530 | 50 | |
pyeh9 | 0:cdd566529530 | 51 | //set coordinates given for testing (numOfSquares for testing only) |
pyeh9 | 0:cdd566529530 | 52 | numOfSquaresX = 2; |
pyeh9 | 0:cdd566529530 | 53 | numOfSquaresY = 1; |
pyeh9 | 0:cdd566529530 | 54 | |
pyeh9 | 0:cdd566529530 | 55 | //when actually recieveing data, change numOfSquares to destX |
pyeh9 | 0:cdd566529530 | 56 | destinationX = numOfSquaresX * 210 - clawLocationX; |
pyeh9 | 0:cdd566529530 | 57 | destinationY = numOfSquaresY * 181 - clawLocationY; |
pyeh9 | 0:cdd566529530 | 58 | |
pyeh9 | 0:cdd566529530 | 59 | moveX(destinationX); |
pyeh9 | 0:cdd566529530 | 60 | moveY(destinationY); |
pyeh9 | 0:cdd566529530 | 61 | wait(1); |
pyeh9 | 0:cdd566529530 | 62 | moveZ(0.49); |
pyeh9 | 0:cdd566529530 | 63 | wait(1); |
pyeh9 | 0:cdd566529530 | 64 | claw = OPEN; |
pyeh9 | 0:cdd566529530 | 65 | wait(1); |
pyeh9 | 0:cdd566529530 | 66 | moveZ(0.36); |
pyeh9 | 0:cdd566529530 | 67 | */ |
pyeh9 | 0:cdd566529530 | 68 | //need to set clawLocation here again |
pyeh9 | 0:cdd566529530 | 69 | |
pyeh9 | 0:cdd566529530 | 70 | /* |
pyeh9 | 0:cdd566529530 | 71 | // test program (opens claw, picks up piece below, and moves to new destination) |
pyeh9 | 0:cdd566529530 | 72 | claw = OPEN; |
pyeh9 | 0:cdd566529530 | 73 | wait(1); |
pyeh9 | 0:cdd566529530 | 74 | moveZ(0.49); |
pyeh9 | 0:cdd566529530 | 75 | claw = CLOSE; |
pyeh9 | 0:cdd566529530 | 76 | wait(1); |
pyeh9 | 0:cdd566529530 | 77 | moveZ(0.36); |
pyeh9 | 0:cdd566529530 | 78 | moveX(210); //210 per one square of X |
pyeh9 | 0:cdd566529530 | 79 | moveY(181); //181 per one square of Y |
pyeh9 | 0:cdd566529530 | 80 | wait(1); |
pyeh9 | 0:cdd566529530 | 81 | moveZ(0.49); |
pyeh9 | 0:cdd566529530 | 82 | wait(1); |
pyeh9 | 0:cdd566529530 | 83 | claw = OPEN; |
pyeh9 | 0:cdd566529530 | 84 | wait(1); |
pyeh9 | 0:cdd566529530 | 85 | moveZ(0.36); |
pyeh9 | 0:cdd566529530 | 86 | */ |