There have been a few requests for field centric X-drive code in the past couple of weeks. I’ve linked to an old RobotC example, but I revised that code today for my demo drivetrain and pushed out to github. My drive uses 8 motors, but it should be easy to revise the code for four. Obviously, it needs a V5 Inertial sensor to run.
in the first line. you cannot update ctrl_fwd as it’s used in the second line, so temp holds the value that will be used for ctrl_fwd after the next calculation is done.
It is best to keep the inertial sensor’s tracking center as close to the center of the robot as possible (I was told that the further out the more likely you are to max out the g-force limit of the sensor)
Mecanum drive and x drive are code wise the same, try modifying the code until it works or find other sources to compare code to