An approach to the dynamic modeling and sliding mode control of the constrained robot is proposed in this article. On the basis of the Udwadia-Kalaba approach, the explicit equation of the constrained robot system is obtained first. This equation is applicable to systems with either holonomic or non-holonomic constraints, as well as with either ideal or non-ideal constraint forces. Second, fully considering the uncertainty of the non-ideal force, that is, the dynamic friction in the constrained robot system, the sliding mode control algorithm is put forward to trajectory tracking of the endeffector on a vertical constrained surface to obtain actual values of the unknown constraint force. Moreover, model order reduction method is innovatively used in the Udwadia-Kalaba approach and sliding mode controller to reduce variables and simplify the complexity of the calculation. Based on the demonstration of this novel method, a detailed robot system example is finally presented.