Die Wahrscheinlichkeit dass der Asuro die Linie findet ist mir aber zu gering. und wenn er in einem ~90° Winkel auf die Linie zukommt wird er sicherlich nicht auf der Linie weiterfahren.
Habe nun mal LineData mit eingebaut. Auch dass sich die StatusLED farbe ändert. Aber noch nichteinmal die Farbe ändert sich.
Code:
#include "asuro.h"
#include "math.h"
int main(void)
{
double const a=1.5;
double time;
double tan;
double time1;
double time2;
double v;
int arc;
int x;
double arc2;
unsigned int data[2];
unsigned char tmp[2] = {OFF,OFF};
Init();
while(1)
{
MotorDir(FWD,FWD);
MotorSpeed(120,120);
v = 120/818;
LineData(data);
if (data[0] > 400) {
tmp[0] = ON;
time1 = Gettime();
StatusLED(RED);
}
else{}
if (data[1] > 400) {
tmp[1] = ON;
time1 = Gettime();
StatusLED(RED);
}
else{}
while(tmp[0]==ON)
{
LineData(data);
if (data[1] > 400)
tmp[1] = ON;
else{}
if(tmp[1]==ON)
{ StatusLED(YELLOW);
time2 = Gettime();
time = (time2 - time1)/1000;
tan=a/(v*time);
arc2 = atan(tan) * 180 / M_PIl;
arc = (int)arc2;
MotorDir(BREAK,BREAK);
MotorSpeed(0,0);
Turn (arc, v);
tmp[1] = OFF;
tmp[0] = OFF;
}
else{}
}
while(tmp[1]==ON)
{
LineData(data);
if (data[0] > 400)
tmp[0] = ON;
else{}
if(tmp[0]==ON)
{ StatusLED(YELLOW);
time2 = Gettime();
time = (time2 - time1)/1000;
tmp[1]==OFF;
tan=a/(v*time);
arc2 = atan(tan) * 180 / M_PIl;
arc = (int)arc2;
MotorDir(BREAK,BREAK);
MotorSpeed(0,0);
Turn (arc, v);
tmp[1] = OFF;
tmp[0] = OFF;
}
else{}
}
}
return 0;
}
Lesezeichen