What is the role of the diode D1 in this ramp generator circuit?
I'm presuming that the input to the circuit is a rectangular wave and that output waveform shapes are approximately sawtooth in nature.

A sawtooth signal looks something like this: -



And you can't make a reasonable sawtooth signal from just a resistor and capacitor because charge rate and discharge rate of the capacitor are equal and you get a "near" triangle wave like this: -



Notice that charge rate and discharge rate are identical. So, to get a sawtooth wave you need to discharge the capacitor much faster than you charge it hence, when the input wave goes low, the capacitor discharges much more rapidly via the diode.