Skip to main content

MuscledAgents

OpenAI Gym MuJoCo environments rigged with muscles which can be used with PyMuscle fatigable muscle models.

Prerequisites

  • MuJoCo 1.5
  • mujoco-py
  • gym

Setup

python setup.py develop

Usage

import gym
import muscledagents
import math


def main():

    # Load a muscled ant
    env = gym.make("MuscledAnt-v0")  # Only functional env at the moment
    env.reset()

    print("Observation Space Dims", env.observation_space.shape)
    print("Action Space Dims", env.action_space.shape)

    action_size = env.action_space.shape[0]

    action = [0.0] * action_size
    total_steps = 60 * 10
    for i in range(total_steps):
        action[1] = ((math.sin(i / 25) + 1) / 2)
        action[5] = ((math.sin(i / 35) + 1) / 2)
        action[9] = ((math.sin(i / 45) + 1) / 2)
        action[13] = ((math.sin(i / 55) + 1) / 2)
        env.step(action)
        env.render()


if __name__ == '__main__':
    main()

To explore these environments and models further you will need to understand how input values get translated into final simulated movements.

Control Signals

The action space for an ant is continuous control over 16 muscles. For each of four legs there are four muscles. One leg extensor, one leg flexor, and two hip muscles which move the leg left and right (or forward and back depending on your perspective.)

Gym Environment

The step method takes an array of 16 values which represent the input to the fatigable muscle model for each muscle. Inputs should be in the range [0-1].

PyMuscle Fatigue

After use muscles produce less force for the same level of input. So if you were to send an input signal which recruited all motor units in a muscle constantly for several seconds the output the model will return will rapidly decrease. A period of light or no use is required for the muscle to recover.

MuJoCo Model

Each tendon actuator is control limited to the range [-1.0, 0.0]. When a General actuator is tied to a Tendon in MuJoCo negative values are the equivalent of contractions. Muscles cannot produce force in extension so no positive non-zero values are allowed.

Actuators have a gainprm which scales this input value. This is tuned to a value of 100 to work with the mass of the ant and the resistances of opposing tendons.

Altering the Models

Due to frustration editing XML files the ant model is generated by a python script that uses the mjcf library which I wrote to wrap MuJoCo xml elements in python classes. Note: This may be replaced with the mjcf library from dm_control in the future.

You can view and modify that script in scripts/gen_ant.py.

Metadata

Release files for muscledagents 0.0.2

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

Source distribution (sdist)

Source distribution for muscledagents 0.0.2
File Size Uploaded Provenance Actions
muscledagents-0.0.2.tar.gz 9.6 kB Without provenance Details for muscledagents-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for muscledagents 0.0.2
File Interpreter ABI Platform Actions
muscledagents-0.0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details for muscledagents-0.0.2-py2.py3-none-any.whl

Total release size: 21.2 kB

Release files / muscledagents-0.0.2.tar.gz

Download URL muscledagents-0.0.2.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
751a2c761e9116851e5e41e18a4ae4874714f7eafc53daa7b0794540bacc7882
BLAKE2b-256 checksum
How to use checksums
e3e59d86ab638449ed13f6d628c536095702a89a4dab6d9a30214561b75e06db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.5

Release files / muscledagents-0.0.2-py2.py3-none-any.whl

Download URL muscledagents-0.0.2-py2.py3-none-any.whl
Size 11.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fe54b7dbe8cc5b0795e1d204efb09e59e92719ded387bf6db00ce9b2ce9fb880
BLAKE2b-256 checksum
How to use checksums
20af06ec09e21a5f79ab4d1eedc8eff35bb508723b536472e2a7f2e88db700ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.5

Security for muscledagents 0.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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