How are $V_r$ and $V_2$ determined?
The limits of the $V_{r}$ and $V_{2}$ are determined by the regulations in place. The rotation speed is the speed at which the pilot can the aircraft rotation for take off even when one engine is inoperative.

Consequently, this speed should be more than the minimum control speed with one engine inoperative, $V_{MC}$. The current regulations stipulate that the $V_{r}$ should be at least 1.05 times $V_{MC}$.

The safe climb out speed or takeoff climb speed is the speed which the aircraft should have reached at a given altitude. As per FAA regulations, this height is 35 feet above the takeoff surface.

The climb out speed $V_{2}$ should be at least 20% greater than the stall speed $V_{s}$ and 10% greater than $V_{MC}$.

The FAA regulations prohibit lifting the nose landing gear before reaching $V_{r}$ and retracting it till the aircraft is completely airborne.

All aircrafts undergo these tests during their certification process and these data is used by the pilots. Another thing is that both $V_{r}$ and $V_{2}$ are given in terms of calibrated air speed.