Xmotion V3 – Motor Outputs Not Balanced, Causing Robot to Drift

Looking at the XMotionV3 library, I can see that as well as the Forward() and Backward() functions there is another function called ArcTurn().

The ArcTurn() function is similar to the Forward() function, but whereas Forward() accepts a single parameter for the speed, ArcTurn() accepts separate parameters for the left and right motor speeds.

Forward()
void XMotionClass::Forward(byte speed, int Time){
   
   speed = constrain(speed,0,100);
   speed = map(speed,0,100,0,255);
   digitalWrite(RM_DIR,HIGH);
   digitalWrite(LM_DIR,HIGH);
   analogWrite(RM_PWM, speed);
   analogWrite(LM_PWM, speed);
   delay(Time);
   
}

ArcTurn()
void XMotionClass::ArcTurn(byte LeftSpeed, byte RightSpeed, int Time){
	
	LeftSpeed = constrain(LeftSpeed,0,100);
	LeftSpeed = map(LeftSpeed,0,100,0,255);
	RightSpeed = constrain(RightSpeed,0,100);
	RightSpeed = map(RightSpeed,0,100,0,255);
	digitalWrite(RM_DIR,HIGH);
    digitalWrite(LM_DIR,HIGH);
    analogWrite(RM_PWM, RightSpeed);
    analogWrite(LM_PWM, LeftSpeed);
    delay(Time);
	
}

Try using the ArcTurn() function, putting in slightly different values for RightSpeed and LeftSpeed.
Put in a lower value for the motor that is currently running faster.

By trial and error, you should be able to get the robot to run in a straight line using that function.

You might be able to come up with a rule such as:
RightSpeed = 0.85 * LeftSpeed;
that keeps the robot going in a straight line.