Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MM_rat_Assignment4 by
Diff: header.h
- Revision:
- 3:4e34437daef4
- Parent:
- 2:7da65637e512
- Child:
- 6:ce498700a28c
diff -r 7da65637e512 -r 4e34437daef4 header.h
--- a/header.h Wed Nov 22 01:40:27 2017 +0000
+++ b/header.h Mon Nov 27 17:33:34 2017 +0000
@@ -29,8 +29,8 @@
Serial pc(SERIAL_TX, SERIAL_RX);
QEI LeftEncoder(lfront, lback, NC, 4096, QEI::X4_ENCODING);
QEI RightEncoder(rfront, rback, NC, 4096, QEI::X4_ENCODING);
-const float rbase = 0.2f;
-const float lbase = 0.25f;
+const float rbase = 0.14f;
+const float lbase = 0.15f;
const float WALL_IR_L = 0.74f;
const float WALL_IR_R = 0.74f;
const float WALL_IR_FL = 0.74f;
@@ -107,31 +107,35 @@
void turn_right(){
int l_init = LeftEncoder.getPulses();
pc.printf("l_init %d \n", l_init);
- while((LeftEncoder.getPulses() - l_init) < 3000){
+ while((LeftEncoder.getPulses() - l_init) < 166){
lpwmb = 0.0f;
rpwmf = 0.0f;
lpwmf = lbase;
rpwmb = rbase;
- pc.printf("LeftEncoder: %d \n", LeftEncoder.getPulses());
- pc.printf("lEncoderDifference %f \n", LeftEncoder.getPulses() - l_init);
+ //pc.printf("LeftEncoder: %d \n", LeftEncoder.getPulses());
+ // pc.printf("lEncoderDifference %f \n", LeftEncoder.getPulses() - l_init);
}
//lpwmb = 0.0f;
//rpwmf = 0.0f;
- //lpwmf = 0.0f;
- //rpwmb = 0.0f;
+ lpwmf = 0.0f;
+ rpwmb = 0.0f;
+ wait(1.0);
}
void turn_left(){
int r_init = RightEncoder.getPulses();
pc.printf("r_init %d \n", r_init);
- while((RightEncoder.getPulses() - r_init) < 2000){
+ while((RightEncoder.getPulses() - r_init) < 150){
lpwmf = 0.0f;
rpwmb = 0.0f;
lpwmb = lbase;
rpwmf = rbase;
- pc.printf("RightEncoder: %d \n", RightEncoder.getPulses());
- pc.printf("rEncoderDifference %f: \n", RightEncoder.getPulses()-r_init);
+ // pc.printf("RightEncoder: %d \n", RightEncoder.getPulses());
+ //pc.printf("rEncoderDifference %f: \n", RightEncoder.getPulses()-r_init);
}
+ lpwmb = 0.0f;
+ rpwmf = 0.0f;
+ wait( 1.0);
}
void ProcessIR(float dt, pid& IR_lman, float& lspeed, float& rspeed){
