-
-
Notifications
You must be signed in to change notification settings - Fork 69
Home
Andrew Gresyk edited this page May 10, 2019
·
18 revisions
hfsm.dev API Cheat Sheet
Using default settings:
using M = hfsm2::Machine;
Customizable version:
using M = hfsm2::MachineT<
TContext, // data shared between states and external code
Config<>, // optional: config, see below
TPayload // optional: transition payload
>;
hfsm2::Config<
TUtility, // optional: customizable Expected Utility Value type (default: float)
NMaxPlanTasks, // optional: max number of plans' entries across the entire FSM
// (default: 2x number of sub-states in all regions)
NMaxSubstitutions = 4 // optional: max number of guard substitutions
>
Abbreviations:
- H => Head
- SS => SubStates
Type | Root | Headless Root | Region | Headless Region |
---|---|---|---|---|
Composite | M::Root<H, SS> |
M::PeerRoot<SS> |
M::Composite<H, SS> |
M::CompositePeers<SS> |
Resumable | M::ResumableRoot<H, SS> |
M::ResumablePeerRoot<SS> |
M::Resumable<H, SS> |
M::ResumablePeers<SS> |
Utilitarian | M::UtilitarianRoot<H, SS> |
M::UtilitarianPeerRoot<SS> |
M::Utilitarian<H, SS> |
M::UtilitarianPeers<SS> |
Orthogonal | M::OrthogonalRoot<H, SS> |
M::OrthogonalPeerRoot<SS> |
M::Orthogonal<H, SS> |
M::OrthogonalPeers<SS> |
#define S(s) struct s
using FSM = M::Root<S(..),
..
>;
#undef S
Group | Methods |
---|---|
Pre-Conditions | Config::Utility utility(const Control&) |
Guards |
void entryGuard(GuardControl&) void exitGuard(GuardControl&)
|
Transition Events |
void enter(PlanControl&) void exit(PlanControl&)
|
Periodic Updates | void update(FullControl&) |
Event Reactions | void react(const TEvent&, FullControl&) |
Plan Events |
void planSucceeded(FullControl&) void planFailed(FullControl&)
|
Group | Methods |
---|---|
Plan Events |
void planSucceeded(FullControl&) void planFailed(FullControl&)
|
Default:
struct UserState
: FSM::State
{}
Inject shared code (see Injections below for more details)
struct UserState
: FSM::StateT<TInjection1, TInjection2>
{}
struct UserInjection
: FSM::Bare
{}
Group | Methods |
---|---|
Guards |
void preEntryGuard(Context&) void preExitGuard(Context&)
|
Bounds |
void preEnter(Context&) void postExit(Context&)
|
Periodic Updates | void preUpdate(Context&) |
Event Reactions | void preReact(const TEvent&, Context&) |
GuardControl
-> FullControl
-> PlanControl
-> Control
Type | Additional Functionality |
---|---|
Control |
Inspect |
PlanControl |
Modify plans |
FullControl |
Issue transitions Succeed and fail plans |
GuardControl |
Cancel in-flight transitions |
Used in:
M::State::utility()
Group | Methods | |
---|---|---|
Inspect Structure |
StateID stateId<TState>() RegionID regionId<TRegion>()
|
|
Access Context |
Context& _() Context& context()
|
|
Query State Activity |
bool isActive<TState>() bool isResumable<TState>() bool isScheduled<TState>()
|
bool isActive(StateID) bool isResumable(StateID) bool isScheduled(StateID)
|
Inspect Own Plan | ConstPlan plan() |
|
Inspect Plans | ConstPlan plan<TRegion>() |
ConstPlan plan(RegionID) |
Used in:
void enter(PlanControl&)
void exit(PlanControl&)
Group | Methods | |
---|---|---|
Modify Own Plan | Plan plan() |
|
Modify Plans | Plan plan<TRegion>() |
Plan plan(RegionID) |
Used in:
void update(FullControl&)
void react(const TEvent&, FullControl&)
void planSucceeded(FullControl&)
void planFailed(FullControl&)
Group | Methods | |
---|---|---|
Initiate Transitions |
void changeTo<TState>() void restart<TState>() void resume<TState>() void utilize<TState>() void schedule<TState>()
|
void changeTo(StateID) void restart(StateID) void resume(StateID) void utilize(StateID) void schedule(StateID)
|
Succeed / Fail Plans |
void succeed() void fail()
|
Used in:
void entryGuard(GuardControl&)
void exitGuard(GuardControl&)
Group | Methods |
---|---|
Cancel In-Flight Transitions | void cancel() |