bio robot

Dependencies:   MPU6050-DMP QEI_hw mbed-rpc mbed

Fork of MPU6050_Example by Shundo Kishi

Committer:
amandaghassaei
Date:
Wed Dec 09 03:08:30 2015 +0000
Revision:
12:49813131dd15
Parent:
11:711d3c207e8c
Child:
14:d620415259b1
simple targeting;

Who changed what in which revision?

UserRevisionLine numberNew 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 5:c3d671959ef3 51 void openGripper2Wrapper(Arguments * input, Reply * output){
amandaghassaei 5:c3d671959ef3 52 comm.openGripper2(input, output);
amandaghassaei 5:c3d671959ef3 53 };
amandaghassaei 5:c3d671959ef3 54 RPCFunction OpenGripper2(&openGripper2Wrapper, "OpenGripper2");
amandaghassaei 5:c3d671959ef3 55 void closeGripper2Wrapper(Arguments * input, Reply * output){
amandaghassaei 5:c3d671959ef3 56 comm.closeGripper2(input, output);
amandaghassaei 5:c3d671959ef3 57 };
amandaghassaei 5:c3d671959ef3 58 RPCFunction CloseGripper2(&closeGripper2Wrapper, "CloseGripper2");
amandaghassaei 9:1d9b24d7ac77 59 void setSwingUpKWrapper(Arguments * input, Reply * output){
amandaghassaei 9:1d9b24d7ac77 60 comm.setSwingUpK(input, output);
amandaghassaei 5:c3d671959ef3 61 };
amandaghassaei 9:1d9b24d7ac77 62 RPCFunction SetSwingUpK(&setSwingUpKWrapper, "SetSwingUpK");
amandaghassaei 9:1d9b24d7ac77 63 void setSwingUpDWrapper(Arguments * input, Reply * output){
amandaghassaei 9:1d9b24d7ac77 64 comm.setSwingUpD(input, output);
amandaghassaei 9:1d9b24d7ac77 65 };
amandaghassaei 9:1d9b24d7ac77 66 RPCFunction SetSwingUpD(&setSwingUpDWrapper, "SetSwingUpD");
amandaghassaei 10:769cc457c3a4 67 void setCurrentPWrapper(Arguments * input, Reply * output){
amandaghassaei 10:769cc457c3a4 68 comm.setCurrentP(input, output);
amandaghassaei 10:769cc457c3a4 69 };
amandaghassaei 10:769cc457c3a4 70 RPCFunction SetCurrentP(&setCurrentPWrapper, "SetCurrentP");
amandaghassaei 10:769cc457c3a4 71 void setCurrentDWrapper(Arguments * input, Reply * output){
amandaghassaei 10:769cc457c3a4 72 comm.setCurrentD(input, output);
amandaghassaei 10:769cc457c3a4 73 };
amandaghassaei 10:769cc457c3a4 74 RPCFunction SetCurrentD(&setCurrentDWrapper, "SetCurrentD");
amandaghassaei 9:1d9b24d7ac77 75 void setTargetWrapper(Arguments * input, Reply * output){
amandaghassaei 5:c3d671959ef3 76 comm.setTarget(input, output);
amandaghassaei 5:c3d671959ef3 77 };
amandaghassaei 9:1d9b24d7ac77 78 RPCFunction SetTarget(&setTargetWrapper, "SetTarget");
amandaghassaei 11:711d3c207e8c 79 void setThetaWrapper(Arguments * input, Reply * output){
amandaghassaei 11:711d3c207e8c 80 comm.setTheta(input, output);
amandaghassaei 9:1d9b24d7ac77 81 };
amandaghassaei 11:711d3c207e8c 82 RPCFunction SetTheta(&setThetaWrapper, "SetTheta");
amandaghassaei 10:769cc457c3a4 83 void printGainsWrapper(Arguments * input, Reply * output){
amandaghassaei 10:769cc457c3a4 84 comm.printGains();
amandaghassaei 10:769cc457c3a4 85 };
amandaghassaei 10:769cc457c3a4 86 RPCFunction PrintGains(&printGainsWrapper, "PrintGains");
amandaghassaei 10:769cc457c3a4 87 void printPositionWrapper(Arguments * input, Reply * output){
amandaghassaei 10:769cc457c3a4 88 comm.printPosition();
amandaghassaei 10:769cc457c3a4 89 };
amandaghassaei 10:769cc457c3a4 90 RPCFunction PrintPosition(&printPositionWrapper, "PrintPosition");
amandaghassaei 5:c3d671959ef3 91
amandaghassaei 5:c3d671959ef3 92
amandaghassaei 5:c3d671959ef3 93
amandaghassaei 5:c3d671959ef3 94
syundo0730 0:8d2c753a96e7 95
amandaghassaei 10:769cc457c3a4 96