STEM 隨筆︰古典力學︰動力學【一】

心想何不讓寫故事的人︰

Dynamics with Python balancing the five link pendulum

Dynamics with Python

We’ve been working on a conference paper to demonstrate the ability to do multibody dynamics with Python. We’ve been calling this work flowPyDy, short for Python Dynamics. Several pieces of the puzzle have come together lately to really demonstrate the power of the scientific python software packages to handle complex dynamic and controls problems (i.e. IPython notebooks, matplotlib animations, python-control, and our software package mechanics which is a part of SymPy). After writing the draft of our paper, which uses a general n-link pendulum as it’s main example, I came across this blog post by Wolfram demonstrating their ability to symbolically derive the equations of motion for the n-link pendulum and stabilize it with an LQR controller. It inspired me to replicate the example as I realized that it was relatively easy to do with all free and open source software!

In this example problem we will derive the equations of motion of an n-link pendulum on a laterally sliding cart and then develop a controller to stabilize it. Balancing a single inverted pendulum is a classic problem that is many times a student’s first experience with non-linear dynamics and control. The problem here is extended to a general n-link pendulum and as we will see the equations of motion quickly get messy with greater than 2 links.

 

說故事呢?

 

一則可知『派生動力學』 PyDy 來龍去脈,再者能得創作精神也!

由於這本筆記使用了

Python Control Systems Library

The Python Control Systems Library is a Python module that implements basic operations for analysis and design of feedback control systems.

Features

  • Linear input/output systems in state-space and frequency domain
  • Block diagram algebra: serial, parallel, and feedback interconnections
  • Time response: initial, step, impulse
  • Frequency response: Bode and Nyquist plots
  • Control analysis: stability, reachability, observability, stability margins
  • Control design: eigenvalue placement, linear quadratic regulator
  • Estimator design: linear quadratic estimator (Kalman filter)

Links

 

程式庫,特先指明

‧安裝

sudo pip3 install slycot

sudo pip3 install control

 

同時告知

‧手冊

Introduction

Welcome to the Python Control Systems Toolbox (python-control) User’s Manual. This manual contains information on using the python-control package, including documentation for all functions in the package and examples illustrating their use.

Overview of the Toolbox

The python-control package is a set of python classes and functions that implement common operations for the analysis and design of feedback control systems. The initial goal is to implement all of the functionality required to work through the examples in the textbook Feedback Systems by Astrom and Murray. A MATLAB compatibility package (control.matlab) is available that provides many of the common functions corresponding to commands available in the MATLAB Control Systems Toolbox.

In addition to the documentation here, there is a project wiki that contains some additional information about how to use the package (including some detailed worked examples):

Some Differences from MATLAB

The python-control package makes use of NumPy and SciPy. A list of general differences between NumPy and MATLAB can be found here:

In terms of the python-control package more specifically, here are some thing to keep in mind:

  • You must include commas in vectors. So [1 2 3] must be [1, 2, 3].
  • Functions that return multiple arguments use tuples
  • You cannot use braces for collections; use tuples instead
  • Transfer functions are currently only implemented for SISO systems; use state space representations for MIMO systems.

 

‧書籍

Second Edition

 (Redirected from Main Page)
Feedback Systems: An Introduction for Scientists and Engineers
Karl J. Åström and Richard M. Murray

Welcome to FBSwiki. This is the wiki for the Second Edition of text Feedback Systems by Karl J. Åström and Richard M. Murray.

WARNING: The second edition of FBS is still in beta. If you would like a more stable version of this book, please use the first edition.

Copyright in this book is held by Princeton University Press, who have kindly agreed to allow us to keep the book available on the web.

News (archive)

……

First Edition

Feedback Systems: An Introduction for Scientists and Engineers
Karl J. Åström and Richard M. Murray
Obtaining AM08

Welcome to FBSwiki. This is the wiki for the text Feedback Systems by Karl J. Åström and Richard M. Murray. On this site you will find the complete text of the book as well as additional examples, exercises, and frequently asked questions.

Copyright in this book is held by Princeton University Press, who have kindly agreed to allow us to keep the book available on the web.

News (archive)
  • 22 Jun 2014: A preprint of the second edition is now available. Warning: this version is still be developed and may contain bugs.
  • 28 Sep 2012: Version 2.11b, which contains corrections to the third printing, is now posted. This version includes corrections to all errata identified as of 28 September 2012. Hypertext and e-reader optimized versions are also available.
  • 30 Jul 2011: Version 2.10e, which contains corrections to the third printing, is now posted. This version includes corrections to all errata identified as of 30 August 2011. Hypertext and e-reader optimized versions are also available.
  • 23 Dec 2009: Updated pages have been created for the BFS, NCS and OBC supplements.
  • 16 Aug 2008: A solutions manual is now available for instructors.

 

之出處,方便查閱開始耳。