This project utilizes the Quantum-behaved Particle Swarm Optimization (QPSO) algorithm in MATLAB to compute an optimal 3D path for an Autonomous Underwater Vehicle (AUV). This path enables the AUV to navigate from a starting point to a destination while avoiding obstacles. The entire environment, including the positions of the AUV, obstacles, and the final destination, is configured and transmitted from the Unreal Engine.
- 3D Path Planning: Searches for and optimizes a trajectory in a three-dimensional space.
- QPSO Algorithm: Applies the QPSO algorithm to find the shortest and safest path.
- Unreal Engine: Communicates bidirectionally with Unreal Engine via the UDP protocol to receive environment data and send back the calculated path.
- Collision Avoidance: The calculated path is designed to avoid obstacles, which are defined by their Axis-Aligned Bounding Boxes (AABBs).
- Visualization: Displays the 3D environment, obstacles, and the optimized path directly present combine MATLAB with Unreal Engine Software.
The system operates in a closed loop between Unreal Engine and MATLAB:
-
Receive Data From Unreal Engine:
- The user sets up a scenerio in Matlab, defining the start position (AUV), destination (Flag), and obstacles (Rocks).
- Unreal receiver and feedback to Matlab which information operate AUV.
- The
unreal_receive_only.mscript in MATLAB listens on UDP port9010, receives this data, and saves it to a file namedscene_note.txt.
-
Calculate Path in MATLAB:
- The main script,
QOA.m, is executed. It can either read the environment data fromscene_note.txtor use pre-defined values within the script. - The QPSO algorithm is run to find a sequence of waypoints that form the optimal path.
- The resulting waypoints are written to the
blue_points.txtfile.
- The main script,
-
Send Path to Unreal Engine:
- The
send_bluepoints_to_unreal.mscript reads theblue_points.txtfile. - It sends each waypoint coordinate to Unreal Engine via UDP port
3008. - Unreal receives these points and directs the AUV to follow the calculated path.
- The
QOA.m: Main execution file.- Initializes the 3D environment, including the start point, goal, and obstacles.
- Implements the QPSO algorithm to optimize the path.
- Visuale final patizes the results and saves thh to
blue_points.txt.
send_bluepoints_to_unreal.m: Sends the path to Unreal.- Reads the
blue_points.txtfile. - Transmits the waypoint coordinates to Unreal via UDP.
- Reads the
unreal_receive_only.m: Receives scene information from Unreal.- Receive data from UDP port to achieve coordinates of the AUV, flag (goal), and rocks.
- PSaves into
scene_note.txt.
readObj.m: Utility function.- Reads and parses 3D model files in the
.objformat to visualize obstacles.
- Reads and parses 3D model files in the
- MATLAB: Version R201a or newer.
- Toolbox: Instrument Control Toolbox™ (required for the
udpportfunction). - Unreal Engine: Version 4 or 5, with a project configured for UDP communication.
-
Start the Unreal Engine Scene: Open your project in Unreal Engine and run the simulation. Ensure your setup is configured to send scene data (AUV, flag, rocks positions) via UDP to port
9010. -
Receive enviroment Data (in MATLAB):
- Run the
unreal_receive_only.mscript. - The script will wait for incoming data. Upon successful reception, it will create the
scene_note.txtfile.
- Run the
-
Calculate the Optimal Path (in MATLAB):
- Open and run the
QOA.mscript. - Note: Ensure
QOA.mis configured to read fromscene_note.txtif you are using live data from Unreal. - The optimization process will begin. A plot window will appear, visualizing the environment and the resulting path.
- Once completed, a file named
blue_points.txtcontaining the path's waypoints will be generated.
- Open and run the
-
Send the Path back to Unreal (in MATLAB):
- Run the
send_bluepoints_to_unreal.mscript. - This script will send the waypoints from
blue_points.txtto Unreal via port3008. - Observe the AUV in Unreal Engine as it moves along the calculated path.
- Run the
You can easily customize the algorithm's parameters in QOA.m:
start,goal: The start and end points of the path.rocks: The coordinates and sizes of the obstacles.num_waypoints: The number of intermediate points that make up the path.num_particles,max_iter: QPSO algorithm parameters (number of particles and maximum iterations).unrealIP,unrealPort: The IP address and port for the receiving Unreal Engine application (customizable insend_bluepoints_to_unreal.m).