GSoC 2014 Application Maciej Barański: Control Toolbox

Maciej Barański edited this page Mar 21, 2014 · 3 revisions

Short biography

This year I've graduated from AGH University of Science and Technology with a Bachelor’s degree in Automatics and Robotics. Currently I'm pursuing a master’s degree within the same field. I have strong background in mathematics (including linear algebra, ODEs, PDEs, probability and stochastic) and Control Theory (LTI and non-linear systems). I'm also interested in programming (in general), open source applications, systems and networking.

Contact:

Programming experience:

Mainly I've been using Matlab and Simulink for computations related to Control Theory. As a hobby I've been developing some Django applications (mainly http://gigasik.pl/). I'm also familiar in using Python for scientific computations. Platform: For Python programming I almost always use Eclipse with pydev plug-in because it has features like: tab-wise insertions, autocompletion and a great utility (ctrl+shift+f which makes python code pep8 valid). I work on Ubuntu/Gentoo OS everyday and sometimes on Windows (using Virtualbox).

For my Bachelor’s thesis I made a Matlab application which solved Saint-Venant equations of river flow using my own implemented Preissman scheme (finite-difference method). I've been also writing minor applications in Matlab for solving Control Theory problems. A programming language in which I am most experienced is Python. For four year I have been using Python in a Django project (a web hosting service – I have created the customer panel which connects server applications with GUI). I have been also writing minor python applications (using PyQT, SciPy, NumPy, python-visual and much more).

I prefer programming in Python mainly because of the simplicity and beauty of its code. Also simple but powerful mechanisms of OOP, function overloading, argument unpacking makes this language as simple as robust. Thus, I strongly believe that Python is one of the best tools to solve problems in a much easier and time-efficient way. The greatest advantage of using Python is the fact that everything in it is treated as an object. It creates unlimited possibilities, for instance easy implementation of the code documentation.

My favorite feature in SymPy is computation of the characteristic polynomials and eigenvalues. Maybe it is not the most sophisticated feature there, but I had to compute these values manually a plenty of times and I am really grateful of this utility.

    from sympy import symbols
    from sympy.matrices import Matrix
    from sympy.core.symbol import Symbol
    from sympy.polys.polytools import Poly
    from sympy.solvers.solvers import solve


    def place(A, B, p):
        K_symbols = symbols('k0:{0}'.format(A.rows))
        K = Matrix([[ k for k in K_symbols]])
        closed_coeffs = Matrix((A - B * K).berkowitz()[2])
        desired_poly = Poly([1],Symbol('lambda'))
        for pole in p:
            desired_poly = desired_poly * Poly([1, -pole],Symbol('lambda'))
        desired_coeffs = Matrix(desired_poly.all_coeffs())
        return K.subs(solve(closed_coeffs - desired_coeffs, K_symbols))


    if __name__ == "__main__":
        A = Matrix([[0, 0, 1], [1, 0, 1], [1, 0, 0]])
        B = Matrix([0, 0, 1])
        p = [-2, -5, -1]
        print place(A, B, p)

I've been using Git before in several projects (however only on the GitLab platform).

Project: Control Theory Toolbox

During the GSOC project I would like to create a Control Theory Toolbox for LTI systems. Even though a lot of Control Theory is based on numerical computations some solutions are done symbolically, especially in LTI systems. This toolbox would be useful in many academic and personal projects. Many electronic and mechanical devices can be described by the LTI systems (more complicated ones can be simplified by linearization near equilibrium point) so with the toolbox with the aid of the mentioned toolbox there would be a possibility to create easily proper control. Determining whether a system is stable or controllable of a system is in interest of industry, robotics and much more. All reasons mentioned ensure that this project would be a valuable part of SymPy.

Why I think this project suits SymPy?

The main reason in my opinion is that this Control Toolbox will bring a whole new branch of mathematics into SymPy's world. Also, a lot of already implemented functionalities in SymPy - for example matrices, characteristic polynomials, eigenvalues, Laplace's transformations - will be used in this project.

Given the extensive mathematical training I have completed throughout the past three years of my Automatics and Robotics studies I consider myself definitely capable of completing the project. The numerous courses I have completed include Control Theory, Modelling of Dynamical Systems, Automation courses and Control of Mobile Robots at coursera (https://class.coursera.org/conrob-002, certificate). During those, I have familiarised myself with the Control toolbox of Matlab, which gave me an idea of the organisation any related project should have. Furthermore, I have expanded my knowledge beyond the material covered in the courses undertaken by independent studies and reading including the Control Theory documentation and textbooks, read both in my native language (Polish) and in English.

Motivation:

I have found out about SymPy while looking for a GSOC project. I am excited about the possibility of bringing my Control Theory knowledge into practical use. I think that this control toolbox will be really useful especially as I have seen many international students working on Control of Mobile Robots on coursera. Python was the second most used environment (after Matlab). The hardest part of the course was the purely mathematical part in which Control Theory was implemented in symbolical maths. The most satisfying part was creating a working control algorithm. Hence my opinion that, in the academic environment, the fully developed Toolbox will be used for training purposes.

Plan

Community Bonding Period

  1. getting more familiar with SymPy (code organization, style)
  2. gathering necessary documentation
  3. create a draft of the LTI model (to be discussed over the community)

Week 1-3 Implementing the core of the LTI systems

Implementing core fundamentals of the project – the representation of the LTI systems. The systems have various forms: state-space systems, transfer function, zero-pole-gain model, frequency model, descriptor state-space systems. Therefore, all forms should be implemented and all the possible transformations from one form to another delivered. http://www.mathworks.com/help/control/fixed-coefficient-models.html

  1. implementing representations, outputs of the systems
  2. creating conversion methods
  3. documentation and examples
  4. pull request

Week 3-6 Implementing the interconnections between the LTI systems

LTI models can be combined in many ways, e.g. by feedback, serial and parallel connection. The result of those transformations is always a new LTI system.

  1. implementing interconnections: feedback, connect, sumblk, series, parallel, append, blkdiag, imp2exp, inv
  2. documentation and examples (mid-term)
  3. pull request

Week 6-8 Implementing of methods describing properties of the LTI systems

LTI systems needs the utilities to describe stability, controllability and observability. Thus, in this time I will focus on methods to compute poles, zeros and functions to check stability (based on the Hurwitz algorithm), generate controllability and observability matrices and check if those systems are controllable and observable.

  1. poles, zeros, stability
  2. controllability, observability, documentation
  3. pull request

Week 8-12 Implementing control utilities

The final period is reserved for implementing the most exciting feature – control utilities. First, the PID controller and pole placement will be created. After that, the LQR controller will be designed and for the grand finale – Kalman's filter.

  1. PID controller, pole placement (1 week)
  2. LQR controller (1 week)
  3. Kalman's filter (2 weeks)
  4. final pull request

Week 13 Finishing documentation and fixing last bugs

  1. finishing documentation
  2. fixing bugs related to the final pull request

Estimated completion time may be different – LTI systems may be delivered faster. However, its documentation should be finished and all functionalities should have their unit tests.  The time gained can be utilised during the controllers phase of the project, which, due to the complication level, may take longer than estimated.

The Google Summer of Code will be my priority this summer therefore I am willing to work on it as a full-time job (40h/week).

Contributions to SymPy:

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.