27 DBFUNCCALLln(
"DriveCtrl::loop()");
32 DBFUNCCALLln(
"DriveCtrl::loop(Event)");
42 DBFUNCCALL(
"DriveCtrl::process ");
43 DBEVENTln(String(
"DriveCtrl ") + String(
decodeEvent(e)));
157 DBSTATUSln(
"Drive Entering State: idle");
164 DBINFO1ln(
"Drive State: idle");
170 DBSTATUSln(
"Drive Leaving State: idle");
175 DBSTATUSln(
"Drive Entering State: turningLeft");
185 DBINFO1ln(
"Drive State: turningLeft");
195 DBSTATUSln(
"Drive Leaving State: turningLeft");
201 DBSTATUSln(
"Drive Entering State: turningRight");
211 DBINFO1ln(
"Drive State: turningRight");
221 DBSTATUSln(
"Drive Leaving State: turningRight");
227 DBSTATUSln(
"Drive Entering State: turningAround");
238 DBINFO1ln(
"Drive State: turningAround");
242 DBINFO2ln(abs(linedev));
251 DBSTATUSln(
"Drive Leaving State: turningAround");
257 DBSTATUSln(
"Drive Entering State: followingLineForward");
268 DBINFO1ln(
"Drive State: followingLineForward");
275 }
else if ((abs(linedeviation) == 200)) {
279 if ((linedeviation != 180) && (linedeviation != 200)) {
295 DBSTATUSln(
"Drive Leaving State: followingLineForward");
301 DBSTATUSln(
"Drive Entering State: followingLineBackward");
315 DBINFO1ln(
"Drive State: followingLineBackward");
344 DBSTATUSln(
"Drive Leaving State: followingLineBackward");
352 DBERROR(
"Drive Entering State: errorState");
361 DBSTATUSln(
"Drive State: errorState");
367 DBSTATUSln(
"Drive Leaving State: errorState");
372 DBERROR(
"Entering State: resetState");
378 DBINFO1ln(
"State: resetState");
384 DBSTATUSln(
"Leaving State: resetState");
392 return "State::idle";
395 return "State::turningLeft";
397 return "State::turningRight";
400 return "State::turningAround";
403 return "State::errorState";
406 return "State::resetState";
409 return "ERROR: No matching state";
417 return "Event::TurnLeft";
420 return "Event::TurnRight";
423 return "Event::TurnAround";
426 return "Event::FollowLineForward";
429 return "Event::FollowLineBackward";
432 return "Event::LineAligned";
435 return "Event::FullLineDetected";
438 return "Event::Error";
441 return "Event::Resume";
444 return "Event::Reset";
447 return "Event::NoEvent";
450 return "ERROR: No matching event";
const unsigned int REDUCED_SPEED
Reduced operating speed.
void exitAction_followingLineForward()
executes the exit action of the followingLineForward
Contains the FSM to controll the Drive.
follow the line while driving forward state
const State getcurrentState()
Get the current State.
const unsigned int SPEED
Standard operating speed.
DriveCtrl::Event doAction_errorState()
main action of the errorState
void entryAction_idle()
executes the entry action of the idle
DriveCtrl::Event doAction_turningAround()
executes the main action of the turningAround
void entryAction_turningLeft()
executes the entry action of the turningLeft
unsigned long currentMillis
will store current time
The Drive Controll class contains the FSM for the Drive.
Ext.: Reset after Error occured.
Ext.: Follow the line backwards.
PID pController
PID-Controller Object.
double pController_Output
Controller Output.
Drive pDrive
Drive Object.
EnvironmentDetection pEnvdetect
EnviromentDetection Object.
const unsigned long ignoreSensorTurnMillis
sets how long the sensors are ignored for a turn
void exitAction_turningLeft()
executes the exit action of the turningLeft
Event currentEvent
holds the current event of the FSM
double pVal_d
D-Value (independet of SamplingTime)
void drive(Direction direction, unsigned int speed)
Drive straight Forwards or Backwards.
State lastStateBevorError
holds the last state of the FSM so it's possible to resume after error
Ext.: Follow the line forwards.
void exitAction_idle()
executes the exit action of the idle
State currentState
holds the current state of the FSM
void process(Event e)
changes the state of the FSM based on the event
DriveCtrl::Event doAction_turningRight()
executes the main action of the turningRight
void exitAction_resetState()
exit action of the resetState
Event(DriveCtrl::* doActionFPtr)(void)
Functionpointer to call the current states do-function.
DriveCtrl::Event doAction_followingLineBackward()
executes the main action of the followingLineBackward
void entryAction_turningRight()
executes the entry action of the turningRight
void exitAction_turningAround()
executes the exit action of the turningAround
DriveCtrl::Event doAction_turningLeft()
executes the main action of the turningLeft
follow the line while driving backward state
Signal: Full line detected.
String decodeState(State state)
Decodes the State-Enum and returns a description.
String decodeEvent(Event event)
Decodes the Event-Enum and returns a description.
Signal: Line is alligned in the middle of the vehicle.
DriveCtrl::Event doAction_idle()
executes the main action of the idle
void stop()
Power of the Motor. Does not apply breaking.
double pVal_i
I-Value (independet of SamplingTime)
State
Enum holds all possible states.
const int Linedeviation()
Recognise deviation from vehicle to line.
void turn(Direction direction, unsigned int speed)
Turn left or right. Speed will add to one Motor's actual speed and substract from the others depenig ...
int pSampleTime
Controler SampleTime in ms.
void entryAction_errorState()
entry action of the errorState
void entryAction_followingLineForward()
executes the entry action of the followingLineForward
double pController_Input
Controller Input.
const unsigned long ignoreSensorAroundMillis
sets how long the sensors are ignored for a turning around
DriveCtrl::Event doAction_followingLineForward()
executes the main action of the followingLineForward
void exitAction_followingLineBackward()
executes the exit action of the followingLineBackward
Event
Enum holds all possible events.
const unsigned int TURNING_SPEED
Turning speed.
void entryAction_followingLineBackward()
executes the entry action of the followingLineBackward
DriveCtrl::Event doAction_resetState()
main action of the resetState
Ext.: Turn around on position.
void loop()
Calls the do-function of the active state and hence generates Events.
void turnonpoint(Direction direction, unsigned int speed)
Turn on Point Drive on Motor Forward and the other Backward with the given speed.
void exitAction_turningRight()
executes the exit action of the turningRight
void entryAction_resetState()
entry action of the resetState
void exitAction_errorState()
exit action of the errorState
Ext.: Resume after Error occured.
unsigned long previousMillis
will store last time
DriveCtrl()
Construct a new Drive Ctrl object and set the currentState with idle state and initialize the PID-Con...
void entryAction_turningAround()
executes the entry action of the turningAround