This lesson introduces hierarchical state machines (HSMs), explaining how they solve the state transition explosion problem found in traditional finite state machines. Using a time bomb application as an example, it demonstrates how nesting states (substates inheriting behavior from superstates) eliminates repeated transitions and follows the DRY principle. The lesson covers a basic C implementation of HSMs using a SUPER macro and a while-loop dispatch mechanism, then ports the application from a toy micro-framework to the professional QPC framework, which provides full HSM support including proper entry/exit action chains and nested initial transitions.

31m watch time
1 Impression