In Lagrangian mechanics, we use what is called the generalized coordinates (gc's) as the variable of the machanics problem in hand. These gc's represent the degrees of freedom that the studied system has. Lagrangian mechanics deals with the energies of the system (kinetic $T$ and potential $U$ energies) through the so-called Lagrangian function $L(q,\dot{q})$, where $q$ ('s) are the generalized coordinate(s) and $\dot{q}$ ('s) the corresponding generalized velocities. This is why people say that Lagrangian mechanics is easier to deal with than Newtonian mechanics, because the quantities are only scalars and not vectors. But by saying only this we are leaving something very important without mentioning it. The determination of the generalized coordinates is not that simple.
The question is: Is there any systematic/clever/cheating way that could be used to determine these gc's?
Example:
The picture tells everything. mass $m_1$ connected to the spring moves on the x-axis, and mass $m_2$ swings left and right. The generalized coordinates, in many references, are $x$ and $\theta$. But are $\theta$ and $x$ really independent? Since $m_2$ has inertia, its movement will influence that of $m_2$, and vice versa. In other words, there exists some coupling between the two variables, and the motion could even be chaotic. So how could we set these two as the gc's of the system anyway, and what's the reasoning here?