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.0

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.0
File Size Uploaded Provenance
virtualmodelcontrol-1.2.0.tar.gz 1.1 MB With provenance Details

Built distribution (wheel)

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

Total release size: 1.4 MB

Release files / virtualmodelcontrol-1.2.0.tar.gz

Download URL virtualmodelcontrol-1.2.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
5f154a4ebc81178216eb455024b686f7d764f073e9b53781dbc079a1e8ce26e4
BLAKE2b-256 checksum
How to use checksums
d219c6e91e54d23fece4fe08e29f716ca9f59c36d5b54cd4a9c7b1e20729639b
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 9, 2026.

Transparency log

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

Download URL virtualmodelcontrol-1.2.0-py3-none-any.whl
Size 239.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6f63c6f1a1c7acc1ea2a0364bdce23f39d6623a2f094bc946dc4f18973b694c
BLAKE2b-256 checksum
How to use checksums
b7c7305a8d8358e475ad8152b7db5e9d7f4d097a784f1c34604f099256dea8c2
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 9, 2026.

Transparency log

Security for virtualmodelcontrol 1.2.0

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.0.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 9, 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