Coder Social home page Coder Social logo

mpc-spring-mass-example's Introduction

Simple MPC for Spring-mass system

Simple Model Predictive Control (MPC) for non-linear spring-mass system. The system is illustrated below, with M masses (m_1=m_2...m_M=m) connected by (non-linear) springs, and with velocity-dependent friction under each mass. The system is controlled by appling forces u1 and u2 to the first and last masses. Noise is applied to the control signals. Objective is to hold masses as close to their "0"s as possible, while applying as little control force as possible.

For linear springs, the force is k*r, where r is displacement. For non-linear springs, the force is h(r) = k*r - 0.01 r^3. Friction force is 2*c*v, where v is velocity.

|   k     _______    k     _______         k     _______    k    |
|__/\/\__|       |__/\/\__|       |_ ... _/\/\__|       |__/\/\__|
|        |  m_1  |        |  m_2  |             |  m_M  |        |
|  u1 -->|_______|        |_______|             |_______|--> u2  |   x
============(c)==============(c)====== ... ========(c)================== -->

System dynamics is as following:

m*x_i'' + 2*c*x_i' + h(x_i - x_{i-1}) + h(x_i โˆ’ x_{i+1}) = 0, for i=1..M,

where x_i is the position of mass i, x_0 = x_{M+1} = 0, x_i' and x_i'' are first and second derivatives of x_i.

Results

Figure below shows:

  • uncontrolled simulation,
  • closed-loop simulation,
  • thin lines indicate positions predicted by MPC.

Potential improvements

  • Make controller aware of spring non-linearity: Linearize non-linear terms around the solution from the previous MPC iteration.

  • Consider more realistic noise: Add noise to all elements. Something that would perhaps mimic gusts of wind, or temperature effects on spring and friction coefficients. Also, try giving "noisy" system parameters (k, m, c, x, v) to the MPC solver.

  • Add latency of MPC calculations There should be a delay from the time MPC gets (x,v) and the time it outputs a solution.

  • Can we learn system parameters from observations? Use optimal estimation, system identification, or machine learning to find system parameters (k, m, c) from observing uncontrolled/controlled system. Can also be done as reinforcement learning. Could also balance exploration-vs-exploitation, as opposed to only doing exploration.

Dependencies

License

MIT.

mpc-spring-mass-example's People

Contributors

alexvoronov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.