Installation

Install pycapacity with pip (tested with Python 3.10 and newer):

pip install pycapacity

and import the modules you need:

import pycapacity.robot        # robot capacity metrics
import pycapacity.human        # human musculoskeletal capacity metrics
import pycapacity.algorithms   # the polytope algorithms
import pycapacity.objects      # Polytope and Ellipsoid
import pycapacity.visual       # matplotlib plotting

Optional extras

  • pip install pycapacity[fast] adds the compiled backend pycapacity-cpp: 6 to 50 times faster polytopes, used automatically (see C++ acceleration)

  • pip install pycapacity[cvxopt] adds cvxopt (GLPK): slightly faster linear programs for small problems, and the 'qp' option of human.torque_to_muscle_force

  • pip install pycddlib pypoman adds the reference methods: the exact pycapacity.polyhedral functions, used for comparisons

The extras can be combined: pip install "pycapacity[fast,cvxopt]".

The compiled backend is distributed as pre-built wheels for Linux (x86_64, aarch64), macOS (Apple Silicon and Intel) and Windows, so no compiler is needed.

Installing from source

Directly from the git repository:

pip install git+https://github.com/auctus-team/pycapacity.git

or, to modify the code, clone it and install it in editable mode:

git clone https://github.com/auctus-team/pycapacity.git
cd pycapacity
pip install -e .

and run the unit tests to check the installation:

pip install pytest
pytest tests

The compiled backend from source

Building pycapacity-cpp needs a C++17 compiler and CMake; its dependencies (Eigen, Qhull, HiGHS) are downloaded during the build if they are not found. From the repository folder:

pip install ./cpp

With conda, the environment file installs everything, compiler included, from conda-forge:

conda env create -f cpp/environment.yml
conda activate pycapacity

Robotics and biomechanics libraries

pycapacity only needs numpy arrays (Jacobians, mass matrices, limits), so it works with any library that provides them. The tutorials use:

  • pinocchio and robot_descriptions: pip install pin robot_descriptions

  • robotics-toolbox-python: pip install roboticstoolbox-python

  • mujoco: pip install mujoco

  • biorbd (conda only): conda install -c conda-forge biorbd

  • opensim (conda only): conda install -c opensim-org opensim

See the tutorials for robots, human models and polytopes for complete examples.