# Robotic Motion Learning Framework to Promote Social Engagement
## 2 System Design and Algorithms
### Robotic Learning from Gestures
GMR is used for each iteration of the system to calculate whether the magnitude of the current activation state is sufficient to maintain the desired trajectory, or whether the system must utilize the next activation state. Due to its superior results during our preliminary comparisons, DMP with GMR was chosen as the motion learning algorithm for this study. This research brings multiple contributions to the DMP with GMR algorithm. Firstly, it adds angle-based reproduction. The original open-source DMP with GMR code solely performed point-based reproduction. In point-based reproduction, the goal state is a set of specified coordinates in three-dimensional space. The physical arrangement and angles of the robot limbs used to achieve this point are irrelevant. This can lead to unnatural limb positioning. In angle-based reproduction, the goal is for the robot's end effector angles to match the specified angles, resulting in a pose that mimics the user's own. We developed the code to produce angle-based replication by modifying the program inputs. The DMP with GMR algorithm plots two inputs, and then attempts to recreate the resulting line graph. Substituting angle inputs for Cartesian coordinate values resulted in angle-based reproduction values, rather than point-based ones. This research improved the reproduction accuracy of the algorithm by incorporating trajectory segmentation and fusion. A single user demonstration may contain multiple unique gestures, and therefore contain multiple movement primitives. However, the more primitives, or points within a primitive, are assigned to an activation state, the less accurate the reproduction will be. Additionally, there is not a linear relationship between the number of activation states implemented and the amount of time needed to run the algorithm--it takes longer to run one long segment with 20 activation states than it does to run four short segments with 5 activation states each. Figure 1: An example of DMP learning applied in trajectory: **(a) A** comparison of the reproduction accuracy of two motion learning systems (the rainbow overlays) for a two dimensional drawing (underneath, in gray), between WLS and GMR; **(b)** Grey bars represent the force components exerted when creating the original trajectory over time. Note that the forces are strongest when the trajectory forms each corner of the triangle. The activation states of Gaussian mixture regression (GMR) are automatically assigned based on the perturbation of the force on the system’s replication of the original trajectory; **(c)** The five activation states of each motion learning algorithm. Weighted least squares (WLS) activation states fire after equal intervals of time, whereas GMR activation states fire at corners, which are the defining portions of this particular trajectory. Therefore, in order to create the most accurate and time efficient reproduction, a trajectory should be separated into primitives before being processed by the motion learning algorithm. The segments are then rejoined before imitation, resulting in one full-length, higher accuracy reproduction. An example of this improvement to the methodology can be seen below in Figure 2. The blue original trajectory is roughly 350 points long. On the left is the reproduction (overlaid in orange), created using the motion learning algorithm once on the entire length, using ten activation states. On the right is the reproduction created using the motion learning algorithm on 90 point segments, with a 20 point overlap between segments, also using ten activation states. Finally, dynamic modulation of the activation state input was added to the DMP with GMR algorithm. In DMP with GMR, activation states are used to map the most drastic changes in system trajectory. The number of activation states needed vary based on the complexity of the trajectory segment presented. If too few states are used, the DMP recreation will be oversimplified beyond recognition.