Skip to main content

CREATE Lab, EPFL

VirtualModelControl

virtualmodelcontrol is a Python library for Virtual Model Control. You build a controller by attaching virtual springs, dampers and masses to your robot, and the library turns them into motor torques at the control rate, in simulation and on the real robot.

virtualmodelcontrol logo   Documentation: tutorials, examples, API

A soft arm whose tip a virtual spring pulls towards a goal, and the distance from the tip to the goal over time

Install

pip install virtualmodelcontrol

The newest code, from GitHub, before it is released (the same line updates an existing install):

pip install --upgrade "git+https://github.com/vigno0405/VirtualModelControl.git"

Virtual environments, conda, ROS 2 and pinned versions are covered in Installation.

Requirements

Python 3.10 or newer, tested with 3.10 to 3.14 on Ubuntu 22.04 and 24.04, and with the oldest versions of the packages below. Nothing to compile; ROS and LaTeX are not needed.

Dependencies

pip installs them with the library:

Package Version Used for
numpy 1.26 or newer, 2.x included arrays
CasADi 3.6 or newer the symbolic models, their derivatives and the compiled controllers
SciPy 1.11 or newer rotations of chains built from DH tables; fitting stiffness and damping
matplotlib 3.8 or newer figures and animations
imageio-ffmpeg 0.5 or newer MP4 videos of the animations
PyYAML 6 or newer robot and hardware files
PyTorch (optional, pip install virtualmodelcontrol[torch]) 2.0 or newer models as PyTorch code

The example in the figure

The robot and the controller are two separate mechanisms: the robot mechanism describes the hardware, and the controller holds the virtual elements placed on it.

import numpy as np
import virtualmodelcontrol as vmc
from virtualmodelcontrol.robots import helyx

arm = helyx.arm("145-145-145")  # a soft arm with nine tendon motors
tip = arm.point(s=1.0)

ctrl = vmc.Mechanism("ctrl")
ctrl.add("reach", vmc.LinearSpring(tip - [0.15, 0.0, 0.35], 600.0))  # [N/m]
ctrl.add("damp", vmc.LinearDamper(tip, 5.0))  # [N·s/m]
ctrl.add("gravity", vmc.GravityCompensation(arm))
controller = vmc.VMCController(vmc.compile(vmc.VirtualMechanismSystem(arm, ctrl)))

meas = vmc.Signals(0.0, motor_position=np.zeros(9), motor_velocity=np.zeros(9))
torques = controller.step(0.0, meas)["motor_torque"]  # [N·m], one per motor

The same controller runs on a simulation built from the robot's own masses, stiffness and damping; readme_figure.py draws the figure from this run.

arm = helyx.add_dynamics(arm)
plant = vmc.sim.ModelPlant(arm)
log = vmc.sim.run(plant, controller, vmc.sim.SimClock(dt=1 / 330), T=3.0)

Examples

Each example builds a ready-made robot, controls it in simulation and animates the run:

  • Soft arm: reach past an obstacle, and limit the force with a tanh spring.
  • Hanging soft arm: identify its stiffness and damping, and reach around an obstacle.
  • Two arms: squeeze an object between the tips of two soft arms.
  • Finger: a stiff fingertip and soft joint limits.
  • Hand: grasp a ball, alone or mounted on a UR5 arm.
  • Turtle: two cranks that follow a virtual flywheel.

Documentation

The documentation holds the tutorials, the examples, the concepts and the API. What changed is in the changelog, what comes next in the roadmap, and how to contribute in Contributing.

Authors

Lorenzo Vignoli, at the CREATE Lab of EPFL (Prof. Josie Hughes), in a collaboration with the University of Cambridge (Prof. Fulvio Forni). To cite the library, see CITATION.cff. The code is under the MIT license.

Metadata

Release files for virtualmodelcontrol 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for virtualmodelcontrol 1.2.1
File Size Uploaded Provenance
virtualmodelcontrol-1.2.1.tar.gz 1.1 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for virtualmodelcontrol 1.2.1
File Interpreter ABI Platform
virtualmodelcontrol-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / virtualmodelcontrol-1.2.1.tar.gz

Download URL virtualmodelcontrol-1.2.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
8c499acbe439669cd343934f6c0a580541924d523f1e820e747d5819cfb5ed15
BLAKE2b-256 checksum
How to use checksums
08238d16686a1d92a761e3c86877bd1408d245927c260b89bed10ecb5996c4cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / virtualmodelcontrol-1.2.1-py3-none-any.whl

Download URL virtualmodelcontrol-1.2.1-py3-none-any.whl
Size 239.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8da4ec55ecb8d12986361c4729779310a6ed709133866c630eec0349aba5b3f
BLAKE2b-256 checksum
How to use checksums
e9d65442da692dd270cc05d1e6be1257f4210ddbd54467eadd3d291e5d277bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Security for virtualmodelcontrol 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for virtualmodelcontrol-1.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page