also, dass man in jeder Funktion den Controller neu initialisieren muss wäre mir neu aber wenn es so geht is ja in Ordnung
. Aber wie gesagt ich hab nur die motion control verschoben und es geht auch.
Code:
#include "RP6RobotBaseLib.h"
uint8_t ok=0;
void senkrecht (void)
{
writeString_P("achtung");
stop();
while(ok == 0) //nicht wundern das die schleife nie endet
{
task_motionControl();
statusLEDs.LED5 = obstacle_left; //Hinderniss Links
statusLEDs.LED2 = obstacle_right; //Hinderniss rechts
updateStatusLEDs();
}
}
int main(void)
{
initRobotBase();
powerON();
setACSPwrHigh();
moveAtSpeed(100,150); //erste Bewegung
startStopwatch1(); //Zeitnhemer bis andere Richtung
while(true)
{
task_motionControl();
task_ACS();
if (getStopwatch1() >= 3000) //rechts herum
{
stopStopwatch1();
moveAtSpeed(150,100);
setStopwatch1(0);
startStopwatch2();
}
if (getStopwatch2() >= 3000) //links herum
{
stopStopwatch2();
moveAtSpeed(100,150);
setStopwatch2(0);
startStopwatch1();
}
if (obstacle_left || obstacle_right)
{
senkrecht();
}
}
return 0;
}
Lesezeichen