Lanzo98
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # MPCC ## Installation ### Local installation - linux only Clone this repo ``` git clone https://github.com/UMBSDriverless/MPpyC ``` Install the boost dependencies ``` apt-get install libboost-dev libboost-python-dev libboost-numpy-dev ``` Install the python requirements ``` apt-get install python3 python3-numpy python3-matplotlib python3-tk ``` (the names of the dependencies may vary in other distros) cd into the _src_ directory, then run ``` sh install.sh ``` This will download the external dependencies and install them, then build libMPCC and the python binding. ### Container installation #### Linux To build the container with MPpyCC in it run ``` docker build -t mppycc . ``` Then enter it by using ``` sh run.sh ``` #### Windows MPpyCC works on Windows too, but only the docker version. The process is based on [this guide](https://www.vitaarca.net/post/tech/a-simple-docker-example/). Do not use this unless you hate yourself. Use Linux instead. - Install __WSL2__ and Ubuntu (from the windows store) - Install [vcxsrv](https://sourceforge.net/projects/vcxsrv/) - Install __Docker__ - Enable virtualization from the BIOS - Enable WSL integration from the Docker frontend. Settings > Resources > WSL integration - Allow VcXsrv (both vcxsrv and xlaunch) through Windows Firewall for both public and private network. Press Windows key and type “Allow an app through Windows Firewall” and check for the VcXsrv entry. - Launch XLaunch (in folder VcXsrv), go through the setup and set “Disable access control”. - Open Ubuntu console by pressing the windows key and typing ubuntu (the Ubuntu app previously installed from Windows Store). - From within the ubuntu console type `sudo apt install x11-xserver-utils` then `xhost local:root` - From within the ubuntu console type `export DISPLAY=$(grep -oP "(?<=nameserver ).+" /etc/resolv.conf):0.0` - Build the image with ``` docker build -t mppycc . ``` - Run the image with ``` docker run -it \ --volume="$(pwd)/params:/MPpyCC/params:ro" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --env="DISPLAY" mppycc /bin/bash ``` ## Troubleshooting and known issues - ```multiple definition of `BLASFEO_PROCESSOR_FEATURES'``` error during build. this error is caused by the External/Blasfeo examples. To solve it simply set _BLASFEO_EXAMPLES_ to OFF in _CmakeLists.txt_ on line 121/122. ``` set(BLASFEO_EXAMPLES OFF CACHE BOOL "Examples disabled") ``` OR simply delete the _External/blasfeo/examples_ directory and remove the import from _CmakeLists.txt_ ``` if(BLASFEO_EXAMPLES MATCHES ON) add_subdirectory(examples) endif() ``` ## References Alex Liniger's [MPCC](https://github.com/alexliniger/MPCC/tree/master/C%2B%2B) ## MPpyC docs **Get started** - [Introduction](#introduction) - [Resources](#resources) **Organization** - [Structure](#structure) + [main.py](#main.py) + [bindings](#bindings) + [libMPCC](#libMPCC) + [params](#params) + [python_code](#python_code) - [Domain Model](#domain_model) **Going further** - [Customization](#customization) + [Adding custom sensors](#adding-custom-sensors) ## Introduction This MPC is written in python and uses Alex Liniger's [MPCC](https://github.com/alexliniger/MPCC/tree/master/C%2B%2B) in C++. ## Resources ### Boost.Python [Boost.Python](https://www.boost.org/doc/libs/1_66_0/libs/python/doc/html/index.html) is a C++ library which enables seamless interoperability between C++ and the Python programming language. The library includes support for: - References and Pointers - Globally Registered Type Coercions - Automatic Cross-Module Type Conversions - Efficient Function Overloading - C++ to Python Exception Translation - Default Arguments - Keyword Arguments - Manipulating Python objects in C++ - Exporting C++ Iterators as Python Iterators - Documentation Strings ### Nlohmann JSON [Nlohmann JSON](https://github.com/nlohmann/json) is a library for an easy use of JSON in C++. ## Structure Explained directory and file structure. ### main.py The behaviour of the _main_ can be summarized as follows: - Loads configuration parameters from a JSON file. - Initialises the variables (plotter for the graphs, an interface used to call the MPCC methods and the initial state). - In a loop gets the action from the MPCC, makes the step forward and logs the moves. ### bindings The bindings directory contains the C++ code that works as intermediate to call the MPCC methods. The class _python_interface_ has an header where the structs _TrackPosNumpy_, _ConsoleFrame_ and StabilityMatrices are defined. ```cpp class PythonInterface { public: PythonInterface(); PythonInterface(std::string path_name); State reset(); MPCReturn run_mpc(State x); State step(State x_old, Input u); TrackPosNumpy get_track(); ConsoleFrame get_console_frame(); StabilityMatrices get_stability_matrices(); private: Integrator* integrator; MPC* mpc; Track* track; double v0; double Ts; int n_sim; std::array<Stage, N + 1> current_stages; }; ``` In three private variables are kept the pointers to the track, the MPC and the integrator. In _python_interface.cpp_ are defined the classes needed in the python code through the Boost.Python library: - _State_ - _Input_ - _OptVariables_ - _MPCReturn_ - _TrackPosNumpy_ - _ConsoleFrame_ - _StabilityMatrices_ ### libMPCC In this directory is contained the code from the Alex Liniger's [MPCC](https://github.com/alexliniger/MPCC/tree/master/C%2B%2B). ### params In the _params_ directory are present the JSON files containing system parameters. ### python_code Here are presents the _plotting.py_ and _stability_checker.py_ files. The first is used to plot graphs with physical informations of the system during the simulation. The second checks the rank of the control matrices and the observation matrix. ## Domain Model ![domain_model](images/domain_model.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully