Skip to content

Commit

Permalink
code upload
Browse files Browse the repository at this point in the history
  • Loading branch information
driesmarzougui committed Feb 9, 2024
1 parent 8e99fa8 commit 43fb85f
Show file tree
Hide file tree
Showing 21 changed files with 2,370 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Format code with Black
uses: psf/black@stable
with:
src: moojoco_env/
34 changes: 34 additions & 0 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Co-Evolve
Copyright (c) 2023 Co-Evolve

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements.txt
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# moojoco-utils
A unified framework for implementing and interfacing with MuJoCo and MuJoCo-XLA simulation environments.
# moojoco-env

**moojoco-env** provides a unified framework for implementing and interfacing with MuJoCo and MuJoCo-XLA simulation
environments.
The main goal of this framework is to **unify** the development and interfaces of environments implemented in native
MuJoCo (MJC) and MuJoCo-XLA (MJX).

## MJCFMorphology and MJCFArena

* Both are parameterized/reconfigurable MJCF (MuJoCo-XML) generators that serve as input to an environment.
* MJCFMorphology defines the robot morphology.
* MJCFMorphologies are parameterized using
the [Framework for Parameterized Robot Specifications (FPRS)](https://github.com/Co-Evolve/fprs).
* MJCFMorphologies follow a modular design, dividing the robot into distinct parts.
* MJCFArena defines the arena in which the robot is places (i.e. all non-morphological structures).
* MJCFArena are reconfigurable via a `ArenaConfig[requirements.txt](requirements.txt)uration`
* reconfigurable via a configuration
[requirements.txt](requirements.txt)

## Unified MJC and MJX environment in[README.md](README.md)terface

* Reconfigurable through an environment configuration
* Functional programming
* MJX requires the functional programming paradigm. To unify MJC and MJX, we thus apply this stronger coding
constraint to the MJC side as well.
* Simply said: functions are pure, and should not have side effects.
* Environments expect states and return states.
* Gymnasium-like interface
* Environments provide an observation and action space (automatically)
* Outside code interacts with the environment using the typical `step`, `reset`, `render` and `close` functions.
* Main difference with the original gymnasium interface: here the environment returns and expects states, which
encapsulates the original observations, rewards, info, etc. in a datastructure, together with the underlying
physics state.
* Differences between MJCEnv (i.e. a native MuJoCo environment) and MJXEnv (i.e. an MJX environment):
* development: MJXEnv's should be implemented in JAX, MJCEnv's do not necessarily require JAX.
* usage: MJXEnvState contains JAX arrays (and the additional mjx.Model and mjx.Data structures), the MJCEnvState
uses numpy arrays.
* Observations are implemented using Observables; these define retriever functions that extract the observation based on
the state datastructure and provide an easy way to implement observations.
* DualMuJocoEnvironment provides the unification of MJC and MJX, and allows conditional environment creation based on
a backend string.
* Both MJC and MJX support human-mode and rgb_array rendering modes.
* Note: MJX rendering is slow due to the offloading of datastructures of the GPU

## Examples

For practical applications and demonstrations of **moojoco-env**, please refer to
the [Bio-inspired Robotics Benchmark](https://github.com/Co-Evolve/brb),
which employs this framework extensively.

## Installation

``pip install moojoco-env``
Empty file added moojoco_env/__init__.py
Empty file.
Empty file.
Loading

0 comments on commit 43fb85f

Please sign in to comment.