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 Roboshark_V7 by
Diff: Fahren.cpp
- Revision:
- 7:862d80e0ea2d
- Parent:
- 6:7bbcdd07bc2d
- Child:
- 8:d0a27278c108
diff -r 7bbcdd07bc2d -r 862d80e0ea2d Fahren.cpp
--- a/Fahren.cpp Thu May 03 19:36:16 2018 +0000
+++ b/Fahren.cpp Fri May 04 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/*Roboshark V4
+/*Roboshark V6
Fahren.cpp
Erstellt: J. Blunschi
geändert: V.Ahlers
@@ -12,11 +12,11 @@
using namespace std;
-const float Fahren :: PERIOD = 0.2f;
+const float Fahren :: PERIOD = 0.8f;
//Konstruktor
-Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight, Regler& regler):
- controller(controller), counterLeft(counterLeft), counterRight(counterRight), regler(regler){
+Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight, Regler& regler, int reglerEin):
+ controller(controller), counterLeft(counterLeft), counterRight(counterRight), regler(regler), reglerEin(reglerEin){
SpeedR = 50;
SpeedL = 50;
@@ -27,16 +27,22 @@
Fahren::~Fahren() {
ticker.detach();
}
+
+
//Korrigierte Geschwindigkeit aus der Klasse Regler aufrufen
void Fahren::getSpeed(){
- SpeedR = regler.get_SpeedR();
- SpeedL = regler.get_SpeedL();
+ if(reglerEin == 1){
+ SpeedR = regler.getSpeedR();
+ SpeedL = regler.getSpeedL();
+ }else {SpeedR = 50;
+ SpeedL = 50;
+ }
//printf("SpeedR in F = %f\n",SpeedR);
//printf("SpeedL in F = %f\n",SpeedL);
}
-
+
//Implementation der Methode geradeaus fahren ungeregelt
void Fahren::geradeausU(){
@@ -49,16 +55,16 @@
wegLinks = 1773;
//Geschwindigkeit
- speedRight = 50;
- speedLeft = 50;
+ //speedRight = 50;
+ //speedLeft = 50;
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
stopLeft = false;
//Drehrichtung der Motoren
- controller.setDesiredSpeedRight(speedRight);
- controller.setDesiredSpeedLeft(-(speedLeft));
+ controller.setDesiredSpeedRight(SpeedR);
+ controller.setDesiredSpeedLeft(-(SpeedL));
while(1){
@@ -101,8 +107,7 @@
//speedRight = 50;//SpeedR
//speedLeft = 50;//SpeedL
- //printf("SpeedR in F2= %f\n",SpeedR);
- //printf("SpeedL in F2= %f\n",SpeedL);
+
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
@@ -111,7 +116,8 @@
//Drehrichtung der Motoren
controller.setDesiredSpeedRight(SpeedR);
controller.setDesiredSpeedLeft(-(SpeedL));
-
+ printf("SpeedR in F2= %f\n",SpeedR);
+ printf("SpeedL in F2= %f\n",SpeedL);
while(1){
@@ -146,21 +152,22 @@
initialClicksLeft = counterLeft.read();
//Anzahl Clicks die der Encoder zählen soll
- wegRechts = 872;
- wegLinks = 872;
+ wegRechts = 868;
+ wegLinks = 868;
//Geschwindigkeit
- speedRight = 50;
- speedLeft = 50;
+ //speedRight = 50;
+ //speedLeft = 50;
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
stopLeft = false;
//Drehrichtung der Motoren
- controller.setDesiredSpeedRight((speedRight));
- controller.setDesiredSpeedLeft((speedLeft));
-
+ controller.setDesiredSpeedRight((SpeedR));
+ controller.setDesiredSpeedLeft((SpeedL));
+ //printf("SpeedR in F = %f\n",SpeedR);
+ //printf("SpeedL in F = %f\n",SpeedL);
while(1){
// printf("Encoderrechts %d \n\r", counterRight.read()); //Debugging Zweck (Putty benutzen!)
@@ -196,20 +203,20 @@
initialClicksLeft = counterLeft.read();
//Anzahl Clicks die der Encoder zählen soll
- wegRechts = 1755;
- wegLinks = 1755;
+ wegRechts = 1752;
+ wegLinks = 1752;
//Geschwindigkeit
- speedRight = 50;
- speedLeft = 50;
+ //speedRight = 50;
+ //speedLeft = 50;
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
stopLeft = false;
//Drehrichtung der Motoren
- controller.setDesiredSpeedRight((speedRight));
- controller.setDesiredSpeedLeft((speedLeft));
+ controller.setDesiredSpeedRight((SpeedR));
+ controller.setDesiredSpeedLeft((SpeedL));
while(1){
@@ -249,16 +256,16 @@
wegLinks = 878;
//Geschwindigkeit
- speedRight = 50;
- speedLeft = 50;
+ //speedRight = 50;
+ //speedLeft = 50;
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
stopLeft = false;
//Drehrichtung der Motoren
- controller.setDesiredSpeedRight((-speedRight));
- controller.setDesiredSpeedLeft((-speedLeft));
+ controller.setDesiredSpeedRight((-SpeedR));
+ controller.setDesiredSpeedLeft((-SpeedL));
while(1){
@@ -298,16 +305,16 @@
wegLinks = 7050;
//Geschwindigkeit
- speedRight = 80;
- speedLeft = 80;
+ //speedRight = 80;
+ //speedLeft = 80;
//Zustand, dass der Roboter nicht gestoppt hat
stopRight = false;
stopLeft = false;
//Drehrichtung der Motoren
- controller.setDesiredSpeedRight((speedRight));
- controller.setDesiredSpeedLeft((speedLeft));
+ controller.setDesiredSpeedRight((SpeedR));
+ controller.setDesiredSpeedLeft((SpeedR));
while(1){
