hallo sternthaler
ich hatte jetzt nie wirklich zeit um dir zu antworten!
hier einmal mein code:
Code:
void kurve(int radius, int winkel, int speed)
{
unsigned long count_a_soll,count_i_soll;
int count_a=0, count_i=0;
int speed_a, speed_i;
int radius_a, radius_i;
float quot, teiler;
MotorSpeed(0,0);
MotorDir(FWD,FWD);
radius_a=radius+BREITE/2;
radius_i=radius-BREITE/2;
teiler=(float)360/abs(winkel); //Bruchteil des Kreises
quot=((float)radius_a)/((float)radius_i);
//berechnen der notwendigen tics am außen- und innenrad
count_a_soll=2*radius_a*(PI*10000L/teiler);
count_a_soll/=MY_GO_ENC_COUNT_VALUE;
count_i_soll=count_a_soll/quot;
//mindestgeschwindigkeit=70
if(speed<70) speed=70;
//anfangsgeschwindigkeiten berechnen
speed_a=speed;
speed_i=speed_a/quot;
//speed_i=speed;
//Motoren starten
if(winkel>0)
MotorSpeed(speed_i,speed_a);
else
MotorSpeed(speed_a,speed_i);
EncoderSet(0,0);
while (count_a<count_a_soll)
{
//Odometrie einlesen
if(winkel>0)
{
count_a=encoder[RIGHT];
count_i=encoder[LEFT];
}
else
{
count_a=encoder[LEFT];
count_i=encoder[RIGHT];
}
//Geschwindigkeiten anpassen
if (count_a <(count_i*quot))
{ /*außen zu langsam */
if ((speed_a > speed) || (speed_a > 244))
speed_i -= 10;
else
speed_a += 10;
}
if (count_a >(count_i*quot))
{ /* außen zu schnell */
if ((speed_a > speed))
speed_a -= 10;
else
speed_i += 10;
}
/* reset encoder */
//EncoderSet (0, 0);
if(winkel>0)
MotorSpeed(speed_i,speed_a);
else
MotorSpeed(speed_a,speed_i);
//Msleep (1);
}
MotorDir(BREAK,BREAK);
Msleep(200);
}
kleine Änderung am 16.8.2008, 9:36
diese infos hatte ich vorher versehentlich zu meinem code hinzu gefügt:
ich verwende die lib 2.71
mein wert von MY_GO_ENC_COUNT_VALUE beträgt 21240L
und zum prog. verwende ich "eierlegende Wollmilchsau" (Asuroflash von Osser), falls das auch noch wichtig ist
ich hoffe du kannst damit was anfange
Lesezeichen