How do I get my drone to fly though a gap

I’m new to drones so forgive me if the question is too simple. I’ve been working on this project for far too long and I’m sooo exhausted. The biggest hurdles involve understanding the inner workings of the drone.

I’m great at programming and good with AI but I’m struggling to utilize both skills into controlling my drone.

Goal: fly drone through square gap (could be window or balcony) when gap is detected. The drone will need to be tilted in some instances to fit into the window

problem:
don’t event know where to start. Ok maybe I do, but only just a little, and I’m tired of hitting so many dead ends.
__Should I use offboard or manual mode ?
__which commands will I send to the drone to get it to navigate inside the window/gap—yaw, angle, pitch,
__will the commands be sent through mavLink?
__should I modify the internal kalman filter or just a few variables/mavLink messages?
__do I need to the the gap navigation in a simulated environment first?

Please give me some leads so I know not to read unnecessary information. It’s been over a month and I’m tired.

ex image::

ex paper:: (Flying through a narrow gap using neural network: an end-to-end planning and control approach | Jiarong Lin)

ex video::

ex video::