Calling v=dot x and omega = dot theta and
v_c = r omega(cos(theta),-sin(theta))+(v,0) we have
E_K = 1/2(J omega^2+m_2 << v_c, v_c >> + m_1v^2)
=1/2 ((m_1 + m_2)dot x^2 +
2 m_2 r cos(theta) dot x dot theta+ (J +
m_2 r^2)dot theta^2)
E_P=(R-r)(1-cos(theta))m_2 g+1/2 x^2
so
L = E_K-E_P
The movement equations are obtained solving for dot v, dot omega
d/(dt)((partial L)/(partial dot q))-(partial L)/(partial q) = F_q
where q = (x, theta) and F_q = (F,0) obtaining
ddot x= ((J+m_2r^2)(F-k x + m_2 r sin(theta) dot theta^2)+m_2 g r(R-r)cos(theta)sin(theta))/((m_1+m_2)(J+m_2r^2)-m_2^2r^2cos^2(theta))
ddot theta=-(m_2cos(theta)(F r+ g(m_1+m_2)(R-r)tan(theta)-k r x +m_2r^2sin(theta)dot theta^2))/((m_1+m_2)(J+m_2r^2)-m_2^2r^2cos^2(theta))