Hi Sana, you are looking for a Magnetometer (Compass) Board. Adafruit and Sparkfun offer them.

The accelerometer is using gravity to determine the angles, but you need to use a different force to calculate yaw.

The Magnetometer senses magnetic forces, and hopefully it will sense magnetic north and not anything else.

Especially the magnetic fields of the motors. You could set a direction and have the robot go to that heading.

If you are looking just to find out what the angle of deviation is, just send the robot out a known distance along a straight line.

mark a starting spot, send it off, mark the finish spot. Then measure how far it's off from the line.

Using geometry you can calculate the angle.

inverse tangent (tan-1) multiplied by (length the robot traveled along straight line / distance robot veered ).

Both measurements must be the same units, ex. inches, feet, etc. (6 inches is .5 feet)

That will give you the angle.....