## 4 Event-Based Programming Model With Geometric Spatial Semantics
### Syntax  
The GeFB is the basic unit of programming, and a CPPS application consists of a network of ECProFBs. Suppose that we have an GeFB library \(\mathcal{L}\), where each GeFB \(\in\mathcal{L}\) is an 8-tuple as defined in Definition 1. However, the definitions of \(ea\) and the event model as given in Definitions 3 and 5, respectively, are expanded as introduced below. **Definition 8**. : _An execution control action is renamed as an action primitive, \(ap\in SO(3)\), which is defined as a 4-tuple:_  
\[ap=\langle g,algo,\pi,eo\rangle\]  
_where \(g\) is a guard function, which checks the constraints before the action primitive is executed; \(alg\) is the algorithm for the action primitive; \(\pi\) is a boundary function, which approximates the geometric action space of the physical entity during the time of execution of the action primitive; and \(eo\) is an event output, \(eo\in EO\)._  
Suppose that two robots are working on the same workbench, to collaboratively assemble a specific picture with Lego bricks. _Fetch_ and _Place_ are two action primitives. _Fetch_ requires a robot to fetch a Lego brick from the feed zone. _Place_ requires a robot to place the Lego brick it is currently holding in a specific position. Here, we consider _Fetch_ as an example. The guard function \(g\) for _Fetch_ needs to constantly check to see whether there are any obstacles present above the feed zone. Let \(L\), \(W\), and \(C\) represent the length, width, and geometric center, respectively, of the rectangular feed zone, where \(C=(c_{x},c_{y},c_{z})*\theta\) indicates the position of the feed zone in space. The reachable region above the feed zone is represented by  
\[\Gamma=\left\{ \begin{array}{rl}&(x,y,z)\ \left|\ \begin{array}{l}(|x- \theta c_{x}|=L/2)\wedge\\ (|y-\theta c_{y}|=W/2)\wedge\\ (|z-\theta c_{z}|=\epsilon)\end{array}\right.\end{array} \right\}\]  
where \(\epsilon\) is the height above the feed zone. The guard function is \(g:\Gamma\cap\mathcal{O}\rightarrow\{true,false\}\), where \(\mathcal{O}\) is the obstacle region, which is also the boundary of the other robot's action space. The _Fetch_ algorithm \(algo\) and the boundary function \(\pi\) are executed serially when the guard function g returns a value of \"true\". The algorithm \(algo\) includes the motion planning stage and the trajectory tracking control stage. The trajectory \(\tau\) obtained via motion planning is discretized into trajectory segments \(\tau_{1},\dots,\tau_{T}\), where \(\tau_{T}\) indicates that the _Fetch_ primitive is about to be completed. To track the segments \(\tau_{t}\), t = 1,2,..., T, the tracking controller applies the constraint space \(\mathcal{Q}_{t}\) to the joints of the robot. The robot's motion space is approximated by \(\pi\) as the trajectory is discretized. \[W(\tau)=\bigcup_{t=1}^{T}\{((\psi_{x}(q_{n}),\psi_{y}(q_{n}),\psi_{z}(q_{n}))| \psi(q_{n})\in\mathcal{Q}_{t}\}\ \mathcal{Q}_{t}=\{q|q_{n}^{dt}\leq q_{n}\leq q_{n}^{ut}\}\]  
where \(q_{n}=[q_{1},...,q_{n}]^{T}\) are the joint variables, \(n\) is the number of joints of the robot, and \(\psi_{\cdot}(q_{n})\) represents the length of the space that the robot can be controlled to reach by the variable \(q_{n}\) in a certaindimension, with \(q_{n}^{dt}\) and \(q_{n}^{ut}\) representing the lower and upper limits, respectively, of the joint motion. These boundary estimates are associated with a time series, and the number of estimates is related to the specifications for collaborative interaction in the specific application scenario. From a global perspective, the action space of one robot is the obstacle region of the other robot, i.e., \(W(\tau)\)\(\subseteq\)\(\mathcal{O}\). **Definition 9**.