Skip to main content

Tools for bionics research

Project description

pyonics

A Python library for simulating and controlling pneumatic artificial muscles using Klamp't robotics library.

Quick Start

Install:

pip install pyonics

Create a controller:

import klampt
from pyonics import ExoController, MuscleEmulator

# Load configuration
config = {
    "has_robworld": True,
    "world_path": "data/world.xml",
    "core": "data/robot.rob",
    "attachments": "data/muscles.csv",
    "timestep": 0.01,
    "address": "127.0.0.1",
    "port": 5005
}

pcm = ExoController(config)

Create a dataframe of muscles that looks like the following:

name;link_a;link_b;transform_a;transform_b;label_a;label_b;turns;r_0;l_0;weave_length;max_pressure

right_inferior_latissimus;9;4;0,0,0;0,-1,0;superior;inferior;20;1;2;2;80000
import pandas as pd
from klampt.sim.simulation import SimpleSimulator

sim = SimpleSimulator(pcm.world)

muscleinfo_df = pd.read_csv(config['attachments'], sep=";")

for _, row in muscleinfo_df.iterrows():
    row = muscleinfo_df.iloc[x] 
    muscle = MuscleEmulator(row, pcm, sim)
    sim.addEmulator(pcm.robot, muscle)

Start simulation:

import asyncio

async def startup():
    await pcm.setup_osc_server()
    await pcm.server.enable_osc_logging()
    
    running = True
    while running:
        sim.simulate(0.01)
        await asyncio.sleep(0.01)
        
asyncio.run(startup())

Features

  • Pneumatic muscle emulation
  • Pressure-driven actuation
  • Klamp't simulator integration
  • OSC network control

Requirements

  • Python 3.x
  • Klamp't installed
  • python-osc
  • differint

Configuration Format

has_robworld: Boolean. Currently must be true.

world_path: Filepath to the world, in XML format.

core: Filepath to the robot, in .rob format.

attachments: Filepath to the muscle attachment CSV.

timestep: Control rate for the robot.

address: IP address. Currently only tested locally.

port: Networking port to receive on.

Muscle Attachment DataFrame Format

name: A name for the muscle.

link_a: The index of the first robot link to attach to.

link_b: The index of the second robot link to attach to.

transform_a: The local transform on link A to attach to.

transform_b: The local transform on link B to attach to.

label_a: For convenience. Functionality not yet implemented.

label_b: For convenience. Functionality not yet implemented.

turns: Number of turns in the weave.

r_0: Resting radius of the muscle.

l_0: Resting length of the muscle.

weave_length: Length of the weave surrounding the muscle.

pressure: Pressure of the muscle. Updated with muscle commands.

Acknowledgments

Thanks to Dr. Paul Savala, my research advisor, for support in developing this library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyonics-2.1.0.tar.gz (96.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyonics-2.1.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file pyonics-2.1.0.tar.gz.

File metadata

  • Download URL: pyonics-2.1.0.tar.gz
  • Upload date:
  • Size: 96.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyonics-2.1.0.tar.gz
Algorithm Hash digest
SHA256 7e07d2fdea0cc73c2f82ef3759af136761120a5c4bee8d5c82fb4d978560536e
MD5 8ebf33c7b248f7baf5db544e8b5a096d
BLAKE2b-256 3657a353c67f478221a6ad645eb99020ed87c622e806a67133d45c8a8dc000bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyonics-2.1.0.tar.gz:

Publisher: ci.yml on pyromakesmusic/pyonics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyonics-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyonics-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyonics-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17671eba7f742104783c5fe266ad4db80c76dff1e904ec8d16229660d206818d
MD5 4099175a77802acd7ae53b8d525feeb6
BLAKE2b-256 36b70138d7ce3f40b37626d3d6be034cc1f30dfaa6c4c1b891311ab18cfcc405

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyonics-2.1.0-py3-none-any.whl:

Publisher: ci.yml on pyromakesmusic/pyonics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page