## 4 An Indoor Positioning Algorithm Combining IMU and LBP-FFT-CNNs
### Indoor Positioning Algorithm Based on IMU and LBP-FFT-CNNs  
Indoor positioning algorithms need to consider both the IMU module and the vision-based computing module. Algorithm 1 illustrates an indoor positioning algorithm based on an IMU and LBP-FFT-CNNs, designed to determine the position of a target object by integrating IMU and visual data. The input includes initial position, velocity, acceleration, orientation, and time step (\(\Delta t\)), while the output is the final position of the target object.  
The algorithm features key sub-functions: \(get\_IMU\_data()\) retrieves acceleration and angular velocity data from the accelerometer and gyroscope, \(update\_orientation()\) updates the object's orientation based on angular velocity and time step, \(update\_velocity()\) calculates updated velocity using acceleration and time step, and \(update\_position()\) computes the new position based on updated velocity and time step.  
In the main loop, IMU data are acquired, followed by sequential updates to orientation, velocity, and position. After updating orientation, acceleration is transformed into a global coordinate system for improved accuracy. The final position is determined through conditional checks. If obstacles are detected on the left or right, the algorithm combines IMU-derived x-coordinates and visual y-coordinates. Similarly, for obstacles above or below, the algorithm uses visual x-coordinates and IMU-derived y-coordinates. If surrounded by obstacles, both coordinates are derived from IMU data; otherwise, both are based on visual data.  
In summary, the algorithm integrates IMU and visual data to accurately determine the object's position, especially under obstacle interference, ensuring reliable positioning. Figure 7 shows the flow chart of the positioning algorithm combining IMU and LBP-FFT-CNNs.  
Figure 6: A 2D diagram of the experimental environment.  
```
Input: position, velocity, acceleration, orientation and time_step = \(\Delta\)t Output: Target object position
```
1  Define function get_IMU_data():
2  acceleration = read_accelerometer()
3  angular_velocity = read_gyroscope()
4  return acceleration, angular_velocity
5  Define function update_orientation(orientation, angular_velocity, \(\Delta\)t):
6  orientation = orientation + angular_velocity * \(\Delta\)t
7  return orientation
8  Define function update_velocity(velocity, acceleration, \(\Delta\)t):
9  velocity = velocity + acceleration * \(\Delta\)t
10  return velocity
11  Define function update_position(position, velocity, \(\Delta\)t):
12  position = position + velocity * \(\Delta\)t
13  return position
14  while True:
15  acceleration, angular_velocity = get_IMU_data()
16  orientation = update_orientation(orientation, angular_velocity, time_step)
17  global_acceleration = convert_to_global_frame(acceleration, orientation)
18  velocity = update_velocity(velocity, global_acceleration, time_step)
19  IMU_position = update_position(position, velocity, time_step)
20  if obstacles on the left or right sides of object are TRUE:
21  vision_position_y = (C_y - B_y)/2 + B_y
22  return (IMU_position_x, vision_position_y)
23  Else if obstacles above or below the object are TRUE:
24  vision_position_x = (C_x - B_x)/2 + B_x
25  return (vision_position_x, IMU_position_y)
26  Else if obstacles surround the object are TRUE:
27  return (IMU_position_x, IMU_position_y)
28  Else if no obstacles around the object are TRUE:
29  return (vision_position_x, vision_position_y) ```  
**Algorithm 1** Inertia-based Indoor Positioning Algorithm based on LBP-FFT-CNNs  
Figure 7: Flowchart of the positioning algorithm combining IMU and LBP-FFT-CNNs.