# Reconfigurable Robotic Exercising Companion
## 3 Emotion-Based Feedback per Performance of Exercise  
### Perceiving Exercises  
The correctness of an exercise depends on several parameters. Each exercise requires the movements of a unique set of body joints in predefined ranges. Not achieving or exceeding these ranges tends to reduce the overall outcome expected from the exercise. This scenario can be used as a measure to evaluate the correctness of an exercise. For example, a situation of a person doing an exercise involved with hand movements can be considered. This exercise mainly involves two body joints (i.e., shoulder and elbow joints). Monitoring the movements of these joints can give an idea of how correct the exercise is. There should be a method to extract the information related to the body joint movement for the proposed system to evaluate the correctness of an exercise. In this regard, the proposed system utilizes a monocular camera to capture the movements of body joints. The locations of the body joints are extracted from 2D image frames using MediaPipe Pose framework ([[https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker)]([https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker)) accessed on 15 May 2024). Figure 1: Overview of the system. Figure 2: (**a**) Smorphi robot platform. (**b**) Robot shape configurations. This joint extraction model returns a total of 33 human body joints as depicted in Figure 3a. Here, each joint has a unique Identity (ID), which is useful for tracking. This information is then used to derive the joint angles that can be used to determine the correctness of the posture during an exercise [24]. Apart from varying the posture, the speed of the movements should be within certain limits for a specific exercise where the movement speed should not be too slow or too fast [25]. Therefore, posture correctness and movement speed are considered to evaluate the correctness of an exercise. The posture correctness is measured as the deviation from the required posture movement range. Given the 2D body joint coordinates for considered exercise, joint angles can be derived. For a predefined set of exercises, the required joint angles to be calculated are stored in a database with a given reference ID to each joint angle. Let set \(A\) consist of the exercises \(\{E_{1},E_{2},\ldots E_{e}\ldots E_{n}\}\). The \(e\)th exercise consists of an array of joint angles IDs \([\theta_{1},\theta_{2}\ldots\theta_{i}\ldots\theta_{n}]\) to be measured. Equation (1) explains how each exercise data point with relevant angles is stored in the database \(A\). The required angles can be derived using this database for a known exercise. \[A=\{E_{1}:[\theta_{a},\theta_{b},\ldots],\ldots,E_{e}:[\theta_{1},\theta_{2} \ldots\theta_{i}\ldots\theta_{n}],\ldots E_{n}\} \tag{1}\]  
A specific joint angle can be calculated using another database that stores a stack of body joint IDs required to form a specific joint angle. Let \(B\) be the set of the joint angle identities for the \(e\)th exercises such that \(B=\{\theta_{1},\theta_{2},\ldots\theta_{i}\ldots\theta_{n}\}\). Each joint angle ID points to a set of body joint IDs where \(i\)th joint angle can be measured using the locations of the joints \((j_{i-1},j_{i},j_{i+1})\). The mapping of joint IDs to each joint in database \(B\) is explained in (2). \[B=\{\theta_{1}:(j_{0},j_{1},j_{2}),\ldots,\theta_{i}:(j_{i-1},j_{i},j_{i+1}), \ldots\theta_{n}\} \tag{2}\]  
The joint angle \(\theta_{i}\) can be calculated as in (3), where \((x_{i},y_{i})\) is the extracted joint coordinates (see Figure 3b). \[\theta_{i}=tan^{-1}\frac{y_{i+1}-y_{i}}{x_{i+1}-x_{i}}-tan^{-1}\frac{y_{i-1} -y_{i}}{x_{i-1}-x_{i}} \tag{3}\]  
such that relevant body joint angles are calculated for each captured image frame at time \(t\).