# Reconfigurable Robotic Exercising Companion
## 3 Emotion-Based Feedback per Performance of Exercise
### Exercise Correctness Score  
The goal of this module is to evaluate the correctness of an exercise performed by a user. Although the mathematical modeling of the relationship between perceived parameters (i.e., posture deviation, \(D\) and movement speed, \(S\)) and exercise correctness is challenging, linguistic explanations based on expert knowledge can provide insights. In this context, fuzzy logic can be employed to model this process, which involves unknown dynamics and linguistic relationships [26]. Fuzzy logic is a universal approximator that can map the nonlinear relationship between input and output spaces through linguistic expressions [27; 28]. Additionally, the user parameters perceived by the robot may contain noise due to limitations in the vision-based detection of human body joints. In contrast, fuzzy logic effectively handles imprecise sensory information [29]. Furthermore, the relationships between input parameters and exercise correctness should be adapted to each exercise. Fuzzy logic possesses adaptive abilities, making it well-suited for evaluating exercise correctness based on the perceived information. Hence, fuzzy logic is utilized to develop the module to evaluate the correctness of an exercise performed by a user based on the perceived information.  
The inputs of the fuzzy logic module are the posture deviation, \(D\), and movement speed, \(S\). Figure 4a,b depict the corresponding input fuzzy membership functions. Nonsingleton fuzzy sets have been chosen to cope with the uncertainties in the inputs. The membership function for \(D\) has been defined with the three triangular fuzzy sets; L: Low, M: Medium, and H: High. The membership function for \(S\) has been defined with the three triangular fuzzy sets; S: Slow, G: Good, and F: Fast. The ranges \(D\) and \(S\) should be varied with the exercise a user is conducting since the amount of variation in body joint angles and the expected speed differ from one exercise to another. The ranges of the input membership functions are adapted with \(K_{e}\) and \(L_{e}\) to facilitate the adaptation of the fuzzy logic module for different exercises. The parameters \(K_{e}\) and \(L_{e}\) define the possible posture deviation and the speed range for the \(e\)th exercise. These range parameter values are derived by analyzing a set of typical series of exercise cycles, and obtaining the average for each selected parameter. These data are pre-stored in the database and retrieved when they are required.  
The output of this fuzzy logic module is the correctness score of an exercise performed by a user (defined by \(C\)). The output membership function is given in Figure 4c. The output membership function has five triangular fuzzy sets; VL: Very Low, L: Low, M: Medium, H: High, and VH: Very High. The fuzzy rule base given in Table 1 maps the input fuzzy sets with the output fuzzy sets. There is a particular speed that is most effective for a specific exercise, and performing it too fast or too slow would not be as impactful. Similarly, deviation in the postures should be minimized to make the exercise perfect. These facts were considered in formulating the rule base based on expert knowledge. The fuzzy sets in the output membership function are defined by equivalently dividing the output range in such a way that the minimum and the maximum output are in the range \([0,100]\). The fuzzy logic module is considered to be a Mamdani-type system with the center of area method for the defuzzification. A \(C\) value closer to 100 indicates that the exercise is performed flawlessly, while 0 indicates that the exercise is not performed at a satisfactory level.  
Figure 4: Membership function of the fuzzy logic module developed for evaluating the correctness of exercises. (**a**): the input membership function for \(D\), (**b**): the input membership function for \(S\), and (**c**): the output membership function.