PID Test
Dependencies: AVEncoder mbed-src-AV
Diff: main.cpp
- Revision:
- 7:b866e3aae05f
- Parent:
- 6:61b503990cd6
- Child:
- 8:03e5c3aaa9c9
--- a/main.cpp Thu Dec 03 01:26:44 2015 +0000 +++ b/main.cpp Fri Dec 04 02:51:37 2015 +0000 @@ -66,11 +66,21 @@ const float enco_propo = 6; const float enco_integ = 10;//1; -const float enco_deriv =800;//.0002; +const float enco_deriv = 1000;//.0002; const float spin_enco_weight = 1; const float spin_gyro_weight = 1 - spin_enco_weight; +const float base_RS = 0.2; +const float base_LS = 0.1; +const float base_RF = 0.002; +const float base_LF = 0.15; + +const float thresh_LF = 0.25; +const float thresh_RF = 0.0045; // TODO: CAUTION USING THIS ALONE. +// +//const float + const float frontWall = 0.07; //need to calibrate this threshold to a value where mouse can stop in time const float open_left = 0.20; const float open_right = 0.17; @@ -290,7 +300,7 @@ eLF = 1; float left = rLF.read(); eLF = 0; - if(left > frontWall || right > frontWall) + if(left > thresh_LF || right > thresh_RF ) { mouse_state = STOPPED; wall_in_front = 1; //handler for this condition sets back to zero @@ -432,13 +442,25 @@ // // pc.printf("left pulss %f, right pulses %f \r\n", l_enco.getPulses(), r_enco.getPulses()); // //wait(1); - /*eLS = 1; - eRS = 1; + //wait(1); + /*eRS = 1; + wait_us(50); float right_side = rRS.read(); + eRS = 0; + eLS = 1; + wait_us(50); float left_side = rLS.read(); - pc.printf("right side IR %f, left side IR %f \r\n", right_side, left_side); eLS = 0; - eRS = 0;*/ + eRF = 1; + wait_us(50); + float right_front = rRF.read(); + eRF = 0; + eLF = 1; + wait_us(50); + float left_front = rLF.read(); + eLF = 0; + pc.printf("right side: %f, left side: %f right_front: %f, left_front: %f \r\n", right_side, left_side, right_front, left_front); + wait(1);*/ } // pc.printf("left pulses %d, right pulses %d \r\n", l_enco.getPulses(), r_enco.getPulses()); //encoder testing //wait(1);