Why $\mathbf{Q} = \mathbf{J}_{R}^{T}\tau$? Yesterday I asked this question: Having hard time computing generalized forces
And I got the answer, however I don't get why $\mathbf{Q} = \mathbf{J}_{R}^{T}\tau$, namely I don't see where matrix $\mathbf{J}$ comes from. Could anyone elaborate? How to get this expression using virtual work?
 A: Lets look at this example

\begin{align*}
&\text{Newton equations of motion (free body diagram)}\\
&I_1\dot{\omega}_1=\tau_1+\tau_c\\
&I_1\dot{\omega}_1=-\tau_c\\
&\text{and the constraint equation}\\
&\omega_1-\omega_2=0
\end{align*}
or with matrix notation
\begin{align*}
  &\underbrace{\begin{bmatrix}
    I_1 & 0 \\
    0 & I_2 \\
  \end{bmatrix}}_{\mathbf I}\,
  \underbrace{\begin{bmatrix}
    \dot{\omega}_1 \\
    \dot{\omega}_2 \\
  \end{bmatrix}}_{\mathbf{\dot{\omega}}}=
  \underbrace{\begin{bmatrix}
    \tau_1 \\
    0 \\
  \end{bmatrix}}_{\mathbf \tau}+
  \underbrace{\begin{bmatrix}
    1 \\
    -1 \\
  \end{bmatrix}}_{\mathbf c}\tau_c\tag 1
\end{align*}
from the constraint equation you choose the generalized coordinate $~\omega_1~\quad\Rightarrow\omega_2=\omega_1~$ thus
\begin{align*}
&\mathbf{{\omega}}=\underbrace{\begin{bmatrix}
                         1 \\
                         1 \\
                       \end{bmatrix}}_{\mathbf{J}_R}\omega_1\quad,
    &\mathbf{{\dot \omega}}={\begin{bmatrix}
                         1 \\
                         1 \\
                       \end{bmatrix}}\dot \omega_1
\end{align*}
to eliminate the constraint torque $\tau_c~$ you multiply equation (1) with $~\mathbf{J}_R^T~$ (with$~\mathbf{J}_R^T\,\mathbf c=\mathbf 0~$ ) you obtain the equation of motion
\begin{align*}
  \mathbf{J}_R^T\,\mathbf{I}\,\mathbf{J}_R\,\dot\omega_1=\mathbf{J}_R^T\,\mathbf{\tau}
 \end{align*}
so $~\mathbf Q=\mathbf{J}_R^T\,\mathbf{\tau}~$ are the generalized "forces".
A: This expression comes from the balance of power across a joint.
Keeping in the rotational theme (although there is generalization to screw joints that include  both revolute and prismatic), the kinematic relationship across the joint is
$$ \boldsymbol{\omega}_{\rm out} = \boldsymbol{\omega}_{\rm in} + \mathbf{J}_R \dot{q} \tag{1}$$
Now the power balance relationship is expressed with the following scalar equation
$$ P_{\rm out} = P_{\rm in} + P_{\rm motor} \tag{2} $$
where $$\begin{aligned}
 P_{\rm motor} & = \dot{q} \, Q \\
 P_{\rm in} &= \boldsymbol{\omega}_{\rm in}^\top \boldsymbol{\tau} \\ 
 P_{\rm out} &= \boldsymbol{\omega}_{\rm out}^\top \boldsymbol{\tau}
\end{aligned}$$
or
$$ 
\boldsymbol{\omega}_{\rm out}^\top \boldsymbol{\tau} = \boldsymbol{\omega}_{\rm in}^\top \boldsymbol{\tau} + \dot{q} \,Q \tag{3} $$
Now use (1) in (3) to get
$$ \dot{q}\,Q = ( (\boldsymbol{\omega}_{\rm in}+ \mathbf{J}_R \dot{q} )^\top \boldsymbol{\tau} - \boldsymbol{\omega}_{\rm in}^\top \boldsymbol{\tau}) = \dot{q}\, (\mathbf{J}_R^\top \boldsymbol{\tau})$$
or
$$ \boxed{ Q = \mathbf{J}_R^\top \boldsymbol{\tau} } \tag{4} $$
