-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the LagrangeMechanics wiki!
This library will allow you to model a 2D mechanical system. I made it when a took the courses "Optimization and Control", "Modeling and Simulation" and "Modeling and Control of Robots". Especially the two latter ones required a lot of calculation by hand to find the Euler-Lagrange equations of motion, which I though was strenuous. Therefore I made this library to be able to confirm my workings. With this, I could easily check the energies of each mass and of the total system, and of course, the Euler-Lagrange equations.
you get to:
- easily calculate the symbolic expressions for kinetic and potential energy for each individual mass, as well as for your system in total.
- skip long and strenuous calculations to acquire symbolic expressions for the Euler-Lagrange equations of motion by hand.
- easily design several controllers for your system and implement them.
- simulate the system with or without the controller you made.
- automatically plot the simulation.
- easily animate the simulation afterwards. (- and many other practical function. (not all of them are refined to be easy to use/understand yet...))
NB! Models that require inertia must me modelled as a point mass at the correct position, and then two masses extending to opposite sides must be associated with the main mass. That is, three masses in a line, where the middle one is the actual position of the mass. Make the distance to the two masses equal to 1(r = 1), then their masses to half of the inertia each(m_1_1 = m_1_2 = 0.5*I_1), then the middle mass to the mass of the point minus the inertia(m_1 = M_1 -I_1). After modeling the system like this, there is a function "RepairInertia", that converts the equations to contain only the actual mass(M_1) and inertia(I_1), rather than the three masses(m_1, m_1_1, m_1_2). This will be automated in the future.
Also: the format of the animations must be adjusted using the configuration struct, such that the grid is not 'squished'. For the normal pop-up figure size, formatRatio = 5/4 usually works fine. For fullscreen, formatRatio = 5/41.55 is good. For half-screen, formatRatio = 5/40.75 is good.
Please give feeback! I will try to improve what is bad/confusing, and add features if needed/requested.