Kinect Controlled NAO Robot for Telerehabilitation

In this paper, we focus on the human upper limb rehabilitation scheme that utilizes the concept of teleoperation. Teleoperation can help the therapist demonstrate different rehab exercises to a different group of people at the same time remotely. Different groups of people from a different place connected to the same network can get therapy from the same therapist at the same time using the telerehabilitation scheme. Here, we presented a humanoid robot NAO that can be operated remotely by a therapist to demonstrate the exercise to a patient. To mimic the movement demonstrated by the therapist, Kinect V2 sensor which is a markerless vision-based motion-tracking device, was used. Modified Denavit-Hartenberg (DH) convention was used for the kinematicmodeling of thehumanupper arm. From theKinect data, a geometric solutionwasdeveloped to find a unique inverse kinematic solution of human upper-extremity. Experimental results revealed that NAO could be teleoperated successfully to instruct and demonstrate patients to perform different arm movement exercises in real-time.


Introduction
Stroke is one of the major causes of human upper limb impairment. Moreover, it is the fifth leading cause of death for Americans. Statistics reveal that in every 40 seconds someone in the United States suffers from a stroke and in every 4 minutes, someone dies [1]. Including the cost of health care services, medicines, and missed days of work, the total estimated cost is approximately $34 billion each year in the United States [1]. According to the London: Royal College of Physicians, 77% of the stroke survivors, experience altered arm function, among them 40% are left with a non-functional arm [2]. Recovery from a post-stroke disability is obtained by the rehabilitation programs. Such rehabilitation programs are often labor intensive, and therapists usually work with patients one-on-one. Rehabilitation therapy in all phases of post-stroke includes intensive, highly repetitive tasks and task-specific training [3,4]. However, in the US, only 30% of stroke survivors can receive rehabilitation [5] due to an insufficient number of rehabilitation facilities [6]. All these post-stroke rehabilitation challenges demand to develop alternate/new rehabilitation technologies. Robot assistive reha-bilitation technology is one of the emerging technologies in post-stroke rehabilitation. Such technology may improve rehabilitation quality, productivity, and reduce costs of individuals with a disability.
Extensive research has been done to develop robotic devices for rehabilitation of patients with upper limb impairment. The most commonly known robotic orthotic devices include, but are not limited to, ETH Arm rehabilitation (ARMin) [7], InMotion2 developed by Interactive Motion Technologies, Inc., Boston, MA (commercially available version of the MITManus) [8], The Mirror Image Movement Enabler (MIME) [9], ETS-MARSE [10].
Recently, researchers have been interested in developing robotic systems to work as a coach and perform a therapeutic role through human-robot interaction. Studies reveal that using robots in therapeutic roles keep patients motivated and provide promising and positive interaction responses [11]. Tele-operation of robotic devices is one of the emerging technology that enables researchers to use robotic devices in a therapeutic role. The main idea behind such an approach is to extract motion information of an actor's movements and replicate these movements to a robot within the anatomical joints limits and constraints of the robot. The major challenge in this approach is to record joints position (such as upper limb joint) coordinates of the actor and accurately convert it to a joints angle to control a robotic device. Different motion tracking devices exist that are used by the researchers to track human motion. Thobbi and Sheng [12] used a Vicon tracker that use multiple markers to track human movements and applied this information to teleoperate an NAO robot. Cole et al. [13] used a markerless system consists of a single camera that tracks the motion of an actor to map it on a simulated HOAP-2 humanoid robot. To track the actor's joint position, the actor needs to wear a special colored suit. Different researchers also used different methods to obtain joint information by tracking the actor's performance. Wang et al. [14] transformed actor's motion information into a critical frame, which is obtained by a Kinect sensor and applied inverse kinematics through an optimization process to obtain joint information of the NAO robot. Suleiman et al. [15] used Kinect sensors to track an actor's movement information, then formulate it as an optimization problem where constraints are humanoid robot's physical limitations. Rosado et al. [16] also considered a motion mimicking problem as an optimization problem, and teleoperated a simulated 4 DoF robot model by tracking actor movement information through Kinect. Ningjia et al. [17] calculated the joint angles of the robot using the spatial vector method from the data obtained by tracking a human actor through Kinect. Ude et al. [18] used a standard non-linear least square optimization method to obtain robot motion data from the actor's tracked data.
In this paper, we used the Kinect v2 sensor to track human motion. In the recent decade, the Kinect sensor extensively used for human motion assessment and rehabilitation purposes. Kinect sensor integrated with virtual reality for rehabilitation gaming therapy shows promising results for patient's motor and functional recovery [19][20][21][22][23]. Kinect sensor also used for human upper and lower extremity motion assessment for the purpose of recovery improvement tracking and providing feedback [24][25][26][27]. Kinect motion tracking sensor system is a markerless system, and does not require any sophisticated calibration. The markerless system allows us to estimate motion more accurately than other motion capture systems, where there is a possibility for inaccurate marker placement. Instead of solving complex inverse kinematics to estimate joints angles, we proposed a simple complete geometric solution to find joint's angles. This geometric solution allows quick estimation of joint angle and needs less computational power. We used the NAO robot to demonstrate upper limb exercises by mimicking the actor's motion. The humanoid robot NAO can communicate verbally. Verbal communication provides a ground for social interaction and share emotions [28,29]. NAO robot shows promising usability in the fields of pediatric rehabilitation, socially assistive robotics, human motion imitation and learning artificial intelligence [30][31][32][33][34].

Humanoid Robot NAO:
For a demonstration of telerehabilitation, we have used a humanoid robot NAO due to its human-like (a) appearance; (b) acrobatic movement capability; and (c) communication capability using vision sensors, speech sensors, hearing sensors, and touch sensors. All these features make NAO one of the most promising au-tonomous programmable robot [35]. NAO was developed by Aldebaran Robotics. It has 25 joints, two cameras, four microphones, two loudspeakers, nine tactile sensors, and eight pressure sensors. It is 574 mm tall and 275 mm in width. NAO robot has two joints in the head (neck), five joints in each arm along with hand close and open motions, five joints in each leg and two hip joints. All these sensors and actuators make NAO capable of performing all simple human motions such as walking forward and backward; sitting down and standing up; waving hand; playing soccer, etc. In this study, we focused on upper extremity rehabilitation scheme; therefore, throughout the study, we have focused on the upper arm (right) of the NAO. NAO has its own central processing unit (CPU) to execute command and control all the sensors. Its motherboard consists of Intel ATOM 2530 1.6 GHz processor with cache memory 512KB, clock speed 1.6 GHz and FSB speed 533mHz, 1GB RAM, 2GB flash memory and 8GB Micro SDHC. Also, it provides communication through WiFi using IEEE 802.11 a/b/g/n protocol, Ethernet, and USB interface. Its USB port mainly used for updating the robot operating system. For advanced programming of NAO robot. Aldebaran provides API for language C++, Python and Java for NAO V5. Python SDK for the NAO robot requires Python 2.7-32 bits. It only works for this environment (Python 2.7-32 bits). C++ SDK requires a C++ compiler for different OS. For Windows, C++ SDK only works for Visual Studio 2010. Windows also have some limitations; there is no C++ cross compiler. As a solution to this problem, Windows users need to install qiBuild, a tool design to generate cross-platform projects using CMake along with the C++ SDK. In our study, we have used Python 2.7.13 and Python SDK to control the NAO for advanced functionality.

Human Motion Tracking Device:
The most important thing in teleoperation is to track the human upper limb motion. For this purpose, we use the markerless vision-based tracking device Kinect. Kinect sensor developed by Microsoft, has a depth sensor, a color camera, and a four-microphone array. It can track the full body of a person. Due to its low price, Kinect is used for different applications in different fields. Microsoft Kinect is equipped with an IR depth sensor, one RGB camera, and a four-microphone array. Using depth sensors, it can produce a 3D depth image with regulation 512x424 at 30 FPS (frame per sec) and range 0.5 to 8 meters. It provides light independent infrared and able to remove the ambient light effect. RGB camera provides full HD 1920 x 1080 regulation. It also provides either 30 or 15 FPS based on lighting. The most amazing feature of the Kinect sensor is that it can track a fully human body. It can track 25 joints of the human body with clear identification of hand states whether it is open or close. Body joint tracking means that it provides the coordinates of each joint in 3D space. It can track a total of six-persons simultaneously in front of it within a range of 0.5 to 4.5 meters. Through the microphone, it also can detect sound direction. Field of view of its depth camera is 70 ∘ in horizontal and 60 ∘ in the vertical direction. To access the Kinect data, we used the Kinect V2 SDK. This SDK provides the necessary API to extract Kinect data using Visual Studio 2012 or higher. It is (SDK) compatible with programing language C++, C#, Java. In this research, we have extracted Kinect data to analyze human arm kinematics and also to teleoperate the NAO (in real-time) to establish the proposed telerehabilitation scheme. As mentioned earlier Kinect can track 25 joints of the human body. However, in this study, our focus was on the human upper extremity. To serve our purpose, we tracked only 11 joints of human upper extremities that include shoulder, elbow and wrist joint of each arm along with the head, neck, spine shoulder, spine mid and spine base joint. In the proposed telerehabilitation scheme human right arm movement was considered to actuate the NAO's right arm. To replicate NAO's arm movement, human upper arm was modeled as a two degrees of freedom (DoF) shoulder joint (to provide abduction/adduction, and vertical flexion/extension motion), and a one DoF elbow joint (to provide flexion/extension motion). To develop the kinematic model human right arm's kinematics was analyzed using the modified DH convention [38]. The coordinate frame attachment for this analysis is depicted in Figure 4. In this model, Joint 1 represents shoulder abduction/adduction, joint 2 corresponds to shoulder vertical flexion/extension, and joint 3 depicts the flexion/extension of the elbow joint. Distance between the shoulder joint and the elbow joint is d 1 and that is between the wrist and the elbow joint is d 2 . The modified DH parameters for the human upper arm are summarized in Table 1. where α i−1 is the link twist, a i−1 corresponds to link length, d i stands for link offset, and θ i is the joint angle of Human Arm.
The general form of a link transformation that relates frame {i} relative to the frame {i − 1} is can be expressed as [38]: where, i−1 i R is the rotation matrix that describes the frame {i} relative to frame {i − 1} and can be expressed as: moreover, i−1 i P is the vector that locates the origin of the frame {i} relative to the frame {i − 1} and can be expressed as: The homogenous transformation matrix that relates frame {4} to frame {0} can be obtained by multiplying individual transformation matrices.
The single transformation matrix thus found from equation (4)  For telerehabilitation purpose, teleoperator's upper-limb joint variables (θ 1 , θ 2 , and θ 3 ) were computed in real-time from the Kinect coordinate data (see Figure 3b). More details on this were discussed in the next section. Note that, NAO's upper arm range of motion (ROM) differs compared to that of the human upper arm. For instance, NAO's elbow joint ROM is around 60 ∘ less (see Table 2) compare to that of the human elbow joint (θ 3 ). In addition, NAO's shoulder joint roll (abduction/adduction, θ 1 ) motion ROM is smaller compared to that of human shoulder joint motion. On the other hand, its shoulder pitch (vertical flexion/extension, θ 2 ) ROM is larger compared to that of human shoulder joint pitch motion. Human upper-arm joints motions are depicted in Figure 5.

Control Scheme
To control NAO's right arm movement (remotely), the Kinect sensor was used to generate the control signal. This sensor can track human motion in front of it. Note that, Kinect sensor provides Cartesian coordinate information of the human upper arm joints (shoulder, elbow, and wrist), whereas, human upper arm joint angles are required to teleoperate the NAO. Figure 6 shows the schematic of the control approach where it shows human arm joint angles were used as a reference input to the NAO's controller. The geometric approach was used to compute human arm joint angles from Kinect data.

Geometric Calculation of Joint Angles:
As stated earlier, Tele-operators upper arm joint coordinates (i.e., the coordinates of the shoulder (x sk , y sk , z sk ), elbow (x ek , y ek , z ek ), and wrist (x wk , y wk , z wk ) joints) in 3D space with respect to the Kinect's reference coordinate frame (see Figure 2) can be directly obtained from Kinect. However, we need to compute the joint angles from the co-ordinates data. Note that, the orientation of the frame {0} (teleoperator's shoulder joint frames, see Figure 4) is identical to the Kinect coordinate frame (see Figure 2). The co-ordinate of the elbow (frame {3}) and the wrist (frame {4}) joint with respect to frame shoulder frame {0}, {1} or {2} thus can be found by subtracting shoulder joint coordinate from the elbow and the wrist joint coordinates which were obtained from Kinect sensor. Therefore, for a known shoulder joint co-ordinate (x sk , y sk , z sk ), the elbow and wrist joint coordinates with respect to the shoulder joint of the teleoperators can be found as follows: • Elbow joint coordinates with respect to the shoulder frame: (xe , ye , ze) = (x ek − x sk , y ek − y sk , z ek − z sk ), and • Wrist joint coordinates with respect to the shoulder frame: Let us consider a vector OA along Z 0 axis is in a negative direction with unit length (see, Figure 7). Then the point A locates at (0, 0,−1) position. Now, the angle between the d 1 vector OA is the angle θ 2 . Also, consider a vector OB along the X 0 axis is in a positive direction with unit length. Then the point B locate at (1, 0, 0) position. Therefore, the angle between OB and d 1 is the angle θ 1 . then, and, sin θ 1 = ± √︁ 1 − (cos θ 1) 2 . therefore, and, sin θ 2 = ± √︁ 1 − (cos θ 2) 2 .
Finally, from the triangle shown in Figure 8, θ 3 can be found using the cosine rule.  For the convenience of representation, three joint angles of NAO are represented as θ 1 , θ 2 and θ 3 throughout this paper.

Control Architecture:
Computation of joints angle from the Kinect data was performed in the host PC in the MATLAB environment. The angle values are then sent to the NAO's operating system as input information to the NAO's controller where a built-in position controller was used to maneuver the NAO to follow the desired joint angles (i.e., in this case, upper arm joint angles). Note that, to transfer the MATLAB output (i.e., joint angles) to NAO, Python programming language was used along with Python SDK. In this project, a TCP/IP socket was used to establish communication between the MATLAB and the Python. For this, a TCP/IP object was created in both MATLAB and Python with the same IP address and port number. MATLAB sends the angle value to python through this TCP/IP object and after receiving the angel values Python sends the motor command to NAO robot by calling ALmotion modules in NAOqi [40] Then NAOqi sends the control signal to the NAO's joint motor. NAOqi uses linear interpolation method to generate the motion trajectory between two successive motor commands.

Performance Analysis:
To analyze the performance of the developed teleoperation scheme, some basic experiments were conducted on NAO robot, where a healthy adult subject (age: 25, height: 5.4ft, mas: 65Kg) performed following singlejoint movement exercises in front of the Kinect to teleoperate the NAO robot in real-time.
The experimental results are shown below. In our first teleoperation experiment, NAO's shoulder abduction/adduction motion was controlled. Figure 9 shows the position of NAO's upper arm and that of teleoperator's upper arm at different instances while performing shoulder abduction/adduction motion. As shown in Figure 10, the motion began from −10 ∘ , and ended at −74 ∘ (i.e., within the range of NAO's joint ROM). Figures 10(a), and 10(c) show the Kinect coordinate data of the teleoperator's upper arm joints (i.e., shoulder, elbow, and wrist joint). While performing shoulder joint abduction/adduction motion, the Z coordinate from Kinect frame of all joint should be constant which is matched with the tracked results ( Figure 10(a)). Figures 10 (b) and 10(c) display the trajectory followed by a human operator and NAO robot. Motor position feedback from the NAO was obtained through Device Communication Manager (DCM). There are two separate data come from NAO's DCM; one set of data that comes from motor controller output, and goes to the motor for execution which is called motor command; and the other set of data that comes from the joint position sensor MRE (Magnetic Rotary Encoders) is called sensor reading. From Figure 10(b), it is obvious that there was some difference between these two data. The reason of this difference is when NAO moves any of its (upper arm) joints, the motion is interpolated between the current value of the motor position and the targeted value, and it takes some time for the command to go to the motor cards and take some time for sending the reading back. There was also some delay between the Kinect data and the motor command because these two programs run in two different platforms. Kinect extract data in MATLAB and Python communicate with NAO robot through Wi-Fi communication. MATLAB and Python communicate through TCP/IP communication. There is some delay between sending and receiving data between MATLAB and Python. Besides, NAO's controller needs some time to execute all its current command to take the next command. To eliminate/reduce such delay all the platforms are needed to be synchronized. However, it is a little bit difficult when there are multiple platforms are used (in this case MATLAB, Python, NAOqi). Nevertheless, from the above results, it is obvious that the operator's upper limb trajectory pattern was nicely followed by the NAO robot. Figure 11 shows the upper arm position of the NAO and the human operator at different instances of shoulder joint vertical flexion/extension motion. The experimental results are shown in Figure 12 where it can be found that the motion starts at 90 ∘ and ends at 15 ∘ . Note that, the actual range for this motion was higher than the range 90 ∘ to 15 ∘ , but we limit this motion 90 ∘ to 15 ∘ for experimental purpose. Figure 13 shows the hand position of the NAO robot and human operator at different instances of elbow joint flexion/extension motion. It can be seen from the Figure 14 that the elbow motion was started at 15 ∘ and ended at 85 ∘ . Figure 14 (a) shows the coordinate data obtained from the Kinect sensor for the shoulder, elbow, and wrist joint. It is to be noted that, while performing elbow flexion/extension motion, the joint coordinates of the elbow and the shoulder joint (measured from the Kinect frame) should remain unchanged and only the wrist joint coordinates change with elbow flexion/extension motion. In addition, the X coordinate for wrist joint should be constant as the elbow motion is in YZ plane. Thus, in Figure 14 (a), it can be seen that all the red dots (proximal red dots-indicates) and black dots (indicates shoulder joint) were clustered at the same position throughout the trial.    second multi-joint experiment was diagonal reaching which is a combination of three joints motion-shoulder vertical flexion/extension and abduction/adduction, and elbow flexion/extension. The results of this experiment are shown in Figure 17 and Figure 18. From these experimental results, it is clear that there has a lagging between the human operator's upper arm joint angle and that of the NAO robot. However, the pattern of the trajectory followed by the NAO robot was the same as that of the human operator. The objective of the developed control approach is to teleoperate the NAO robot according to the trajectory produced by a human operator. The experimental results evident that the developed control scheme can successfully be deployed to teleoperate the NAO. Therefore, we may conclude that using the developed control approach one can remotely control the NAO as long as they are connected to the same network. Thus, a therapist can introduce/demonstrate new exercises remotely using the NAO robot.

Conclusion
We developed a successful telerehabilitation scheme in which a therapist can introduce new exercises to the patient (or a group of patients) remotely. By doing so, it can facilitate many patients in different places under rehabilitation as long as the NAO and Kinect sensor are connected under the same network. The motion tracking is easy and simple. In this research, a unique inverse kinematic solution was obtained to overcome the singularity problem. Studies show that patients often do not feel comfortable showing their disability to other people, or they do not feel good being in front of other people. The telerehabilitation would be a potential solution in such cases. Note that, this telerehabilitation scheme is the part of a high-level remote rehabilitation scheme in which we will utilize all the joints (5DoFs) of NAO robot and will introduce a remote communication strategy in which we will not require to connect the NAO and the Kinect in the same network.