You are on page 1of 2

OffenseSM

Private Functions
static ES_Event_t DuringDrive4Offset(ES_Event_t Event);
static ES_Event_t DuringLook4Goal( ES_Event_t Event);
static ES_Event_t DuringDrive2Goal( ES_Event_t Event);
static ES_Event_t DuringFire( ES_Event_t Event); static

Private Variables
static uint16_t TEAM = 1;

ES_Event_t RunOffenseSM( ES_Event_t CurrentEvent )


Set MakeTransition to false
Set Next State to Current State
Assume we are not consuming event, Set Return Event to Current Event

Select based on Current State


case OffDrive4Offset :
if we receive an event
Select based on Event Type
case TIMEOUT:
Set Robot to Backwards
Set Robot Speed
Set Robot Target Position to Center Field
Set Robot to Backwards
case X Target Reached:
Set Next State to Look For Goal
Make Transistion
case Look For Goal:
if we receive an event
Select based on Event Type
case Goal Beacon Found:
Stop Beacon Detection
Set Next State to Drive2Goal
Make Transition
case Drive To Goal:
if we receive an event
Select based on Event Type
case Y Target Reached:
Set Next State to Fire
Make Transition
case Fire:
if we receive an event
Select based on Event Type
case Timeout:
Set Next State to Rest
Make Transition
case Rest:
if we receive an event
Select based on Event Type
case Timeout:
Show Debug Info
if we are making an transition
Execute exit function for current state
Execute entry function for new state
void StartOffenseSM ( ES_Event_t CurrentEvent ) {
Set Current State to Entry State
Grab team info and reload station period info
TEAM = CurrentEvent.EventParam; //grab TEAM color info
Call the entry function (if any) for the ENTRY_STATE

OffenseState_t QueryOffenseSM ( void )


Returns Current State

static ES_Event_t DuringDrive4Offset( ES_Event_t Event)


On Entry to State:
Set a delay timer for 2 seconds in order to catch reload
On Exit from State:
// nothing
Else for Every Event:
// nothing

static ES_Event_t DuringLook4Goal( ES_Event_t Event)


On Entry to State:
Set Robot Direction to CounterClockwise
Set Robot Speed to 10
Start Beacon Finding Code
On Exit from State:
// nothing
Else for Every Event:
// nothing

static ES_Event_t DuringDrive2Goal( ES_Event_t Event)


On Entry to State:
Set Robot Direction to Forward
Set Robot Speed to 15 RPM
Set Target to Firing Position
On Exit from State:
// nothing
Else for Every Event:
// nothing

static ES_Event_t DuringFiring( ES_Event_t Event)


On Entry to State:
Execute Servo Motor Firing Sequence
On Exit from State:
// nothing
Else for Every Event:
// nothing

You might also like