having problems with embeding imu sensor code in my code

hello everyone, i am new in this forum and to arduino, so please excuse my terminology as i am not sure how to describe all this stuff properly.
at school project we need to make a boat that do some tasks autonumosly. the idea is that the boat will get redings from a 9 dof imu and from a ultrasonic sensor.
basically i found the code that run each of those sensors properly and i mange to get good results.
i tried to turn those sketches into seperate functions() that i can call from the main code.
the code compiles fine but the readings from the imu are way off.
i am not sure i understend what can cause this since i really havent change that much exept removing some serial.begins/print and moving all the defines to the main code.
thanks in advance and help will be much apricieted!

Did you forget something?

Post some code, we’re not mind readers here.
Use the code tag button, </> on the menu.
If the post is over 9000 character, scroll down and use the Attachments and other options button to attach your file.

sorry for the mess, here are the files.
i only wrote “boat, sail, approach,turn” all the rest i found and tried to integrate/embed (not sure if those are the terms) in my code.

approach.ino (1.76 KB)

boat.ino (4.8 KB)

Compass.ino (1.98 KB)

DCM.ino (6.05 KB)

I2C.ino (2.51 KB)

imu.ino (3.31 KB)

matrix.ino (1.5 KB)

sail.ino (1021 Bytes)

turn.ino (1.08 KB)

ultra_sonic.ino (1.75 KB)

Vector.ino (1.84 KB)

the code is a bit messy because i had to copy all the global veriables to the main code and there are a lot of them. also the imu code that i found is pretty complicated so it is hard to keep track. my main goal is to get only the yaw angle from this massive code because it is doing it very precisely.

since i have very basic knoladge in programing and i am ney to arduino, i can use some guidence on what can cause a code to run fine when it's running isolated from the main function and turn very unstable once it's inserted into it. the simptoms are rapidly randomly changing values.

maybe my approach to this is wrong in the way that i took a ready code and tried to just copy it into my own. is there any other way to do it?

managed to solve the problem. it had to do with the imu code should run at 50hz and by putting it in my code the frequancy changed.

thank you anyway!