SmartVehicle-Sortic
SmartFactory
NavigationCtrl Class Reference

Contains the FSM for the Navigation. More...

#include <NavigationCtrl.h>

Collaboration diagram for NavigationCtrl:

Classes

struct  ActualPos
 Holds the actual information about the vehicleposition. More...
 
struct  TargetPos
 Holds the information about the vehicle target. More...
 

Public Types

enum  Event {
  Event::MoveToTargetPosition, Event::PosEndPointReached, Event::PosTransitReached, Event::PosReached,
  Event::Error, Event::Resume, Event::Reset, Event::NoEvent
}
 Enum holds all possible events. More...
 
enum  State {
  State::endPoint, State::toGateway, State::gateway, State::crossTransit,
  State::toEndPoint, State::resetState, State::errorState
}
 Enum holds all possible states for the Navigation. More...
 
enum  Sector {
  Sector::SorticHandover, Sector::SorticToHandover, Sector::SorticWaitForGateway, Sector::SorticGateway,
  Sector::TransitWaitForGatewaySortic, Sector::TransitToSortic, Sector::TransitToTransfer, Sector::Parking,
  Sector::TransitWaitForGatewayTransfer, Sector::TransferGateway, Sector::TransferWaitForGateway, Sector::TransferToHandover,
  Sector::TransferHandover, Sector::error
}
 Enum holds all possible sectors. More...
 

Public Member Functions

 NavigationCtrl ()
 Construct a new Navigation Ctrl object and initailize the currentState with endPoint state. More...
 
void loop ()
 Calls the do-function of the active state and hence generates Events. More...
 
void loop (Event currentEvent)
 Procceses the current Event and calls the do-function of the active state. More...
 
const State getcurrentState ()
 Get the current State. More...
 
const Sector getcurrentSector ()
 Get the current Sector. More...
 
const int getcurrentLine ()
 Get the current Line. More...
 
void setTargetPosition (Sector sector, const int line)
 Set the Target Position object. More...
 
void setActualPosition (Sector sector, const int line)
 Set the actual Position object. More...
 
void giveToken ()
 give Token to access the Gateway More...
 
String decodeSector (Sector sector)
 Decodes the Sector-Enum and returns a description. More...
 
NavigationCtrl::Sector decodeSector (String sector)
 Decodes a sectro String and returns the sector. More...
 

Private Member Functions

void process (Event e)
 changes the state of the FSM based on the event More...
 
void entryAction_endPoint ()
 executes the entry action of the endPoint state. More...
 
NavigationCtrl::Event doAction_endPoint ()
 executes the main action of the endPoint state. This is an Idel-state ->NoEvent generated More...
 
void exitAction_endPoint ()
 executes the exit action of the endPoint state. More...
 
void entryAction_toGateway ()
 executes the entry action of the toGateway state. More...
 
NavigationCtrl::Event doAction_toGateway ()
 executes the main action of the toGateway state. More...
 
void exitAction_toGateway ()
 executes the exit action of the toGateway state. More...
 
void entryAction_gateway ()
 executes the entry action of the gateway state. More...
 
NavigationCtrl::Event doAction_gateway ()
 executes the main action of the gateway state. More...
 
void exitAction_gateway ()
 executes the exit action of the gateway state. More...
 
void entryAction_crossTransit ()
 executes the entry action of the crossTransit state. More...
 
NavigationCtrl::Event doAction_crossTransit ()
 executes the main action of the crossTransit state. More...
 
void exitAction_crossTransit ()
 executes the exit action of the crossTransit state. More...
 
void entryAction_toEndPoint ()
 executes the entry action of the toEndPoint state. More...
 
NavigationCtrl::Event doAction_toEndPoint ()
 executes the main action of the toEndPoint state. More...
 
void exitAction_toEndPoint ()
 executes the exit action of the toEndPoint state. More...
 
void entryAction_errorState ()
 entry action of the errorState state. More...
 
NavigationCtrl::Event doAction_errorState ()
 main action of the errorState state. More...
 
void exitAction_errorState ()
 exit action of the errorState state. More...
 
void entryAction_resetState ()
 entry action of the resetState More...
 
NavigationCtrl::Event doAction_resetState ()
 main action of the resetState More...
 
void exitAction_resetState ()
 exit action of the resetState More...
 
String decodeState (State state)
 Decodes the State-Enum and returns a description. More...
 
String decodeEvent (Event event)
 Decodes the Event-Enum and returns a description. More...
 

Private Attributes

State lastStateBevorError
 holds the last state of the FSM so it's possible to resume after error More...
 
State currentState
 holds the current state of the FSM More...
 
Event currentEvent
 holds the current event of the FSM More...
 
int pCurrentSubState = 0
 Counter for the Current Substate. More...
 
int pLastSubStateBevorError = 0
 Holds the last Substate befor an Error occured. More...
 
int pSubStateLoopInc = 0
 Counter so you can call the same substatefunction multiple times. More...
 
struct NavigationCtrl::ActualPos pActual
 
struct NavigationCtrl::TargetPos pTarget
 
bool tranistonce = true
 prevents an loop between transit and gateway More...
 
DriveCtrl::Event pLastGatewayTurn
 Variable which holds the last made turn in gateway. More...
 
Event(NavigationCtrl::* doActionFPtr )(void) = nullptr
 Functionpointer to call the current states do-function. More...
 
DriveCtrl pDriveCtrl
 Navigation Object. More...
 

Detailed Description

Contains the FSM for the Navigation.

NavigationCtrl.png
Gametable.png

Definition at line 27 of file NavigationCtrl.h.

Member Enumeration Documentation

◆ Event

enum NavigationCtrl::Event
strong

Enum holds all possible events.

Enumerator
MoveToTargetPosition 

Ext: Start MoveToTargetPosition.

PosEndPointReached 

Signal: PosEndPointReached.

PosTransitReached 

Signal: PosTransitReached.

PosReached 

Signal: Position reached.

Error 

Error occured.

Resume 

Ext: Resume after Error occured.

Reset 

Ext.: Reset after Error occured.

NoEvent 

No event generated.

Definition at line 34 of file NavigationCtrl.h.

◆ State

enum NavigationCtrl::State
strong

Enum holds all possible states for the Navigation.

Enumerator
endPoint 

endPoint State

toGateway 

toGateway State

gateway 

gateway State

crossTransit 

crossTransit State

toEndPoint 

toEndPoint State

resetState 

reset state

errorState 

error State

Definition at line 48 of file NavigationCtrl.h.

◆ Sector

Enum holds all possible sectors.

Enumerator
SorticHandover 

Sortic - Handover.

SorticToHandover 

Sortic - to Handover.

SorticWaitForGateway 

Sortic - Wait for Gateway.

SorticGateway 

Sortic - Gateway.

TransitWaitForGatewaySortic 

Transit - Wait for Gateway Sortic.

TransitToSortic 

Transit - to Sortic.

TransitToTransfer 

Transit - to Transfer.

Parking 

Parking (not used atm)

TransitWaitForGatewayTransfer 

Transit - Wait for Gateway Transfer.

TransferGateway 

Transfer - Gateway.

TransferWaitForGateway 

Transfer - wait for Gateway.

TransferToHandover 

Transfer - to Handover.

TransferHandover 

Transfer - Handover.

error 

error for unknown sector

Definition at line 61 of file NavigationCtrl.h.

Constructor & Destructor Documentation

◆ NavigationCtrl()

NavigationCtrl::NavigationCtrl ( )

Construct a new Navigation Ctrl object and initailize the currentState with endPoint state.

Definition at line 18 of file NavigationCtrl.cpp.

Member Function Documentation

◆ loop() [1/2]

void NavigationCtrl::loop ( )

Calls the do-function of the active state and hence generates Events.

Definition at line 21 of file NavigationCtrl.cpp.

◆ loop() [2/2]

void NavigationCtrl::loop ( Event  currentEvent)

Procceses the current Event and calls the do-function of the active state.

Parameters
currentEvent- Event

Definition at line 26 of file NavigationCtrl.cpp.

◆ getcurrentState()

const NavigationCtrl::State NavigationCtrl::getcurrentState ( )

Get the current State.

Returns
State - current State

Definition at line 32 of file NavigationCtrl.cpp.

◆ getcurrentSector()

const NavigationCtrl::Sector NavigationCtrl::getcurrentSector ( )

Get the current Sector.

Returns
const Sector - current Sector

Definition at line 38 of file NavigationCtrl.cpp.

◆ getcurrentLine()

const int NavigationCtrl::getcurrentLine ( )

Get the current Line.

Returns
const int - current line

Definition at line 43 of file NavigationCtrl.cpp.

◆ setTargetPosition()

void NavigationCtrl::setTargetPosition ( Sector  sector,
const int  line 
)

Set the Target Position object.

Parameters
sector- TargetSector ( HandoverSortic or HandoverTransfer)
line- TargetLine

Definition at line 48 of file NavigationCtrl.cpp.

◆ setActualPosition()

void NavigationCtrl::setActualPosition ( Sector  sector,
const int  line 
)

Set the actual Position object.

Parameters
sector- actualSector ( HandoverSortic or HandoverTransfer)
line- actualLine

Definition at line 54 of file NavigationCtrl.cpp.

◆ giveToken()

void NavigationCtrl::giveToken ( )

give Token to access the Gateway

Definition at line 60 of file NavigationCtrl.cpp.

◆ decodeSector() [1/2]

String NavigationCtrl::decodeSector ( Sector  sector)

Decodes the Sector-Enum and returns a description.

Parameters
sector- enum Sector
Returns
String - Sector as String

Definition at line 65 of file NavigationCtrl.cpp.

◆ decodeSector() [2/2]

NavigationCtrl::Sector NavigationCtrl::decodeSector ( String  sector)

Decodes a sectro String and returns the sector.

Parameters
sector- Sector as String
Returns
NavigationCtrl::Sector - enum Sector

Definition at line 113 of file NavigationCtrl.cpp.

◆ process()

void NavigationCtrl::process ( Event  e)
private

changes the state of the FSM based on the event

Parameters
e- Event

Definition at line 144 of file NavigationCtrl.cpp.

◆ entryAction_endPoint()

void NavigationCtrl::entryAction_endPoint ( )
private

executes the entry action of the endPoint state.

Update actual sector and startsector with taregt sector.

Definition at line 240 of file NavigationCtrl.cpp.

◆ doAction_endPoint()

NavigationCtrl::Event NavigationCtrl::doAction_endPoint ( )
private

executes the main action of the endPoint state. This is an Idel-state ->NoEvent generated

Returns
NavigationCtrl::Event - generated Event

Definition at line 256 of file NavigationCtrl.cpp.

◆ exitAction_endPoint()

void NavigationCtrl::exitAction_endPoint ( )
private

executes the exit action of the endPoint state.

Definition at line 262 of file NavigationCtrl.cpp.

◆ entryAction_toGateway()

void NavigationCtrl::entryAction_toGateway ( )
private

executes the entry action of the toGateway state.

Definition at line 268 of file NavigationCtrl.cpp.

◆ doAction_toGateway()

NavigationCtrl::Event NavigationCtrl::doAction_toGateway ( )
private

executes the main action of the toGateway state.

NavigationCtrlSubtoGateway.png
  • 0 Drive backwards
  • 10 turn around
  • 20 drive forward once and return Event::PosReached
Returns
NavigationCtrl::Event - generated Event

Definition at line 282 of file NavigationCtrl.cpp.

◆ exitAction_toGateway()

void NavigationCtrl::exitAction_toGateway ( )
private

executes the exit action of the toGateway state.

Definition at line 312 of file NavigationCtrl.cpp.

◆ entryAction_gateway()

void NavigationCtrl::entryAction_gateway ( )
private

executes the entry action of the gateway state.

Definition at line 318 of file NavigationCtrl.cpp.

◆ doAction_gateway()

NavigationCtrl::Event NavigationCtrl::doAction_gateway ( )
private

executes the main action of the gateway state.

NavigationCtrlSubGateway.png
  • 0 Wait for Token
  • 10 Drive forward once
  • 20 turn left/right depending on target and current orientation or go straight to (50)
  • 30 drive forward n times depending on actual line and targetline
  • 40 turn left/right depending on target and current orientation
  • 50 drive forward twice.
  • if startsector = target.sector
  • else
Returns
NavigationCtrl::Event - generated Event
Todo:
Refactoring so it only checks the neares sector and does not relay on startsector

Definition at line 334 of file NavigationCtrl.cpp.

◆ exitAction_gateway()

void NavigationCtrl::exitAction_gateway ( )
private

executes the exit action of the gateway state.

Definition at line 450 of file NavigationCtrl.cpp.

◆ entryAction_crossTransit()

void NavigationCtrl::entryAction_crossTransit ( )
private

executes the entry action of the crossTransit state.

Definition at line 472 of file NavigationCtrl.cpp.

◆ doAction_crossTransit()

NavigationCtrl::Event NavigationCtrl::doAction_crossTransit ( )
private

executes the main action of the crossTransit state.

drive forward three times and return Event::PosReached

Returns
NavigationCtrl::Event - generated Event

Definition at line 487 of file NavigationCtrl.cpp.

◆ exitAction_crossTransit()

void NavigationCtrl::exitAction_crossTransit ( )
private

executes the exit action of the crossTransit state.

Definition at line 503 of file NavigationCtrl.cpp.

◆ entryAction_toEndPoint()

void NavigationCtrl::entryAction_toEndPoint ( )
private

executes the entry action of the toEndPoint state.

Definition at line 509 of file NavigationCtrl.cpp.

◆ doAction_toEndPoint()

NavigationCtrl::Event NavigationCtrl::doAction_toEndPoint ( )
private

executes the main action of the toEndPoint state.

drive forward once and return Event::PosEndPointReached

Returns
NavigationCtrl::Event - generated Event

Definition at line 524 of file NavigationCtrl.cpp.

◆ exitAction_toEndPoint()

void NavigationCtrl::exitAction_toEndPoint ( )
private

executes the exit action of the toEndPoint state.

Definition at line 539 of file NavigationCtrl.cpp.

◆ entryAction_errorState()

void NavigationCtrl::entryAction_errorState ( )
private

entry action of the errorState state.

Definition at line 545 of file NavigationCtrl.cpp.

◆ doAction_errorState()

NavigationCtrl::Event NavigationCtrl::doAction_errorState ( )
private

main action of the errorState state.

Returns
NavigationCtrl::Event - generated Event

Definition at line 555 of file NavigationCtrl.cpp.

◆ exitAction_errorState()

void NavigationCtrl::exitAction_errorState ( )
private

exit action of the errorState state.

Definition at line 561 of file NavigationCtrl.cpp.

◆ entryAction_resetState()

void NavigationCtrl::entryAction_resetState ( )
private

entry action of the resetState

Definition at line 566 of file NavigationCtrl.cpp.

◆ doAction_resetState()

NavigationCtrl::Event NavigationCtrl::doAction_resetState ( )
private

main action of the resetState

Returns
NavigationCtrl::Event - generated Event

Definition at line 572 of file NavigationCtrl.cpp.

◆ exitAction_resetState()

void NavigationCtrl::exitAction_resetState ( )
private

exit action of the resetState

Definition at line 578 of file NavigationCtrl.cpp.

◆ decodeState()

String NavigationCtrl::decodeState ( State  state)
private

Decodes the State-Enum and returns a description.

Parameters
state- enum State
Returns
String - State as String

Definition at line 590 of file NavigationCtrl.cpp.

◆ decodeEvent()

String NavigationCtrl::decodeEvent ( Event  event)
private

Decodes the Event-Enum and returns a description.

Parameters
event- enum Event
Returns
String - Event as String

Definition at line 618 of file NavigationCtrl.cpp.

Member Data Documentation

◆ lastStateBevorError

State NavigationCtrl::lastStateBevorError
private

holds the last state of the FSM so it's possible to resume after error

Definition at line 159 of file NavigationCtrl.h.

◆ currentState

State NavigationCtrl::currentState
private

holds the current state of the FSM

Definition at line 160 of file NavigationCtrl.h.

◆ currentEvent

Event NavigationCtrl::currentEvent
private

holds the current event of the FSM

Definition at line 161 of file NavigationCtrl.h.

◆ pCurrentSubState

int NavigationCtrl::pCurrentSubState = 0
private

Counter for the Current Substate.

Definition at line 162 of file NavigationCtrl.h.

◆ pLastSubStateBevorError

int NavigationCtrl::pLastSubStateBevorError = 0
private

Holds the last Substate befor an Error occured.

Definition at line 163 of file NavigationCtrl.h.

◆ pSubStateLoopInc

int NavigationCtrl::pSubStateLoopInc = 0
private

Counter so you can call the same substatefunction multiple times.

Definition at line 164 of file NavigationCtrl.h.

◆ pActual

struct NavigationCtrl::ActualPos NavigationCtrl::pActual
private

◆ pTarget

struct NavigationCtrl::TargetPos NavigationCtrl::pTarget
private

◆ tranistonce

bool NavigationCtrl::tranistonce = true
private

prevents an loop between transit and gateway

Definition at line 187 of file NavigationCtrl.h.

◆ pLastGatewayTurn

DriveCtrl::Event NavigationCtrl::pLastGatewayTurn
private

Variable which holds the last made turn in gateway.

Definition at line 188 of file NavigationCtrl.h.

◆ doActionFPtr

Event(NavigationCtrl::* NavigationCtrl::doActionFPtr) (void) = nullptr
private

Functionpointer to call the current states do-function.

https://stackoverfendPoint.com/questions/1485983/calling-c-class-methods-via-a-function-pointer

Definition at line 196 of file NavigationCtrl.h.

◆ pDriveCtrl

DriveCtrl NavigationCtrl::pDriveCtrl
private

Navigation Object.

Definition at line 198 of file NavigationCtrl.h.


The documentation for this class was generated from the following files: