Theta is what, exactly?
This is a four wheel robot where theta is the angle of the steering input?
Two wheel differential drive where theta is calculated from the distance between the wheels and the difference in wheel speed?
The equation you have is fine if X and Y are positions on a grid and theta is the angle at which the robot is traveling relative to the Y axis of your coordinate system - but a little more math will be involved if you want to calculate the trajectory from on board measurements and angles based on the robot coordinate system. You will need to calculate the robot heading based on accumulated changes in direction (rate of turn times time) then use the heading as your theta in your original calculation.
The gyro could be used to estimate your rate of change in direction. It may be more accurate than measuring a steering input angle or wheel speed differential due to wheel slip, bumps in the surface, etc. The problem with the gyro is that "zero" is typically not exactly 0 - so as you integrate the rate of turning small errors tend to add up. A magnetic sensor (compass) could be used to adjust the heading calculation. But, realize that the measurement of your steer encoder, the gyro, and a compass are going to give you three different results - which is right?