<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    I have two scripts which implement method to model a wheeled
    inverted pendulum, the first one implementing a Kanes method, the
    second one with Lagrange.<br>
    <br>
    Using Kane, I obtain the right result into the "fr+frstar" variable,
    but after linearization the matrices A and B are completely wrong.<br>
    <br>
    The same behavior seems to append with the Lagrange script, where
    after the Lagrange Method the
    <style type="text/css">
p, li { white-space: pre-wrap; }
</style>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">"form_lagranges_equations()" output is correct but the generated matrices A and B not...</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In my opinion the right matrices should be:</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A= np.matrix([
                [0,     0,      1,      0],
                [0,     0,      0,      1],
                [((L_w*M_w+L_p*M_p)*g)/(L_w^2*M_w-J_w+J_p),     0,      0,      0],
                [-((L_w*M_w+L_p*M_p)*g)/(L_w^2*M_w-J_w+J_p),    0,      0,      0]]     )</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">B = np.matrix(
                [0],
                [0],
                [-K_t/(L_w^2*M_w-J_w+J_p)],
                [(K_t*L_w^2*M_w+J_p*K_t)/(J_w*L_w^2*M_w-J_w^2+J_p*J_w)]
        )</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Both scripts are attached</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Thanks in advance</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Best regards</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Roberto
</p>
  </body>
</html>