Partial Lagrangian for Efficient Extension and Reconstruction of Multi-DoF Systems and Efficient Analysis Using Automatic Differentiation
Abstract
:1. Introduction
2. Methods
2.1. Partial Lagrangian
- Dynamics: Differentiation of state variables as physical constraints.
- Kinematics: Position and velocity as geometric constraints.
- Partial Lagrangian.
- (a)
- Quadratic form: calculate and to find the energies. Calculate the partial energies: and .
- (b)
- Compute the partial Lagrangian: .
- Find the partial generalized force: . If it is a multi-degree-of-freedom system, find the sum .
2.2. Postural Operator for Hand Calculations
- Cancellation:
- Interference:
- Derivative:
2.3. System Analysis Using Automatic Differentiation for Numerical Calculation
- Dynamics: The time evolution of the state variable is registered in the calculation graph as a constraint.
- Kinematics: Register a geometric constraint on a calculation graph.
- Register a partial Lagrangian in the computed graph
- Register the partial generalized force, and if it is a multi-DoF, find the sum for each DoF.
- Backpropagate and find the coefficients as the gradient of the state variable.
3. Results
3.1. Example of 1-DoF: Effect of Postural Operator
3.2. Example of 2-DoF: Effect of Divide-and-Conquer by Partial Lagrangian
3.3. Example of 3-DoF and Changing System Construction
4. Discussion
4.1. Computational Advantages of Partial Lagrangian
4.2. Application of Partial Lagrangian as an Extension or Restructuring of the System
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Appendix A. A Sample Analysis of Partial Lagrangian Using Automatic Differentiation
Listing A1. Example of the partial Lagrangian module. |
# 0. State variables and their constraints of time evolution for AD |
(_theta, _omega, _acc) = state acc = torch.tensor(_acc, requires_grad=True) omega = torch.tensor(_omega, requires_grad=True) + acc ∗ self.dt theta = torch.tensor(_theta, requires_grad=True) + omega ∗self.dt |
# 1. Geometric constraints and their derivatives |
x = self.l ∗ torch.cos(theta) y = self.l ∗ torch.sin(theta) dx = torch.autograd.grad(x, self.dt, create_graph=True) dy = torch.autograd.grad(y, self.dt, create_graph=True) |
# 2. (Partial) Lagrangian with friction |
K = 0.5∗self.m ∗ (dx[0]∗∗2+dy[0]∗∗2) P = 0.5∗self.k ∗ (x∗∗2+y∗∗2) + self.m∗9.8∗y R = 0.5∗self.c ∗ (dx[0]∗∗2+dy[0]∗∗2) L = K−P |
# 3. Lagrange Equation of Motion |
dLdth = torch.autograd.grad(L, theta, create_graph=True) dLdomega = torch.autograd.grad(L, omega, create_graph=True) dLdt = torch.autograd.grad(dLdomega, self.dt, create_graph=True) dRddth = torch.autograd.grad(R, omega, create_graph=True) Iacc = dLdth[0] − dRddth[0] T = dLdt[0] − Iacc # balance |
# 4. Backpropagation |
T.backward(retain_graph=True) |
# 5. Convert force to acc |
I = acc.grad acc = float(Iacc/I) omega += acc ∗ self.dt state = (theta, omega, acc) return state |
References
- de Jesus Rubio, J.; Humberto Perez Cruz, J.; Zamudio, Z.; Salinas, A.J. Comparison of two quadrotor dynamic models. IEEE Lat. Am. Trans. 2014, 12, 531–537. [Google Scholar] [CrossRef]
- Ali, S. Newton-Euler Approach for Bio-Robotics Locomotion Dynamics: From Discrete to Continuous Systems. Ph.D. Thesis, Ecole des Mines de Nantes, Nantes, France, 2011; p. 251. [Google Scholar]
- Sciavicco, L.; Siciliano, B.; Luigi, V. Lagrange and Newton-Euler dynamic modeling of a gear-driven robot manipulator with inclusion of motor inertia effects. Adv. Robot. 1995, 10, 317–334. [Google Scholar] [CrossRef]
- Robotic Systems Lab, ETH Zurich Robot Dynamics Lecture Notes. 2017. Available online: https://ethz.ch/content/dam/ethz/special-interest/mavt/robotics-n-intelligent-systems/rsl-dam/documents/RobotDynamics2017/RD_HS2017script.pdf (accessed on 20 September 2022).
- De Luca, A.; Ferrajoli, L. A modified newton-euler method for dynamic computations in robot fault detection and control. In Proceedings of the 2009 IEEE International Conference on Robotics and Automation, Kobe, Japan, 12–17 May 2009; pp. 3359–3364. [Google Scholar] [CrossRef] [Green Version]
- Buondonno, G.; De Luca, A. A recursive Newton-Euler algorithm for robots with elastic joints and its application to control. In Proceedings of the 2015 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Hamburg, Germany, 28 September–2 October 2015; pp. 5526–5532. [Google Scholar] [CrossRef]
- Li, X.; Nishiguchi, J.; Minami, M.; Matsuno, T.; Yanou, A. Iterative calculation method for constraint motion by extended newton-euler method and application for forward dynamics. In Proceedings of the 2015 IEEE/SICE International Symposium on System Integration (SII), Nagoya, Japan, 11–13 December 2015; pp. 313–319. [Google Scholar] [CrossRef]
- Hirata, Y.; Iwano, T.; Tajika, M.; Kosuge, K. Motion Control of Wearable Walking Support System with Accelerometer Based on Human Model; Advances in Human-Robot Interaction; IntechOpen: London, UK, 2009. [Google Scholar] [CrossRef] [Green Version]
- Benaddy, A.; Labbadi, M.; Bouzi, M. Adaptive Nonlinear Controller for the Trajectory Tracking of the Quadrotor with Uncertainties. In Proceedings of the 2020 2nd Global Power, Energy and Communication Conference (GPECOM), Izmir, Turkey, 20–23 October 2020; pp. 137–142. [Google Scholar] [CrossRef]
- Rameez, M.; Khan, L.A. Modeling and dynamic analysis of the biped robot. In Proceedings of the 2015 15th International Conference on Control, Automation and Systems (ICCAS), Busan, South Korea, 13–16 October 2015; pp. 1149–1153. [Google Scholar] [CrossRef]
- Nicotra, M.M.; Garone, E. Control of Euler-Lagrange systems subject to constraints: An Explicit Reference Governor approach. In Proceedings of the 2015 54th IEEE Conference on Decision and Control (CDC), Osaka, Japan, 15–18 December 2015; pp. 1154–1159. [Google Scholar] [CrossRef]
- Su, B.; Gong, Y. Euler-Lagrangian modeling and exact trajectory following controlling of Ballbot-like robot. In Proceedings of the 2017 IEEE International Conference on Robotics and Biomimetics (ROBIO), Macau, Macao, 5–8 December 2017; pp. 2325–2330. [Google Scholar] [CrossRef]
- Al-Shuka, H.F.N.; Corves, B.; Zhu, W.H. Dynamics of Biped Robots during a Complete Gait Cycle: Euler-Lagrange vs. Newton-Euler Formulations; Research Report; School of Control Science and Engineering, Shandong University: Jinan, China, 2019; Available online: https://hal.archives-ouvertes.fr/hal-01926090 (accessed on 19 September 2022).
- Kusaka, T.; Tanaka, T.; Kaneko, S.; Suzuki, Y.; Saito, M.; Kajiwara, H. Assist Force Control of Smart Suit for Horse Trainers Considering Motion Synchronization. Int. J. Autom. Technol. 2009, 3, 723–730. [Google Scholar] [CrossRef]
- Kusaka, T.; Tanaka, T.; Kaneko, S.; Suzuki, Y.; Saito, M.; Kajiwara, H. Smart suit for horse trainers-power and skill assist based on semi-active assist and energy control. In Proceedings of the 2010 IEEE/ASME International Conference on Advanced Intelligent Mechatronics, Montreal, QC, Canada, 6–9 July 2010; pp. 509–514. [Google Scholar] [CrossRef]
- Kusaka, T.; Tanaka, T.; Kaneko, S.; Suzuki, Y.; Saito, M.; Seki, S.; Sakamoto, N.; Kajiwara, H. Assist force control of Smart Suit for horse trainer considering motion synchronization and postural stabilization. In Proceedings of the 2009 ICCAS-SICE, Fukuoka, Japan, 18–21 August 2009; pp. 770–775. [Google Scholar]
- Tsuchiya, Y.; Imamura, Y.; Tanaka, T.; Kusaka, T. Estimating Lumbar Load During Motion with an Unknown External Load Based on Back Muscle Activity Measured with a Muscle Stiffness Sensor. J. Robot. Mechatron. 2018, 30, 696–705. [Google Scholar] [CrossRef]
- Tsuchiya, Y.; Kusaka, T.; Tanaka, T.; Matsuo, Y. Wearable Sensor System for Lumbosacral Load Estimation by Considering the Effect of External Load. In Proceedings of the Advances in Human Factors in Wearable Technologies and Game Design; Advances in Intelligent Systems and Computing; Ahram, T., Falcão, C., Eds.; Springer International Publishing: Cham, Switzerland, 2018; pp. 160–168. [Google Scholar] [CrossRef]
- Nethery, J.; Spong, M. Robotica: A Mathematica package for robot analysis. IEEE Robot. Autom. Mag. 1994, 1, 13–20. [Google Scholar] [CrossRef]
- Sadati, S.H.; Naghibi, S.E.; Shiva, A.; Michael, B.; Renson, L.; Howard, M.; Rucker, C.D.; Althoefer, K.; Nanayakkara, T.; Zschaler, S.; et al. TMTDyn: A Matlab package for modeling and control of hybrid rigid–continuum robots based on discretized lumped systems and reduced-order models. Int. J. Robot. Res. 2021, 40, 296–347. [Google Scholar] [CrossRef]
- Sadati, S.M.H.; Naghibi, S.E.; Naraghi, M. An Automatic Algorithm to Derive Linear Vector Form of Lagrangian Equation of Motion with Collision and Constraint. Procedia Comput. Sci. 2015, 76, 217–222. [Google Scholar] [CrossRef] [Green Version]
- Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. Introduction to Algorithms, 3rd ed.; The MIT Press: Cambridge, MA, USA; London, UK, 2009. [Google Scholar]
- Knuth, D.E. The Art of Computer Programming; Addison-Wesley Pub. Co.: Reading, MA, USA, 1968. [Google Scholar]
- Poursina, M.; Anderson, K.S. An extended divide-and-conquer algorithm for a generalized class of multibody constraints. Multibody Syst. Dyn. 2013, 29, 235–254. [Google Scholar] [CrossRef]
- Critchley, J.; Binani, A.; Anderson, K. Design and Implementation of an Efficient Multibody Divide and Conquer Algorithm. In Proceedings of the International Design Engineering Technical Conferences and Computers and Information in Engineering Conference, Las Vegas, NV, USA, 4–7 September 2007. [Google Scholar] [CrossRef]
- Mukherjee, R.M.; Bhalerao, K.D.; Anderson, K.S. A divide-and-conquer direct differentiation approach for multibody system sensitivity analysis. Struct. Multidiscip. Optim. 2008, 35, 413–429. [Google Scholar] [CrossRef]
- Zahedi, A.; Shafei, A.M.; Shamsi, M. On the dynamics of multi-closed-chain robotic mechanisms. Int. J. Non-Linear Mech. 2022, 147, 104241. [Google Scholar] [CrossRef]
- Mazare, M.; Taghizadeh, M. Geometric Optimization of a Delta Type Parallel Robot Using Harmony Search Algorithm. Robotica 2019, 37, 1494–1512. [Google Scholar] [CrossRef]
- Baydin, A.G.; Pearlmutter, B.A.; Radul, A.A.; Siskind, J.M. Automatic Differentiation in Machine Learning: A Survey. J. Mach. Learn. Res. 2018, 18, 43. [Google Scholar]
- Neidinger, R.D. Introduction to Automatic Differentiation and MATLAB Object-Oriented Programming. SIAM Rev. 2010, 52, 545–563. [Google Scholar] [CrossRef] [Green Version]
- Naumann, U. The Art of Differentiating Computer Programs; Software, Environments, and Tools, Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 2011. [Google Scholar] [CrossRef] [Green Version]
- Harrison, D. A Brief Introduction to Automatic Differentiation for Machine Learning. arXiv 2021, arXiv:2110.06209. [Google Scholar]
- Al Seyab, R.; Cao, Y. Nonlinear system identification for predictive control using continuous time recurrent neural networks and automatic differentiation. J. Process Control 2008, 18, 568–581. [Google Scholar] [CrossRef] [Green Version]
- Griewank, A.; Walther, A. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, 2nd ed.; Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 2008. [Google Scholar] [CrossRef]
- Hollerbach, J.M. A Recursive Lagrangian Formulation of Maniputator Dynamics and a Comparative Study of Dynamics Formulation Complexity. IEEE Trans. Syst. Man Cybern. 1980, 10, 730–736. [Google Scholar] [CrossRef]
- Luh, J.Y.; Walker, M.W.; Paul, R.P. On-line computational scheme for mechanical manipulators. Trans. ASME J. Dyn. Syst. Meas. Control 1980, 102, 69–76. [Google Scholar] [CrossRef]
- Fox, H.; Bolton, W. Mathematics for Engineers and Technologists; Butterworth-Heinemann: Oxford, UK, 2002. [Google Scholar]
- Rawlins, J.C.; Fulton, S.R.B.A.C. Basic AC Circuits; Newnes: Boston, MA, USA, 2000. [Google Scholar]
- Robbins, A.; Miller, W.C. Circuit Analysis: Theory and Practice; DELMAR Cengage Learning: Clifton Park, NY, USA, 2013. [Google Scholar]
- McCarthy, J.M. An Introduction to Theoretical Kinematics; MIT Press: Cambridge, MA, USA, 1990. [Google Scholar]
- Vicci, L. Quaternions and Rotations in 3-Space: The Algebra and its Geometric Interpretation; Technical Report; UNC: Chapel Hill, NC, USA, 2001. [Google Scholar]
- Shoemake, K. Quaternions. 1994. Available online: https://web.archive.org/web/20200503045740/http://www.cs.ucr.edu/~vbz/resources/quatut.pdf (accessed on 11 September 2022).
- Dam, E.B.; Koch, M.; Lillholm, M. Quaternions, Interpolation and Animation; Technical Report; Datalogisk Institut, Kobenhavns Universitet: Copenhagen, Denmark, 1998. [Google Scholar]
- Bar-Itzhack, I. New Method for Extracting the Quaternion from a Rotation Matrix. J. Guid. Control. Dyn. 2000, 23, 1085–1087. [Google Scholar] [CrossRef]
- Ma, F.; Liu, W.; Ma, T. Automatic differentiation application on stochastic finite element. In Proceedings of the 2010 International Conference on Computer, Mechatronics, Control and Electronic Engineering, Changchun, China, 24–26 August 2010; Volume 2, pp. 219–221. [Google Scholar] [CrossRef]
- Jeßberger, J.; Marquardt, J.E.; Heim, L.; Mangold, J.; Bukreev, F.; Krause, M.J. Optimization of a Micromixer with Automatic Differentiation. Fluids 2022, 7, 144. [Google Scholar] [CrossRef]
- Enciu, P.; Gerbaud, L.; Wurtz, F. Automatic Differentiation Applied for Optimization of Dynamical Systems. IEEE Trans. Magn. 2010, 46, 2943–2946. [Google Scholar] [CrossRef] [Green Version]
- Kaheman, K.; Brunton, S.L.; Kutz, J.N. Automatic Differentiation to Simultaneously Identify Nonlinear Dynamics and Extract Noise Probability Distributions from Data. arXiv 2020, arXiv:2009.08810. [Google Scholar] [CrossRef]
- Feldmann, P.; Melville, R.; Moinian, S. Automatic differentiation in circuit simulation and device modeling. In Proceedings of the 1992 IEEE/ACM International Conference on Computer-Aided Design, Santa Clara, CA, USA, 8–12 November 1992; pp. 248–253. [Google Scholar] [CrossRef]
- Toshiji, K. Generalization of Circuit Simulator by Automatic Differentiation. IEEJ Trans. Electron. Inf. Syst. 2004, 124, 404–410. [Google Scholar] [CrossRef] [Green Version]
- Christoffersen, C. Implementation Of Exact Sensitivities in a Circuit Simulator Using Automatic Differentiation. In Proceedings of the 20th European Conference on Modelling and Simulation, Bonn, Germany, 28–31 May 2006. [Google Scholar] [CrossRef]
- Ueding, M. Lagrange Examples. 2013. Available online: https://martin-ueding.de/posts/lagrange-examples/ (accessed on 19 September 2022).
- Assencio, D. The Double Pendulum: Lagrangian Formulation—Diego Assencio. Available online: https://diego.assencio.com/?index=1500c66ae7ab27bb0106467c68feebc6 (accessed on 19 September 2022).
- Weisstein, E.W. Double Pendulum—From Eric Weisstein’s World of Physics; Wolfram Research, Inc.: Champaign, IL, USA, 2018; Available online: https://scienceworld.wolfram.com/physics/DoublePendulum.html (accessed on 19 September 2022).
- Harman; Nick, N. Motion of a Triple Rod Pendulum. Available online: https://www.authorea.com/users/259349/articles/412491-motion-of-a-triple-rod-pendulum (accessed on 19 September 2022).
- Jake VanderPlas, Triple Pendulum CHAOS! | Pythonic Perambulations. Available online: https://jakevdp.github.io/blog/2017/03/08/triple-pendulum-chaos/ (accessed on 19 September 2022).
- Automatic Differentiation Package—torch.autograd—PyTorch 1.12 Documentation. Available online: https://pytorch.org/docs/stable/autograd.html (accessed on 21 September 2022).
Partial Lagrangian | Lagrange Method | ||||||||
---|---|---|---|---|---|---|---|---|---|
⋯ | ⋯ | ||||||||
⋯ | ⋯ | → | |||||||
0 | ⋯ | ⋯ | → | ||||||
0 | 0 | ⋯ | ⋯ | → | |||||
⋮ | ⋮ | ⋮ | ⋮ | ⋱ | ⋮ | ⋮ | ⋮ | ⋮ | |
0 | 0 | 0 | ⋯ | ⋯ | → | ||||
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋱ | ⋮ | ⋮ | ⋮ | |
0 | 0 | 0 | ⋯ | 0 | ⋯ | → |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Kusaka, T.; Tanaka, T. Partial Lagrangian for Efficient Extension and Reconstruction of Multi-DoF Systems and Efficient Analysis Using Automatic Differentiation. Robotics 2022, 11, 149. https://doi.org/10.3390/robotics11060149
Kusaka T, Tanaka T. Partial Lagrangian for Efficient Extension and Reconstruction of Multi-DoF Systems and Efficient Analysis Using Automatic Differentiation. Robotics. 2022; 11(6):149. https://doi.org/10.3390/robotics11060149
Chicago/Turabian StyleKusaka, Takashi, and Takayuki Tanaka. 2022. "Partial Lagrangian for Efficient Extension and Reconstruction of Multi-DoF Systems and Efficient Analysis Using Automatic Differentiation" Robotics 11, no. 6: 149. https://doi.org/10.3390/robotics11060149
APA StyleKusaka, T., & Tanaka, T. (2022). Partial Lagrangian for Efficient Extension and Reconstruction of Multi-DoF Systems and Efficient Analysis Using Automatic Differentiation. Robotics, 11(6), 149. https://doi.org/10.3390/robotics11060149