Ordinary differential equation (ODE) models are quite popular for modelling complex dynamic processes in many scientific fields, and the parameters in these models are usually unknown, and we need to estimate them using statistical methods. When some observations are contaminated, regular estimation methods, such as nonlinear least-square estimation, will bring large bias. In this paper, robust estimations of both constant and time-varying parameters in ODE models using M-estimators are proposed, and their asymptotic properties are obtained under some mild conditions. We focus on Huber M-estimator, and also provide a method to adjust the Huber parameter automatically to the observations. The proposed method is compared to existing methods in numerical simulations and CD8 + T cell data analysis. It is demonstrated that our method gain substantial efficiency as well as robust properties.