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
Fork of TestRegler by
Diff: Fahren.cpp
- Revision:
- 7:b2a16b1cf487
- Parent:
- 6:a4b745625dbe
- Child:
- 8:d7dfee648545
--- a/Fahren.cpp Mon Apr 30 13:22:32 2018 +0000
+++ b/Fahren.cpp Mon Apr 30 22:11:38 2018 +0000
@@ -1,16 +1,36 @@
#include "Fahren.h"
#include <mbed.h>
+#include "Regler.h"
+#include "Fahren.h"
+using namespace std;
+
+const float Fahren :: PERIOD = 2.0f;
+
//Konstruktor
-Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight, float SpeedR, float SpeedL):
- controller(controller), counterLeft(counterLeft), counterRight(counterRight), SpeedR(SpeedR), SpeedL(SpeedL)
+Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight):
+ controller(controller), counterLeft(counterLeft), counterRight(counterRight), regler(regler){
-{}
+ SpeedR = 0;
+ SpeedL = 0;
+ ticker.attach(callback(this, &Fahren::getSpeed), PERIOD);
+}
+
//Dekonstruktor
-Fahren::~Fahren() {}
+Fahren::~Fahren() {
+ ticker.detach();
+ }
+void Fahren::getSpeed(){
+ SpeedR = regler.get_SpeedR();
+ SpeedL = regler.get_SpeedL();
+
+ printf("SpeedR in F = %f\n",SpeedR);
+ printf("SpeedL in F = %f\n",SpeedL);
+}
+
//Implementation der Methode geradeaus fahren ungeregelt
void Fahren::geradeausU(){
@@ -73,8 +93,8 @@
wegLinks = 1767;
//Geschwindigkeit
- speedRight = SpeedR; // SpeedR
- speedLeft = SpeedL; // SpeedL
+ speedRight = 20; // SpeedR
+ speedLeft = 20; // SpeedL
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
