Q:

Regulating voltage to compensate for random motor load

I'm currently using an L298N with PWM to control the speed of 2 scalextric cars. I need the cars to move round at a consistent speed, while I understand no 2 motors are the same and simply providing the same voltage won't guarantee that, and as such I have slight variations in the PWM values for each lane depending on the car and my own "by eye" calibration.
However some days one of the cars will have a high amount of internal resistance in that it crawls along while being provided with the same voltage as the other car.
Here is a video demonstrating this:
https://www.youtube.com/watch?v=WpusScFLhj4
As you can see about 6V is going through both lanes.
Could I add a linear voltage regulator between the L298N and the lane to make sure it maintains the desired voltage no matter the random load the car's motor seem to be under at that point in time?

A:

Brushed permanent-magnet motor speed can be kept fairly constant by driving it with negative resistance equal to resistance of its armature winding. This assumes that internal motor brush resistance is negligible. In your case, the track/brush contact resistance is not negligible, which means that remotely sensing track current can't be done - you'd have to monitor motor current right at the motor of each car. Negative resistance drive requires motor current to be sampled, and used to adjust drive voltage. When your motor draws more current, voltage going in is increased (this is equivalent to negative resistance). So you need extra voltage available.
For example, a motor may have resistance of 10 ohms. With 6v applied, and with no mechanical load, its current is near zero. This suggests that a stalled motor would pull 0.6 A from the 6v supply.
With negative resistance drive, it becomes much harder to stall the motor. A -10 ohm driver would apply 12v to a motor drawing 0.6 A.
This method of speed control is called feedforward control. To the extent that the motor's internal resistance is matched by the controller's negative resistance, motor shaft speed remains constant. In practice, the controller has limits to how much voltage it can apply, so its negative resistance fails under extreme load. I've burned my fingers trying to stall a toy motor shaft like yours when driven this way.
In your case, the car's pick-up brushes that contact the track have significant variable resistance that makes remote sensing a difficult problem. If this variable resistance can be made much smaller than motor resistance, then feedforward control of track voltage is a possible solution.

