![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Diff: main.cpp
- Revision:
- 15:9c5aaeda36dc
- Parent:
- 14:c638d4b9ee94
- Child:
- 16:52250d8d8fce
- Child:
- 18:10adf96f5416
diff -r c638d4b9ee94 -r 9c5aaeda36dc main.cpp --- a/main.cpp Sat Apr 06 15:43:47 2013 +0000 +++ b/main.cpp Sat Apr 06 20:57:54 2013 +0000 @@ -102,13 +102,16 @@ //ledphototransistortest(); //colourtest(); // Red SnR too low //cakesensortest(); - //feedbacktest(); + feedbacktest(); + + /* DigitalOut l1(LED1); Thread p(printingThread, NULL, osPriorityNormal, 2048); l1=1; Thread a(printingtestthread, NULL, osPriorityNormal, 1024); Thread b(printingtestthread2, NULL, osPriorityNormal, 1024); Thread::wait(osWaitForever); + */ } #include <cstdlib> @@ -145,14 +148,14 @@ Encoder Eright(P_ENC_RIGHT_A, P_ENC_RIGHT_B), Eleft(P_ENC_LEFT_A, P_ENC_LEFT_B); MainMotor mright(P_MOT_RIGHT_A, P_MOT_RIGHT_B), mleft(P_MOT_LEFT_A, P_MOT_LEFT_B); - float Pgain = -0.002; - float fwdspeed = -200/3.0f; + float Pgain = -0.005; + float fwdspeed = -400/3.0f; Timer timer; timer.start(); while(true){ float expecdist = fwdspeed * timer.read(); - float errleft = Eleft.getPoint() - (expecdist*1.07f); + float errleft = Eleft.getPoint() - (expecdist*1.05); float errright = Eright.getPoint() - expecdist; mleft(max(min(errleft*Pgain, 0.4f), -0.4f)); @@ -350,12 +353,12 @@ } void encodertest(){ - Encoder E1(p28, p27); - Encoder E2(p29, p30); + Encoder E1(P_ENC_LEFT_A, P_ENC_LEFT_B); + //Encoder E2(P_ENC_RIGHT_A, P_ENC_RIGHT_B); Serial pc(USBTX, USBRX); while(true){ wait(0.1); - pc.printf("Position is: %i \t %i \n\r", E1.getPoint(), E2.getPoint()); + pc.printf("Position is: %i \t %i \n\r", E1.getPoint(), 0);//E2.getPoint()); } }