A Precise Spatial Positioning Method for Magnetically Controlled Capsule Robots Based on ISCSO-LMNN

By improving the BP neural network and sand cat swarm optimization algorithm, and combining it with ISCSO-LMNN, the initial parameters of the capsule robot were optimized, which solved the problem of insufficient positioning accuracy of microrobots in the complex environment of the gastrointestinal tract and achieved high-precision spatial positioning effect.

CN116337074BActive Publication Date: 2026-03-10CHINA UNIV OF MINING & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In the existing technology, the in vivo positioning and tracking technology of microrobots fails to match the complex environment of the gastrointestinal tract in real time, and lacks adaptive high-precision positioning algorithms to cope with the rugged surface of the gastrointestinal tract, resulting in insufficient positioning accuracy.

Method used

An improved BP neural network algorithm is used to provide accurate initial values ​​for the LM algorithm. By combining ISCSO-LMNN and the sand cat swarm optimization algorithm, the spatial positioning of the capsule robot is optimized. Magnetic field information is obtained through a magnetic sensor, and the weights and thresholds of the BP neural network are optimally initialized using the improved sand cat swarm optimization algorithm to achieve accurate positioning.

Benefits of technology

It improves the spatial positioning accuracy of capsule robots, enhances the local and global search capabilities of the algorithm, and achieves precise spatial positioning in complex gastrointestinal environments, making it suitable for positioning work of related robots and mechanical equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116337074B_ABST
    Figure CN116337074B_ABST
Patent Text Reader

Abstract

This invention discloses a precise spatial positioning method for a magnetically controlled capsule robot based on ISCSO-LMNN. The method includes: using the LM algorithm to inversely determine the capsule robot's position based on its spatial magnetic field information; designing a BP neural network to optimize the initial parameters of the LM algorithm, thus improving its performance; improving the initialization and output stages of the basic sand cat swarm optimization algorithm based on a segmented mapping population initialization strategy and an adversarial learning strategy, effectively enhancing the algorithm's local and global search capabilities; and using the improved sand cat swarm optimization algorithm to optimally initialize the initial weights and thresholds of the BP neural network, effectively improving its model performance. Through these improved ISCSO-LMNN techniques, precise positioning of the capsule robot under a spatial magnetic field can be effectively achieved. This algorithm has high applicability and can be effectively applied to the positioning of related robots and mechanical equipment.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a space positioning method, in particular to a magnetic capsule robot precise space positioning method based on ISCSO-LMNN, and belongs to the technical field of positioning and navigation. BACKGROUND

[0002] With the development of today's society and the continuous change of human lifestyle, the gastrointestinal tract of most people is in a sub-health state. Therefore, how to reduce the incidence and mortality of gastrointestinal diseases has become a major global health problem. Medical capsule robots can safely and effectively perform non-invasive diagnosis and treatment of gastrointestinal diseases, avoiding the shortcomings of traditional gastroscopic diagnosis, such as great pain and long duration, and become an important milestone in the development of micro medical robots. Therefore, as an important means to promote early screening of the gastrointestinal tract in China, the capsule robot has extremely important clinical application value.

[0003] At present, the active capsule robot mainly uses magnetic control means, and the external driving magnetic field, the geomagnetic field and the device magnetic field have great interference on the positioning of the capsule robot. Therefore, researching an effective space positioning method for the medical capsule robot has become a key point that needs to be broken through. With the continuous development of capsule robot positioning technology, the following problems have also been found in the research process:

[0004] 1) The in-vivo positioning and tracking technology of the micro robot has been widely studied, but it is not real-time matched with the complex environment inside the gastrointestinal tract;

[0005] 2) In view of the actual situation that the surface of the gastrointestinal tract is rugged and changeable, the algorithm parameter adjustment mechanism research of the surface structure and positioning technology still needs to be carried out, and a self-adaptive high-precision positioning algorithm needs to be designed. SUMMARY

[0006] The purpose of the application is to provide a magnetic capsule robot precise space positioning method based on ISCSO-LMNN to solve at least one of the above technical problems, and an improved BP neural network algorithm is used to accurately position the initial value of the LM algorithm, and the accurate initial value is provided for the LM algorithm to effectively improve the space positioning accuracy of the capsule robot.

[0007] The application achieves the above purpose through the following technical scheme: a magnetic capsule robot precise space positioning method based on ISCSO-LMNN, comprising the following steps:

[0008] Step one, acquiring the space magnetic field information of the capsule robot according to the magnetic sensor;

[0009] Step two, selecting the number of hidden layers and the number of nodes of the BP neural network

[0010] Step three, obtaining the optimal initial network model weight and threshold value through the improved sand cat group optimization algorithm

[0011] Step four, calculating the actual output, accurately positioning the LM algorithm initial value, judging whether the expectation is reached, if not, then back propagation, updating the weight and threshold value; if yes, then outputting the LMI optimal initial value, and using the LM algorithm to inversely solve the capsule robot space magnetic field information, realizing the accurate space positioning of the capsule robot.

[0012] As a further scheme of the application, the model establishment of the BP neural network comprises:

[0013] The number selection formula of the neural network hidden layer neuron is as follows:

[0014]

[0015] In the formula, n is the number of layers of the neural network input layer, m is the number of layers of the neural network hidden layer, l is the number of layers of the neural network output layer, and A is a constant between 1 and 10;

[0016] In the BP neural network, data is transmitted from the input layer to the hidden layer, and then transmitted from the hidden layer to the output layer, and in the transmission process of each layer, the data is processed by an activation function, so that the output formula of the hidden layer of the BP neural network is:

[0017]

[0018] In the formula, θ j represents the output of the jth hidden layer neuron, x i is the input value of the neural network input layer, ω ij is the weight of the ith input layer neuron to the jth hidden layer neuron, b i is the bias of the input layer to the hidden layer; f1 is an excitation function, and a S-type function is selected, so that i=1, 2,..., n, j=1, 2,..., m, wherein n and m are positive integers;

[0019] The output formula of the output layer of the BP neural network is:

[0020]

[0021] In the formula, β k is the output of the kth output layer neuron, ω jk represents the weight of the hidden layer to the output layer, b k represents the bias of the hidden layer to the output layer, f2 is an excitation function, and a purelin activation function is selected, so that f2(x)=x, k=1, 2,..., l, and l is a positive integer;

[0022] The calculation error function is:

[0023]

[0024] In the formula, C k is the expected output of the neural network model;

[0025] The partial derivative of the error function to the output layer and the hidden layer is calculated:

[0026]

[0027] The partial derivative of the error function to the parameters between the hidden layer and the input layer is calculated:

[0028]

[0029] Then the parameters are corrected, and the parameters between the output layer and the hidden layer are:

[0030]

[0031] The parameters between the hidden layer and the input layer are:

[0032]

[0033] The global error is calculated, and it is judged whether the global error meets the requirements, when the global error meets the requirements, that is, the actual output meets the expected output.

[0034] As a further scheme of the application: the improved sand cat swarm optimization algorithm (ISCSO) is used to optimize the selection of the weight and threshold in the BP neural network model, so as to improve the performance of the network model;

[0035] The sand cat swarm optimization algorithm (SCSO) simulates the behavior of sand cats trying to survive in nature, which specifically includes:

[0036] Firstly, the initialization of the sand cat population is completed, and for the optimization problem of d dimensions, the population solution of the sand cat swarm is:

[0037]

[0038] In the formula: X is the population matrix of the sand cat; X i is the position of the i-th sand cat; x i,j is the position of the j-th dimension of the i-th sand cat; and N is the population number of the sand cat;

[0039] Secondly, prey exploration is carried out, and the prey search mechanism of the sand cat depends on the emission of low-frequency noise, and the sensitive range of the sand cat depends on its hearing ability in low-frequency detection and the low-frequency signals that it can perceive;

[0040] The sand cat can perceive low frequencies below 2 kHz, and in the mathematical model, this value is It will be linearly reduced from 2 to 0 as the iteration process proceeds, in order to gradually approach the prey without losing or skipping it; therefore, in order to search for the prey, assuming that the sand cat's sensitivity range is 2 kHz to 0, its behavior is represented by the following equation:

[0041]

[0042] where S M The hearing characteristics of the sand cat are simulated, assuming a value of 2 (of course, this value can be adjusted as appropriate for different problems to determine the speed of the agent's behavior); in addition, iter c is the current iteration number, is the maximum number of iterations;

[0043] During the search process, each sand cat individual updates its own position according to the best candidate position and the current position and its sensitivity range The formula for updating the position is as follows:

[0044]

[0045] During the search process for other possible best prey positions, the sand cat lays a new local optimal solution in the search area, and the obtained position is located between the current position and the prey position; therefore, the position update formula for the sand cat individual is as follows:

[0046]

[0047] At the same time, during the sand cat's attack on the prey (development) stage, it detects the prey according to its hearing; in order to mathematically model the attack stage of the SCSO, the best position (the best solution) and the current position are calculated, as shown below:

[0048]

[0049] The sand cat's sensitivity range is assumed to be a circle, and its movement direction is determined by a random angle (θ) on the circle; since the selected random angle is between 0 and 360, its value will be between -1 and 1;

[0050] In this way, each member of the population can move in different circumferential directions of the search space.

[0051] As a further scheme of the present application: the wheel selection mechanism of the SCSO is beneficial for selecting a random angle for each sand cat, which can approach the hunting position;

[0052] Random angles are also used to avoid local optima traps, which will have a positive impact on the hunting method of search agents;

[0053]

[0054] During the exploration and development phase, the main parameters controlling the transition between exploration and utilization are parameter and The adaptive values ​​ensure exploration and development; these parameters allow SCSO to seamlessly switch between the two phases; in this algorithm, The formula for obtaining it is shown below:

[0055]

[0056] Due to parameters depending on Therefore, its fluctuation range will also decrease;

[0057] when When the value is uniformly distributed, The values ​​are also uniform, therefore, depending on the problem, the number of operation opportunities between the two stages is roughly equal;

[0058] From the above formula, we can see that It is an interval One of the random values, where It decreases linearly from 2 to 0 during the iteration process; when When the random value is [-1, 1], the sand cat's next position can be anywhere between its current position and its hunting position; when When the value is less than or equal to 1, the SCSO algorithm forces the search agent to develop; otherwise, the search agent is forced to explore and seek prey. During the prey-seeking phase (exploration), the different radii of each cat avoid local optima traps. This feature is also one of the effective parameters for attacking prey (development). The position updates of each sand cat during the exploration and development phases are as follows:

[0059]

[0060] As a further aspect of this invention: for the improved Sand Cat Population Optimization Algorithm (ISCSO), a segmented mapping population initialization strategy is adopted, and different transformation formulas are set for the initial values ​​distributed at different locations. The specific mathematical expressions are as follows:

[0061]

[0062] Where, x t For the random result of the rand function during the initialization phase, x t+1The output result after using the segmented mapping population initialization strategy; d is a control parameter used to determine the segment range of the four segments, and in this invention d = 0.3.

[0063] As a further aspect of this invention: for the improved Sand Cat Population Optimization Algorithm (ISCSO), an opposition learning strategy is designed to increase population diversity. The main idea is to simultaneously explore both the positive and negative directions of the search space to obtain a better solution. In ISCSO, the position of the sand cat population at each step is optimized using the opposition learning strategy, as described below:

[0064]

[0065] Where x i,j (t) represents the coordinates of the j-th position of sand cat i in the t-th iteration. It is x i,j (t) is the opposite of learning the sand cat. lb j (t) and ub j (t) represents the dynamic boundary of the j-th sand cat population output, which can be calculated as:

[0066] lb j (t)=min(x i,j (t)), ub j (t)=max(x i,j (t)) (19)

[0067] If the initial boundary is no longer satisfied, then The following should be corrected:

[0068]

[0069] The beneficial effects of this invention are:

[0070] 1) Based on the actual working conditions of the capsule robot, design the LM algorithm to realize its position inverse solution under the spatial magnetic field, and design a BP neural network to optimize the selection of the initial parameters of LM and improve the performance of LM algorithm.

[0071] 2) Based on the segmented mapping population initialization strategy and the opposition learning strategy, the initialization and output stages of the basic sand cat swarm optimization algorithm are improved, which effectively enhances the local search ability and global search ability of the algorithm. The improved sand cat swarm optimization algorithm is used to perform optimal initialization of the initial weights and thresholds of the BP neural network, which effectively improves the model performance of the BP neural network.

[0072] 3) Through the improved technology of ISCSO-LMNN, the precise positioning of capsule robots in a spatial magnetic field can be effectively achieved;

[0073] 4) This algorithm has high applicability and can be effectively applied to the positioning work of relevant robots and mechanical equipment. Attached Figure Description

[0074] Figure 1 This is a technical roadmap for the present invention;

[0075] Figure 2 This is a flowchart of the sand cat swarm optimization algorithm in this invention;

[0076] Figure 3 This is a flowchart of the improved sand cat swarm optimization algorithm in this invention;

[0077] Figure 4 This is a convergence curve of the first test function in this embodiment of the invention under ISCSO and SCSO.

[0078] Figure 5 This is a convergence curve of the second test function in this embodiment of the invention under ISCSO and SCSO. Detailed Implementation

[0079] 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 embodiments of the present invention, and not all embodiments. 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.

[0080] Example 1

[0081] like Figure 1 As shown, a precise spatial positioning method for a magnetically controlled capsule robot based on ISCSO-LMNN includes the following steps:

[0082] Step 1: Acquire the spatial magnetic field information of the capsule robot using magnetic sensors;

[0083] Step 2: Select the number of hidden layers and nodes in the BP neural network.

[0084] Step 3: Obtain the optimal weights and thresholds for the initial network model using the improved sand cat swarm optimization algorithm.

[0085] Step 4: Calculate the actual output, accurately locate the initial value of the LM algorithm, and determine whether the expectation has been met. If not, backpropagate and update the weights and thresholds. If yes, output the optimal initial value of LMI, and use the LM algorithm to solve the spatial magnetic field information of the capsule robot to achieve accurate spatial positioning of the capsule robot.

[0086] This application uses the LM algorithm to solve the position of the capsule robot based on the spatial magnetic field information of the capsule robot.

[0087] The Levenberg-Marquardt (LM) algorithm is a method that primarily combines the Gauss-Newton method and the steepest descent method to calculate the initial guessed solution and iteratively searches for and selects the optimal solution. It uses the previous position calculation result to solve for the initial position value for the next calculation, thereby reducing the number of iterations and effectively increasing the probability of obtaining the global optimum.

[0088] Example 2

[0089] In addition to all the technical features included in Embodiment 1, this embodiment also includes:

[0090] The model building of a BP neural network includes:

[0091] The formula for choosing the number of neurons in the hidden layer of a neural network is as follows:

[0092]

[0093] Let n be the number of input layers in the neural network, m be the number of hidden layers, l be the number of output layers, and A be a constant between 1 and 10.

[0094] In a backpropagation (BP) neural network, data is transmitted from the input layer to the hidden layer, and then from the hidden layer to the output layer. During this transmission process at each layer, data undergoes activation function processing. Therefore, the output formula of the hidden layer of the neural network is:

[0095]

[0096] In the formula, θ j x represents the output of the j-th hidden layer neuron. i ω is the input value of the neural network input layer. ij Let b be the weight from the i-th input layer neuron to the j-th hidden layer neuron. i f1 is the bias from the input layer to the hidden layer; f1 is the activation function, chosen as a sigmoid function.

[0097] The output formula of the output layer of the neural network is:

[0098]

[0099] In the formula, β k The output of the kth output layer neuron, ω jk b represents the weights from the hidden layer to the output layer. kThis represents the bias from the hidden layer to the output layer. f2 is the activation function; if we choose the purelin activation function, then f2(x) = x.

[0100] Calculate the error function:

[0101]

[0102] In the formula, C k This represents the expected output of the neural network model of this invention.

[0103] Calculate the partial derivatives of the error function with respect to the output layer and hidden layers:

[0104]

[0105] Calculate the partial derivatives of the error function with respect to the parameters of the hidden layer and the input layer:

[0106]

[0107] After adjusting the parameters, the parameters between the output layer and the hidden layer are as follows:

[0108]

[0109] The parameters between the hidden layer and the input layer are:

[0110]

[0111] Calculate the global error and determine whether the global error meets the requirements. When the global error meets the requirements, the actual output meets the expected output.

[0112] Example 3

[0113] like Figure 2 As shown, in addition to all the technical features included in Embodiment 1, this embodiment also includes:

[0114] To avoid the problem that conventional BP neural network models are greatly affected by initial weights and thresholds, resulting in significant randomness in convergence speed, this application employs an improved Sand Cat Group Optimization (ISCSO) algorithm to optimize the selection of weights and thresholds in the BP neural network model, thereby improving network performance. Specifically, the Sand Cat Group Optimization (SCSO) algorithm simulates the behavior of sand cats attempting to survive in nature, including:

[0115] First, initialize the sand cat population. For the d-dimensional optimization problem, the population solution for the sand cat population is:

[0116]

[0117] In the formula: X is the population matrix of sand cats; X iLet x be the position of the i-th sand cat; i,j Let be the position of the i-th sand cat in the j-th dimension; N is the population size of sand cats;

[0118] Afterwards, the sand cat explores for prey. Its prey-hunting mechanism relies on low-frequency noise emission. The sand cat's sensitivity range depends on its auditory ability in low-frequency detection and the low-frequency signals it can perceive.

[0119] Sand cats can sense low frequencies below 2kHz. In mathematical models, based on the working principle of the algorithm, this value... The sensitivity range of the sand cat is linearly reduced from 2 to 0 as the iteration process progresses, gradually approaching the prey without losing or skipping it; therefore, in order to search for prey, assuming the sand cat's sensitivity range is from 2kHz to 0, its behavior is represented by the following formula:

[0120]

[0121] Among them, S M The auditory characteristics of a sand cat were simulated, with an assumption of 2 (which can be adjusted appropriately for different problems to determine the speed of agent behavior); in addition, iter c It is the current iteration number. It is the maximum number of iterations;

[0122] Each individual sand cat, during the search process, is based on the best candidate location. and current location and its sensitivity range The formula for updating one's position is as follows:

[0123]

[0124] During the search for other possible optimal prey locations, the sand cat lays the groundwork for new local optima within the search area, obtaining a position between its current position and the prey's location; therefore, the sand cat's position update formula is as follows:

[0125]

[0126] Meanwhile, during the Sand Cat's prey-attacking (development) phase, it detects prey based on its hearing; for mathematical modeling of the Sand Cat's prey-attacking phase, the optimal position... (Best solution) and current location The calculation is as follows:

[0127]

[0128] The sensitive range of the sand cat is assumed to be a circle, and its direction of movement is determined by a random angle (θ) on the circle; since the selected random angle is between 0 and 360, its value will be between -1 and 1; thus, each member of the population can move in different circumferential directions in the search space.

[0129] SCSO's roulette selection mechanism helps to choose a random angle for each sand cat, allowing the sand cat to approach the hunting position; the random angle is also used to avoid local optimum traps, which will have a positive impact on the hunting method of the search agent.

[0130]

[0131] During the exploration and development phase, the main parameters controlling the transition between exploration and utilization are parameter and The adaptive values ​​ensure exploration and development; these parameters allow SCSO to seamlessly switch between the two phases; in this algorithm, The formula for obtaining it is shown below:

[0132]

[0133] Due to parameters depending on Therefore, its fluctuation range will also decrease; when When the value is uniformly distributed, The values ​​are also uniform, therefore, depending on the problem, the number of operation opportunities between the two stages is roughly equal;

[0134] From the above formula, we can see that It is an interval One of the random values, where It decreases linearly from 2 to 0 during the iteration process; when When the random value is [-1, 1], the sand cat's next position can be anywhere between its current position and its hunting position; when When the value is less than or equal to 1, the SCSO algorithm forces the search agent to develop; otherwise, the search agent is forced to explore and seek prey. During the prey-seeking phase (exploration), the different radii of each cat avoid local optima traps. This feature is also one of the effective parameters for attacking prey (development). The position updates of each sand cat during the exploration and development phases are as follows:

[0135]

[0136] Example 4

[0137] like Figure 3 As shown, in addition to all the technical features included in Embodiment 1, this embodiment also includes:

[0138] For the improved Sand Cat Group Optimization (ISCSO) algorithm, a segmented mapping population initialization strategy is adopted, and different transformation formulas are set for the initial values ​​distributed at different locations. The specific mathematical expressions are as follows:

[0139]

[0140] Where, x t For the random result of the rand function during the initialization phase, x t+1 The output result after using the segmented mapping population initialization strategy; d is a control parameter used to determine the segment range of the four segments, and in this invention d = 0.3.

[0141] For the improved Sand Cat Group Optimization (ISCSO) algorithm, an opposition learning strategy is designed to increase population diversity. The main idea is to simultaneously explore both the positive and negative directions of the search space to obtain a better solution. In ISCSO, the position of the sand cat population at each step is optimized using the opposition learning strategy, as described below:

[0142]

[0143] Where x i,j (t) represents the coordinates of the j-th position of sand cat i in the t-th iteration. It is x i,j (t) is the opposite of learning the sand cat. lb j (t) and ub j (t) represents the dynamic boundary of the j-th sand cat population output, which can be calculated as:

[0144] lb j (t)=min(x i,j (t)), ub j (t)=max(x i,j (t))

[0145] If the initial boundary is no longer satisfied, then The following should be corrected:

[0146]

[0147] Through the two improvements mentioned above, the sand cat swarm optimization algorithm is improved, the BP neural network model is optimized, and the initial values ​​of the LM algorithm are optimized to achieve precise spatial positioning of the magnetically controlled capsule robot under a spatial magnetic field.

[0148] Example 5

[0149] like Figure 4 As shown, the commonly used test functions selected in this invention are as follows:

[0150]

[0151]

[0152] The performance of the ISCSO algorithm was verified using the aforementioned test function, whose theoretical optimal value is 0, and whose search region is defined as [-50, 50]. The ISCSO optimization algorithm was compared with the basic SCSO algorithm to test the performance of the improved sand cat swarm optimization algorithm ISCSO. To ensure fairness in the testing, the population size for each algorithm was set to 30, and the maximum number of iterations was set to 500.

[0153] like Figure 4 As shown, the ISCSO algorithm has a faster optimization speed than the basic SCSO algorithm and can find the optimal value of the function very well.

[0154] Example 6

[0155] The commonly used test functions selected in this invention are as follows:

[0156]

[0157] The performance of the ISCSO algorithm was verified using the aforementioned test function, whose theoretical optimal value is 0, and whose search region is defined as [-32, 32]. The ISCSO optimization algorithm was compared with the basic SCSO algorithm to test the performance of the improved sand cat swarm optimization algorithm ISCSO. To ensure fairness in the testing, the population size for each algorithm was set to 30, and the maximum number of iterations was set to 500.

[0158] like Figure 5 As shown, the ISCSO algorithm has a faster optimization speed than the basic SCSO algorithm and can find the optimal value of the function very well.

[0159] Working principle: An improved sand cat swarm optimization algorithm is used to optimize the selection of the initial weight threshold of the BP neural network. The optimized BP neural network model is then used to accurately locate the initial value of the LM algorithm, providing accurate initial values ​​for the LM algorithm to effectively improve the spatial positioning accuracy of the capsule robot.

[0160] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

[0161] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

Claims

1. An ISCSO-LMNN-based precise spatial positioning method for a magnetically controlled capsule robot, characterized in that: The method comprises the following steps: Step one, acquiring the spatial magnetic field information of the capsule robot according to the magnetic sensor; Step two, selecting the number of hidden layers and nodes of the BP neural network; Step three, obtaining the optimal initial network model weight and threshold value through the improved sand cat swarm optimization algorithm; Step four, calculating the actual output, accurately positioning the initial value of the LM algorithm, and judging whether the expectation is reached: if not, updating the weight and threshold value through back propagation; if yes, outputting the optimal initial value of the LMI and inversely solving the spatial magnetic field information of the capsule robot by using the LM algorithm to realize the accurate spatial positioning of the capsule robot; In step two, the model of the BP neural network comprises: The number of neurons in the hidden layer of the neural network is selected according to the following formula: In the formula, n is the number of input layers of the neural network, m is the number of hidden layers of the neural network, l is the number of output layers of the neural network, and A is a constant between 1 and 10; In the BP neural network, data is transmitted from the input layer to the hidden layer, and then from the hidden layer to the output layer, and in the transmission process of each layer, the data is processed by an activation function, wherein the output formula of the hidden layer of the BP neural network is: wherein θ j represents the output of the jth hidden layer neuron, x i is the input value of the input layer of the neural network, ω ij is the weight from the ith input layer neuron to the jth hidden layer neuron, b i is the bias from the input layer to the hidden layer; f1 is the activation function, and a sigmoid function is selected, then n represents the number of layers of the input layer of the neural network, i = 1, 2, …, n, j = 1, 2, …, m, wherein n and m are both positive integers. The output formula of the output layer of the BP neural network is: where β k the output of the kth output layer neuron, ω jk denotes the weight from the hidden layer to the output layer, b k denotes the bias from the hidden layer to the output layer, f2 is an activation function, and purelin is selected as the activation function, f2(x) = x, k = 1, 2, …, l, and l is a positive integer. The error function is calculated: In the formula, C k is the expected output of the neural network model, β k represents the output of the kth output layer neuron; The partial derivative of the error function with respect to the output layer and the hidden layer is calculated: where β k represents the output of the kth output layer neuron, C k is the desired output of the neural network model, ω jk represents the weight from the jth input layer neuron to the kth hidden layer neuron, θ j represents the output of the jth hidden layer neuron; The partial derivative of the error function with respect to the parameters between the hidden layer and the input layer is calculated: wherein β k represents the output of the kth output layer neuron, C k is the expected output of the neural network model, ω jk represents the weight of the jth input layer neuron to the kth hidden layer neuron, ω ij represents the weight of the ith input layer neuron to the jth hidden layer neuron, θ j represents the output of the jth hidden layer neuron, f1is an activation function, and a sigmoid function is selected, f2is an activation function, and a purelin activation function is selected, f2(x) = x, k = 1, 2, …, l, and l is a positive integer. Then the parameters between the output layer and the hidden layer are corrected: where ω jk (t) represents the weight values from the current hidden layer to the output layer, ω jk (t+1) represents the update of the weights from the hidden layer to the output layer; is the partial derivative of the error function with respect to the output layer and the hidden layer; The parameters between the hidden layer and the input layer are: where ω ij (t) represents the current input-to-hidden layer weight value, ω ij (t+1) represents the update to the input-to-hidden layer weight; is the partial derivative of the error function with respect to the parameter between the hidden and input layers; The global error is calculated, and it is judged whether the global error meets the requirements, that is, whether the actual output meets the expected output.

2. The method for precise spatial positioning of a magnetically controlled capsule robot according to claim 1, characterized in that: In step three, the improved sand cat swarm optimization algorithm is used to optimize the selection of the weight and threshold value in the BP neural network model; The sand cat swarm optimization algorithm simulates the behavior of sand cats trying to survive in nature, which specifically comprises: Firstly, the initialization of the sand cat population is completed, and for a d-dimensional optimization problem, the population solution of the sand cat swarm is: where: X is the population matrix of the sand cats; X i is the position of the ith sand cat; x i,j is the position of the ith sand cat in the jth dimension; and N is the population size of the sand cats. Secondly, prey exploration is performed, and the prey search mechanism of the sand cat depends on the emission of low-frequency noise, and the sensitive range of the sand cat depends on its hearing ability in low-frequency detection and its perception of low-frequency signals. Assuming that the sensitive range of the sand cat is 2 kHz to 0, its behavior can be represented by the following formula: where S M The hearing properties of a cat were simulated, assuming 2, iter c is the current iteration number, is the maximum iteration number; Each sand cat individual updates its own position during the search process according to the best candidate position and the current position and its range of sensitivity its formula is as follows: The position updating formula of the sand cat individual is as follows: wherein is the current best candidate position of the sand cat population, is the updated position of the sand cat population, rand(0,1) is a random number between 0 and 1, is the current position of the population; To mathematically model the attack phase of SCSO, the optimal position and the current position are calculated as follows: In the formula, is the updated position of the sand cat population, rand(0, 1) is a random number between 0 and 1, is the best position of the population, is the current position of the population, simulating the direction of the sand cat's circular motion; The sensitive range of the sand cat is assumed to be a circle, and the movement direction is determined by a random angle on the circle. Since the selected random angle is between 0 and 360, its value will be between -1 and 1. In this way, each member in the population can move in different circumferential directions of the search space.

3. The method for precise spatial positioning of a magnetically controlled capsule robot according to claim 2, characterized in that: The roulette wheel selection mechanism of the SCSO is beneficial to selecting a random angle for each sand cat to approach the hunting position. The random angle is also used to avoid local optimal traps and has a positive impact on the hunting method of the search agent. The parameters that control the transition between exploration and exploitation are parameters and adaptive values of ensure exploration and exploitation. These parameters allow the SCSO to seamlessly switch between the two stages. In this algorithm, The acquisition formula is as follows: Parameters Depending on The range of its fluctuations will therefore also be reduced; When the values are uniformly distributed, the values are also uniform; The position updating of each sand cat in the exploration and development stages is as follows: wherein is the updated position of the sand cat population, rand(0, 1) is a random number between 0 and 1, is the current position of the population, is the updated position of the sand cat population, is the best position of the population, θ is a random angle (-1 ≤ cosθ ≤ 1) simulating the direction of the sand cat's circular motion, exploitation indicates that the algorithm is in the exploration phase, exploration indicates that the algorithm is in the development phase, 4. The method of claim 2, wherein: For the improved sand cat swarm optimization algorithm, a segmented mapping population initialization strategy is adopted, and different transformation formulas are set for the initial values distributed in different positions, and the specific mathematical expression is as follows: where x t is the random result of the initialization phase of the rand function, x t+1 is the output result after using the segmented mapping population initialization strategy; d1 is a control parameter used to determine the segmented range of the four segments, d1 = 0.

3.

5. The method for precise spatial positioning of a magnetically controlled capsule robot according to claim 2, characterized in that: In SCSO, the position of the cat population is optimized by using the opposite learning strategy each time, which is described as follows: where x i,j (t) is the jth position coordinate of the lynx i at the tth iteration, is the opposite of x i,j (t), lb j (t) and ub j (t) are the dynamic boundaries of the jth lynx population output result, calculated as: lb j (t) = min(x i,j (t)),ub j (t) = max(x i,j (t) (19) If the initial boundary is no longer satisfied, then Should be amended as follows: wherein is x i,j (t) is the opposite learning lynx, lb j (t) and ub j (t) is the dynamic boundary of the jth output result of the lynx population, (ub j (t)-lb j (t)) represents the dynamic interval length, and rand(ub j (t)-lb j (t)) represents a random number selected between 0 and the interval length, represents that the opposite learning lynx uses the correction formula under the condition of exceeding the upper and lower boundaries.