Professional Documents
Culture Documents
DuringDrive4Offset
DuringTurn2Reload
DuringDrive4Offset2
DuringLook4Reload
DuringDrive2Reload
DuringLook4Emitter
DuringDrive2Emitter
DuringReload
RunFaceOffSM
set MakeTransition to false by default
set NextState to CurrentState
default to normal entry to new state
assume we are not consuming event
if an event is active
if event is EV_X_TARGET_REACHED
set ReachedXGoal to true
if we have reached YGoal
stop robot
Decide the next state to be Turn2Reload
for internal transitions, skip changing MakeTransition
mark that we are taking a transition
if transitioning to a state with history change kind of
entry
optionally, consume or re-map this event for the upper
level state machine
end if
end if
end of this block
if event is EV_Y_TARGET_REACHED
set ReachedYGoal to true
if we have reached XGoal
stop robot
Decide the next state to be Turn2Reload
for internal transitions, skip changing MakeTransition
mark that we are taking a transition
if transitioning to a state with history change kind of
entry
optionally, consume or re-map this event for the upper
level state machine
end if
end of this block
if an event is active
if event is EV_X_TARGET_REACHED
set ReachedXGoal to be true
Decide next state to be Look4Reload
for internal transitions, skip changing MakeTransition
mark that we are taking a transition
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if an event is active
if event is EV_BEACON_FOUND
Execute action function for Look4Reload, EV_BEACON_FOUND
if CurrentEvent EventParam is close to the reload period we
are looking for
stop beacon capture interrupt and beacon oneshot
interrupt
Decide next state to be Drive2Reload
for internal transitions, skip changing MakeTransition
mark that we are taking a transition
else
set NextState to Look4Reload, keep looking for beacon
set MakeTransition to false
end if
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if event is EV_BEACON_NOTFOUND
perform dummy searching, rotate a small angle per time
set robot to turn CW at some speed
start a timer for rotating
set NextState to Look4Reload
set MakeTransition to false
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
ReturnEvent.EventType = ES_NO_EVENT;
end of this block
if event is ES_TIMEOUT
restart oneshot after turning a fixed angle to determine if
we find the beacon
set NextState to Look4Reload
set MakeTransition to false
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if an event is active
if event is EV_X_TARGET_REACHED
decide the next state to be Look4Emitter
for internal transitions, skip changing MakeTransition
mark that we are taking a transition
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if event is EV_EMITTER_MISSED
perform dummy searching, rotate a small angle per time
set robot to turn CW at some speed
start a timer for turning
Set NextState to be Look4Emitter
mark that we are not making a transition
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if event is ES_TIMEOUT
restart oneshot after turning a fixed angle to determine if
we find the beacon
set NextState to Look4Emitter
mark that we are not making a transition
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
if an event is active
If event is event one
Execute action function for Reload,ES_ENTRY
Decide next state to be Reload
for internal transitions, skip changing MakeTransition
mark that we are not taking a transition
if transitioning to a state with history change kind of entry
optionally, consume or re-map this event for the upper
level state machine
end of this block
return ReturnEvent
End of RunFaceOffSM
StartFaceOffSM
set CurrentState to be ENTRY_STATE
grab team info from passed-in event
set reload station period info according to TEAM
call the entry function (if any) for the ENTRY_STATE
End of StartFaceOffSM
QueryFaceOffSM
return CurrentState
End
/***************************************************************************
private functions
***************************************************************************/
DuringDrive4Offset
assume no re-mapping or consumption
after that start any lower level machines that run in this state
else if ES_EXIT
on exit, give the lower levels a chance to clean up first
now do any local exit functionality
else
do the 'during' function for this state
run any lower level state machine
end if
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringDrive4Offset
DuringTurn2Reload
assume no re-mapping or consumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringTurn2Reload
DuringDrive4Offset2
assume no re-mapping or consumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringDrive4Offset2
DuringLook4Reload
assume no re-mapping or consumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringLook4Emitter
DuringDrive2Reload
assume no re-mapping or consumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringDrive2Reload
DuringLook4Emitter
assume no re-mapping or consumption
else if ES_EXIT
on exit, give the lower levels a chance to clean up first
else
do the 'during' function for this state
run any lower level state machine
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringLook4Emitter
DuringDrive2Emitter
assume no re-mapping or consumption
after that start any lower level machines that run in this state
else if ES_EXIT
on exit, give the lower levels a chance to clean up first
else
do the 'during' function for this state
run any lower level state machine
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringDrive2Emitter
DuringReload
assume no re-mapping or consumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringReload