Joachim Schaeffer
/
Roboter
g
Fork of Roboter by
Revision 1:36bcf4659c1c, committed 2017-01-11
- Comitter:
- JoachimSch
- Date:
- Wed Jan 11 10:09:54 2017 +0000
- Parent:
- 0:d453d7554981
- Commit message:
- f?r dich
Changed in this revision
diff -r d453d7554981 -r 36bcf4659c1c Runden_Anzeigen.h --- a/Runden_Anzeigen.h Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -//LEDs ansteuern - #include "mbed.h" - #include "m3pi_ng.h" - #include "LED_ansteuern.h" - #include <sstream> - -class Runden_Anzeigen -{ - public: - LEDD A; //Klasseninstanz A - string str; //für die Umwandlung in String - stringstream s; //für die Umwandlung in stringstram - - const char * Runden (int Runden) - { - A.Runden_LED(Runden); - s << Runden; //Zahl hinzufügen, in Stringstram - str = s.str(); //stringstram in string umwandeln - const char * y = str.c_str(); //Wandelt String in const char* um - - str = ""; //Löscht str - s.str(""); //stringstream löschen - - return y; //Gibt die Rundenzahl als const char* ab - } - -}; \ No newline at end of file
diff -r d453d7554981 -r 36bcf4659c1c Runden_Anzeigen_cpp.h --- a/Runden_Anzeigen_cpp.h Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -//LEDs ansteuern - #include "mbed.h" - #include "m3pi_ng.h" - #include "LED_ansteuern.h" - #include <sstream> - -m3pi pi; - -int main() -{ - LEDD A; //Klasseninstanz A - int Runden=0; - string str; //für die Umwandlung in String - stringstream s; //für die Umwandlung in stringstram - - while (1) - { - A.Runden(Runden); - - s << Runden;// Zahl hinzufügen, in Stringstram - str = s.str(); //stringstram in string umwandeln - const char * y = str.c_str(); //Wandelt String in const char* um - - pi.printf(y); //Zeigt die Rundenzahl an - wait(0.5); - pi.cls(); - - str = ""; //Löscht str - s.str(""); //stringstream löschen - - Runden++; - } -} -//Ab 46? kommt die nächste Zeile -//je 8 Zeichenfelder \ No newline at end of file
diff -r d453d7554981 -r 36bcf4659c1c TEST.h --- a/TEST.h Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -// Drive the m3pi forward, turn left, back, turn right, at half speed for half a second - - #include "mbed.h" - #include "m3pi_ng.h" - - m3pi pi; - - int main() { - - wait(0.5); - pi.right_motor(0.5); - pi.left_motor(0.2); - wait(0.5); - pi.left_motor(0.5); - pi.right_motor(0.2); - wait(0.5); - - pi.stop(); - wait(0.5); - - int i=1, n=0; - while(n!=8) - { - pi.leds(i); - wait(0.2); - i=i*2; - n++; - } - - wait(1); - - i=1, n=0; - while(n!=8) - { - pi.leds(i); - wait(0.2); - i=i*2; - n++; - } - - pi.stop(); - wait(0.5); - - pi.right_motor(-0.5); - pi.left_motor(-0.2); - wait(0.5); - pi.left_motor(-0.5); - pi.right_motor(-0.2); - wait(0.5); - - - pi.stop(); - -}
diff -r d453d7554981 -r 36bcf4659c1c basic.h --- a/basic.h Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -#include "mbed.h" -#include "m3pi_ng.h" - -m3pi pi; - -int main() { - - // Parameters that affect the performance - float speed = 0.7; //geschw. - float correction = 0.5; //korrektur links, rechts - float threshold = 0.5; //schwelle, korrektur - - pi.locate(0,1); //vorgefertigte position, ausrichten - pi.printf("Runde: "); - - wait(2.0); - - pi.sensor_auto_calibrate(); - - while (1) { - - // -1.0 is far left, 1.0 is far right, 0.0 in the middle - float position_of_line = pi.line_position(); - - // Line is more than the threshold to the right, slow the left motor - if (position_of_line > threshold) { - pi.leftt_motor(speed); - pi.right_motor(speed-correction); - } - - // Line is more than 50% to the left, slow the right motor - else if (position_of_line < -threshold) { - pi.right_motor(speed); - pi.left_motor(speed-correction); - } - - // Line is in the middle - else { - pi.forward(speed); - } - } -} \ No newline at end of file
diff -r d453d7554981 -r 36bcf4659c1c basic2.h --- a/basic2.h Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -#include "mbed.h" -#include "m3pi_ng.h" - -m3pi m3pi; - -// Minimum and maximum motor speeds -#define MAX 1.0 -#define MIN 0 - -// PID terms -#define P_TERM 1 -#define I_TERM 0 -#define D_TERM 20 - -int main() { - - m3pi.locate(0,1); - m3pi.printf("Line PID"); - - wait(2.0); - - m3pi.sensor_auto_calibrate(); - - float right; - float left; - float current_pos_of_line = 0.0; - float previous_pos_of_line = 0.0; - float derivative,proportional,integral = 0; - float power; - float speed = MAX; - - while (1) { - - // Get the position of the line. - current_pos_of_line = m3pi.line_position(); - proportional = current_pos_of_line; - - // Compute the derivative - derivative = current_pos_of_line - previous_pos_of_line; - - // Compute the integral - integral += proportional; - - // Remember the last position. - previous_pos_of_line = current_pos_of_line; - - // Compute the power - power = (proportional * (P_TERM) ) + (integral*(I_TERM)) + (derivative*(D_TERM)) ; - - // Compute new speeds - right = speed+power; - left = speed-power; - - // limit checks - if (right < MIN) - right = MIN; - else if (right > MAX) - right = MAX; - - if (left < MIN) - left = MIN; - else if (left > MAX) - left = MAX; - - // set speed - m3pi.left_motor(left); - m3pi.right_motor(right); - - } -} \ No newline at end of file
diff -r d453d7554981 -r 36bcf4659c1c m3pi_ng.lib --- a/m3pi_ng.lib Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/users/ngoldin/code/m3pi_ng/#5589eef1f879
diff -r d453d7554981 -r 36bcf4659c1c main.cpp --- a/main.cpp Wed Jan 11 09:43:00 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -#include "mbed.h" -#include "m3pi_ng.h" -//#include "Umwandeln.h" -#include "LED.h" -m3pi pi; - - -int main() -{ - //umwandeln A; - LED B; - pi.sensor_auto_calibrate(); - int sensors[5]={}; - while (1){ - pi.calibrated_sensor(sensors); - if ((sensors[0]>400) && (sensors[4]>400)) - B.Blau_Blinken(2,0.2); - } -} -//0=weiß 1000=schwarz -/* -int main() -{ - - umwandeln A; - pi.sensor_auto_calibrate(); - int sensors[5]={}; - - - while (1) - { - pi.calibrated_sensor(sensors); - pi.printf(A.int_umwandeln(sensors[0])); - wait(0.1); - pi.cls(); - } - -} -*/ \ No newline at end of file