miller_viz.py
def plot_residual_torque(x, u, nlp: NonLinearProgram):
    """
    Compute the residual torque of the system.

    Parameters
    ----------
    x
        State vector
    u
        Control vector
    nlp: NonLinearProgram
        Non linear program
    """
    qddot_mx = nlp.controls["qddot"].mx if "qddot" in nlp.controls.keys() else nlp.states["qddot"].mx
    ID_func = biorbd.to_casadi_func(
        "ResidualTorque",
        nlp.model.InverseDynamics,
        nlp.states["q"].mx,
        nlp.states["qdot"].mx,
        qddot_mx,
        expand=True,
    )

    q = nlp.states["q"].mapping.to_second.map(x[nlp.states["q"].index, :])
    qdot = nlp.states["qdot"].mapping.to_second.map(x[nlp.states["qdot"].index, :])
    qddot = (
        u[nlp.controls["qddot"].index, :]
        if "qddot" in nlp.controls.keys()
        else nlp.states["qddot"].mapping.to_second.map(x[nlp.states["qddot"].index, :])
    )

    return np.array(ID_func(q, qdot, qddot)[:6, :])

    Compute the residual torque of the system.

    Parameters
    ----------
    x
        State vector
    u
        Control vector
    nlp: NonLinearProgram
        Non linear program
    
Compute the residual torque of the system.
Parameters

x
State vector
u
Control vector
nlp: NonLinearProgram
Non linear program
Compute the residual torque of the system . Parameters x State vector u Control vector nlp : NonLinearProgram Non linear program
def plot_residual_torque(x, u, nlp: NonLinearProgram):
    qddot_mx = nlp.controls["qddot"].mx if "qddot" in nlp.controls.keys() else nlp.states["qddot"].mx
    ID_func = biorbd.to_casadi_func(
        "ResidualTorque",
        nlp.model.InverseDynamics,
        nlp.states["q"].mx,
        nlp.states["qdot"].mx,
        qddot_mx,
        expand=True,
    )
    q = nlp.states["q"].mapping.to_second.map(x[nlp.states["q"].index, :])
    qdot = nlp.states["qdot"].mapping.to_second.map(x[nlp.states["qdot"].index, :])
    qddot = (
        u[nlp.controls["qddot"].index, :]
        if "qddot" in nlp.controls.keys()
        else nlp.states["qddot"].mapping.to_second.map(x[nlp.states["qddot"].index, :])
    )
    return np.array(ID_func(q, qdot, qddot)[:6, :])
def plot_residual_torque ( x , u , nlp : NonLinearProgram ) : qddot_mx = nlp . controls [ "qddot" ] . mx if "qddot" in nlp . controls . keys ( ) else nlp . states [ "qddot" ] . mx ID_func = biorbd . to_casadi_func ( "ResidualTorque" , nlp . model . InverseDynamics , nlp . states [ "q" ] . mx , nlp . states [ "qdot" ] . mx , qddot_mx , expand = True , ) q = nlp . states [ "q" ] . mapping . to_second . map ( x [ nlp . states [ "q" ] . index , : ] ) qdot = nlp . states [ "qdot" ] . mapping . to_second . map ( x [ nlp . states [ "qdot" ] . index , : ] ) qddot = ( u [ nlp . controls [ "qddot" ] . index , : ] if "qddot" in nlp . controls . keys ( ) else nlp . states [ "qddot" ] . mapping . to_second . map ( x [ nlp . states [ "qddot" ] . index , : ] ) ) return np . array ( ID_func ( q , qdot , qddot ) [ : 6 , : ] )
Compute the residual torque of the system.
Compute the residual torque of the system .
"""
    Compute the residual torque of the system.

    Parameters
    ----------
    x
        State vector
    u
        Control vector
    nlp: NonLinearProgram
        Non linear program
    """
x
u
nlp
NonLinearProgram