Jansen Linkage [gnuplot]

Thursday, April 16, 2020

gnuplot Linkage Mechanism YouTube

t f B! P L

YouTube

 

Formulation

Find the coordinates of the joints $A$, $B$ and $C$

Let \begin{array}{lll} a=38.0 & b=41.5 & c=39.3 & d=40.1 & e=55.8\\ f=39.4 & g=36.7 & h=65.7 & i=49.0 & j=50.0\\ k=61.9 & l=7.8 & m=15.0 & & \\ \end{array} These numbers are called "Holy Numbers" [1]. Then \begin{eqnarray*} \v{OA} &=& \begin{bmatrix}m\cos\theta\\m\sin\theta\end{bmatrix}\\ \v{OB} &=& \begin{bmatrix}-a\\-l\end{bmatrix}\\ \v{OC} &=& \v{OB}+\v{BC}=\left[ \begin{array}{c} -a + b\cos(\alpha+\beta)\\ -l + b\sin(\alpha+\beta) \end{array} \right] \end{eqnarray*} where \begin{eqnarray*} \alpha &=& \arctantwo\left(A_y-B_y, A_x-B_x\right)\\ \beta &=& \arccos\left(\frac{AB^{2}+b^{2}-j^{2}}{2\cdot AB\cdot b}\right) \end{eqnarray*}

Find the coordinates of the joints $D$ and $E$

\begin{eqnarray*} \v{OD} &=& \v{OB}+\v{BD}&=&\left[ \begin{array}{c} -a + b\cos(\alpha+\beta+\gamma)\\ -l + b\sin(\alpha+\beta+\gamma) \end{array} \right]\\ \v{OE} &=& \v{OB}+\v{BE}&=&\left[ \begin{array}{c} -a + c\cos(\alpha-\delta)\\ -l + c\sin(\alpha-\delta) \end{array} \right] \end{eqnarray*} where \begin{eqnarray*} \gamma &=& \arccos\left(\frac{b^{2}+d^{2}-e^{2}}{2bd}\right)\\ \delta &=& \arccos\left(\frac{AB^{2}+c^{2}-k^{2}}{2 \cdot AB \cdot c}\right) \end{eqnarray*}

Find the coordinates of the joints $F$ and $G$

\begin{eqnarray*} \v{OF} &=& \v{OE}+\v{EF}\nonumber\\ &=&\left[\begin{array}{c} -a + c\cos(\alpha-\delta)+g\cos(\varepsilon+\zeta)\\ -l + c\sin(\alpha-\delta)+g\sin(\varepsilon+\zeta) \end{array} \right]\\ \v{OG} &=&\v{OE}+\v{EG}\nonumber\\ &=&\left[ \begin{array}{c} -a + c\cos(\alpha-\delta)+i\cos(\varepsilon+\zeta+\eta)\\ -l + c\sin(\alpha-\delta)+i\sin(\varepsilon+\zeta+\eta) \end{array} \right] \end{eqnarray*} where \begin{eqnarray*} \varepsilon &=& \arctantwo\left(D_y-E_y, D_x-E_x\right)\\ \zeta &=& \arccos\left(\frac{DE^{2}+g^{2}-f^{2}}{2\cdot DE \cdot g}\right)\\ \eta &=& \arccos\left(\frac{g^{2}+i^{2}-h^{2}}{2gi}\right) \end{eqnarray*}

Simulation [gnuplot]

Program 1 : Output animation of Jansen's linkage

Source code (PLT file)

Output (PNG file → GIF file)

Program 2 : Output animation of 6 legs

Source code (PLT file)


Output (PNG file → GIF file)


Extra

Animation of 12 legs (Strandbeest [2] )

Changing the number of legs, you can increase the number of robot legs.
LEG_SET_NUM = 6

Only 6 legs (not display coordinate plane)

Altering the setting of plot area and disappearing coordinate plane, 6-legged robot appears to walk.
unset xlabel # or set xlabel "..." tc(=textcolor) rub 'white' 
unset ylabel # or set ylabel "..." tc rub 'white'
unset tics # or set tics tc rub 'white'
unset grid # or set grid lc rub 'white'
unset border # or set border lc rub 'white'

Note

Color setting for each leg

If you make gradual color change, you use the following code.
WHITEN_VAL = int(180./LEG_SET_NUM) # If numerator is not 180 but 255, the last pair of legs turns too white.
color = 0x000000 + (WHITEN_VAL*k << 16)+(WHITEN_VAL*k << 8)+(WHITEN_VAL*k << 0) # If base color is black
color = 0xff0000 + (WHITEN_VAL*k << 8)+(WHITEN_VAL*k << 0) # If base color is red
On the other hand, if you specify the color used for each leg, you use the following code.
(k=0 : Red, k=1 : Green, k=2 : Blue)
color = (k==0 ? 0xff0000 : (k==1 ? 0x00ff00 : 0x0000ff))

Transparency in png terminal

When transparency is used in png terminal, the "truecolor" option must be selected [3]. Then you use transparent color if you represent color by 32 bits AARRGGBB [4]. So, I modified the code as follows.
set term png truecolor enhanced size 960, 720 # truecolor is important!
CIRC_R = 4 # Largen radius
color = (j==0 ? 0x80ff3434 : (j==1 ? 0x80759dff : 0x8056bf56)) # 0x80RRGGBB = 50% transparency, rgb RRGGBB
plot_command = plot_command.sprintf(", outputfile u %d:%d every ::%d::%d w l lw LW*0.7 lc rgb 'gray30'", 16+2*k, 17+2*k, start, end) # Change color
Thanks to truecolor, all of the circles representing joint $A$ are transparent as shown in the below figure. However, arrows drawn without a head are not transparent. So, if you want to draw transparent not only circles but also lines, I suggest you to set the qt terminal. Please note that you can't save image by using command 'set output' in qt terminal.
Terminal type : 'png' Terminal type : 'qt' (in MacOS)

References

  1. ^ Jansen's linkage - Wikipedia
  2. ^ Leg System | Exploratorium
  3. ^ Gnuplot surprising: transparency in gnuplot
  4. ^ gnuplot demo script: rgba_lines.dem

External links

▶︎ Strandbeest (Homepage)
▶︎ Theo Jansen: My creations, a new form of life | TED Talk

Search This Blog

Translate

QooQ