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. 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
Dynamixel SDK 3.7 or newer Dynamixel motors (leaves in 0.4.0)
pyserial 3.5 or newer the serial port of the Dynamixel SDK (leaves in 0.4.0)

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 0.3.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 0.3.0
File Size Uploaded Provenance
virtualmodelcontrol-0.3.0.tar.gz 508.6 kB With provenance Details

Built distribution (wheel)

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

Total release size: 652.4 kB

Release files / virtualmodelcontrol-0.3.0.tar.gz

Download URL virtualmodelcontrol-0.3.0.tar.gz
Size 508.6 kB
Tags Source
SHA-256 checksum
How to use checksums
296649ae9d9bac1eb2c4c925c96cefc814c29a04ecf42755ad6cb159e545f96a
BLAKE2b-256 checksum
How to use checksums
e8e6e2b2b4178d2d50de3c52a55d07f1f8081ccd9e1587d48bf7af09dbdc7341
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 5, 2026.

Transparency log

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

Download URL virtualmodelcontrol-0.3.0-py3-none-any.whl
Size 143.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3131e2e9d64b30e1bc0349c9aafb3196a25f38b98abff4403ed5808a8110c907
BLAKE2b-256 checksum
How to use checksums
dcd26b25dd75b15b87502ad023bf3d601f7a6c8480ff1a78db44f7c428525455
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 5, 2026.

Transparency log

Security for virtualmodelcontrol 0.3.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-0.3.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 5, 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