## 3 Personalized Exergame Language
### Metrics component
The EBNF grammar for metrics block is specified next:  
\begin{tabular}{l l l} METRICS & \(::=\) & \"**metrics '**' ':' BLOCK_METRICS \\ BLOCK_METRICS & \(::=\) & '{' KPI {',' KPI } }' \\ KPI & \(::=\) & REHAB_TIME | MOBILITY | \\  & & BALANCE_CTRL | DISPLACEMENT | \\  & & PERFORMANCE \\ REHAB_TIME & \(::=\) & \"**rehabilitation_time '**' ':' \\  & & BLOCK_REHABTIME \\ BLOCK_REHABTIME & \(::=\) & '{' DEFINITION_REHABTIME '}' \\ DEFINITION_REHABTIME & \(::=\) & TIME_ACTIVITY ',' TIME_VNODE ',' \\  & & TIME_REPETITION ',' TIME_REST \\ TIME_ACTIVITY & \(::=\) & \"**time_activity '**':' BLOCK_TIME \\ TIME_VNODE & \(::=\) & \"**time_vnodes '**':' BLOCK_TIME \\ TIME_REPETITION & \(::=\) & \"**time_repetition '**':' BLOCK_TIME \\ TIME_REST & \(::=\) & \"**time_rest '**':' BLOCK_TIME \\ BLOCK_TIME & \(::=\) & '{' DEFINITION_TIME '}' \\ DEFINITION_TIME & \(::=\) & TIME ',' LABELS \\ TIME & \(::=\) & \"**time '**':' VALUES \\ VALUES & \(::=\) & '[' integer ',' integer '] \\ LABELS & \(::=\) & \"**labels '**':  
\begin{tabular}{l l} DISPLACEMENT & \(\mathrel{\mathop{:}\mskip-10.0 mu =}\) & **\"displacement \"'', \\  & BLOCK\_DISPLACEMENT & \(\mathrel{\mathop{:}\mskip-10.0 mu =}\) \\ BLOCK\_DISPLACEMENT & \(\mathrel{\mathop{:}\mskip-10.0 mu =}\) & \(\mathrel{\mathop{:}\mskip-10.0 mu =}\) \\ DEFINITION\_BLOCKDIS & \(\mathrel{\mathop{:}\mskip-10.0 mu =}\) & STATIC\_STEP'''''''''''''''''''''''''''''''''''''''' '  
It should be noted that, although the language proposed in this work is simple enough, the therapist is not intended to be the one that use it. As already mentioned, the idea is to have an intermediate language that can be manipulated by advanced subsystems, according to various aspects, such as the interaction of the patient with the exercise. In this context, the therapist may need a high-level authoring tool that facilitates the design of the exergame. This tool would integrate a software module in order to generate the PEL sentences that are equivalent to the graphic definition of the exergame. Although the development and evaluation of this tool is beyond the scope of this article, a first design has been addressed in order to complement the proposed approach. For the definition of the exercise and rehabilitation objectives specific to each patient, the therapist will be provided with a graphical definition tool that facilitates the definition of key positions, as well as the specification of the different variables and options available in the exergame. This graphic editor encapsulates the gITF and JSON components that will be automatically exported and used by the other components of the tool. Internally, the graphical editor module would employ a description based on the H-Anim standard (ISO/IEC IS 19774-1:2019). As for the bone hierarchy, each animation chain is composed of several _articulated_ elements that define transformations from the root of the hierarchy. There are several specific avatars for rehabilitation, such as [38] or [39], which, however, are not focused on the creation of exercises by non-technical staff without using motion capture techniques. The precise configuration of the positions and rotations of each part of the animation hierarchy is essential when defining rehabilitation exercises. The definition of movement must allow for both rapid definition of movements, using in our proposal inverse kinematics (IK), and subsequent fine tuning, using direct kinematics methods. In the virtual avatar integrated in the proposed tool, every element of the kinematic chain can be positioned and rotated while using realistic human limitations. This is the most time consuming phase in the generation of a new exergame. As detailed next, a new approach has been devised in order to increase the adaptability and the ease of use by the therapist. The graphic editor will allow defining start and end positions in three different ways:  
* Use a set of predefined key positions. This option allows to directly input common positioning settings for each limb.