This MATLAB program generates symbolic Lagrangian formulas for a single leg of a quadruped robot. With just one click, the code calculates the kinetic energy, potential energy, and the torque required for each joint.
simple
: Simplified functions for the calculationsgenTransform
: Functions to generate transformation matrices
- MATLAB
simple
: Simplified functions for the calculationsgenTransform
: Functions to generate transformation matrices
We use the following formula for the calculations:
\frac{\mathrm{d}}{\mathrm{d} t}\left(\frac{\partial L}{\partial q}\right)-\frac{\partial L}{\partial q}=Q
After extracting the terms with ๐ฬ and ๐ฬ, we obtain the standard form:
D \ddot{q}+C \dot{q}+G=\tau
The main script (energyOfLagrange.m
) performs the following calculations:
- Calculate the rotational kinetic energy of the leg
- Calculate the translational kinetic energy of the leg
- Calculate the potential energy due to gravity acting on the leg
- Use Lagrange's equations to calculate the torque required at each joint
- Simplify the expressions and extract the matrices D and C, and calculate G
- Calculate the joint accelerations using the inverse Jacobian method
- Clone the repository or download the code files
- Open MATLAB and navigate to the code directory
- Run the
energyOfLagrange.m
script