reading FMS data not working

At our latest regional we learned that we were actually not able to read the game data. However all of our code works as planned outside of the match when we input the game data into driver’s station ourselves. When I simplified our code to read game data and go straight no matter what side of the switch is ours, our robot took a sharp turn to the side and forward(not a small drift but a clear turn). However when I took out the part where it reads the FMS game data and just went straight, our bot was able to cross the auto line. Ideally I would like to make our robot put a cube in our side of the switch so I need to be able to read the game data. The following is our code to go forward after reading game data (which resulted in our robot crashing into the portal on our side of the field) :

public$@#void$@#autonomousInit() {
timer.reset();
timer.start();
}

public$@#void$@#autonomousPeriodic() {
String$@#gameData;
gameData$@#= DriverStation.getInstance().getGameSpecificMessage();

if(gameData.length() > 0) {
	if(gameData.charAt(0) ==$@#'L') {
		if(timer.get()<2.5) {
			drivetrain.arcadeDrive(0.7,0);
		}
		else {
		        drivetrain.arcadeDrive(0,0);
		}
	}
	else {
		if(timer.get()<2.5) {
			drivetrain.arcadeDrive(0.7 , 0);
		}
		else {
		drivetrain.arcadeDrive(0.7, 0);
		}
	}
}

}

(end code)

Any help would be appreciated! Thanks!

sorry about that formatting, here is our actual code:

public void autonomousInit() {
timer.reset();
timer.start();
}

public void autonomousPeriodic() {
String gameData;
gameData = DriverStation.getInstance().getGameSpecificMessage ();

if(gameData.length() > 0) {
if(gameData.charAt(0) == ‘L’) {
if(timer.get()<2.5) {
drivetrain.arcadeDrive(0.7,0);
}
else {
drivetrain.arcadeDrive(0,0);
}
}
else {
if(timer.get()<2.5) {
drivetrain.arcadeDrive(0.7 , 0);
}
else {
drivetrain.arcadeDrive(0, 0);
}
}
}
}

If the robot is turning unexpectedly, I’d guess that the ‘drivetrain’ object isn’t doing quite what you think. Dig into that, and compare to how ‘arcadeDrive’ is used during teleop.

Also, make sure you check for null when getting the gameData. Your line that checks for the gameData length should look like this:

 if (gameData!=null && gameData.length() > 0) { 

If you could push your code to a Github repository, so I an look at the whole code, that would be appreciated. It is quite a weird occurrence.

I don’t think that that is the issue since when I replaced the autonomous code with the following, it ran as it was supposed to.

 
if(timer.get()<2.5) { 
     drivetrain.arcadeDrive(0.7,0); 
}
else {
     drivetrain.arcadeDrive(0,0);
}