Gyro is not going straight

I’m having problem with driving straight with gyro, the drive tilts whenever I enable. The gyro we’re using is ADXRS450 Gyro. I’m using the guide and code as this:
https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599713-gyros-measuring-rotation-and-controlling-robot-driving-direction

By tilts do you mean continues veering to a direction? Is the sensor reading correctly? One thing I notice with some gyros is sometimes the angle reading gradually drifts to one direction, meaning sometimes when the robot is sitting and not moving, I’ll watch the gyro angle increase by a degree every couple seconds. I don’t know the root cause, but check and see if that’s your issue.

Yes exactly, the degrees moves every sec or so and the driving is continues veering. Do you think it’s something to do with the PID like kP = .03 is not the proper value.

Gyros pretty much always drift due to integration of noise in your measurement.

Here’s some more info: https://stackoverflow.com/questions/14210206/gyroscope-drift-on-mobile-phones

The main answer has some pretty good resources to look through.

The drift is not caused by your PID values