A mower comprising: a machine body ; a traveling device provided on the machine body; a mowing device provided on the machine body; a posture detection device device configured to detect at least a pitch angle of the machine body as a posture of the machine body; and a controller configured to control the traveling device so as to cause the machine body to travel along a reference line, wherein the controller includes a first posture changing unit configured to control the traveling device to change a direction of the machine body at least before the machine body is caused to travel along the reference line, characterized in that the mower further comprises: a contour line calculation unit configured to calculate, when the machine body is positioned on a slope, a contour line on the slope based on a plurality of pitch angles each of which is detected by the posture detection device at each time when the direction of the machine body is changed by the first posture changing unit, a line setting unit configured to set the contour line calculated by the contour line calculation unit as the reference line, and a second posture changing unit configured to change the direction of the machine body so as to cause the machine body to travel along the reference line set by the line setting unit. a machine body ; a traveling device provided on the machine body; a mowing device provided on the machine body; a posture detection device device configured to detect at least a pitch angle of the machine body as a posture of the machine body; and a controller configured to control the traveling device so as to cause the machine body to travel along a reference line, wherein the controller includes a first posture changing unit configured to control the traveling device to change a direction of the machine body at least before the machine body is caused to travel along the reference line, characterized in that the mower further comprises: a contour line calculation unit configured to calculate, when the machine body is positioned on a slope, a contour line on the slope based on a plurality of pitch angles each of which is detected by the posture detection device at each time when the direction of the machine body is changed by the first posture changing unit, a line setting unit configured to set the contour line calculated by the contour line calculation unit as the reference line, and a second posture changing unit configured to change the direction of the machine body so as to cause the machine body to travel along the reference line set by the line setting unit. a contour line calculation unit configured to calculate, when the machine body is positioned on a slope, a contour line on the slope based on a plurality of pitch angles each of which is detected by the posture detection device at each time when the direction of the machine body is changed by the first posture changing unit, a line setting unit configured to set the contour line calculated by the contour line calculation unit as the reference line, and a second posture changing unit configured to change the direction of the machine body so as to cause the machine body to travel along the reference line set by the line setting unit. <EOS>