bio robot
Dependencies: MPU6050-DMP QEI_hw mbed-rpc mbed
Fork of MPU6050_Example by
main.cpp@17:8a0e647cf551, 2015-12-11 (annotated)
- Committer:
- amandaghassaei
- Date:
- Fri Dec 11 00:44:45 2015 +0000
- Revision:
- 17:8a0e647cf551
- Parent:
- 14:d620415259b1
- Child:
- 18:0cfe72d8a006
eod
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
amandaghassaei | 3:be5cf450436d | 1 | #include "mbed.h" |
amandaghassaei | 7:7efcd3bf3302 | 2 | #include "mbed_rpc.h" |
amandaghassaei | 2:17b18ea93551 | 3 | #include "Comm.h" |
amandaghassaei | 7:7efcd3bf3302 | 4 | #include "Controls.h" |
amandaghassaei | 3:be5cf450436d | 5 | |
amandaghassaei | 7:7efcd3bf3302 | 6 | Controls controls; |
amandaghassaei | 9:1d9b24d7ac77 | 7 | Comm comm(&controls); |
amandaghassaei | 9:1d9b24d7ac77 | 8 | |
amandaghassaei | 9:1d9b24d7ac77 | 9 | long serialCounter = 0; |
amandaghassaei | 9:1d9b24d7ac77 | 10 | |
amandaghassaei | 9:1d9b24d7ac77 | 11 | |
amandaghassaei | 10:769cc457c3a4 | 12 | Ticker controlsInterrupt; |
amandaghassaei | 10:769cc457c3a4 | 13 | |
syundo0730 | 0:8d2c753a96e7 | 14 | |
amandaghassaei | 6:12b6be801ad8 | 15 | int main() { |
amandaghassaei | 9:1d9b24d7ac77 | 16 | controls.setPC(comm.getPC()); |
amandaghassaei | 10:769cc457c3a4 | 17 | controls.setup(); |
amandaghassaei | 9:1d9b24d7ac77 | 18 | // comm.printPosition(); |
amandaghassaei | 11:711d3c207e8c | 19 | comm.printGains(); |
amandaghassaei | 10:769cc457c3a4 | 20 | |
amandaghassaei | 10:769cc457c3a4 | 21 | controlsInterrupt.attach_us(&controls, &Controls::loop, 1000); |
amandaghassaei | 10:769cc457c3a4 | 22 | |
amandaghassaei | 6:12b6be801ad8 | 23 | while(1) { |
amandaghassaei | 10:769cc457c3a4 | 24 | controls.updateIMUS(); |
amandaghassaei | 6:12b6be801ad8 | 25 | comm.check(); |
amandaghassaei | 11:711d3c207e8c | 26 | |
amandaghassaei | 11:711d3c207e8c | 27 | if (serialCounter++>100) { |
amandaghassaei | 11:711d3c207e8c | 28 | // comm.printPosition(); |
amandaghassaei | 10:769cc457c3a4 | 29 | // comm.getPC()->printf("%f\n", controls.getTheta1()); |
amandaghassaei | 10:769cc457c3a4 | 30 | // comm.getPC()->printf("%f", controls.motor.getPWM()); |
amandaghassaei | 9:1d9b24d7ac77 | 31 | serialCounter = 0; |
amandaghassaei | 12:49813131dd15 | 32 | // float z[4] = {1,2,0,0}; |
amandaghassaei | 12:49813131dd15 | 33 | // comm.getPC()->printf("%f\n",controls.target.getTheta2ForTarget(z)); |
amandaghassaei | 9:1d9b24d7ac77 | 34 | } |
amandaghassaei | 6:12b6be801ad8 | 35 | } |
amandaghassaei | 6:12b6be801ad8 | 36 | } |
amandaghassaei | 6:12b6be801ad8 | 37 | |
amandaghassaei | 6:12b6be801ad8 | 38 | |
amandaghassaei | 10:769cc457c3a4 | 39 | |
amandaghassaei | 10:769cc457c3a4 | 40 | |
amandaghassaei | 10:769cc457c3a4 | 41 | |
amandaghassaei | 6:12b6be801ad8 | 42 | //wrappers for comm stack |
amandaghassaei | 5:c3d671959ef3 | 43 | void openGripper1Wrapper(Arguments * input, Reply * output){ |
amandaghassaei | 5:c3d671959ef3 | 44 | comm.openGripper1(input, output); |
amandaghassaei | 5:c3d671959ef3 | 45 | }; |
amandaghassaei | 5:c3d671959ef3 | 46 | RPCFunction OpenGripper1(&openGripper1Wrapper, "OpenGripper1"); |
amandaghassaei | 5:c3d671959ef3 | 47 | void closeGripper1Wrapper(Arguments * input, Reply * output){ |
amandaghassaei | 5:c3d671959ef3 | 48 | comm.closeGripper1(input, output); |
amandaghassaei | 5:c3d671959ef3 | 49 | }; |
amandaghassaei | 5:c3d671959ef3 | 50 | RPCFunction CloseGripper1(&closeGripper1Wrapper, "CloseGripper1"); |
amandaghassaei | 17:8a0e647cf551 | 51 | |
amandaghassaei | 17:8a0e647cf551 | 52 | |
amandaghassaei | 5:c3d671959ef3 | 53 | void openGripper2Wrapper(Arguments * input, Reply * output){ |
amandaghassaei | 5:c3d671959ef3 | 54 | comm.openGripper2(input, output); |
amandaghassaei | 5:c3d671959ef3 | 55 | }; |
amandaghassaei | 5:c3d671959ef3 | 56 | RPCFunction OpenGripper2(&openGripper2Wrapper, "OpenGripper2"); |
amandaghassaei | 5:c3d671959ef3 | 57 | void closeGripper2Wrapper(Arguments * input, Reply * output){ |
amandaghassaei | 5:c3d671959ef3 | 58 | comm.closeGripper2(input, output); |
amandaghassaei | 5:c3d671959ef3 | 59 | }; |
amandaghassaei | 5:c3d671959ef3 | 60 | RPCFunction CloseGripper2(&closeGripper2Wrapper, "CloseGripper2"); |
amandaghassaei | 17:8a0e647cf551 | 61 | |
amandaghassaei | 17:8a0e647cf551 | 62 | |
amandaghassaei | 9:1d9b24d7ac77 | 63 | void setSwingUpKWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 9:1d9b24d7ac77 | 64 | comm.setSwingUpK(input, output); |
amandaghassaei | 5:c3d671959ef3 | 65 | }; |
amandaghassaei | 9:1d9b24d7ac77 | 66 | RPCFunction SetSwingUpK(&setSwingUpKWrapper, "SetSwingUpK"); |
amandaghassaei | 9:1d9b24d7ac77 | 67 | void setSwingUpDWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 9:1d9b24d7ac77 | 68 | comm.setSwingUpD(input, output); |
amandaghassaei | 9:1d9b24d7ac77 | 69 | }; |
amandaghassaei | 9:1d9b24d7ac77 | 70 | RPCFunction SetSwingUpD(&setSwingUpDWrapper, "SetSwingUpD"); |
amandaghassaei | 17:8a0e647cf551 | 71 | |
amandaghassaei | 17:8a0e647cf551 | 72 | |
amandaghassaei | 14:d620415259b1 | 73 | void setDesiredThetaPWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 14:d620415259b1 | 74 | comm.setDesiredThetaP(input, output); |
amandaghassaei | 10:769cc457c3a4 | 75 | }; |
amandaghassaei | 14:d620415259b1 | 76 | RPCFunction SetDesiredThetaP(&setDesiredThetaPWrapper, "SetDesiredThetaP"); |
amandaghassaei | 17:8a0e647cf551 | 77 | |
amandaghassaei | 17:8a0e647cf551 | 78 | |
amandaghassaei | 9:1d9b24d7ac77 | 79 | void setTargetWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 5:c3d671959ef3 | 80 | comm.setTarget(input, output); |
amandaghassaei | 5:c3d671959ef3 | 81 | }; |
amandaghassaei | 9:1d9b24d7ac77 | 82 | RPCFunction SetTarget(&setTargetWrapper, "SetTarget"); |
amandaghassaei | 17:8a0e647cf551 | 83 | |
amandaghassaei | 17:8a0e647cf551 | 84 | void setTargetingKWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 17:8a0e647cf551 | 85 | comm.setTargetingK(input, output); |
amandaghassaei | 17:8a0e647cf551 | 86 | }; |
amandaghassaei | 17:8a0e647cf551 | 87 | RPCFunction SetTargetingK(&setTargetingKWrapper, "SetTargetingK"); |
amandaghassaei | 17:8a0e647cf551 | 88 | void setTargetingDWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 17:8a0e647cf551 | 89 | comm.setTargetingD(input, output); |
amandaghassaei | 17:8a0e647cf551 | 90 | }; |
amandaghassaei | 17:8a0e647cf551 | 91 | RPCFunction SetTargetingD(&setTargetingDWrapper, "SetTargetingD"); |
amandaghassaei | 17:8a0e647cf551 | 92 | |
amandaghassaei | 17:8a0e647cf551 | 93 | |
amandaghassaei | 17:8a0e647cf551 | 94 | |
amandaghassaei | 17:8a0e647cf551 | 95 | |
amandaghassaei | 11:711d3c207e8c | 96 | void setThetaWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 11:711d3c207e8c | 97 | comm.setTheta(input, output); |
amandaghassaei | 9:1d9b24d7ac77 | 98 | }; |
amandaghassaei | 11:711d3c207e8c | 99 | RPCFunction SetTheta(&setThetaWrapper, "SetTheta"); |
amandaghassaei | 17:8a0e647cf551 | 100 | |
amandaghassaei | 17:8a0e647cf551 | 101 | |
amandaghassaei | 10:769cc457c3a4 | 102 | void printGainsWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 10:769cc457c3a4 | 103 | comm.printGains(); |
amandaghassaei | 10:769cc457c3a4 | 104 | }; |
amandaghassaei | 10:769cc457c3a4 | 105 | RPCFunction PrintGains(&printGainsWrapper, "PrintGains"); |
amandaghassaei | 10:769cc457c3a4 | 106 | void printPositionWrapper(Arguments * input, Reply * output){ |
amandaghassaei | 10:769cc457c3a4 | 107 | comm.printPosition(); |
amandaghassaei | 10:769cc457c3a4 | 108 | }; |
amandaghassaei | 10:769cc457c3a4 | 109 | RPCFunction PrintPosition(&printPositionWrapper, "PrintPosition"); |
amandaghassaei | 5:c3d671959ef3 | 110 | |
amandaghassaei | 5:c3d671959ef3 | 111 | |
amandaghassaei | 5:c3d671959ef3 | 112 | |
amandaghassaei | 5:c3d671959ef3 | 113 | |
syundo0730 | 0:8d2c753a96e7 | 114 | |
amandaghassaei | 10:769cc457c3a4 | 115 |