# Sequence Planner: A Framework for Control of Intelligent Automation Systems
## 2 The Sequence Planner Control Framework
### Resources  
Devices and software algorithms in the system are modeled as _resources_, which group their local state and discrete descriptions of the tasks they can perform. The resource state is encoded into variables of three kinds: _measured state_, _goal state_, and _estimated state_. The state of a resource corresponds to messages of specific types on the ROS network. These message types are generated from the definitions below. SP models the resources using a formalism with finite domain variables, states that are unique valuations of the variables, and non-deterministic transitions between states. The following definitions are provided for clarification. **Definition 1**. : _A transition system (TS) is a tuple \(\langle S,\rightarrow,I\rangle\), where \(S\) is a set of states, \(\rightarrow\subseteq S\times S\) is the transition relation, and \(I\subseteq S\) is the nonempty set of initial states._  
**Definition 2**. : _A state \(s\in S\) is a unique valuation of each variable in the system, e.g., \(s=\langle v_{1},v_{2},\ldots,v_{n}\rangle\)._  
Variables have finite discrete domains, i.e., Boolean or enumeration types. The transition relation \(\rightarrow\) defines the transitions that modify the system state:  
**Definition 3**. : _A transition \(t\) has a guard \(g\), which is a Boolean function over a state, \(g\colon S\rightarrow\{false,true\}\), and a set of action functions \(A\) where \(a\colon S\to S\), which updates the valuations of the state variables in a state. We often write a transition as \(g/A\) to save space._  
**Definition 4**. : _A resource \(i\) is defined as \(r_{i}=\langle V^{M}_{i},V^{G}_{i},V^{E}_{i},T^{e}_{i},T^{a}_{i},T^{e}_{i}\rangle\) where \(V^{M}_{i}\) is a set of measured state variables, \(V^{C}_{i}\) is a set of goal state variables, and \(V^{E}_{i}\) is a set of estimated state variables. Variables are of finite domain. The set \(V_{i}=V^{M}_{i}\cup V^{G}_{i}\cup V^{E}_{i}\) defines all state variables of a resource. The sets \(T^{c}_{i}\) and \(T^{a}_{i}\) define controlled and automatic transitions, respectively. \(T^{e}_{i}\) is a set of effect transitions describing the possible consequences to \(V^{M}_{i}\) of being in certain states._  
\(T^{c}_{i}\)_, \(T^{a}_{i}\), and \(T^{e}_{i}\) have the same formal semantics, but are separated due to their different uses:_  
_Controlled transitions \(T^{c}_{i}\) are taken when their guard condition is evaluated to be true, only if they are also activated by the planning system. Figure 2: Overview of the SP control framework. _Automatic transitions_\(T_{i}^{a}\) are always taken when their guard condition is evaluated to be true, regardless of if there are any active plans or not. All automatic transitions are taken before any controlled transitions can be taken. This ensures that automatic transitions can never be delayed by the planner. _Effect transitions_\(T_{i}^{e}\) define how the measured state is updated, and as such, they are not used during control such as for the control transitions \(T_{i}^{c}\) and \(T_{i}^{a}\). They are important to keep track of, however, as they are needed for online planning and formal verification algorithms. They are also used to determine if the plan is correctly followed--if the expected effects do not occur, it can be due to an error. Consider the case of a door with two binary sensors: one for detecting whether it is open, and one for detecting whether it is closed. The door can be opened and closed by the control system, but not moved to an arbitrary position. The measured state for this door resource would be two Boolean variables, closed: \(c_{? }\) and opened: \(o_{? }\) (to ease notation in the coming sections, we use a notation in which measured state variables are denoted with a subscript \"?\", goal state variables are denoted with a subscript \"?\", and estimated state variables are denoted with a hat--see Table 1). To control the door, a _goal state_ variable model is introduced: \(gs_{!}\in\{closed,opened\}\).