A simple dynamics simulator for a configurable planar robot arm.
Project description
skelarm
A lightweight, physics-based dynamics simulator for a configurable planar robot arm. skelarm focuses on kinematics and dynamics simulation without collision detection or complex shape rendering, treating the robot as a "skeleton" of links.
Features
- Configurable Robot: Define arbitrary planar robots with custom link lengths, masses, inertias, and centers of mass. Support for TOML configuration files.
- Kinematics:
- Forward Kinematics (FK) to compute end-effector position from joint displacements.
- Dynamics (Planar, No Gravity):
- Inverse Dynamics (ID) using Recursive Newton-Euler algorithm.
- Forward Dynamics (FD) using mass matrix and Coriolis/centrifugal terms.
- Physics integration using
scipy.integrate.solve_ivp. - Note: Gravity is explicitly ignored as the robot operates on a horizontal plane.
- Visualization:
- Static plotting with
matplotlib. - Interactive GUI visualizer with
PyQt6and joint sliders.
- Static plotting with
- Quality Assurance: Fully typed, tested with
pytestandhypothesis, and linted withruff.
Getting Started
Prerequisites
- Python 3.12 or higher.
uvpackage manager (recommended) or standardpip.
Installation
-
Clone the repository:
git clone https://github.com/hrshtst/skelarm.git cd skelarm
-
Install dependencies using
uv(Recommended):uv syncOr using
make:make installAlternatively, using pip:
pip install .
Usage Examples
TOML Configuration
You can define robot configurations in TOML files. See examples/simple_robot.toml or examples/four_dof_robot.toml.
[[link]]
length = 1.0
mass = 2.0
inertia = 0.5
com = [0.5, 0.0] # Center of mass [x, y] relative to joint
limits = [-180.0, 180.0] # Joint limits [min, max] in degrees
[[link]]
length = 0.8
# ...
Load it using Skeleton.from_toml:
from skelarm import Skeleton
skeleton = Skeleton.from_toml("path/to/robot.toml")
4-DOF Simulation Example
Run a dynamic simulation of a 4-DOF robot loaded from a TOML file:
uv run python examples/simulate_four_dof.py
Interactive Visualizer
Launch the PyQt6 GUI to manipulate a 3-link robot arm with sliders:
uv run python examples/interactive_gui.py
Basic Kinematics & Plotting
Run a script that defines a robot, computes its kinematics, and plots it using Matplotlib:
uv run python examples/basic_plotting.py
Dynamics Simulation
You can use the library to simulate robot motion. See src/skelarm/dynamics.py and tests/test_dynamics.py for API usage.
from skelarm import LinkProp, Skeleton, simulate_robot
import numpy as np
# Define a single link
link = LinkProp(length=1.0, m=1.0, i=0.1, rgx=0.5, rgy=0.0, qmin=-np.pi, qmax=np.pi)
skeleton = Skeleton([link])
# Initial state
skeleton.q = np.array([0.0])
skeleton.dq = np.array([0.0])
# Simulation parameters
time_span = (0.0, 1.0)
def control_torques(t, skel):
return np.array([0.0]) # Zero torque
# Run simulation
times, q_traj, dq_traj = simulate_robot(skeleton, time_span, control_torques)
Running Tests
This project uses pytest for unit testing and hypothesis for property-based testing of physics consistency.
To run the full test suite:
make test
# OR
uv run pytest
To run tests with coverage report:
make test-cov
Development
We use ruff for linting and formatting, and pyright for static type checking.
- Linting:
make lint - Formatting:
make format - Type Checking:
make type-check - Run all checks:
make all
Documentation
The project documentation is built using MkDocs.
- Build Documentation:
make docs-build - Serve Documentation Locally:
make docs-serve
License
GPLv3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skelarm-0.1.0.tar.gz.
File metadata
- Download URL: skelarm-0.1.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d52015c15bc5eee599f5307f31eefb44d04812ed936b416a8d42e5c959562c6
|
|
| MD5 |
617a78b747dfef86bb24e5f04ecc5807
|
|
| BLAKE2b-256 |
c898c9fd82b5257fb37a665071b57de8ee0ccc380e0d90a31424cfc81d29ad7c
|
Provenance
The following attestation bundles were made for skelarm-0.1.0.tar.gz:
Publisher:
release.yml on hrshtst/skelarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skelarm-0.1.0.tar.gz -
Subject digest:
4d52015c15bc5eee599f5307f31eefb44d04812ed936b416a8d42e5c959562c6 - Sigstore transparency entry: 767115793
- Sigstore integration time:
-
Permalink:
hrshtst/skelarm@304f056516d9f26cdc00b875448b73b4d20186a2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hrshtst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@304f056516d9f26cdc00b875448b73b4d20186a2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file skelarm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: skelarm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb7995e17660efe66f89bd9c64e6d5c74d09f3ef4543f02f6e6537aaccdeb302
|
|
| MD5 |
6698f931ebdcc646c471e6f3b443cb9d
|
|
| BLAKE2b-256 |
604e1f95acd27a58f4df1aeed40c97839248eeb747c1c112566565dee5820314
|
Provenance
The following attestation bundles were made for skelarm-0.1.0-py3-none-any.whl:
Publisher:
release.yml on hrshtst/skelarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skelarm-0.1.0-py3-none-any.whl -
Subject digest:
eb7995e17660efe66f89bd9c64e6d5c74d09f3ef4543f02f6e6537aaccdeb302 - Sigstore transparency entry: 767115801
- Sigstore integration time:
-
Permalink:
hrshtst/skelarm@304f056516d9f26cdc00b875448b73b4d20186a2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hrshtst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@304f056516d9f26cdc00b875448b73b4d20186a2 -
Trigger Event:
release
-
Statement type: