An Adaptive Hybrid Control Architecture for an Active Transfemoral Prosthesis

The daily usage of a prosthesis for people with an amputation consists of phases of intermittent and continuous walking patterns. Based on this observation, this paper introduces a novel hybrid architecture to control a trans-femoral prosthesis, where separate algorithms are used depending on these two different types of movement. For intermittent walking, an interpolation-based algorithm generates control signals for the ankle and knee joints, whereas, for continuous walking, the control signals are generated by means of an adaptive frequency oscillator. A switching strategy that allows for smooth transitioning from one controller to another is also presented in the design of the architecture. The individual algorithms for the generation of the joints angles’ references, along with the switching strategy was experimentally validated on a pilot test with an healthy subject wearing an able-bodied adapter and a designed trans-femoral prosthesis. The results demonstrate the capability of the individual algorithms to generate the required control signals while undergoing smooth transitions when required. Through the use of a combination of interpolation and adaptive frequency oscillator-based methods, the controller also demonstrates its response adaptation capability to various walking speeds.


I. INTRODUCTION
T HE restoration of mobility for people with transfemoral amputation is essential to improve their quality of life. However, through the use of passive prostheses, only a partial restoration may be achieved due to their limited adaptation capability to different activities of daily living. To ease ambulation, the development of active transfemoral prostheses is considered an important area of research, as they provide suitable actuation to the joints thanks to the control strategies designed to achieve the desired system behavior.
In literature, various architectures have been proposed for the control of active transfemoral prostheses, as summarized in Table 1. In [1], [18], a multi-modal intent recognizer for a transfemoral prosthesis is proposed and designed for different locomotion modes, comprising level ground walking and stair/ramp climbing, while two supplementary modes of stand-still and stumble are added to improve the safety of the system. A similar state machine is designed for the transfemoral prostheses in [2]- [4] and [5] where, based on gait events (i.e., heel-strike, flat-foot, and toe-off), the phases of walking are classified into different states (i.e., controlled plantarflexion, controlled dorsiflexion, powered plantarflexion, and knee swing). Inspired by [1], an echo control strategy running atop the previously mentioned state machine is discussed in [6], [7] and [8], where a modified motion of the healthy leg is played back on the contralateral side, while [2], [9] and [11] discuss a state machine-based impedance control. There are also methods found in the literature that allow for speed adaptation and obstacle crossing over by the use of joint torque regulation through the generation of quasi-stiffness torque profiles [19] and use of heuristic techniques [20]. Apart from the state machine and echo control strategies, in the past few years, significant efforts have also been made in using electromyography(EMG) from residuallimb muscles to classify user intent and then impose a predetermined gait trajectory. Progress using this method has been demonstrated in [12], [21]- [23] and [17]. Furthermore, in recent times with the improvement in processing power of onboard computers, computer vision and range sensors, have also been proposed to improve classification accuracy as has Multi-mode above-knee prosthesis controller Ankle/Foot Multi-mode state machine [2] 2009 Powered ankle-foot prosthesis improves walking metabolic economy Knee/Ankle Gait event-based state machine [3] 2013 Ankle/knee prosthesis with powered ankle energy transfer (CYBERLEGs-α) Knee Gait event-based state machine [4] 2011 Metabolic cost of walking comparison Knee Gait event-based state machine [5] 2014 CYBERLEGs: A user-oriented robotic transfemoral prosthesis Knee/Ankle Gait event-based state machine [6] 2008 Design and control of an active electrical knee and ankle prosthesis Knee/Ankle Echo control [7] 2008 Design and control of powered transfemoral prosthesis Knee/Ankle Echo control [8] 2009 A powered self-contained knee and ankle prosthesis for near normal gait Knee/Ankle Echo control [9] 2014 WalkMECHadapt Knee Iterative learning control [10] 2014 Virtual constraint based control of powered leg Knee/Ankle Virtual constraint defining joint patterns [11] 2015 A powered prosthesis intervention for bilateral transfemoral amputee Knee/Ankle State machine with impedance control [12] 2015 Intuitive control of powered prosthetic leg during ambulation Knee/Ankle EMG-based control [13] 2012 Cybernetic knee prosthesis Knee/Ankle AFO-based control [14] 2019 Phase variable approach for rhythmic & non-rhythmic human locomotion Knee/Ankle Knee angle phase variable control [15] 2020 Online estimation of continuous gait phase for transtibial prosthesis Ankle/Foot AFO-based control [16] 2020 Compliant control of transfemoral prosthesis Knee/Ankle AFO-based control [17] 2021 Stand, squat, lunge, walk with knee/ankle prosthesis with Neural Control Knee/Ankle EMG-based control been shown in [24], [25] and [26]. A phase variable control approach, wherein a single variable can parameterize the entire gait cycle of the prosthetic leg, is often used to determine motion trajectories as an alternate to EMG and state machine methods. In [10] the progression of the center of pressure was used as a phase variable for gait tracking, while [27] and [28] showed the existence of multiple angles associated with the hip joint that might be used as phase variable candidates in gait tracking for multiple activities.
An extension of the phase-variable approach to prosthesis control is the controller design based on central pattern generators or Adaptive Frequency Oscillators (AFOs) [29], [30], wherein virtual joint angle references are generated to guarantee continuous control of prosthetic limbs by coupling the gait frequency with the frequency of the oscillators, as shown in prosthesis [13], [15], [16] and orthotic devices [31]- [33]. This is achieved by using a mathematical periodic function with an initial starting frequency on which the frequency of the gait cycle is dependent. Over the course of multiple gait cycles, a change in gait frequency causes a change in the period of the function. Although AFOs are capable of allowing for continuous trajectory generation for repetitive tasks, usually in applications, their allowable frequency variance is fixed between maximum and minimum limits. Beyond these limits the performance of oscillators for gait tracking becomes unsatisfactory.
In this study, we contemplated upon the observation that the natural human gait in everyday life is a combination of cyclic and acyclic phases [34], [35]. For example, movements inside closed/confined spaces (e.g., indoors, such as livingroom, kitchen, etc.) are generally intermittent in nature, whereas, outdoor walking is generally more repetitive with a maintained gait speed. Building upon this observation, we propose a hybrid control architecture in which periods of continuous movement (i.e., level ground walking at different velocities) are controlled by AFOs, while the aperiodic phases (i.e., start and stop walking) are controlled by using interpolation techniques through the detection of gait events (i.e., heel strike and toe-off). Throughout the operation of the system, the AFO algorithm runs in parallel to the state machine, while the hybrid nature of the controller ensures smooth transitioning between the two control modes.
The significance of using such an approach is twofold. Firstly, in the case of a singular state-machine-based system, the walking speeds of the subject for slow, normal, and fast walking are usually determined experimentally, followed by which, joint-angular velocities are used as a reference for various walking efforts. On the other hand, in a system supplemented with an oscillator-based speed adaptive algorithm, this is not necessary as the AFO automatically and continuously adapts the joints' reference angles according to the walking speed, estimated using inertial measurement units (IMUs). Moreover, in a singular state machine approach, the speed change is discrete and the extents of change are predetermined through experiments. On the other hand, AFO adaptations have the inherent benefit of having a continuous speed change. Secondly, an AFO algorithm running in parallel to the state machine might act as a fallback method for reference generation for the system during emergencies, such as the failure of onboard sensors (force, pressure sensors). Usually, a sudden failure of onboard sensors in a prosthetic system results in the system becoming unusable. On the other hand by supplementing the control system with a gait tracking algorithm that depends on inputs from a single IMU only, a limited operation of the prosthesis might still be possible. Finally, when the only IMU in the system fails, the safety of the user must be ensured by locking the joint positions to a neutral position for the ankle and a hyperextended knee.
The adaptive hybrid control architecture proposed in this study has been implemented and tested in a custom-made transfemoral prosthesis that has been designed for level ground walking at different velocities, with an eye on mechanical simplicity and lightness in weight. Experiments with the prosthesis using an able-bodied adapter show that the control architecture is capable of generating reference angles for the ankle and knee joints, in both start/stop walking (using the state machine-based control) and continuous walking at different speeds (using the AFO-based control).
The remainder of the paper is organized as follows. The hybrid control architecture for a transfemoral prosthesis is presented in Section II. Section III describes the mechatronic design of the transfemoral prosthesis that has been realized to validate the control architecture. The experimental results are presented and discussed in Sections IV and V, respectively. Finally, concluding remarks are drawn in Section VI.

II. HYBRID CONTROL ARCHITECTURE
The proposed adaptive hybrid control architecture, as shown in Figure 1, is responsible for the detection of the mode of the prosthesis (namely whether the user is stationary, starts/stops walking, or walks continuously), along with the generation of the reference angles for the knee/ankle joints. A low-level motor controller, then, tracks these reference angles while monitoring the peak torque and current limits.
The controller receives the vertical acceleration data from a single IMU (MPU 9250-9 DOF, Sparkfun USA,www. sparkfun.com) placed above the knee joint. These data are then used to detect heel strike gait events and to keep a count of the number of steps taken by the prosthesis' user. The flowchart of the gait event detection function used in the prosthesis is shown in Figure 2. The algorithm uses the vertical component of the filtered accelerometer data sourced at 200Hz to detect gait events. At any given time, two data points (latest and previous) are compared against a set-threshold to set/unset a flag for a gait event. The threshold is determined experimentally based on the chosen sensitivity, measurement ranges, placement/orientation, and data filtration bandwidth of the IMU. For the current application with an IMU sensitivity of 4 G, a cut-off of 1.2 G proved to be a reliable threshold for comparison. The output of this algorithm is then sent to the step counter algorithm for counting the number of steps and classifying whether the prosthesis is in motion or stationary.  The flowchart of the step counter algorithm is shown in Figure 3. The algorithm takes the flag of the gait event from the gait-event detection algorithm along with a record of the system time during the last detected positive gait event as input and compares the time duration between two successive gait events. In the case where this time difference lies between a minimum and maximum of allowed step time, the event is considered a valid step, and the step count increases. For the current application, the minimum and maximum limits to be considered a step was set at 250 ms and 2200 ms, respectively. In the cases where it lies outside these limits, a further check is made by comparing it to the allowed VOLUME XX, 2022 time_diff>=MIN_STEP_TIME && time_diff<=MAX_STEP_TIME time_diff> STEP_ BUFFER_TIME step_count=reset step_count+=1 step_time=time_diff step buffer time. If the time difference is greater than the step buffer time, the step counter is reset. For the current application, the step buffer time was selected to be 2800 ms. In this way, the two algorithms working together can keep track of gait events and step counts. Once more than 2 steps are detected by the algorithm, the prosthesis is considered to be in motion, while for a step count lesser than 2 the prosthesis is considered to be stationary.

Yes
This information is, then, processed either through a state machine (i.e., the stationary/transient walking mode) or an AFO (i.e., the steady-state walking mode), that sets the reference angles for the knee and ankle joints, which are tracked by the motor controller. Herein lies the hybrid nature of the controller, which is capable of switching from one mode to the other.

A. STATIONARY AND TRANSIENT WALKING MODE
In the stationary and transient walking mode, two different reference angles are generated. When the prosthesis is detected to be stationary, fixed values of angles are maintained at the joints. On the other hand, when the prosthesis is detected to be in transition walk, predetermined reference angles are imposed to the joints. The reference angles are computed starting from a vector y(n), with n ⩽ N , containing the angular kinematics of one gait-cycle of healthy subjects during normal level ground walking [36]. Here N is the number of data points in one gait cycle determined at "normal walking speed" and fixed frequency determined by the system's frequency (200Hz in this case), whereas y(n) is the vector determined by resampling the reference data at the same frequency and walking speed. Starting from this, a new vectorȳ(n) is generated by using the step time information from the heel strike gait events. Specifically, the reference anglesȳ(n), withn ⩽N , is computed in real time by using a linear interpolation technique. The total number of reference angle pointsN in one footstep is given by: where ref _st is the step time in the reference data [36] and latest_st is the step time of the latest gait-cycle. For every new step, the reference anglesȳ(n) is given by: where ⌊·⌋ indicates the floor function and {·} the fractional function.
Following this for every footstep, a single value of reference angle is used as output, based on the prosthesis state, and time as input. In this way, varied references are generated from a fixed-speed system. This method of reference generation is active when the subject is undergoing start/stop and transient walking (e.g., walking in confined spaces), and is yet to cross the step threshold R1. This mode is also active when the number of steps taken by the subject crosses R1 and yet the frequency and angles of the gait cycle detected using the AFO and the interpolation techniques are not close enough for a switch. Thus, in the stationary mode fixed values of angles are maintained, while in the transient mode, timevarying angles corresponding to variable walking speeds are generated.

B. CONTINUOUS WALKING MODE
The continuous walking mode is active whence the number of steps taken by the user goes beyond the step threshold R1 and a gait frequency and angle match happen between the AFO and interpolation methods [29], [30]. In this mode, the phase of an adaptive oscillator is used to generate the reference angles for the joints. The adaptive oscillator based algorithm as shown in Algorithm 1, consists of M sinusoidal oscillators (see line 5), with parameters α, β, ω, that control their amplitude, offset, and angular frequency, respectively, which are used to generate an estimated acceleration A est . The A est is an estimate of the gravity removed Algorithm 1: Gait Adaptation Algorithm Input: mode_IM U, no_of _steps, current_acc Output: gaitP hase / * Return gait phase * / 18 return gaitP hase actual acceleration of the knee as it moves through space (see line 4). In the current implementation of the algorithm, M is the minimum number of oscillators chosen to give a Fourier representation of the desired signal A des obtained from the IMU. A teaching signal T as shown in line 6, is then generated as a difference between the actual/desired and the Fourier estimated acceleration. This teaching signal is used to alter the frequency of the oscillators in real-time by solving the differential equations using Euler's technique with a constant time step as shown in line 7 after initialization ofẎ to Y 0 . For the AFO, ϵ, ν, and f min form the parameters that control the coupling strength, learning factor, and the minimum frequency limit. At any point in time, the phase of the first oscillator (CHOSEN _OSC) estimated the gait phase. A minimum frequency limit of 0.4 Hz was chosen to prevent the frequency of the oscillators from falling too low while staying close enough to the frequency of level-ground walking for amputees(line 14). Using the above-mentioned technique, it is possible to automatically monitor and adjust the frequency of the oscillators using feedback from the acceleration signals of the IMU. Since the walking frequency is coupled to the frequency of one of the three oscillators (CHOSEN _OSC), it is possible to generate continuously varying reference signals following the changing gait speed. This was done through trials by calculating the frequency of walking beforehand using a stopwatch and using a value smaller than this as an initial estimated minimum frequency for the oscillators, while the coupling strength and learning factors were chosen to smoothen out the high-frequency noise in the vertical accelerations but still able to adapt to the low frequency of the gait cycle. For the current experiments, the number of oscillators was fixed at 3 while setting the coupling strength and learning factor to 6 and 10 respectively resulted in adaptation within 6-8 steps. Finally, the phase of the oscillators was reset whenever a stationary state was detected. During the subsequent restart of walking, the frequency of the oscillators begins adaptation from the minimum frequency limit.

C. SWITCH
The switch between the two mentioned control modes, is done by keeping a count of the number of steps taken by the prosthesis, along with the frequencies at which the references are generated by the interpolation and AFO methods, as shown in Figure 1. In the current experiments, R1 is chosen as 6 steps, R2 as 0, and R3 as 2. In our current implementation we have assumed that indoor distances(livingroom/kitchen etc.) can be covered in less than 6 steps, while outdoor distances require a step count greater than 6. Hence there is no requirement of switch for the indoor distances. While for outdoors, we begin with interpolation, find a suitable match and switch over to the continuous method. These assumptions on the choices of the step-counts associated with the R values may be changed based on application as required in future. Thus the chosen 6 step mark is only a pointer to a user performing multiple steps without stopping. Henceforth, for reference, the associated step count is mentioned in bracket along with the R identifier for easier understanding. When the number of steps taken by the prosthesis is between R2 (0) and R3 (2), the prosthesis is considered stationary, and a constant angle value is used VOLUME XX, 2022 as a reference for the joints. When the step count reaches between R3 (2) and R1 (6) the prosthesis is considered to be in a transient walking mode. In this mode, the references are generated using the interpolation technique. Beyond R1 (6), a switch for reference method change is enabled (although the switching does not happen yet, and the references are still generated using interpolation). As further steps are taken, the search for a match in the frequencies and angles of the gaitreferences continues. the moment a match is detected, and the prosthesis is found to undergo swing extension, the AFO method takes over the function of reference generation. At this point, the subject is considered to be walking steadily.
To have a smooth transition from the interpolation method to AFO, the frequencies are continuously monitored while the phase information from the AFO is adapted in the transient walking mode between step count of R3 (2) and R1 (6) by constantly updating the phase of the oscillator using heel strike gait events. These checks ensure that switching happens only when the user is truly in a state of continuous walking [34], [35].
Once the source of reference angle is chosen, the angles are generated using respective angle generator functions. The angle generator functions then provide input to the low-level motor controller for motion generation. In this way, through the use of this hybrid architecture, it is possible to monitor the gait independently of the number of steps taken by the subject by using vertical acceleration information from one IMU only. Tricky situations, such as intermittent walking or walking in confined spaces allowing limited mobility, are handled mostly through the state machine by employing the interpolation method, while stretches of continuous walking with limited variation in walking speeds are handled solely by the adaptive oscillator.

III. MECHATRONIC DESIGN
This Section presents the mechatronic design of the transfemoral prosthetic leg realized for this study to validate the hybrid control architecture. The requirements and specifications of the mechanical design are described, and the choices of the sensors and electronics are explained.

A. REQUIREMENTS
The requirements for the mechanical design of the transfemoral prosthesis have been derived from the biomechanical data of healthy human subjects for level ground walking [36] specifically, from the ranges of motion and the joint power that should be (partially) provided by the artificial limb at the ankle and knee joints respectively. Figure 4 shows the plots of the knee and ankle joint angles (top) and power (bottom) over a gait cycle at a self-selected speed. From the figure (top), it may be noted that the ankle joint angle ranges from 7 • (dorsiflexion) to 20 • (plantarflexion), while the knee joint angle ranges from a minimum of 0 • (full extension) to a maximum of 65 • (full flexion). The figure (bottom) shows that to perform level ground walking at a preferred speed, the power required at the ankle is of the order of 4.5 W/kg, while it is around 0.8 W/kg at the knee joint. Besides the above-mentioned requirements on the range of motion and of the joints' power, a transfemoral prosthesis should be lightweight while its height should be adjusted according to the comfort of the amputee.

B. MECHANICAL DESIGN
The transfemoral prosthesis has been designed with two degrees of freedom, one at each knee and ankle joint [37]. Functionality with simplicity was emphasized, hence the ankle was designed to allow at least 10 • of dorsiflexion and 7 • of plantarflexion. The ankle joint has a relatively small range of motion, as the idea here is to only provide a part of the push-off effort as assistance while walking [36]. On the other hand, the dorsiflexion angle was maintained at 10 • to allow for a smooth rollover. The knee has been designed keeping in mind a range of motion of at least 100 • allowing for knee flexion during the sit-to-stand transition. An extra −5 • of knee hyperextension was implemented to guarantee the locking of the knee in the stance rollover phase. The hyperextension also helps stabilize the knee during the standing weight-bearing phase. The axis of the knee joint was strategically placed behind the load line of the knee to assist in the stance hyperextension phase of the gait cycle like a conventional passive prosthesis [38]. For the ankle joint, back-drivability of the joint was prevented by placing endstops to the ankle joint coupler. These end-stops restricted the motion of the foot blade and only allowed joint motion between desired angular limits. Figure 5 shows the 3D rendering of the complete lower limb prosthesis and the details of the bevel gear mechanism at the knee and ankle joints. The 3D drawings for all parts were made using SolidWorks (Dassault Systèmes, France, www.solidworks.com) prototyping software. The height of the prosthesis was limited to 420mm corresponding to a subject of height 175cm. The current implementation includes a size 28 ready-made foot blade of the Ossur's Proflex ® (Össur hf., Iceland, www.ossur.com), the attachment of which to the ankle joint was done utilizing a custom-made connector to complete the foot design.

C. HARDWARE ARCHITECTURE DESIGN
The control system hardware for the transfemoral prosthesis consists of a PIC32 microcontroller running at 200 MHz, which acts as the backbone of the control architecture with all sensors connected to the mainboard using the I2C protocol. The sensors are one MPU 9250-9 DOFs inertial measurement units (IMUs) (SparkFun, USA, www.sparkfun.com for the knee and ankle joints, mounted proximally to the body above the respective joints, and two magnetic encoders AS5600L (AMS AG, Austria, www.ams.com), mounted at custom-designed encoder mounts for contact-less absolute joint-angle sensing. This placement is chosen to get a better estimate of the movement of the upper leg and the lower leg, which in turn can give a better estimate of the tendency of motion of the amputee. This placement also avoids noise that can be introduced when IMUs are placed more distal to the knee joint during ground contact.
The DC motors for the system are directly coupled to the ankle and knee joints and are powered using high-power motor drivers from Pololu (Pololu Corporation, USA, www. pololu.com). The motor for the knee is a Maxon RE30 60 W (Maxon Motor AG, maxongroup.com, Switzerland), and the knee motor is a Maxon DCX 10 W. Since the operation of the device is intermittent in nature, i.e., positive power pulses are provided mainly during pushoff phase, the ankle motor was set for operation at a maximum torque of 0.8 Nm. Coupled with the overall transmission ratio of 2 × 67 : 1, from the motor gear head and bevel gear-pinion set, the peak torque that can be supplied is around 107 Nm. A low-power knee motor was selected as its functionality was limited to dampening of the leg at the end of the swing phase only. Support to the body-weight was provided by the end stops at both joints. The selection of the powering elements was done keeping in mind the objective of minimal strategic power injection at joints to provide an assistive push-off only. The detailed specifications of the motors are reported in Table 2. The movements in both joints are achieved by the use of a bevel gear mechanism which allows the concealment of the ankle and knee actuators within the shank of the prosthesis. Data from the position sensors and IMU's are sampled at a frequency of 200 Hz while motor current sensors are sampled at a frequency of 2 kHz. Power to the system is provided by using a 24V Base Tech, BT-305 lab bench power supply.
The IMU's on the prosthesis record the accelerations of the upper and lower leg. These IMU's include an onboard signal processor that allows for real-time data filtration using a lowpass filter with a cut-off frequency of 10 Hz. This enables get-VOLUME XX, 2022 ting the filtered data directly from the IMU, thereby freeing up the microcontroller from data filtration tasks. The filtered data is then directly fed into the microcontroller for gait characterization. The collection of processed data from the transfemoral prosthesis is done using a UART protocol. For this purpose, a circular data buffer of 16-bit unsigned integers was implemented where data was added synchronously at the speed of 200 Hz. The accumulated data is then sent to a PC asynchronously over a standard USB connection. Floating point data was limited by truncating float values to two significant digits by multiplying it by 100 followed by integer typecasting. The structural framework of the manufactured prosthesis along with the mounted electronics is shown in Figure 6.

A. EXPERIMENTS
The sole motive of the experiments performed using the prosthesis was to ascertain the working of the hybrid control strategy for the transfemoral system. In this regard, the designed prosthesis serves as the mechanical backbone on which the validations of the reference generation capability of the control strategy were made. The initial experiment consisted of a multiple trials ranging from 30 seconds to 1 minute where a healthy subject walked on level-ground with an IMU placed close to the knee joint. This was done to get estimates of peaks and thresholds of accelerations recorded by the IMU during level ground walking for the algorithms. An average of the peaks and thresholds were taken and programmed for the trials with the prosthesis. Experiments with the prosthesis were done on a treadmill to simulate level ground walking by a healthy subject wearing an ablebodied adapter during a pilot test. In our experience we the initially programmed thresholds were found to not accurately FIGURE 7: The experimental testing process for the control system of the current implementation of the prosthesis. An able-bodied adapter on a healthy subject was used for the test pilot . capture the heel strike using the prosthesis. Hence a separate experiment was performed with the prosthesis to record the and then reprogram the thresholds. The speed of operation for the prosthesis was varied between 1 to 1.5 kmph, to simulate speed variations between slow and medium walking speeds. Data generated from the microcontroller consisting of vertical accelerations of the knee from the IMU, number of steps taken, ankle and knee joint references, gait phase and detected mode of the prosthesis were collected in real-time using a serial console and saved to PC. Figure 8(a) shows the accelerations as recorded by the IMU placed above the knee. While the IMU continues to record the vertical accelerations of the prosthesis in the sagittal plane, the high-level control algorithm counts the number of footsteps by processing the acceleration data. The number of steps taken (blue line) along with the currently detected condition of the prosthesis (stationary, transient walking, or steady-state walking) can be observed in Figure 8(b) in red, green, and yellow patches, respectively. Figures 8(c) and (d) show the final references to the ankle and knee joints using the selected methods during the experiment. Step count as calculated using the gait-event detection and step-counter algorithms. The gait phase as detected by the AFO algorithm along with the source of reference is also shown in the plot. When the references are generated using interpolation, the source is 0, while when a switch over to AFO happens the source is 20. (c) and (d) Reference angles generated for the ankle and knee joints, respectively, as a result of the switching of the algorithms. The yellow areas represent a continuous walk and are governed by references from the AFO algorithm, while the green areas represent transient phases of the walk which are governed by the interpolation technique. The red areas represent stationary instances when constant angles at the knee and ankle joints are maintained. areas covered in green represent slow walking, while the areas in red represent normal speed walking. The capability of the algorithm to respond to changing walking speeds is shown in this figure.

V. DISCUSSION
The results shown in Figure 8 shows the capability of the control architecture to smoothly transition from one method of reference generation to other during walking. The regions in green show the period in which the transfemoral prosthesis is controlled by the state and gait-event-based interpolation method, while the regions in yellow show the time spans for which the system is controlled by the AFO. With each step detected, the value showed by the blue line in Figure 8b increases accordingly. The first acceleration spike is always used as an indication of motion only, with the step count remaining unchanged. Beyond this, the step counter begins to increment as shown by the blue line in the subplot. Once a certain number of steps have been detected (i.e., R1 = 6), the mode change flag is set. Following this, the system continues to check for a suitable match in reference generation frequencies. Once a match is found, the switchover takes place during the swing phase of the subsequent gait cycle. The transitioning phenomenon can be observed in the plot around the 40 and 100 s mark. In either of these instances, the references are provided through interpolation for at least 6 steps before switching. The number 6 has been chosen based on the movement by a user within confined spaces, for example indoors where usually only a limited number of steps may be taken. As the step counts increase and a suitable match is found in the gait reference generation frequency, a switchover takes place. Thus, the areas in yellow may be considered analogous to steady walking. The saw tooth profile in figure 8(b) represents the gait phase of walking as estimated from the acceleration data of the knee IMU. The gait phase represented in black has been divided by 10 to bring in to scale with the rest of the plots. The AFO based gait phase estimation algorithm starts running whenever the prosthesis is detected to be in motion and is reset whenever the prosthesis is stationary. Figures 8(c) and 8(d) show the reference angles for the ankle and knee joints through the phases of intermittent and steady walking. Through the use of the above-mentioned technique of frequency match detection, a smooth transition between the two reference generation methods is ensured. It must be mentioned that whenever the prosthesis is detected to be in motion, both the reference generation techniques continue to run in the background, while at any point in time, only one is chosen to supply the references to the motor while the other is kept suppressed.  Figure. 9 shows the ability of the system to adapt its response to changing gait speeds. The regions shown in green in the figure are areas of slow walking speeds, whereas the region in red are areas where normal speed walk takes place. This is also evident from the acceleration plot in the figure, where the frequency of spikes in accelerations increases in the higher speed region. As the walking speed changes, the joint angle references generated by the algorithms alter their frequencies accordingly. In this way, continuously varying references for joint angles are generated in real-time.
There are several benefits of using this hybrid control algorithm of joint angle referencing. Firstly, the tracking of the angular velocities can be done based on the gait phase information obtained from the AFO alone. Since the gait phase keeps track of the changing gait velocities, there is no requirement of pre-determining the velocities for various speeds of walking. This saves time and effort as prior experiments to determine velocities from the amputee subject may be avoided. A second benefit is that the memory of the microcontroller used in controlling the prosthesis, which is often extremely limited, can be used for alternate processing tasks. Thirdly, since in this approach the prosthesis response can be made independent of the amputee, the same control system can be used for various amputees with minor tuning without the need for extensive personalization. Finally, having a pre-determined set of velocities for the control instead of allowing for self-selected velocities, causes the user to adapt his/her response to the response of the prosthesis. This might not be totally in line with the desired comfort level of the amputee where ideally it is desired that the prosthesis should adjust its response to the response to that of the amputee. By removing this forced kinematic control, the current approach gives a choice of speed back to the prosthesis user to an extent. For all the above-mentioned reasons, the significance of supplementing control algorithms using oscillator-based gait tracking systems can be observed. Thus, using this hybrid control implementation of the high-level controller, where the prosthesis works at velocities generated through interpolation for a fixed number of steps, and subsequently switches over to an adaptive control scheme, some limitations related to singular state machine-based methods may be circumvented.

A. LIMITATIONS AND FUTURE OUTLOOK
Although the above technique has its benefits, certain limitations can be observed in the current implementation. Since in the current implementation, references generated when the interpolation method is active depends on the information of gait-events and step time from the previous step, the reference velocity to the joints using this method is always dependent on the gait cycle time of the previous step. As a result of this, the reference velocities and angles are always one step behind the actual occurrence in steps. While this may not cause issues when the walking speed is constant, sudden variation in walking speed need at least one step before matching the phases of walking. This issue may be solved either by using data from pressure sensors to further subdivide the walking pattern. Allowing for further subdivi-sions such as mid-stance, flat-foot, late-stance shall allow for further points of phase correction. Another way would be to use the IMU to detect more points of one cycle. For instance, detect change from upswing of the lower leg to forward swing. Another area that might need improvement is the knee design. Since a low-power knee actuator has been selected to minimize the weight of the system, the entirety of knee torque required for the stance roll-over phase is not available directly. The second issue may be solved by altering the reference knee joint trajectory to provide a hyper-extended knee between 0 and 50 percent of the gait cycle which is in accordance with how passive prosthesis are aligned in practice. By doing so, the holding torque to support the body weight during stance rollover may be provided using the end stop. Once these improvements are implemented, the test of the performance of the algorithms with the prosthesis mounted on an amputee subject needs to be performed to ensure validity and better tuning of parameters. In the process of development of this hybrid control architecture, there was a discussion on whether there should be a switchover again to the transient mode following the continuous mode of walking before coming to a complete halt. For the current iteration of the control system, this was not included mainly due to two reasons. Firstly, it is difficult to estimate, the exact number of steps, that the user would require to reach a complete halt, and secondly, since the adaptive oscillator whose frequency may go down to 0.4Hz is still capable of keeping track of the slowing down the process. As the gait frequency falls below this limit, the subject is assumed to have stopped for all practical walking tasks. However, still, a switchover may be designed based on a minimum frequency limit that allows the interpolation technique to take over once the walking frequency falls below this limit. An implementation of this technique and whether a switchover to a transient walk where references are generated through interpolation makes a significant difference in usability or not are topics that shall be addressed through further research in the future.

VI. CONCLUSIONS
In this paper, we proposed a hybrid control architecture for an active transfemoral prosthesis by combining a state and gait event-based interpolation technique with an adaptive frequency oscillator using information from a single IMU only. The hybrid nature of the controller allows for gait characterization in stationary/transient and steady walking. The experimental results on a transfemoral prosthesis with an able bodied adapter show that the technique of combining two different methods of reference generation can generate references both for periodic and aperiodic phases of gait cycles. Along with reference generation, through the use of adaptive oscillators, the algorithm was able to continuously adjust its response to changing velocities of walking. The obtained results show that this technique of combining two methods can be used as a hybrid control method for active transfemoral prostheses. .