Calculating road Gradient
The Gradient of a road, or Slope angle, can be calculated simply by taking the ratio of the horizontal speed against the vertical velocity. Note that the output may be quite noisy, so it is best to use a smoothing filter to display this result.
Here are some Maths Channel examples to create a percentage gradient:
VBOX Test Suite
VBOX Tools