Calibrating a distance sensor on an agricultural vehicle provided for measuring the distance between the sensor and a set of points on a ground surface in front of the agricultural vehicle, includes: performing a reference measurement when the agricultural vehicle is standing on a paved and substantially flat ground surface processing the results of the reference measurement to reference data for use as reference during further measurements storing the reference data in a memory.