# Equations of motion with mass attached to end effector and external force

I have to find the equations of motion for the given manipulator:

The links of the manipulator are considered weightless and the equations of motion have to be derived by using the Lagrange equations. The coordinated of the point mass are:

$$x_m = q_1+l_1+l_2c_2$$ $$y_m = l_2s_2$$ And the Lagrangian of the system is:

$$L = T - V = \frac{1}{2}\cdot \Big[\dot{q_1}^2-2l_2s_2\dot{q_1}\dot{q_2}+l_2^2\dot{q_2}^2\Big]-mgl_2s_2$$

Now, in order to find the equations of motion, I applied the Lagrange's Method:

$$\frac{d}{dt}\Big(\frac{\partial L}{\partial \dot{q_i}}\Big) - \frac{\partial L}{\partial q_i} = \tau_i$$

And the final equations of motion written in matrix form are:

$$\begin{bmatrix} m & -ml_2s_2 \\ -ml_2s_2 & ml_2^2 \end{bmatrix}\cdot \begin{bmatrix} \ddot{q_1} \\ \ddot{q_2} \end{bmatrix} + \begin{bmatrix} 0 & -ml_2c_2\dot{q_2} \\ 0 & 0 \end{bmatrix}\cdot \begin{bmatrix} \dot{q_1} \\ \dot{q_2} \end{bmatrix} + \begin{bmatrix} 0 \\ mgl_2c_2 \end{bmatrix}=\begin{bmatrix} \tau_1 \\ \tau_2 \end{bmatrix}$$

The above equations of motion have been derived by ignoring the force applied $$F_x$$. Now, my issue is how to include this force in terms of the Lagrange Method. Should I modify the method like the one below:

$$\frac{d}{dt}\Big(\frac{\partial L}{\partial \dot{q_i}}\Big) - \frac{\partial L}{\partial q_i} = \tau_i + F_x$$

But in which of the two equations of motion should the force be included ? The force $$F_x$$ is an external constant force applied in the direction of $$x_0$$.

In Lagrangian mechanics, you're required to deal with the generalized forces and the concept of virtual work $$\delta W$$.
In our case we have: $$\delta W_{F_x} = F_x \cdot \delta q_1 + F_x \left( -l_2s_2\right) \cdot \delta q_2,$$
where the coefficients of the terms $$\delta q_i$$ are given by $$F_x \frac{\partial x_m}{\partial q_i}$$. By contrast, $$y_m$$ doesn't provide any contribution to the virtual work as $$F_y = 0$$.
This sums up in the final equation as: $$...=\begin{bmatrix} \tau_1 + F_x \\ \tau_2 -F_xl_2s_2 \end{bmatrix}.$$
In particular, $$\tau_1$$ is a force actuating the prismatic joint $$q_1$$, whereas $$\tau_2$$ is a torque actuating the revolute joint $$q_2$$. Therefore, units are consistent.