Robot control algorithm simulation method and system based on shared memory

By employing a shared memory approach in robot control algorithm simulation, low-overhead, non-blocking asynchronous data interaction between the control algorithm simulation platform and the physical simulation platform is achieved. This solves the problem of low data interaction efficiency in existing technologies, improves the real-time performance and stability of the simulation, and supports rapid iteration and high-fidelity verification.

CN122151587APending Publication Date: 2026-06-05HUNAN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN UNIV
Filing Date
2026-05-06
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, the data interaction efficiency between the control algorithm simulation platform and the physical simulation platform in robot simulation is low, which affects the real-time performance and stability of the joint simulation and makes it difficult to meet the requirements of rapid iteration and high realism verification of robot control algorithms.

Method used

By adopting a shared memory-based approach, a shared memory object is created between the control algorithm simulation platform and the physical simulation platform. This object is divided into a control instruction shared area, a status feedback shared area, and a parameter update shared area, enabling non-blocking data interaction. The control algorithm simulation platform and the physical simulation platform operate independently at their respective frequencies, avoiding synchronous blocking and waiting.

Benefits of technology

It significantly reduces the latency and jitter of data interaction, improves the real-time performance and stability of co-simulation, removes the synchronization limitation between the control cycle and the physical simulation step size, improves the efficiency and flexibility of simulation, and supports online parameter tuning and dynamic parameter updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122151587A_ABST
    Figure CN122151587A_ABST
Patent Text Reader

Abstract

The application discloses a kind of robot control algorithm simulation method and system based on shared memory.Method includes: setting control algorithm simulation platform and physical simulation platform;Create shared memory object, and divide control instruction shared area and state feedback shared area in the shared memory object;The control algorithm simulation platform reads the latest valid state data from the state feedback shared area according to control period, runs control algorithm model and generates control instruction, and the control instruction is non-blocked and written in the control instruction shared area;The physical simulation platform reads valid control instruction from the control instruction shared area according to physical simulation step length, drives physical model to run, and non-blocked and writes updated state feedback in the state feedback shared area.The application reduces data interaction delay and jitter, avoids synchronization blocking and step length restriction, improves the real-time performance, stability and operating efficiency of joint simulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of robot simulation technology, specifically relating to a simulation method and system for robot control algorithms based on shared memory. Background Technology

[0002] With the development of robot control technology, the design and verification of control algorithms increasingly require a balance between algorithm performance and response to the actual physical environment. For unmanned motorcycles, self-balancing robots, and other mobile robots, the control effect is not only related to the control law itself, but also closely related to the vehicle's dynamic characteristics, actuator response characteristics, sensor feedback characteristics, and external environmental disturbances. Relying solely on theoretical derivations or simplified mathematical models for offline analysis is insufficient to fully reflect the robot's actual operating state in complex physical environments. Therefore, constructing a co-simulation platform for robot control verification has become an important means in control system development.

[0003] In existing technologies, control algorithms are typically developed and verified on the Simulink platform. Simulink offers advantages such as flexible model building, rich algorithm modules, intuitive control logic expression, and fast iteration speed, making it suitable for controller design, tuning, and rapid algorithm verification. Meanwhile, Webots, as a robot simulation platform, boasts strong 3D scene construction capabilities, a relatively complete physics engine, and convenient sensor and actuator modeling, enabling it to realistically reproduce the robot's motion behavior in the physical environment and its interaction with the environment. Therefore, combining Simulink and Webots for co-simulation can fully leverage the strengths of both, achieving collaborative control algorithm design and physical environment verification.

[0004] To achieve co-simulation between Simulink and Webots, existing technologies typically use data communication to connect the control algorithm platform and the physical simulation platform. This allows the controller output to drive the physical model, while simultaneously returning the physical model's state variables and sensor feedback to the controller. Common data interaction methods include network communication based on TCP and UDP, data exchange based on file read / write or middleware bridging, and co-operation based on synchronous blocking calls.

[0005] However, the aforementioned existing technologies still have the following shortcomings: First, network communication methods based on TCP and UDP typically rely on network protocol stacks for data transmission, which can lead to problems such as long communication links, numerous data copying operations, and significant latency and jitter. In high-frequency closed-loop control scenarios, these issues can easily affect the real-time performance and stability of co-simulation.

[0006] Secondly, existing synchronous blocking co-simulation methods typically require that the controller's computation cycle, physical simulation step size, and sensor refresh frequency remain consistent or strictly aligned. When the operating frequencies of each module are not synchronized, a phenomenon of one end waiting for the other to synchronize can easily occur, causing mutual constraints on step size and a decrease in simulation efficiency, which is not conducive to the rapid iterative verification of complex robot systems.

[0007] Furthermore, in existing co-simulation processes, modifications to control and dynamic parameters made by the MATLAB script are difficult to capture in real-time and stably by the running Simulink model. Typically, the simulation needs to be stopped and the model re-initialized for the changes to take effect. This approach increases debugging and verification costs and fails to meet the needs of robot control system development for online parameter tuning, continuous operating condition testing, and dynamic parameter updates.

[0008] Therefore, existing technologies lack a joint simulation method that can achieve low-overhead, non-blocking asynchronous data interaction between the control algorithm simulation platform and the physical simulation platform to meet the needs of rapid iteration and high-fidelity verification of robot control algorithms. Summary of the Invention

[0009] The technical problem to be solved by the present invention is to overcome the defect of low data interaction efficiency between the control algorithm simulation platform and the physical simulation platform in the prior art, thereby providing a robot control algorithm simulation method and system based on shared memory.

[0010] A simulation method for robot control algorithm based on shared memory, comprising: Set up a control algorithm simulation platform and a physical simulation platform; Create a shared memory object, map the shared memory object to the process address space of the control algorithm simulation platform and the physical simulation platform, and divide the shared memory object into a control instruction shared area and a status feedback shared area; According to the control algorithm simulation platform, the latest valid state data is read from the state feedback shared area in a non-blocking manner according to the control cycle, the control algorithm model is run to calculate and generate control commands, and the control commands are written into the control command shared area in a non-blocking manner. The physical simulation platform reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size to drive the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.

[0011] Furthermore, it also includes a parameter management platform; a parameter update shared area is also divided within the shared memory object; During the joint simulation, the parameter management platform writes the updated parameter information into the parameter update sharing area; the control algorithm simulation platform reads and calls the new parameter values ​​from the parameter update sharing area without interrupting the simulation.

[0012] Furthermore, the parameter update shared area stores grouped parameter data, which is organized in a tabular data format. The tabular data includes breakpoint vectors and parameter tables corresponding to the breakpoint vectors.

[0013] Furthermore, the state feedback sharing area includes an inertial information sharing area, an actuator state sharing area, and a mode flag sharing area; The inertial information sharing area is used to store attitude angle, angular velocity, and linear acceleration inertial state data; the actuator state sharing area is used to store steering angle, wheel rotation angle, and their rate of change actuator state data; the mode flag sharing area is used to store control takeover state, running state, and reset state mode data.

[0014] Furthermore, the control command sharing area, the inertial information sharing area, the actuator status sharing area, and the mode flag sharing area are organized using a fixed-length shared data block method; The control algorithm simulation platform and the physical simulation platform directly read and write the fixed-length shared data block using the nearest valid data reading strategy.

[0015] Furthermore, the tabular data adopts a data organization method with version numbers, and the shared data block of the parameter update sharing area is set with version identifier, number of breakpoints, number of parameter columns and parameter table content.

[0016] Furthermore, when the parameter management platform updates the parameter table, it first writes the version change identifier, then writes the parameter content, and updates it to a stable and readable state after the writing is completed. The control algorithm simulation platform detects whether the version number of the parameter table has changed in each control cycle. Only when a version change is detected and the data is in a stable and readable state, the local parameter cache is read and refreshed.

[0017] Furthermore, the control algorithm simulation platform is equipped with a local caching mechanism; For the fixed-length shared data block, the control algorithm simulation platform directly reads the most recently stable and available data; for the tabular data, the control algorithm simulation platform only refreshes the local cache when it detects a version change and the data is in a stable and readable state, otherwise it uses the existing cache.

[0018] Furthermore, within one control cycle, the physical simulation platform continuously executes multiple physical simulation steps to update the state data, and the control algorithm simulation platform reads the most recently available shared state data and outputs new control commands.

[0019] A robot control algorithm simulation system based on shared memory, which implements robot control algorithm simulation based on the aforementioned shared memory-based robot control algorithm simulation method, includes: Control algorithm model, used to run the control algorithm model; A robot physical environment model, used to drive the operation of the physical model; The shared memory interaction module includes a created shared memory object, which is mapped to the process address space of the control algorithm model and the robot physical environment model, and the shared memory object is divided into a control instruction shared area and a status feedback shared area. The control algorithm model reads the most recent valid state data from the state feedback shared area in a non-blocking manner according to the control cycle, runs the control algorithm model to calculate and generate control commands, and writes the control commands into the control command shared area in a non-blocking manner. The robot's physical environment model reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size, drives the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.

[0020] Beneficial Effects: This invention provides a robot control algorithm simulation method based on shared memory. By creating shared memory objects and mapping them to the process address spaces of the control algorithm simulation platform and the physical simulation platform, data interaction is achieved using shared memory. This avoids the problems of long communication links and numerous data copying operations caused by existing technologies based on network protocols such as TCP / UDP, thus significantly reducing the latency and jitter of data interaction and improving the real-time performance and stability of the co-simulation. By dividing the shared memory object into a control instruction shared area and a status feedback shared area, the partitioned organization and independent access of control instructions and status feedback are realized. The data flow is clear and unambiguous, avoiding interference caused by mixed reading and writing of different types of data, further improving the efficiency and reliability of data reading and writing.

[0021] In this invention, the control algorithm simulation platform reads and writes data non-blockingly according to the control cycle, and the physical simulation platform reads and writes data non-blockingly according to the physical simulation step size. Each platform operates independently at its own frequency without the need for synchronous blocking or waiting. This completely eliminates the restriction that the control cycle and the physical simulation step size must be strictly aligned, avoids the problems of synchronous waiting and mutual constraints on step sizes, and significantly improves the efficiency and operational flexibility of joint simulation. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a schematic flowchart of the main method steps of the present invention; Figure 2 This is a flowchart of the asynchronous co-simulation process of the present invention; Figure 3 This is a structural diagram of the step-by-step co-simulation system of the present invention. Detailed Implementation

[0024] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the specific embodiments of this application are described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.

[0025] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0026] In this application, unless otherwise expressly specified and limited, the terms "installation," "connection," "joining," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise expressly limited. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0027] Example 1: Reference Figure 1 and Figure 2 As shown, this embodiment provides a simulation method for robot control algorithms based on shared memory, including: Step S1: Set up the control algorithm simulation platform and the physical simulation platform; Step S2: Create a shared memory object, map the shared memory object to the process address space of the control algorithm simulation platform and the physical simulation platform, and divide the shared memory object into a control instruction shared area and a status feedback shared area; Step S3: The control algorithm simulation platform reads the most recent valid state data from the state feedback shared area in a non-blocking manner according to the control cycle, runs the control algorithm model to calculate and generate control commands, and writes the control commands into the control command shared area in a non-blocking manner. Step S4: The physical simulation platform reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size to drive the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.

[0028] In this embodiment, the control algorithm simulation platform is preferably Simulink, the physical simulation platform is preferably Webots, and the parameter management platform is a MATLAB script. This method is geared towards constructing robot control verification scenarios. A robot control algorithm model is established in Simulink, and a corresponding robot physical environment model is established in Webots. The robot in this embodiment can be an unmanned motorcycle, a self-balancing robot, or other mobile robots. The Simulink platform is responsible for controller operation, control law calculation, and parameter calling; the Webots platform is responsible for simulating robot dynamics, sensor feedback, and environmental interaction; and the MATLAB script platform is responsible for parameter management and online updates. The various components achieve asynchronous interaction of control commands, status feedback, and parameter information through shared memory, thus forming a closed-loop co-simulation platform between the control algorithm, parameter management, and physical environment.

[0029] Specifically, to ensure data reliability during asynchronous read / write operations of shared memory, the shared memory is preferably implemented based on the named shared memory mechanism provided by the operating system. By creating shared memory objects and mapping them to the process address spaces of the Webots, Simulink, and MATLAB processes, low-overhead data sharing and asynchronous interaction between multiple processes can be achieved.

[0030] The shared memory object is divided into a control instruction shared area, a status feedback shared area, and a parameter update shared area. The control instruction shared area stores actuator control instructions output by Simulink; the parameter update shared area stores control parameters and dynamic parameters that need to be dynamically updated during operation; the status feedback shared area includes an inertial information shared area, an actuator status shared area, and a mode flag shared area. The inertial information shared area stores the robot's attitude angle, angular velocity, and linear acceleration inertial state data; the actuator status shared area stores the robot's steering angle, wheel rotation angle, and rate of change of the actuator status data; and the mode flag shared area stores control takeover status, running status, and reset status mode data.

[0031] Furthermore, for different types of shared data, this implementation adopts a layered consistency guarantee strategy to balance the real-time performance and consistency of data access: For fixed-length data blocks such as the control command sharing area, inertial information sharing area, actuator status sharing area, and mode flag sharing area, a fixed-length shared memory mapping method is used for direct reading and writing. The control algorithm simulation platform is equipped with a local caching mechanism. For the fixed-length shared data blocks, the most recently stable and available data is read directly. The reading end always reads the most recently successfully written complete data frame, thereby effectively ensuring the availability and real-time performance of control commands and status feedback under asynchronous read and write conditions.

[0032] For grouped parameter data in the parameter update shared area, a tabular data format is used. This tabular data includes breakpoint vectors and the corresponding parameter tables. Due to the large data volume and the fact that each update involves multiple fields, a version number-based data organization method is preferred. The shared data block in the parameter update shared area is configured with a version identifier, the number of breakpoints, the number of parameter columns, and the parameter table content. During the writing process, when the parameter management platform updates the parameter table, it first writes the version change identifier, then writes the new parameter content. After all parameter content has been written, the version status is updated to a stable and readable state. During the reading process, the control algorithm simulation platform checks whether the parameter table version number has changed in each control cycle. Only when a version change is detected and the data is in a stable and readable state is the local parameter cache read and refreshed; otherwise, the existing cache is used. Through this collaborative mechanism of step-by-step writing on the write end and version-based refreshing on the read end, not only is it effectively avoided that the read end reads incomplete intermediate data during the parameter update process, but it also reduces the overhead of repeated full-table accesses to shared memory in each control cycle, ensuring the stability of asynchronous interaction. As a preferred embodiment, the parameter update information can also be organized in scalar, vector, or matrix form to support dynamic switching and calling of different types of parameters.

[0033] During simulation, the aforementioned control command writing, state feedback writing, and corresponding reading processes employ an asynchronous, non-blocking method to achieve asynchronous collaborative operation between the control algorithm platform and the physical simulation platform. Simulink reads the most recently valid state data from the state feedback shared area according to the control cycle, completes the control command calculation, and writes the control command into the control command shared area. Webots reads the most recently valid control command from the control command shared area according to the physical simulation step size and drives the robot model accordingly, while simultaneously writing the updated state variables and sensor feedback into the state feedback shared area. Meanwhile, a parameter transfer channel is established between the MATLAB script and the Simulink control model through the parameter update shared area. Updated parameter information is first written to the parameter update shared area by the MATLAB script, and then the Simulink control model reads and calls the new parameter values ​​without interrupting the simulation, thus achieving online updating of runtime parameters.

[0034] In this embodiment, the control cycle is an integer multiple of the physical simulation step size; within one control cycle, the physical simulation platform continuously executes multiple physical simulation steps to update the state data, and the control algorithm simulation platform reads the most recently available shared state data and outputs new control instructions.

[0035] Example 2: This embodiment provides a specific example of a co-simulation implementation of balance control for unmanned motorcycles based on shared memory.

[0036] In this embodiment, the controlled object is an unmanned two-wheeled self-balancing vehicle system, which includes a vehicle body, a front-wheel steering actuator, a control torque gyroscope rotor and its precession actuator, a rear-wheel drive mechanism, and sensing and actuation components such as an inertial measurement unit. The front-wheel steering actuator is used to adjust the vehicle's heading, the control torque gyroscope rotor and its precession actuator provide balance adjustment, and the rear-wheel drive mechanism enables longitudinal drive of the vehicle.

[0037] Based on the aforementioned controlled object, the co-simulation system comprises a MATLAB script-side parameter management module (hereinafter referred to as the MATLAB side), a Simulink control algorithm module (hereinafter referred to as the Simulink side), and a Webots robot physical environment module (hereinafter referred to as the Webots side). These three modules achieve asynchronous closed-loop interaction through shared memory, thereby enabling continuous verification of the unmanned motorcycle balance control algorithm.

[0038] The inertial state vector is denoted as: ; in, , and These represent the roll angle, pitch angle, and yaw angle, respectively. , and Indicates the angular velocity of the three axes. , and This represents the acceleration along three axes. The actuator-related state vector is denoted as: ; in, For steering angle, For the precession angle, and These represent the rotation angles of the rear and front wheels, respectively. , , and These represent the rates of change of the corresponding variables. The control command vector is denoted as: ; in, This indicates the precession control quantity. Indicates steering control quantity. Indicates the rotor control quantity. Indicates the amount of rear wheel control. and To reserve control parameters, the vehicle speed breakpoint vector in the parameter table is denoted as: ; The corresponding parameter table is denoted as: ; in, This represents a set of feedback gains corresponding to the current vehicle speed. If the augmented state vectors participating in the feedback are uniformly denoted as... Then the control law can be written as: ; The system is configured with the following shared memory areas: control command shared area, inertial information shared area, actuator state shared area, mode flag shared area, and parameter table shared area. The control command shared area stores the control command vector (u), and the inertial information shared area stores the inertial state vector. The actuator state sharing area is used to store the actuator state vector. The mode flag shared area is used to store mode switching and reset information, and the parameter table shared area is used to store information organized by vehicle speed breakpoints. and .

[0039] Within a control cycle, the Simulink terminal generates a control command vector based on the current state variables and parameter table lookup results. The control command vector is then written to the control command sharing area. In one specific implementation, the control command vector can be: ; Here, each item represents the precession adjustment, steering correction, rotor speed control, rear-wheel drive control, and reserved space, respectively. After reading the control command vector, the Webots terminal maps each control component to the corresponding actuator. The above values ​​are only used to illustrate the organization and mapping relationship of control commands in shared memory and do not constitute a limitation on the scope of protection of this invention.

[0040] Regarding state feedback, the Webots side will use the inertial state vector Write to the inertial information sharing area. In one example, the inertial state vector could be: ; The example above indicates that the unmanned motorcycle currently has a roll angle of 2.6°, a pitch angle of 0.3°, a yaw angle of 15.4°, and a roll rate of -18.2° / s. Simultaneously, the Webots terminal will also display the actuator-related state vectors. Write to the executor state shared region. In one example, the executor state vector could be: ; The first to fourth items correspond to the steering angle, precession angle, rear wheel rotation angle, and front wheel rotation angle, respectively, while the fifth to eighth items correspond to their rates of change. The Simulink terminal can read these parameters simultaneously. and This allows for the construction of a feedback state vector for control computation. .

[0041] Regarding parameter information, the MATLAB client generates feedback gain tables offline according to different vehicle speeds and writes them into the parameter table shared area. In one implementation, the vehicle speed breakpoint vector can be written as: ; Correspondingly, each speed breakpoint corresponds to a set of feedback gains. This forms a parameter table. During operation, the Simulink terminal adjusts the speed based on the current vehicle speed. Find the most recent breakpoint and read the corresponding feedback gain. And substitute it into the control law Calculate the control commands at the current moment.

[0042] Furthermore, the parameter table shared area adopts a versioned consistency management structure, including at least a version number, the number of breakpoints, the number of parameter columns, a breakpoint vector, and a gain table. When writing to the parameter table in MATLAB, the version identifier is updated first, and then the vehicle speed breakpoint vector is written. and feedback gain table After writing is complete, the stable state flag is updated. In each control cycle, the Simulink terminal first checks if the parameter table version number has changed; it only refreshes the local cache if an update is detected, otherwise it uses the existing cache. Subsequently, the Simulink terminal adjusts the current vehicle speed from... Find the most recent breakpoint and read the corresponding data. It participates in control operations. This method avoids reading intermediate state data during parameter writing and reduces repeated full table accesses to shared memory in each control cycle.

[0043] Regarding the data transmission method, the co-simulation process in this embodiment adopts an asynchronous time-driven approach. Specifically, the simulation cycle on the Webots side is set to 5 ms, the control cycle on the Simulink side is set to 10 ms, and the MATLAB side uses a manually triggered aperiodic update method, writing new vehicle speed breakpoint vectors to the parameter table shared area as needed for parameter tuning. and feedback gain table Therefore, the Webots side performs physical simulation and state updates at a higher frequency, the Simulink side performs state reading, parameter lookup and control calculation at a lower frequency, and the MATLAB side updates control parameters asynchronously when needed, thus forming a joint simulation mechanism in which the three run asynchronously in parallel.

[0044] The co-simulation process in this embodiment may include the following steps: MATLAB offline generation of vehicle speed breakpoint vectors and feedback gain table And write it into the parameter table shared area when the parameter needs to be adjusted by human triggering; The Webots client runs the simulation with a 5 ms cycle, updating the dynamic state of the unmanned motorcycle within each physical step and transferring the inertial state vector. and actuator state vector Write to the corresponding shared memory region; The Simulink terminal operates on a 10 ms control cycle. Within each control cycle, it reads the most recently valid state data from shared memory and checks if the parameter table version number has changed. If the parameter table has been updated, it refreshes the local parameter cache and retrieves the corresponding feedback gain based on the current vehicle speed. ; Simulink based on feedback state vector and feedback gain Calculate the control command vector And write it to the control command shared area; The Webots client reads the most recently written control command vector in subsequent physics steps. Each component is then mapped to its corresponding actuator to complete the next stage of physical simulation calculation.

[0045] Since the simulation cycle on the Webots side is 5 ms and the control cycle on the Simulink side is 10 ms, within one Simulink control cycle, the Webots side can continuously execute two physical simulation steps, prioritizing the continuous updating of the physical environment state; the Simulink side reads the most recently available shared state data and outputs new control commands. The MATLAB side has no strong synchronization relationship with either of these cycles, but directly triggers the update of the shared parameter table when parameters are adjusted. Therefore, low-overhead, non-blocking asynchronous closed-loop co-simulation can be achieved without strict synchronization alignment of the physical simulation cycle, control cycle, and parameter update cycle.

[0046] Furthermore, when the reset flag in the mode flag sharing area fails, the Webots terminal can clear or reset the inertial information sharing area, actuator state sharing area, and control command sharing area to restore the vehicle to the initial balance control verification state; when the reset flag becomes valid again, the system resumes closed-loop balance control operation. This supports the start-up, pause, reset, and repetition testing of the unmanned motorcycle balance control algorithm.

[0047] Example 3: Reference Figure 3 As shown, this embodiment provides a robot control algorithm simulation system based on shared memory. It implements robot control algorithm simulation based on the shared memory-based robot control algorithm simulation method described in Embodiment 1, including: Control algorithm model, used to run the control algorithm model; A robot physical environment model, used to drive the operation of the physical model; The shared memory interaction module includes a created shared memory object, which is mapped to the process address space of the control algorithm model and the robot physical environment model, and the shared memory object is divided into a control instruction shared area and a status feedback shared area. The control algorithm model reads the most recent valid state data from the state feedback shared area in a non-blocking manner according to the control cycle, runs the control algorithm model to calculate and generate control commands, and writes the control commands into the control command shared area in a non-blocking manner. The robot's physical environment model reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size, drives the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.

[0048] Specifically, the control algorithm model is preferably a Simulink control algorithm module, the robot physical environment model is preferably a Webots robot physical environment module, and the system also includes a MATLAB script-based parameter management module. The MATLAB script-based parameter management module is used for parameter generation, tuning, updating, and writing; the Simulink control algorithm module is used to read state and parameter information, complete control law calculations, and generate control commands; the Webots robot physical environment module is used to construct a three-dimensional physical environment model, perform dynamic simulations, and generate sensor feedback.

[0049] The shared memory interaction module is used to realize asynchronous data interaction between the above modules, and preferably includes a control command sharing area, an inertial information sharing area, an actuator status sharing area, a mode flag sharing area, and a parameter table sharing area. The data organization method, hierarchical consistency guarantee strategy, and asynchronous interaction timing between the modules in each shared area are the same as those described in Embodiment 1, and will not be repeated here.

[0050] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0051] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A simulation method for robot control algorithm based on shared memory, characterized in that, include: Set up a control algorithm simulation platform and a physical simulation platform; Create a shared memory object, map the shared memory object to the process address space of the control algorithm simulation platform and the physical simulation platform, and divide the shared memory object into a control instruction shared area and a status feedback shared area; According to the control algorithm simulation platform, the latest valid state data is read from the state feedback shared area in a non-blocking manner according to the control cycle, the control algorithm model is run to calculate and generate control commands, and the control commands are written into the control command shared area in a non-blocking manner. The physical simulation platform reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size to drive the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.

2. The simulation method for robot control algorithm based on shared memory according to claim 1, characterized in that, It also includes a parameter management platform; the shared memory object is further divided into a parameter update shared area; During the joint simulation, the parameter management platform writes the updated parameter information into the parameter update sharing area; the control algorithm simulation platform reads and calls the new parameter values ​​from the parameter update sharing area without interrupting the simulation.

3. The simulation method for robot control algorithm based on shared memory according to claim 2, characterized in that, The parameter update shared area stores grouped parameter data, which is organized in tabular form. The tabular data includes breakpoint vectors and parameter tables corresponding to the breakpoint vectors.

4. The simulation method for robot control algorithm based on shared memory according to claim 1, characterized in that, The state feedback sharing area includes an inertial information sharing area, an actuator state sharing area, and a mode flag sharing area; The inertial information sharing area is used to store attitude angle, angular velocity, and linear acceleration inertial state data; the actuator state sharing area is used to store steering angle, wheel rotation angle, and their rate of change actuator state data; the mode flag sharing area is used to store control takeover state, running state, and reset state mode data.

5. The simulation method for robot control algorithm based on shared memory according to claim 4, characterized in that, The control command sharing area, the inertial information sharing area, the actuator status sharing area, and the mode flag sharing area are organized using a fixed-length shared data block method. The control algorithm simulation platform and the physical simulation platform directly read and write the fixed-length shared data block using the nearest valid data reading strategy.

6. The simulation method for robot control algorithm based on shared memory according to claim 3, characterized in that, The tabular data is organized using a version number, and the shared data block in the parameter update shared area is set with version identifier, number of breakpoints, number of parameter columns, and parameter table content.

7. The simulation method for robot control algorithm based on shared memory according to claim 6, characterized in that, When the parameter management platform updates the parameter table, it first writes the version change identifier, then writes the parameter content, and updates it to a stable and readable state after the writing is completed. The control algorithm simulation platform detects whether the version number of the parameter table has changed in each control cycle. Only when a version change is detected and the data is in a stable and readable state, the local parameter cache is read and refreshed.

8. The simulation method for robot control algorithm based on shared memory according to claim 7, characterized in that, The control algorithm simulation platform is equipped with a local caching mechanism. For the tabular data, the control algorithm simulation platform refreshes the local cache only when it detects a version change and the data is in a stable and readable state; otherwise, it uses the existing cache.

9. The simulation method for robot control algorithm based on shared memory according to claim 1, characterized in that, Within one control cycle, the physical simulation platform continuously executes multiple physical simulation steps to update the state data, and the control algorithm simulation platform reads the most recently available shared state data and outputs new control commands.

10. A robot control algorithm simulation system based on shared memory, which implements robot control algorithm simulation based on the robot control algorithm simulation method based on shared memory as described in any one of claims 1-9, characterized in that, include: Control algorithm model, used to run the control algorithm model; A robot physical environment model, used to drive the operation of the physical model; The shared memory interaction module includes a created shared memory object, which is mapped to the process address space of the control algorithm model and the robot physical environment model, and the shared memory object is divided into a control instruction shared area and a status feedback shared area. According to the control cycle, the control algorithm model reads the most recent valid state data from the state feedback shared area in a non-blocking manner, runs the control algorithm model to calculate and generate control commands, and writes the control commands into the control command shared area in a non-blocking manner. The robot's physical environment model reads valid control commands from the control command sharing area in a non-blocking manner according to the physical simulation step size, drives the physical model to run, and writes the updated state feedback into the state feedback sharing area in a non-blocking manner.