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 Micromouse by
Diff: Motion.cpp
- Revision:
- 2:f898adf2d817
- Parent:
- 1:2b5f79285a3e
- Child:
- 3:076dd7ec7eb4
--- a/Motion.cpp Thu Apr 19 06:19:43 2018 +0000 +++ b/Motion.cpp Thu Apr 19 11:26:51 2018 +0000 @@ -165,7 +165,120 @@ stop(); } - +/** + * Links abbiegen + */ +void Motion::turnL() { + + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(50.0f); + controller.setDesiredSpeedRight(-50.0f); + + while ((countsL - countsLOld) < 824 || (countsR - countsROld) > -824) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(17.0f); + controller.setDesiredSpeedRight(-83.0f); + + while ((countsL - countsLOld) < 440 || (countsR - countsROld) > -2148) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(50.0f); + controller.setDesiredSpeedRight(-50.0f); + + while ((countsL - countsLOld) < 824 || (countsR - countsROld) > -824) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } +} +/** + * Rechts abbiegen + */ +void Motion::turnR() { + + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(50.0f); + controller.setDesiredSpeedRight(-50.0f); + + while ((countsL - countsLOld) < 824 || (countsR - countsROld) > -824) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(83.0f); + controller.setDesiredSpeedRight(-17.0f); + + while ((countsL - countsLOld) < 2148 || (countsR - countsROld) > -440) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } + + controller.counterReset(); + countsLOld = counterLeft.read(); + countsROld = counterRight.read(); + countsL = counterLeft.read(); + countsR = counterRight.read(); + + controller.setDesiredSpeedLeft(50.0f); + controller.setDesiredSpeedRight(-50.0f); + + while ((countsL - countsLOld) < 824 || (countsR - countsROld) > -824) { + + countsL = counterLeft.read(); + countsR = counterRight.read(); + + if (enableMotorDriver == 0) {enableMotorDriver = 1;} + } +} /** * Motor Stop */