# Personalization of Robot Behavior Using Approach Based on Model Predictive Control
## 3 Proposed Solution  
In our previous work [11], we proposed a human-robot interaction framework that can work on multiple platforms and streamline the creation of interaction scenarios. The main focus was on perception modules and framework architecture. In this work, we will extend the adaptive decision module to provide behavior personalization. A diagram presenting our framework architecture is shown in Figure 1. It is written in Python language. _Perception components_ are responsible for processing raw data obtained from the sensors, giving a higher-level perception description. The _face-tracking_ component processes raw video from the camera, taking into account the robot's joint position, and moves the robot to follow the detected user face. Figure 1: Framework architecture. The _Gaze-Detection Direction_ module extracts the user's gaze direction from the video and combines it with the robot's joint positions. The module returns angle values representing the gaze direction in the camera's plane of perspective. The _Question-Detection_ component converts the audio signal to spectrograms and, using a deep neural network, detects when a question is asked. The _Emotion_ component identifies the user's face in the camera image and classifies the expressed emotion using a deep neural network. The _Speech-Recognition_ module transcribes the audio input into text. We use Google Speech-to-Text for this functionality to achieve the best results. The _Behavior Planner_ reads _Activity Scripts_ and, using the perception description and the _Adaptive Decision Module_, selects and executes _Actions_, which represent basic or complex activities performed by the robot according to the scenario outlined in one of the _Activity Scripts_. Our solution is based on the Model Predictive Control (MPC) method [12]. MPC is an advanced control strategy that uses a mathematical model of a system to predict and optimize its future behavior over a defined time horizon. At each step, MPC solves an optimization problem by considering the current system conditions and constraints to determine the best sequence of control actions. Then, it applies the first action from the sequence, recalculating the next optimal sequence in subsequent steps as new data become available. This process allows MPC to handle multivariable systems with constraints on inputs and outputs, making it highly effective for complex, dynamic environments. In our solution, the MPC approach is applied in the decision module. Figure 2 presents its architecture. In Figure 3 we can see a flow chart showing how this module works internally. The _User model_ is a key element used to adapt to the personality of the user. The _User model_ is fed with input _Data_ from the available sensors. Then, it predicts the user reaction to all possible robot actions, and the best action is picked to execute by the optimization component. Selection is based on _cost function_, which currently combines two factors: maximizing the user's positive emotions and increasing the user's focus calculated in a given optimization time horizon. MPC has several limitations. The first is computational complexity. It is necessary to execute the User model many times to choose the best decision, especially when the time horizon value is high. However, in our approach, MPC is not applied to a real-time problem. The _Adaptive Decision Module_ controls high-level functionalities. Therefore, delays are more acceptable. Another problem is the limited resources on the robot platform. Our platform allows for distributed computation; therefore, the solution is to run highly demanding computations on a server. The final issue is cost-function parameter tuning. We have tuned it manually, which is described below, but algorithmic approaches can also be applied (e.g., using Gaussian processes or the genetic algorithm [13; 14]). In our experiments, we apply a time horizon equal to one step for user reaction prediction and for optimization.