0% found this document useful (0 votes)
44 views3 pages

Activegameplaysm

The document describes the states and logic of an active gameplay state machine for controlling a robot. The state machine switches between states like IdleGameplay, Look4Miner, GetMiner, TransportMiner, and MinerDestinationReached based on events and conditions.

Uploaded by

api-502047130
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Activegameplaysm

The document describes the states and logic of an active gameplay state machine for controlling a robot. The state machine switches between states like IdleGameplay, Look4Miner, GetMiner, TransportMiner, and MinerDestinationReached based on events and conditions.

Uploaded by

api-502047130
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

RunActiveGameplay:

Switch on current state:


IdleGamePlay:
Call DuringIdleGameplay
If the event is TargetMinerChanged
Change state to Look4Miner
End if
Look4Miner:
Call DuringLook4Miner
If the event is TargetMinerChanged
Change state to Look4Miner
Else if the event is IRAligned
Clear the odometer
Change state to GetMiner
End if
GetMiner:
Call DuringGetMiner
If the event is TargetMinerChanged
Change state to Look4Miner
Else if the event is BeamBroken
Change state to Waiting2Grab
Else if the event is IRMisaligned
Change state to Look4Miner
End if
Waiting2Grab:
Call DuringWaiting2Grab
If the event is EncoderCountReached
Activate electromagnet
Change state to TransportMiner
TransportMiner:
Call DuringTransportMiner
If the event is TargetSquareReached
Deactivate electromagnet
Change state to MinerDestinationReached
Else if event is TargetDestinationChanged
Self-transition to TransportMiner
Else if event is BeamRestored
Change state to Look4Miner
End if
MinerDestinationReached:
Call DuringMinerDestinationReached
If the event is EncoderCountReached
If we are in the optimal state
Change state to IdleGameplay
Else
Changes state to Look4Miner
End if
Else if event is BeamBroken
Stop the motors
Self-transition to MinerDestinationReached
StartActiveGameplaySM:
Change state to Look4Miner
Call RunActiveGameplaySM

QueryActiveGameplaySM:
Returns state of ActiveGamePlaySM

QueryCurrentMiner:
Returns the current target MINER

SetCurrentTargetMiner:
Sets the current target MINER

DuringIdleGameplay:
If the event is ES_ENTRY
Stop the motors
End if

DuringLook4Miner:
If the event is ES_ENTRY
Call StartLooking4MinerSM
Else if event is ES_EXIT
Call RunLook4MinerSM
Else
Call RunLook4MinerSM and return event

DuringGetMiner:
If the event is ES_ENTRY
Start a hard reset timer
Stop the motors
Set the speed to get the MINER
Post drive forward to MotorSM
Else if the event is ES_EXIT
Stop the motors
End if

DuringWaiting2Grab:
If the event is ES_ENTRY
Start a hard reset timer
Set the speed to grab the MINER
Set the drive odometer to drive forward distance
Post drive forward to MotorSM
End if

DuringTransportMiner:
If the event is ES_ENTRY
Start a hard reset timer
Query target destination from Brains
Post target destination to NavigationSM
End if
DuringMinerDestinationReached:
If the event is ES_ENTRY
Start a hard reset timer
Set the drive odometer to back-up distance
Post drive backward to MotorSM
End if

You might also like