Professional Documents
Culture Documents
Navtogoalshot
Navtogoalshot
Module
NavToGoalShot.c
****************************************************************************/
/*----------------------------- Include Files -----------------------------*/
// Basic includes for a program using the Events and Services Framework
#include "ES_Configure.h"
#include "ES_Framework.h"
/* include header files for this state machine as well as any machines at the
next lower level in the hierarchy that are sub-machines to this machine
*/
#include "NavToGoalShot.h"
#include "AligningToBeacon.h"
#include "MotorDrive.h"
#include "SquaringToWall.h"
#include "MasterSM.h"
/*----------------------------- Module Defines ----------------------------*/
// define constants for the states for this machine
// and any other local defines
//TODO: SWITCH BACK!!!!!!!
#define ENTRY_STATE BACKING_UP_SLIGHTLY_GOAL_SHOT
Parameters
ES_Event_t: the event to process
Returns
ES_Event_t: an event to return
Description
add your description here
Notes
uses nested switch/case to implement the machine.
Author
J. Edward Carryer, 2/11/05, 10:45AM
****************************************************************************/
ES_Event_t RunNavToGoalShot(ES_Event_t CurrentEvent)
{
bool MakeTransition = false;/* are we making a state transition?
*/
NavToGoalShotState_t NextState = CurrentState;
ES_Event_t EntryEventKind = { ES_ENTRY, 0 }; // default to normal entry
to new state
ES_Event_t ReturnEvent = CurrentEvent; // assume we are not
consuming event
switch (CurrentState)
{
case BACKING_UP_SLIGHTLY_GOAL_SHOT: //use encoders to drive forward.
{ ReturnEvent = CurrentEvent = DuringBackingUpSlightlyGoal(CurrentEvent);
/****************************************************************************
Function
StartTemplateSM
Parameters
None
Returns
None
Description
Does any required initialization for this state machine
Notes
Author
J. Edward Carryer, 2/18/99, 10:38AM
****************************************************************************/
void StartNavToGoalShot(ES_Event_t CurrentEvent)
{
if (CurrentEvent.EventType != ES_ENTRY)
{
printf("Warning: Defense state machine was started with a non-entry
event.\r\n");
}
if (ES_ENTRY_HISTORY != CurrentEvent.EventType)
{
CurrentState = ENTRY_STATE;
}
// call the entry function (if any) for the ENTRY_STATE
RunNavToGoalShot(CurrentEvent);
}
/****************************************************************************
Function
QueryTemplateSM
Parameters
None
Returns
TemplateState_t The current state of the Template state machine
Description
returns the current state of the Template state machine
Notes
Author
J. Edward Carryer, 2/11/05, 10:38AM
****************************************************************************/
NavToGoalShotState_t QueryNavToGoalShot(void)
{
return CurrentState;
}
/***************************************************************************
private functions
***************************************************************************/
return ReturnEvent;
}
return ReturnEvent;
}
return ReturnEvent;
}
return ReturnEvent;
}