MBsysPy

MBsysPy is a wrapper of MBsysC libraries. It allows the user to analyze multibody systems without needing to buy Matlab or to learn C programming language.

In its basic way of work it allows to get an equivalent computation speed as Matlab. However for advanced user it can be used to wrap an entire C project, getting the speed of C compiled libraries while keeping the ability to use Python tools (matplotlib, scipy.optimize) and to adapt on the fly the parameters of the model without any compilation step or opening MBsysPad.

WARNING: MBsysPy is only compatible with 64 bits!

Requirements

MBsysPy requires a Python3 (see below for Python2) distribution with numpy for computation and updated pip for packages installation. Other packages such as matplotlib and scipy are usefull as they allow better vizualization (graphs generation) and analysis tools (optimization, statistical tools…).

For MacOS you can install Anaconda, remember to take the Python 3.X (64 bits) version. It is a distribution of Python that includes by default all the required packages, and a lot more. Moreover it comes with Spyder which is a python IDE.

REMARK:

As Python2 has reached its end of life (since january 2020), we do not check the compatibility of MBsysPy with this version.

Upgrading pip

Installing MBsysPy requires an up-to-date version of pip: pip install -U pip. Refer to the official pip documentation for details.

Installation

The package of MBsysPy is distributed using pip but are hosted on a specific repository. The installation is pretty straightforward:

pip install --index-url https://www.robotran.eu/dist/ MBsysPy --user

The option --index-url redirect pip to our repository, while the option --user is used to install the package in the user folders (avoiding admin access requirements). According to your system configuration this command has to be entered by different way described below.

WARNING:

Depending on your python installation, the aforementioned installation command must be entered in specific consoles. Please read the following sections, depending on your configuration, before running the installation command.

MBsysPy without Anaconda

MBsysPy is a classical python package just as numpy or scipy for example. It can be installed within any python environment. Although we advise you to install it within Anaconda, you can chose to install it directly on your computer. For this, we advise you to pass by virtual environments using the python venv module.

Open a system terminal and navigate (using cd ... command) to:

  • your MBProject folder to create a global virtual environment for all your Robotran projects (advised if all your Robotran projects will use the same version of MBsysPy),

  • your Robotran specific project folder to create a specific virtual environment for each Robotran project (advised if you will need different MBsysPy versions depending on your Robotran project).

Create the virtual environment using the command:

python -m venv ./.venv

Activate your newly created virtual environment:

source .venv/bin/activate

Write the previous command installation command (pip install ...). According to your system configuration, your terminal may not have access to pip command. In that case prepend the previous command with python -m (it gives: python -m pip install...).

If your system haves both Python 2 and Python 3 installed, you may have to prepend with python3 -m instead of python -m.

Remarks and Testing

According to your system configuration, you may not have access to the packages installed via anaconda (using anaconda-prompt and/or spyder started from anaconda) from python started from the system. If you cannot access the package containing the MBsysPy module, please check KnownTroubleshootings.

After installation, you can check that everything is correct by typing import MBsysPy in Python. If the MBsysPy module is not found, please check KnownTroubleshootings.

Lot of our class and functions are documented (but not all, work still in progress). You can see the related documentation, after importing MBsysPy, in the field __doc__ of the function or class:

import MBsysPy
print(MBsysPy.MbsData.__doc__)
print(MBsysPy.MbsData.__init__.__doc__)
print(MBsysPy.MbsData.set_qdriven.__doc__)

In spyder you can show the documentation in the Object inspector panel (top right) by writing in the Object field, for example: MBsysPy.MbsData or MBsysPy.MbsData.set_qdriven.

Updating MBsysPy

To update the package follow the same installation procedure than used for installation with the command pip install --index-url https://www.robotran.eu/dist/ MBsysPy --user --upgrade instead of the previous one. The only difference is the addition of the option --upgrade.

Using development version

To update the package follow the same installation procedure than used for installation but with the command pip install --index-url https://www.robotran.eu/dist/ MBsysPy --user --upgrade --pre instead of the previous one. The only difference is the addition of the option --pre.