Motion trajectory recognition method and system based on extended kalman filter
By using extended Kalman filtering technology, combined with quaternions and multi-sensor data, attitude drift is corrected in real time and action boundaries are identified, solving the challenges of attitude estimation and action recognition in smart toys and achieving a high-quality haptic interaction experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU ZHONGDA CHENG TECHNOLOGY DEVELOPMENT CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-06-09
AI Technical Summary
Existing smart toys suffer from the problem of accumulated attitude angle errors in attitude estimation, insufficient action recognition capabilities, and a lack of effective drift suppression and correction mechanisms, resulting in a poor user experience.
A motion trajectory identification method based on extended Kalman filter is adopted. The EKF state vector is initialized by quaternions and error terms. The attitude drift is corrected in real time by combining accelerometer and magnetometer data. The attitude change rate is calculated and multi-level thresholds are set to reconstruct the three-dimensional motion trajectory. The detection threshold is adaptively adjusted by using a finite state machine.
It significantly improves pose estimation accuracy and action recognition capabilities, provides a smooth and accurate user experience, is compatible with low-cost IMUs and embedded platforms, and overcomes the limitations of traditional methods.
Smart Images

Figure CN122173892A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to, and more specifically to, a motion trajectory identification method and system based on extended Kalman filtering. Background Technology
[0002] In the development of smart toys, the application of pose estimation and motion recognition technologies has become increasingly important. However, existing technologies face several key challenges and shortcomings that limit the improvement of user experience and the market competitiveness of products.
[0003] First, in terms of attitude estimation, many current products rely on simple integration or first-order filtering methods to process gyroscope data. This leads to significant accumulation of attitude angle errors after long-term operation, affecting the realism and accuracy of the trajectory. Zero-bias and scaling factor errors in low-cost inertial measurement units are still difficult to completely eliminate even after correction, and temperature changes and aging processes further exacerbate this problem. Furthermore, the lack of effective drift suppression and correction mechanisms can cause stationary states to be incorrectly identified as moving states, reducing the user's gaming experience.
[0004] Secondly, for the recognition of continuous movements, existing simple thresholding methods often can only identify single, large-amplitude movements, while failing to accurately segment and label coherent multi-segment movements. Especially during children's rapid swings or continuous jumps, the superposition of multiple movements on the acceleration and angular velocity axes can easily lead to misjudgments or confusion of movement boundaries by traditional algorithms. The lack of a segmentation mechanism that combines posture change trends and local dynamic features also presents challenges to the reliable encoding of complex combos or combined movements.
[0005] Finally, the continuity and interpretability of the trajectory are another issue that needs to be addressed. Some products rely solely on acceleration thresholds to determine whether an action has occurred, without performing continuous trajectory estimation, resulting in simplistic and crude game feedback. The lack of a unified state modeling framework makes attitude estimation and action determination independent, making it difficult to reconstruct a reasonable trajectory in 3D space. A mismatch between sensor sampling frequency and algorithm update frequency can also lead to discontinuities or unnatural broken lines in the trajectory, affecting the user's immersive experience.
[0006] Therefore, it is necessary to design a new method to improve pose estimation accuracy, enhance action recognition capabilities, and adapt to low-cost IMUs and embedded platforms, providing a smoother and more accurate user experience while maintaining cost-effectiveness and effectively overcoming the limitations of existing technologies. Summary of the Invention
[0007] The purpose of this invention is to overcome the shortcomings of the prior art and provide a motion trajectory recognition method and system based on extended Kalman filtering.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: a motion trajectory identification method based on extended Kalman filtering, comprising:
[0009] The EKF state vector is initialized using quaternions and an error term, and the toy's attitude change is predicted based on gyroscope data to obtain the prediction result.
[0010] An observation function is constructed by combining accelerometer and magnetometer data, and the attitude drift caused by gyroscope integration in the prediction result is corrected and optimized in real time to obtain the corrected attitude quaternion.
[0011] The posture change rate is calculated based on the corrected posture quaternion to identify action boundaries, and multiple threshold levels are set to obtain feature extraction results.
[0012] The feature extraction results are converted and processed into acceleration data to reconstruct the motion trajectory of the toy in three-dimensional space. Static detection technology is used to suppress integral drift in order to obtain the reconstruction result.
[0013] Based on the reconstruction results, the action cycle is analyzed using a finite state machine, the detection threshold is adaptively adjusted, and the identified action sequence is converted into game feedback.
[0014] The further technical solution is as follows: the EKF state vector is initialized using quaternions and an error term, and the toy's attitude change is predicted based on gyroscope data to obtain the prediction result, including:
[0015] Define the state vector of EKF and use quaternions to represent the three-dimensional pose of the toy. Introduce an error term into the three-dimensional pose to obtain the initial state vector.
[0016] Based on the initial state vector, the continuous rotational dynamics equations are converted into nonlinear state transition functions using gyroscope data to predict the prior state at the next moment, thus obtaining the prediction result.
[0017] The further technical solution is as follows: the mathematical expression used to predict the prior state at the next moment is x. k =f(x k-1 u k-1 )+w k , where x k Let u be the state vector at the next time step, f(·) be the nonlinear state transition function, and u be the state vector at the next time step. k-1 For gyroscope data, w k For process noise; x k-1 This is the state vector at the current moment.
[0018] The further technical solution is as follows: The observation function is constructed by combining accelerometer and magnetometer data to correct and optimize the attitude drift caused by gyroscope integration in the prediction result in real time, so as to obtain the corrected attitude quaternion, including:
[0019] Acquire real-time data from accelerometers and magnetometers, and construct observation vectors;
[0020] An observation function is established based on the observation vector, the prediction result is mapped to the expected gravity and magnetic field directions, the expected observation value is calculated, and the deviation between the actual sensor observation value and the expected observation value is calculated. The attitude is corrected by feeding back the state vector through the Kalman gain matrix to obtain the corrected attitude quaternion.
[0021] The further technical solution is as follows: The calculation of the attitude change rate based on the corrected attitude quaternion to identify action boundaries, and the setting of multi-level thresholds to obtain feature extraction results, includes:
[0022] Based on the corrected attitude quaternion, the attitude change at adjacent time points is calculated, and the characteristics of attitude change angle and angular velocity are derived.
[0023] Based on the posture change angle and angular velocity characteristics, the angular velocity magnitude and direction changes are jointly analyzed to identify local peaks to determine the start and end points of the action, identify incomplete continuous action segments, and construct a multi-level threshold system to adapt to motion capture requirements of different amplitudes in order to obtain feature extraction results.
[0024] The further technical solution is as follows: The feature extraction results are converted and processed to transform the acceleration data, reconstruct the toy's motion trajectory in three-dimensional space, and static detection technology is used to suppress integral drift to obtain the restored result, including:
[0025] Using the corrected attitude quaternions, a rotation matrix is constructed to transform the accelerometer data in the feature extraction results from the sensor coordinate system to the world coordinate system, so as to obtain the transformation result;
[0026] After removing the gravity component from the conversion result, the linear acceleration is integrated over time to obtain the velocity, and then the velocity is integrated to obtain the displacement trajectory. A static detection strategy is used to compensate for the cumulative error caused by integration in the displacement trajectory, and the position drift within the required range is smoothed to obtain the restored result.
[0027] The further technical solution is as follows: based on the restoration result, the action cycle is analyzed using a finite state machine, the detection threshold is adaptively adjusted, and the identified action sequence is converted into game feedback, including:
[0028] Construct a finite state machine, and use the attitude change rate and linear acceleration to trigger state transitions based on the reconstruction results to characterize the action lifecycle;
[0029] The motion detection threshold is adaptively adjusted based on the real-time ambient noise level and the intensity of children's activities.
[0030] For action segments with short intervals, a merging strategy is adopted, and the features of each action segment are extracted and mapped to action tags in the game logic, organized into action sequences and output, driving corresponding sound effects, lighting effects and story branch feedback.
[0031] The further technical solution is as follows: the finite state machine includes at least one of the following states: static, ready to move, moving in progress, moving to end, and transition.
[0032] The further technical solution is as follows: the characteristics of each action segment include at least one of duration, maximum angular velocity and trajectory shape.
[0033] The present invention also provides a motion trajectory recognition system based on extended Kalman filtering, comprising:
[0034] The prediction unit is used to initialize the EKF state vector using quaternions and an introduced error term, and to predict the toy's attitude changes based on gyroscope data to obtain the prediction result.
[0035] The correction unit is used to construct an observation function by combining accelerometer and magnetometer data, and to correct and optimize the attitude drift caused by gyroscope integration in the prediction result in real time, so as to obtain the corrected attitude quaternion.
[0036] The extraction unit is used to calculate the attitude change rate based on the corrected attitude quaternion to identify the action boundary, and set multi-level thresholds to obtain the feature extraction result;
[0037] The reconstruction unit is used to convert and process the acceleration data of the feature extraction results, reconstruct the motion trajectory of the toy in three-dimensional space, and use static detection technology to suppress integral drift in order to obtain the reconstruction result;
[0038] The feedback unit is used to analyze the action cycle using a finite state machine based on the restoration result, adaptively adjust the detection threshold, and convert the identified action sequence into game feedback.
[0039] The advantages of this invention compared to existing technologies are as follows: By employing extended Kalman filtering technology, initializing the state vector using quaternions and error terms, predicting attitude changes based on gyroscope data, and constructing an observation function using accelerometer and magnetometer data to correct attitude drift in real time, this invention significantly improves attitude estimation accuracy. Furthermore, by calculating the attitude change rate and setting multi-level thresholds to identify action boundaries, the invention enhances action recognition capabilities, ensuring accurate capture of complex actions. Regarding low-cost IMU and embedded platform adaptation, this method optimizes feature extraction results, suppresses integral drift through stationary detection, and adaptively adjusts the detection threshold based on action cycle analysis using a finite state machine, achieving smooth and accurate motion trajectory reconstruction and game feedback transitions while maintaining cost-effectiveness. The overall solution not only overcomes the attitude drift problem caused by traditional low-cost sensors but also improves the user experience, enabling smart toys to provide high-quality haptic interaction experiences at a lower cost.
[0040] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 A flowchart illustrating the motion trajectory identification method based on extended Kalman filtering provided in an embodiment of the present invention;
[0043] Figure 2 A schematic block diagram of a motion trajectory recognition system based on extended Kalman filtering provided in an embodiment of the present invention;
[0044] Figure 3 A schematic block diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0047] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0048] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0049] Please see Figure 1 , Figure 1 This is a flowchart illustrating the motion trajectory identification method based on Extended Kalman Filter (EKF) provided in this embodiment of the invention. Applied to a server, this method initializes the EKF state vector using quaternions and introduces an error term. It predicts attitude changes using gyroscope data and constructs an observation function based on accelerometer and magnetometer data to correct attitude drift in real time, significantly improving the accuracy of attitude estimation. The method further calculates the attitude change rate to identify action boundaries and sets multi-level thresholds to adapt to different motion capture requirements, enhancing action recognition capabilities. By performing coordinate transformation and processing on the feature extraction results, the motion trajectory of the toy in three-dimensional space is reconstructed. Static detection technology is used to suppress integral drift, ensuring a smooth and accurate user experience even with a low-cost IMU. Furthermore, by using a finite state machine to analyze the action cycle and adaptively adjust the detection threshold, the identified action sequence is transformed into game feedback, enabling the method to effectively run on embedded platforms while maintaining cost-effectiveness and overcoming the limitations of existing technologies.
[0050] Figure 1 This is a flowchart illustrating the motion trajectory identification method based on extended Kalman filtering provided in an embodiment of the present invention. Figure 1 As shown, the method includes the following steps S110 to S150.
[0051] S110. Initialize the EKF state vector using quaternions and introduce error terms, and predict the toy's attitude change based on gyroscope data to obtain the prediction result.
[0052] In this embodiment, the prediction result refers to the estimated value of the toy's attitude at the next moment, calculated by a nonlinear state transition function based on the current state and gyroscope data.
[0053] In one embodiment, step S110 described above may include steps S111 to S112.
[0054] S111. Define the state vector of EKF and use quaternions to represent the three-dimensional posture of the toy. Introduce an error term into the three-dimensional posture to obtain the initial state vector.
[0055] In this embodiment, the initial state vector includes the toy's initial posture (represented in quaternion form) and the sensor error term vector, serving as the starting point for the Extended Kalman Filter (EKF) algorithm for subsequent state prediction and updates.
[0056] First, a state vector containing all necessary information needs to be determined. This vector typically includes the toy's three-dimensional attitude (represented by quaternions), the zero-bias error of the angular velocity sensor, etc. Quaternions are used to describe the toy's three-dimensional attitude because, compared to Euler angles, quaternions avoid gimbal lock-up issues and provide a more stable and continuous attitude representation. To improve the accuracy of attitude estimation, terms representing sensor errors, such as the zero-bias error of the gyroscope, are added to the state vector. These error terms allow the EKF to perform online correction of sensor errors during operation, thereby improving the overall accuracy of attitude estimation.
[0057] S112. Based on the initial state vector, the continuous rotational dynamics equation is converted into a nonlinear state transition function using gyroscope data to predict the prior state at the next moment, so as to obtain the prediction result.
[0058] The mathematical expression used to predict the prior state at the next moment is x. k =f(x k-1 u k-1 )+w k , where x k Let u be the state vector at the next time step, f(·) be the nonlinear state transition function, and u be the state vector at the next time step. k-1 For gyroscope data, w k For process noise; x k-1 This is the state vector at the current moment.
[0059] Using the initial state vector defined above as a basis, and based on the angular velocity data provided by the gyroscope, combined with the discrete time step, the continuous rotational dynamics equations are transformed into a nonlinear state transition function. A mathematical model maps the current state vector to the state vector of the next time step, taking into account the system's process noise.
[0060] These two steps initialize the EKF state vector and use gyroscope data to predict the toy's next pose, thus obtaining the prediction result. This method not only improves the accuracy of pose estimation but also effectively suppresses the drift problem caused by low-cost IMUs, enabling smart toys to maintain stable pose estimation performance during long-term play.
[0061] S120. Combine accelerometer and magnetometer data to construct an observation function, and correct and optimize the attitude drift caused by gyroscope integration in the prediction result in real time to obtain the corrected attitude quaternion.
[0062] In this embodiment, the corrected attitude quaternion refers to a mathematical description of the toy's attitude in three-dimensional space that is more accurately represented by combining accelerometer and magnetometer data and using an extended Kalman filter to correct the attitude drift caused by gyroscope integration in real time.
[0063] In intelligent toy motion-sensing interaction systems, to overcome the problem of accumulated integration errors caused by prolonged use of the gyroscope in low-cost IMUs (Inertial Measurement Units), data from accelerometers and magnetometers are introduced to correct the attitude. This process is achieved through an extended Kalman filter (EKF) to ensure the accuracy and stability of attitude estimation.
[0064] In one embodiment, step S120 described above may include steps S121 to S122.
[0065] S121. Acquire real-time data from the accelerometer and magnetometer, and construct the observation vector.
[0066] In this embodiment, the observation vector is composed of the gravity direction measured by the accelerometer and the geomagnetic direction provided by the magnetometer. Specifically, the accelerometer provides information about the direction of the toy relative to Earth's gravity, while the magnetometer provides a directional reference relative to the Earth's magnetic field. These two pieces of information together constitute a three-dimensional observation vector, used to represent the toy's attitude reference in the current state.
[0067] S122. Based on the observation vector, establish an observation function, map the prediction result to the expected gravity and magnetic field directions, calculate the expected observation value, calculate the deviation between the actual sensor observation value and the expected observation value, and use the Kalman gain matrix to feed back to the state vector for attitude correction, so as to obtain the corrected attitude quaternion.
[0068] In this embodiment, the observation function converts the attitude quaternions generated during the EKF state prediction phase into expected values for the corresponding gravity and magnetic field directions. This is accomplished by using rotation operations described by quaternions to apply the predicted attitude to the theoretical values of gravity and geomagnetic directions, generating "expected observations." These expected values are then compared with actual observations obtained directly from the accelerometer and magnetometer.
[0069] By calculating the difference between the actual and expected observations (i.e., the residual), the error between the current attitude estimate and the true attitude can be quantified. Then, using the Kalman gain matrix, this residual is backpropagated into the EKF state vector, thereby adjusting the attitude estimate and reducing long-term drift caused by gyroscope integration. This step effectively combines static or slowly changing information from the accelerometer and magnetometer, enhancing the stability and accuracy of the attitude estimate.
[0070] Ultimately, the attitude quaternion, corrected through the above steps, not only reflects the latest gyroscope dynamic input but also integrates stable reference information from the accelerometer and magnetometer, ensuring reliable and continuous attitude tracking performance even with low-cost hardware. This strategy is crucial for improving the haptic interaction experience of smart toys, enabling children's actions to be recognized and responded to more accurately and naturally.
[0071] S130. Calculate the attitude change rate based on the corrected attitude quaternion to identify the action boundary, and set multi-level thresholds to obtain feature extraction results.
[0072] In this embodiment, the feature extraction result refers to the system identifying the start and end points of the action and continuous action segments by analyzing the characteristics of the posture change angle and angular velocity, and setting multiple threshold levels according to the action amplitude to optimize the capture accuracy.
[0073] Step S130 describes the process of feature extraction based on the corrected posture quaternion, which aims to identify the boundary of the action by calculating the amount of posture change at adjacent time points and to set a multi-level threshold system that adapts to different action amplitudes.
[0074] In one embodiment, step S130 described above may include steps S131 to S132.
[0075] S131. Based on the corrected attitude quaternion, calculate the attitude change at adjacent time points and derive the attitude change angle and angular velocity characteristics.
[0076] In this embodiment, the attitude change angle and angular velocity characteristics refer to the rotation angle change and rotation speed between adjacent moments calculated based on the corrected attitude quaternion, which are used to accurately describe the dynamic behavior of the toy in three-dimensional space.
[0077] In this stage, the system uses the calibrated attitude quaternions (i.e., the attitude representation corrected for sensor drift and other errors) from the previous step to calculate the attitude change between adjacent sampling points. This typically involves converting the quaternions into rotation matrices or Euler angles for a more intuitive understanding and processing of attitude changes. In this way, we can accurately obtain the toy's attitude change angles and angular velocity characteristics in three-dimensional space. This information is crucial for understanding the toy's specific motion state, such as determining whether it is rotating, swinging, or stationary.
[0078] S132. Based on the posture change angle and angular velocity characteristics, perform joint analysis on the angular velocity magnitude and direction changes, identify local peaks to determine the start and end points of the action, identify incomplete continuous action segments, and construct a multi-level threshold system to adapt to motion capture requirements of different amplitudes, so as to obtain feature extraction results.
[0079] In this step, the system further analyzes the posture change angle and angular velocity features obtained in the previous step. First, by detecting local peaks in the angular velocity magnitude and direction changes, the system can accurately identify the start and end points of the action. This is particularly important for distinguishing between independent actions and different parts of a continuous action. Furthermore, to accommodate motion capture needs ranging from slight swaying to large swings, the system constructs a multi-level threshold system. This approach allows the system to automatically adjust its sensitivity based on the amplitude of the action, ensuring that even minute movements are not missed, while avoiding misjudgments caused by environmental noise. Finally, the feature extraction results obtained through the above process will be used for subsequent action recognition and game logic triggering, such as driving specific sound effects, lighting effects, or storyline development.
[0080] S140. The feature extraction results are converted and processed to reconstruct the motion trajectory of the toy in three-dimensional space. Static detection technology is used to suppress integral drift in order to obtain the restoration result.
[0081] In this embodiment, the restored result refers to the accurate and stable motion trajectory of the toy in three-dimensional space obtained after a series of data processing steps, including coordinate system transformation, gravity component removal, double integration, and the application of a static detection strategy. This restored result not only reflects the toy's actual motion path but also significantly reduces position drift caused by sensor noise and the integration process through an effective error compensation mechanism, thereby ensuring the accuracy and consistency of attitude estimation during long-term use.
[0082] In one embodiment, step S140 described above may include steps S141 to S142.
[0083] S141. Using the corrected attitude quaternion, construct a rotation matrix to transform the accelerometer data in the feature extraction result from the sensor coordinate system to the world coordinate system to obtain the transformation result.
[0084] In this embodiment, the transformation result refers to the successful transformation of the raw linear acceleration data collected by the accelerometer from the sensor coordinate system, which changes with the movement of the toy, to a fixed global world coordinate system using a rotation matrix constructed from the corrected attitude quaternions. This transformation allows for direct analysis and processing of acceleration information from the perspective of the world coordinate system, providing a foundation for accurate calculation of velocity and displacement. The transformed data is no longer affected by the toy's own attitude changes, ensuring the accuracy of further processing (such as gravity component removal).
[0085] S142. After removing the gravity component from the conversion result, the linear acceleration is integrated over time to obtain the velocity, and the velocity is then integrated to obtain the displacement trajectory. A static detection strategy is used to compensate for the cumulative error caused by integration in the displacement trajectory, and the position drift within the required range is smoothed to obtain the restored result.
[0086] This step details how to reconstruct the toy's three-dimensional motion trajectory from the converted acceleration data and takes measures to reduce errors caused by integral drift. First, by subtracting the gravitational component, the pure linear acceleration caused solely by the toy's actual motion is obtained. Then, by integrating the linear acceleration twice (first obtaining velocity, then displacement), the toy's spatial position change is initially reconstructed. To improve trajectory accuracy, a stationary detection strategy is introduced. When the toy is detected to be stationary, the velocity estimate is adjusted to be close to zero, and minor positional drift is smoothed out. This is done to correct trajectory deviations caused by sensor noise and the cumulative effect of numerical integration, ensuring that the final reconstruction is both realistic and stable.
[0087] S150. Based on the restoration results, the action cycle is analyzed using a finite state machine, the detection threshold is adaptively adjusted, and the identified action sequence is converted into game feedback.
[0088] In one embodiment, step S150 described above may include steps S151 to S153.
[0089] S151. Construct a finite state machine, and use the attitude change rate and linear acceleration to trigger state switching based on the restoration result to characterize the action life cycle.
[0090] In this embodiment, the finite state machine includes at least one of the following states: static, ready to move, moving in progress, moving to end, and transition.
[0091] In this embodiment, a finite state machine (FSM) is used to simulate the action process when a user interacts with a toy by defining different states. For example, the "stationary" state indicates that the toy is not being operated, "ready to act" indicates that the toy is about to start performing an action, "action in progress" indicates that a specific action is currently being performed, "action finished" indicates that the action is completed, and the "transition" state is used to handle the transition between different actions.
[0092] State switching mechanism: Using the attitude change rate and linear acceleration information obtained from the EKF algorithm, the system can dynamically determine when to enter or exit these states. For example, when the attitude change rate exceeds a certain threshold and is accompanied by a significant increase in linear acceleration, it may trigger a transition from "stationary" to "preparing for action"; while when both the attitude change rate and linear acceleration fall back to near zero, it may be marked as "action ended".
[0093] S152. Adaptively adjust the motion detection threshold based on the real-time ambient noise level and the intensity of the child's activity.
[0094] This step aims to ensure that the motion recognition system remains stable and reliable even when environmental conditions change or the child's physical strength declines. The specific method is as follows:
[0095] Real-time monitoring: Continuously monitor the noise level in sensor data and the intensity of user activity, which can be achieved by analyzing the average signal strength or fluctuations over a period of time.
[0096] Threshold adjustment: The sensitivity threshold for motion detection is automatically adjusted based on the monitoring results. For example, the detection threshold is increased in high-noise environments to reduce false alarms, while the threshold is decreased in quiet environments to capture more subtle movements.
[0097] S153. For action segments with short intervals, a merging strategy is adopted, and the features of each action segment are extracted and mapped to action tags in the game logic, organized into action sequences and output, driving the corresponding sound effects, lighting effects and story branch feedback.
[0098] In this embodiment, the characteristics of each action segment include at least one of duration, maximum angular velocity, and trajectory shape.
[0099] In this embodiment, the merging strategy is as follows: For action segments that occur very close together, the system employs a merging strategy to avoid incorrectly separating them and affecting the user experience. For example, if the time interval between two waving actions is less than a certain set value, they will be considered as a single, continuous waving action.
[0100] Feature extraction and mapping: For each independent action segment, the system extracts its key features (such as action duration, maximum angular velocity reached, and trajectory shape), and maps these features to action labels in predefined game logic. For example, "quickly swing twice" may be mapped to "double-tap attack", while "slowly spin once" may be "magic casting".
[0101] Feedback Generation: Ultimately, all identified action sequences are organized chronologically and passed as input to the upper-level game engine to trigger corresponding sound effects, lighting effects, or advance the storyline. This approach not only enhances interactivity but also makes the entire experience more vivid and engaging.
[0102] This embodiment involves two main areas: inertial sensor data fusion and intelligent toy motion-sensing interaction. Regarding inertial sensor data fusion, accelerometers are used to collect three-axis acceleration information to achieve a preliminary estimate of the toy's translational acceleration and attitude direction; gyroscopes are used to collect angular velocity signals to depict the toy's rotational dynamics along the roll, pitch, and yaw axes; and magnetometers are used to collect geomagnetic direction information to provide a reference for absolute orientation correction and suppress attitude drift during prolonged use. In the field of intelligent toy motion-sensing interaction, high-precision recognition of the toy's overall motion and local actions enables various interaction methods such as waving, tapping, rotating, and throwing; simultaneously, the user's physical operation trajectory is reconstructed, mapping actions in three-dimensional space to game events, sound effect triggers, or light changes; and through the segmentation and calibration of continuous actions, combo-style motion-sensing games and combined action interactions are achieved.
[0103] The method in this embodiment is based on several key technologies: First, the sensing characteristics of the inertial measurement unit (IMU). Although low-cost IMUs are widely used in children's toys, they suffer from problems such as high noise and zero-bias instability. Accelerometers are more suitable for low-frequency static attitude estimation, while gyroscopes are more suitable for high-frequency dynamic attitude change capture. Magnetometers are susceptible to interference from surrounding metal and electromagnetic environments, requiring robust handling of abnormal readings in the algorithm. Second, the advantages of extended Kalman filtering are utilized. It is suitable for handling nonlinear state transitions and observation relationships in attitude and trajectory estimation, and can obtain near-optimal state estimates with controllable computational costs, meeting the real-time requirements of embedded platforms. Finally, considering the special needs of children's toy-based motion interaction, including the large differences in the amplitude and frequency of movements, from slight shaking to large waving, these movements need to be reliably identified, and the algorithm needs to remain robust under unstable conditions, as well as achieve a sufficiently sensitive and natural interactive experience under limited computing power and storage.
[0104] The method in this embodiment aims to improve attitude estimation accuracy. By constructing a unified state-space model using extended Kalman filtering, it nonlinearly fuses acceleration, angular velocity, and magnetic field information. High-frequency noise from low-cost sensors is effectively suppressed through the synergistic effect of state prediction and observation updates, maintaining the stability of attitude estimation during extended gameplay and significantly reducing overall drift. Furthermore, it focuses on improving motion recognition capabilities, identifying subtle movements based on attitude change rate and acceleration patterns to ensure even delicate haptic inputs are captured. Through motion segmentation, feature extraction, and sequence matching, it achieves reliable recognition and encoding of continuous actions, maintaining the coherence of trajectory and action labels even in complex action combinations, ensuring natural and consistent feedback from the toy to user operations. Finally, it adapts to low-cost IMUs and embedded platforms, controlling computational load by simplifying state dimensions and pre-computing Jacobian structures, ensuring filter iterations can be completed within milliseconds. A fast-convergence initialization and self-calibration strategy is designed to reduce calibration waiting time after power-on, significantly improving the haptic sensitivity and playability of the smart toy while keeping costs under control.
[0105] The technical solution of this embodiment consists of five steps: The first step is to establish the EKF state space and attitude prediction (low-level calculation stage). After the system starts, the extended Kalman filter (EKF) state vector is first defined, using quaternions to represent the toy's attitude in three-dimensional space. This avoids the gimbal lock problem that may occur with traditional Euler angle representation and introduces error terms such as gyroscope bias, enabling the filter to estimate and compensate for sensor system errors online. The second step is attitude correction based on multi-sensor observations (filter update stage). An observation benchmark is constructed by acquiring real-time data from the accelerometer and magnetometer. The predicted attitude state is mapped to the expected gravity and magnetic field directions using the observation function, calculating the "expected observation value." In the filter update stage, the deviation between the actual sensor observation value and the expected observation value is calculated, and the Kalman gain matrix is used to feed back to the state vector to correct the attitude. The third step is attitude change rate analysis and motion segmentation (feature extraction stage). Using the corrected attitude quaternions, the attitude change amount at adjacent time points is calculated, deriving the attitude change angle and angular velocity characteristics. The magnitude and direction changes of angular velocity are jointly analyzed, and the start and end points of the motion are determined by identifying local peaks in angular velocity, thus identifying continuous motion segments that have not yet ended. The fourth step is spatial trajectory integration reconstruction and drift compensation (physics restoration stage). Using the filtered accurate attitude estimate, the coordinate system is transformed, gravity is removed, and double integration is performed to obtain pure linear acceleration. Then, the linear acceleration is integrated over time to obtain velocity, and then the velocity is integrated again to reconstruct the toy's displacement trajectory in three-dimensional space. A compensation strategy based on static detection is used to suppress the cumulative error generated by integration. The fifth step is multi-action state machine recognition and sequence output (semantic interaction stage). A finite state machine containing multiple states is constructed. The state transition is triggered by the combined action change rate and linear acceleration to characterize the complete life cycle of the action. The action detection threshold is adaptively adjusted according to the real-time environmental noise level and the child's current activity intensity to prevent the recognition performance from fluctuating due to environmental changes or physical decline. Finally, the recognized complete action sequence is organized and output to the upper-level interaction engine to drive different sound effects, lighting effects and story branch feedback.
[0106] The method in this embodiment provides stable and reliable attitude and trajectory estimation. Through EKF's nonlinear state modeling and observation correction mechanism, it significantly reduces the attitude drift problem caused by low-cost IMUs. It maintains smooth and consistent attitude output even under long-term operation and complex action scenarios, providing a reliable foundation for trajectory reconstruction. The motion recognition is sensitive and rich, capable of recognizing not only obvious waving and rotating movements but also capturing subtle shaking and minor collisions. It supports the segmentation and combination of continuous actions, giving smart toys interactive capabilities similar to game console motion controllers. The algorithm design fully considers the computing power and storage limitations of MCUs commonly used in children's toys, ensuring real-time operation even in low-power mode. A balance between sensitivity, power consumption, and cost is achieved through reasonable design of state dimensions and update frequency. This not only enhances the toy's motion-sensing interaction experience, enabling the toy to provide more natural and immediate feedback to children's operations, enhancing immersion and participation, but also provides high-quality motion data support for upper-level game logic, allowing the product to build differentiated gameplay and stronger market competitiveness.
[0107] The architecture corresponding to the method in this embodiment includes: integrating a three-axis accelerometer, a three-axis gyroscope, and a three-axis magnetometer into an IMU module inside the toy body. A low-power MCU is used as the main control chip, responsible for sensor sampling control, EKF algorithm execution, and communication with upper-layer applications. Optional output devices such as LED light strips, speakers, and vibration motors can be added to display different motion recognition results.
[0108] The module is responsible for periodically reading IMU data and performing basic filtering and correction; the module is responsible for recursively estimating the current state based on the state equation and observation equation; the module is responsible for dividing the continuous time series into different action segments and classifying them based on trajectory and posture features; and the module is responsible for communication and storage, controlling feedback such as sound effects, lighting, and storylines based on action recognition results.
[0109] The IMU and MCU are connected via buses such as I²C (Inter-Integrated Circuit) and SPI (Serial Peripheral Interface) to ensure stable and reliable data transmission. A small amount of calibration parameters, threshold configurations, and short-term motion history are stored in the MCU's internal or external Flash memory. For some networked toys, anonymized motion characteristics can be uploaded to the cloud for subsequent parameter optimization and gameplay updates.
[0110] Specifically, bandpass or finite impulse response filters are used to process the raw IMU data, removing high-frequency random noise and low-frequency drift components. Significantly anomalous instantaneous spikes are detected and replaced to prevent them from interfering with subsequent filtering and trajectory estimation.
[0111] Acceleration, angular velocity, and other data are normalized to map signals with different dimensions to a unified numerical range. The sensor's zero bias and scaling factor are corrected once based on factory calibration parameters to improve data consistency.
[0112] At the software level, a unified time base is used to align the sampling timestamps of different sensors. Interpolation or resampling is performed to handle occasional delays or sample loss, ensuring the stability of the EKF input sequence time interval.
[0113] In each sampling period, state prediction is performed using a state transition function based on the state estimate from the previous moment and the current gyroscope reading. Simultaneously, the state covariance matrix is predicted, and the uncertainty estimate is updated under the condition that the statistical characteristics of the process noise are known. During the prediction phase, no observation data is used; instead, prior attitude and error covariance are obtained.
[0114] When a new set of acceleration and magnetometer data arrives, the expected observations are calculated using the observation function and compared with the actual observations. The Kalman gain is calculated based on the observation residuals and observation noise covariance to determine the strength of the correction. The state estimate and state covariance are corrected using the Kalman gain, enabling the attitude solution to suppress drift while preserving dynamic responsiveness.
[0115] The filtered quaternion pose is converted into Euler angles or rotation matrices as needed for use by the upper layers. The current pose state and covariance are used as the initial conditions for the next iteration to complete the EKF recursion.
[0116] Output integral trajectory: Using the current attitude, the acceleration data is transformed from the sensor coordinate system to the world coordinate system, and the gravity vector is subtracted. The linear acceleration is numerically integrated to obtain the velocity, and then the velocity is integrated to obtain the displacement increment. The displacement increment is accumulated into the position estimate of the previous moment to form a three-dimensional trajectory point sequence.
[0117] When a stationary state is detected, the velocity estimate is gradually reduced to zero, and the current position is locally smoothed to prevent the trajectory from "wandering" indefinitely. Where the game rules allow, the trajectory can be periodically reset to a reference position to maintain its overall interpretability. Prior knowledge such as symmetry and boundary conditions is used to backtrack and correct trajectory segments that deviate significantly from reality.
[0118] Output 3D trajectory and action labels: Output the trajectory point sequence and action segmentation results together to provide continuous spatial information for the upper-level game logic. Trigger different haptic feedback effects based on action type and trajectory shape, such as different sound effects or light trajectories. Statistically analyze the continuous recognition error rate and adjust the threshold and noise model parameters as necessary to achieve online adaptive optimization.
[0119] For example, in a swinging motion recognition implementation: by setting moderate angular velocity and posture change angle thresholds, the system recognizes left-right or up-down swinging motions performed by a child holding a toy. When the peak swing acceleration and trajectory direction are stable, a single swing is defined as an action segment, and different game logic is triggered based on the number of consecutive swings. Through continuous posture estimation provided by EKF, the direction and intensity of the swinging motion in three-dimensional space are accurately mapped to the game feedback.
[0120] For another example: A rotational motion recognition implementation: When an angular velocity along a certain axis continuously exceeds a set threshold for a given duration, that segment is marked as a rotational motion. The trajectory reconstruction process accurately identifies the number of rotations and the direction of rotation, enabling interactive gameplay similar to "spinning to light up stars." A drift compensation mechanism is used to prevent excessive trajectory deviation after prolonged rotation, which could lead to character position distortion.
[0121] The aforementioned motion trajectory recognition method based on extended Kalman filtering (EDB) employs EDB to initialize the state vector using quaternions and error terms. It predicts attitude changes based on gyroscope data and constructs an observation function using accelerometer and magnetometer data to correct attitude drift in real time, significantly improving attitude estimation accuracy. By calculating the attitude change rate and setting multi-level thresholds to identify action boundaries, the method further enhances action recognition capabilities, ensuring accurate capture of complex actions. Regarding low-cost IMU and embedded platform adaptation, this method optimizes feature extraction results, suppresses integral drift through stationary detection, and adaptively adjusts the detection threshold based on action cycles using finite state machine analysis. This achieves smooth and accurate motion trajectory reconstruction and game feedback transitions while maintaining cost-effectiveness. The overall solution not only overcomes the attitude drift problem caused by traditional low-cost sensors but also improves the user experience, enabling smart toys to provide high-quality haptic interaction experiences at a lower cost.
[0122] Figure 2 This is a schematic block diagram of a motion trajectory recognition system 300 based on extended Kalman filtering provided in an embodiment of the present invention. Figure 2 As shown, corresponding to the above-described motion trajectory identification method based on extended Kalman filtering, the present invention also provides a motion trajectory identification system 300 based on extended Kalman filtering. This motion trajectory identification system 300 includes a unit for executing the above-described motion trajectory identification method based on extended Kalman filtering, and the system can be configured in a server. Specifically, please refer to... Figure 2 The motion trajectory recognition system 300 based on extended Kalman filter includes a prediction unit 301, a correction unit 302, an extraction unit 303, a restoration unit 304, and a feedback unit 305.
[0123] The prediction unit 301 initializes the EKF state vector using quaternions and an introduced error term, and predicts the toy's posture changes based on gyroscope data to obtain a prediction result. The correction unit 302 constructs an observation function by combining accelerometer and magnetometer data, and corrects and optimizes the posture drift caused by gyroscope integration in the prediction result in real time to obtain a corrected posture quaternion. The extraction unit 303 calculates the posture change rate based on the corrected posture quaternion to identify action boundaries and sets multi-level thresholds to obtain feature extraction results. The restoration unit 304 converts and processes the acceleration data of the feature extraction results, reconstructs the toy's motion trajectory in three-dimensional space, and uses static detection technology to suppress integral drift to obtain a restoration result. The feedback unit 305 analyzes the action cycle using a finite state machine based on the restoration result, adaptively adjusts the detection threshold, and converts the identified action sequence into game feedback.
[0124] In one embodiment, the prediction unit 301 includes:
[0125] An initialization subunit is used to define the state vector of the EKF and to represent the three-dimensional posture of the toy using quaternions, and to introduce an error term into the three-dimensional posture to obtain the initial state vector; a state prediction subunit is used to convert the continuous rotational dynamics equation into the form of a nonlinear state transition function based on the initial state vector and using gyroscope data to predict the prior state at the next moment to obtain the prediction result.
[0126] In one embodiment, the correction unit 302 includes:
[0127] The observation vector construction subunit is used to acquire real-time data from the accelerometer and magnetometer and construct the observation vector; the prediction correction subunit is used to establish an observation function based on the observation vector, map the prediction result to the expected gravity and magnetic field directions, calculate the expected observation value, calculate the deviation between the actual sensor observation value and the expected observation value, and feed back the Kalman gain matrix to the state vector for attitude correction to obtain the corrected attitude quaternion.
[0128] In one embodiment, the extraction unit 303 includes:
[0129] The change calculation subunit is used to calculate the attitude change at adjacent time points based on the corrected attitude quaternion, and derive the attitude change angle and angular velocity characteristics. The feature extraction subunit is used to perform joint analysis on the angular velocity magnitude and direction change based on the attitude change angle and angular velocity characteristics, identify local peaks to determine the start and end points of the action, identify incomplete continuous action segments, and construct a multi-level threshold system to adapt to motion capture requirements of different amplitudes in order to obtain feature extraction results.
[0130] In one embodiment, the restoration unit 304 includes:
[0131] The transformation subunit is used to construct a rotation matrix using the corrected attitude quaternions, and transform the accelerometer data in the feature extraction result from the sensor coordinate system to the world coordinate system to obtain the transformation result; the compensation and restoration subunit is used to remove the gravity component from the transformation result, perform time integration on the linear acceleration to obtain the velocity, and then integrate the velocity to obtain the displacement trajectory. A static detection strategy is used to compensate for the cumulative error caused by integration in the displacement trajectory, and to smooth the position drift within the required range to obtain the restoration result.
[0132] In one embodiment, the feedback unit 305 includes:
[0133] The state machine construction subunit is used to construct a finite state machine and trigger state switching based on the restoration result using the attitude change rate and linear acceleration to characterize the action life cycle; the adaptive adjustment subunit is used to adaptively adjust the action detection threshold according to the real-time environmental noise level and the intensity of children's activities; the driving subunit is used to adopt a merging strategy for action segments with short intervals, and extract the features of each action segment and map them to action labels in the game logic, organize them into action sequences and output them to drive the corresponding sound effects, lighting effects and story branch feedback.
[0134] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned motion trajectory recognition system 300 based on extended Kalman filtering and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0135] The aforementioned motion trajectory recognition system 300 based on extended Kalman filtering can be implemented as a computer program, which can be used in various ways, such as... Figure 3 It runs on the computer device shown.
[0136] Please see Figure 3 , Figure 3 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a server, wherein the server can be a standalone server or a server cluster composed of multiple servers.
[0137] See Figure 3 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0138] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform a motion trajectory recognition method based on an extended Kalman filter.
[0139] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0140] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a motion trajectory recognition method based on extended Kalman filtering.
[0141] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0142] The processor 502 is used to run a computer program 5032 stored in the memory to implement all the steps of the motion trajectory identification method based on extended Kalman filter.
[0143] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0144] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0145] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein when executed by a processor, the computer program causes the processor to perform all the steps of the motion trajectory identification method based on the extended Kalman filter.
[0146] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0147] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0148] In the embodiments provided by this invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of each unit is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0149] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the system of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0150] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0151] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A motion trajectory identification method based on extended Kalman filtering, characterized in that, include: The EKF state vector is initialized using quaternions and an error term, and the toy's attitude change is predicted based on gyroscope data to obtain the prediction result. An observation function is constructed by combining accelerometer and magnetometer data, and the attitude drift caused by gyroscope integration in the prediction result is corrected and optimized in real time to obtain the corrected attitude quaternion. The posture change rate is calculated based on the corrected posture quaternion to identify action boundaries, and multiple threshold levels are set to obtain feature extraction results. The feature extraction results are converted and processed into acceleration data to reconstruct the motion trajectory of the toy in three-dimensional space. Static detection technology is used to suppress integral drift in order to obtain the reconstruction result. Based on the reconstruction results, the action cycle is analyzed using a finite state machine, the detection threshold is adaptively adjusted, and the identified action sequence is converted into game feedback.
2. The motion trajectory identification method based on extended Kalman filtering according to claim 1, characterized in that, The process of initializing the EKF state vector using quaternions and introducing an error term, and predicting the toy's attitude changes based on gyroscope data to obtain the prediction result includes: Define the state vector of EKF and use quaternions to represent the three-dimensional pose of the toy. Introduce an error term into the three-dimensional pose to obtain the initial state vector. Based on the initial state vector, the continuous rotational dynamics equations are converted into nonlinear state transition functions using gyroscope data to predict the prior state at the next moment, thus obtaining the prediction result.
3. The motion trajectory identification method based on extended Kalman filtering according to claim 2, characterized in that, The mathematical expression used to predict the prior state at the next moment is x. k =f(x k-1 u k-1 )+w k , where x k Let u be the state vector at the next time step, f(·) be the nonlinear state transition function, and u be the state vector at the next time step. k-1 For gyroscope data, w k For process noise; x k-1 This is the state vector at the current moment.
4. The motion trajectory identification method based on extended Kalman filtering according to claim 1, characterized in that, The observation function, constructed by combining accelerometer and magnetometer data, is used to correct and optimize the attitude drift caused by gyroscope integration in the prediction results in real time, resulting in a corrected attitude quaternion, including: Acquire real-time data from accelerometers and magnetometers, and construct observation vectors; An observation function is established based on the observation vector, the prediction result is mapped to the expected gravity and magnetic field directions, the expected observation value is calculated, and the deviation between the actual sensor observation value and the expected observation value is calculated. The attitude is corrected by feeding back the state vector through the Kalman gain matrix to obtain the corrected attitude quaternion.
5. The motion trajectory identification method based on extended Kalman filtering according to claim 1, characterized in that, The process of calculating the attitude change rate based on the corrected attitude quaternions to identify action boundaries and setting multi-level thresholds to obtain feature extraction results includes: Based on the corrected attitude quaternion, the attitude change at adjacent time points is calculated, and the characteristics of attitude change angle and angular velocity are derived. Based on the posture change angle and angular velocity characteristics, the angular velocity magnitude and direction changes are jointly analyzed to identify local peaks to determine the start and end points of the action, identify incomplete continuous action segments, and construct a multi-level threshold system to adapt to motion capture requirements of different amplitudes in order to obtain feature extraction results.
6. The motion trajectory identification method based on extended Kalman filtering according to claim 1, characterized in that, The process of converting and processing the feature extraction results into acceleration data to reconstruct the toy's motion trajectory in three-dimensional space, and using static detection technology to suppress integral drift to obtain the restored result, includes: Using the corrected attitude quaternions, a rotation matrix is constructed to transform the accelerometer data in the feature extraction results from the sensor coordinate system to the world coordinate system, so as to obtain the transformation result; After removing the gravity component from the conversion result, the linear acceleration is integrated over time to obtain the velocity, and then the velocity is integrated to obtain the displacement trajectory. A static detection strategy is used to compensate for the cumulative error caused by integration in the displacement trajectory, and the position drift within the required range is smoothed to obtain the restored result.
7. The motion trajectory identification method based on extended Kalman filtering according to claim 1, characterized in that, The process of analyzing the action cycle using a finite state machine based on the reconstruction results, adaptively adjusting the detection threshold, and converting the identified action sequence into game feedback includes: Construct a finite state machine, and use the attitude change rate and linear acceleration to trigger state transitions based on the reconstruction results to characterize the action lifecycle; The motion detection threshold is adaptively adjusted based on the real-time ambient noise level and the intensity of children's activities. For action segments with short intervals, a merging strategy is adopted, and the features of each action segment are extracted and mapped to action tags in the game logic, organized into action sequences and output, driving corresponding sound effects, lighting effects and story branch feedback.
8. The motion trajectory identification method based on extended Kalman filtering according to claim 7, characterized in that, The finite state machine includes at least one of the following states: static, ready to move, moving in progress, moving to end, and transition.
9. The motion trajectory identification method based on extended Kalman filtering according to claim 7, characterized in that, The characteristics of each action segment include at least one of duration, maximum angular velocity, and trajectory shape.
10. A motion trajectory recognition system based on extended Kalman filtering, characterized in that, include: The prediction unit is used to initialize the EKF state vector using quaternions and an introduced error term, and to predict the toy's attitude changes based on gyroscope data to obtain the prediction result. The correction unit is used to construct an observation function by combining accelerometer and magnetometer data, and to correct and optimize the attitude drift caused by gyroscope integration in the prediction result in real time, so as to obtain the corrected attitude quaternion. The extraction unit is used to calculate the rate of change of posture based on the corrected posture quaternion to identify the action boundary, and to set multi-level thresholds to obtain the feature extraction result; The reconstruction unit is used to convert and process the acceleration data of the feature extraction results, reconstruct the motion trajectory of the toy in three-dimensional space, and use static detection technology to suppress integral drift in order to obtain the reconstruction result; The feedback unit is used to analyze the action cycle using a finite state machine based on the restoration result, adaptively adjust the detection threshold, and convert the identified action sequence into game feedback.