I assume Spong angles are $\theta_1$ and $\theta_2$.


```python
from __future__ import print_function, division
from sympy import *
init_printing(use_unicode=True)
```


```python
m1, l1, lc1, I1, theta1, theta1dot = symbols('m1 l1 l_{c1} I1 theta1 thetadot1')
m2, lc2, I2, theta2, theta2dot = symbols('m2 l_{c2} I2 theta2 thetadot2')
```


```python
M = Matrix([[m2*l1*(l1+2*lc2*cos(theta2))+I1+I2,
             m2*l1*lc2*cos(theta2)+I2],
            [m2*l1*lc2*cos(theta2)+I2,
             I2]])
```


```python
M
```


```python
C = Matrix([[-2*m2*l1*lc2*sin(theta2)*theta2dot,
             -m2*l1*lc2*sin(theta2)*theta2dot],
            [m2*l1*lc2*sin(theta2)*theta1dot,
             0]])
```


```python
C
```


```python
g = symbols('g')
G = g*Matrix([[-m1*lc1*sin(theta1)-m2*(l1*sin(theta1)+lc2*sin(theta1+theta2))],
              [-m2*lc2*sin(theta1+theta2)]])
```


```python
G
```

Now, let's change the notations to the one that Russ used [here](http://underactuated.csail.mit.edu/underactuated.html?chapter=acrobot) by having ${}^{\texttt{Russ}}I={}^{\texttt{Spong}}I+ml_c^2$ and ${}^{\texttt{Russ}}\theta_1={}^{\texttt{Spong}}\theta_1+\pi/2$


```python
q1, q1dot = symbols('q1 q1dot')
q2, q2dot = symbols('q2 q2dot')
```


```python
M.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2), 
        (theta1,q1+pi/2), (theta2,q2)])
```


```python
C.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2),
        (theta1,q1+pi/2), (theta2,q2)])
```


```python
G.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2),
        (theta1,q1+pi/2), (theta2,q2)])
```

ea8bcf62fb5badb9e105f924415fa803be9fe695
ipynb
Jupyter Notebook
src/2.1_LQR/Spong-Russ-equivalence.ipynb
atabakd/MuJoCo-Tutorials
d6b86726ca9f01e682a45c4de7c11761ec326d38
BSD-3-Clause
2018-09-27T14:04:02.000Z
2022-03-29T21:58:54.000Z
src/2.1_LQR/Spong-Russ-equivalence.ipynb
atabakd/MuJoCo-Tutorials
d6b86726ca9f01e682a45c4de7c11761ec326d38
BSD-3-Clause
2019-02-18T03:26:38.000Z
2020-10-22T20:23:16.000Z
src/2.1_LQR/Spong-Russ-equivalence.ipynb
atabakd/MuJoCo-Tutorials
d6b86726ca9f01e682a45c4de7c11761ec326d38
BSD-3-Clause
2018-10-03T14:20:28.000Z
2022-01-24T08:32:30.000Z
Qwen/Qwen-72B
1. YES
2. YES