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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 11:ad99b62b119f
- Parent:
- 10:bb350e855c59
- Child:
- 12:09932ddcb089
--- a/main.cpp Sat Jun 08 00:25:09 2019 +0000 +++ b/main.cpp Sat Jun 08 00:28:55 2019 +0000 @@ -18,12 +18,6 @@ DigitalOut led2 (PD_2); - -int etatmvt = 00; -int sens = 1, nbiter = 0, nbCC, nbNM; -double pos = 0.5; -T_pixyCCBloc CCBuf; -T_pixyNMBloc NMBuf; double x, y, theta, vG, vD; @@ -92,8 +86,6 @@ main () { - - pc.printf ("\n\rinit\n"); motor.resetPosition(); @@ -114,75 +106,4 @@ movement_deceleration(1300, -30); wait(0.5); } - - while (1) { - motor.getPosition (&x,&y, &theta); - motor.getSpeed (&vG, &vD); - - pc.printf ("\rEtape = %d : x = %5.1lf, y = %5.1lf, theta = %5.1lf - speedG = %5.1lf, speedD = %5.1lf\n", etatmvt, x, y, 180*theta/PI, vG, vD); - - switch (etatmvt) { - case 0 : - // On avance de 50cm (coordonnés X = 500, Y = 0) - motor.setSpeed (NSpeed,NSpeed); - if (x > 300) { - etatmvt = 1; - } - break; - case 1 : - // On tourne à droite de 90° (sens antitrigo => négatif) => Angle = -PI/2 - motor.setSpeed (NSpeed,-NSpeed); - if (theta < (-PI/2.0)) { - etatmvt = 2; - } - break; - case 2 : - // On avance de 50cm (coordonnés X = 500, Y = -500) - motor.setSpeed (NSpeed,NSpeed); - if (y < -300) { - etatmvt = 3; - } - break; - case 3 : - // On tourne à droite de 90° (sens antitrigo => négatif) => Angle = -PI (Attention comme -PI = +PI, on teste le rebouclage) - motor.setSpeed (NSpeed,-NSpeed); - if (theta > 0) { - etatmvt = 4; - } - break; - case 4 : - // On avance de 50cm (coordonnés X = 0, Y = -500) - motor.setSpeed (NSpeed,NSpeed); - if (x < 0) { - etatmvt = 5; - } - break; - case 5 : - // On tourne à droite de 90° (sens antitrigo => négatif) => Angle = PI/2 - motor.setSpeed (NSpeed,-NSpeed); - if (theta < (PI/2.0)) { - etatmvt = 6; - } - break; - case 6 : - // On avance de 50cm (coordonnés X = 0, Y = 0) - motor.setSpeed (NSpeed,NSpeed); - if (y > 0) { - etatmvt = 7; - } - break; - case 7 : - // On tourne à droite de 90° (sens antitrigo => négatif) => Angle = 0 - motor.setSpeed (NSpeed,-NSpeed); - if (theta < 0) { - etatmvt = 0; - } - break; - } - - pc.printf ("\n\n"); - led1 = !led1; - led2 = !led2; - wait (1); - } } \ No newline at end of file