Method for controlling a railway vehicle comprising a motor controller for an electric machine acting on at least one wheel of the railway vehicle, and a torque controller, the method comprising: - receiving a torque request (Tref) from a central controller, the torque request is commanded by a driver; - determining the actual speed (v) of the railway vehicle; - determining the actual wheel rotational speed (ω) of the railway vehicle; - receiving an estimated torque (T est) from the motor controller; - estimating the maximal adherence coefficient (μ est) based on the wheel rotational speed (ω), the actual speed (v) of the railway vehicle, and the estimated torque (T est) received from the motor controller, wherein a three parameters model is used in order to estimate the maximum adherence using the following equation: μ σ θ = σ a + bσ + cσ 2 = σ θ ′ Φ σ, where Φ( σ) = [1, σ, σ 2]' is the regressor vector and θ:= [ θ 1 θ 2 θ 3]' is the parameters vector, μ is the adherence, wherein θ 1 =a, θ 2 =b and θ 3 =c, and σ the slip, wherein a linear filter is used to estimate the maximal adherence coefficient (μ est) and to calculate a torque T comp based on this maximal adherence coefficient, wherein the linear filter is a Kalman filter; - determining an optimal slip based on the maximal adherence coefficient (μ est) using a least square filter for curve fitting, and using the speed of the vehicle and the optimal slip to calculate the optimal wheel rotational speed (ω 0); - calculating an error signal (ωe) based on the difference between the optimal wheel rotational speed (w 0) and the actual wheel rotational speed (w); - calculating a regulated Torque (T reg) based on the calculated error signal using a closed loop control; - determining a reference torque (T contr) by adding the torque T comp provided by the linear filter, the output torque T reg provided by the closed loop control 28, to calculate the reference torque (T contr); and - selecting, by a first selecting device of the torque control, whether the torque request (Tref) is directly provided as an output torque (T contr) to the motor controller or not, wherein when a logical value of a signal (TSWITCH) is 0, the torque request (Tref) commanded by the driver is given to the motor controller as output torque (Tcontr), when the logical value of the signal (TSWITCH) is 1, the torque request (Tref) is no longer given as output torque (Tcontr), but the reference torque (Tcontr) calculated to exploit the maximum adherence force available is provided as output torque (Tcontr) to the motor controller. - receiving a torque request (Tref) from a central controller, the torque request is commanded by a driver; - determining the actual speed (v) of the railway vehicle; - determining the actual wheel rotational speed (ω) of the railway vehicle; - receiving an estimated torque (T est) from the motor controller; - estimating the maximal adherence coefficient (μ est) based on the wheel rotational speed (ω), the actual speed (v) of the railway vehicle, and the estimated torque (T est) received from the motor controller, wherein a three parameters model is used in order to estimate the maximum adherence using the following equation: μ σ θ = σ a + bσ + cσ 2 = σ θ ′ Φ σ, where Φ( σ) = [1, σ, σ 2]' is the regressor vector and θ:= [ θ 1 θ 2 θ 3]' is the parameters vector, μ is the adherence, wherein θ 1 =a, θ 2 =b and θ 3 =c, and σ the slip, wherein a linear filter is used to estimate the maximal adherence coefficient (μ est) and to calculate a torque T comp based on this maximal adherence coefficient, wherein the linear filter is a Kalman filter; - determining an optimal slip based on the maximal adherence coefficient (μ est) using a least square filter for curve fitting, and using the speed of the vehicle and the optimal slip to calculate the optimal wheel rotational speed (ω 0); - calculating an error signal (ωe) based on the difference between the optimal wheel rotational speed (w 0) and the actual wheel rotational speed (w); - calculating a regulated Torque (T reg) based on the calculated error signal using a closed loop control; - determining a reference torque (T contr) by adding the torque T comp provided by the linear filter, the output torque T reg provided by the closed loop control 28, to calculate the reference torque (T contr); and - selecting, by a first selecting device of the torque control, whether the torque request (Tref) is directly provided as an output torque (T contr) to the motor controller or not, wherein when a logical value of a signal (TSWITCH) is 0, the torque request (Tref) commanded by the driver is given to the motor controller as output torque (Tcontr), when the logical value of the signal (TSWITCH) is 1, the torque request (Tref) is no longer given as output torque (Tcontr), but the reference torque (Tcontr) calculated to exploit the maximum adherence force available is provided as output torque (Tcontr) to the motor controller.