diff --git a/.flake8 b/.flake8 deleted file mode 100644 index a2296bd..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 120 -extend-ignore = E203,E701 -exclude = __init__.py \ No newline at end of file diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..ba1b677 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,49 @@ +name: pre-commit + +on: + push: + branches: + - main + pull_request: + types: [opened, reopened, synchronize] + +# Prevent parallel runs +concurrency: + group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: ".python-version" + + - name: Create a virtual environment + run: uv venv + + - name: Install the project + run: uv pip install ".[dev]" + + # Cache pip for Python hook installs + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + # Run pre-commit in check-only mode (fail on any diffs) + - name: Run pre-commit (check-only) + uses: pre-commit/action@v3.0.1 + with: + args: run --all-files --show-diff-on-failure \ No newline at end of file diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 8b3801a..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[settings] -py_version=39 -known_first_party=stretch -known_third_party=stretch_body -known_third_party=stretch_urdf -line_length = 100 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e16ccc0..827a998 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,25 +3,13 @@ repos: rev: v4.6.0 hooks: - id: check-added-large-files - - - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - - - repo: https://github.com/pycqa/isort - rev: 5.11.5 - hooks: - - id: isort - args: ["--profile", "black", "--filter-files"] - - - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - args: ["--config=.flake8"] - + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-xml + - id: check-yaml - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.981 @@ -38,22 +26,13 @@ repos: - --no-strict-optional - --disable-error-code=override - --disable-error-code=attr-defined - - - # Beautysh formats Bash scripts - - repo: https://github.com/lovesegfault/beautysh - rev: v6.2.1 - hooks: - - id: beautysh - - # Mdformat formats Markdown files - - repo: https://github.com/executablebooks/mdformat - rev: 0.7.16 - hooks: - - id: mdformat # Codespell checks the code for common misspellings - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: - - id: codespell \ No newline at end of file + - id: codespell + description: Checks for common misspellings in text files. + entry: codespell --skip="*ipynb" + language: python + types: [text] \ No newline at end of file diff --git a/README.md b/README.md index 728edc9..bd7b412 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) - + This library provides a simulation stack for Stretch, built on [MuJoCo](https://github.com/google-deepmind/mujoco). There is position control for the arm, head, and gripper joints, velocity control for mobile base, calibrated camera RGB + depth imagery, 2D spinning lidar scans, and more. There is a visualizer that supports [user interaction](https://youtu.be/2P-Dt-Jfd6U), or a more efficient headless mode. There is a [ROS2 package](https://github.com/hello-robot/stretch_ros2/tree/humble/stretch_simulation), built on this library, that works with Nav2, Web Teleop, and more. There is 100s of permutations of Robocasa-provided kitchen environments that Stretch can spawn into. The MuJoCo API can be used for features like deformables, procedural model generation, SDF collisions, cloth simulation, and more. @@ -45,8 +45,8 @@ uv run launch_sim.py To exit, press `Ctrl+C` in the terminal.

- - + +

> On MacOS, if `mjpython` fails to locate `libpython3.10.dylib` and `libz.1.dylib`, run these commands: @@ -96,8 +96,8 @@ uv run examples/robocasa_environment.py Ignore any warnings. - - + + ## Writing Code @@ -213,6 +213,16 @@ Check out the following documentation resources: All the enhancements/missing features/Bugfixes are tracked by [Issues](https://github.com/hello-robot/stretch_mujoco/issues) filed. Please feel free to file an issue if you would like to report bugs or request a feature addition. +## Contributing + +This repository uses [pre-commit hooks](https://pre-commit.com/). + +Install pre-commit in the dev optional dependencies: `uv pip install ".[dev]` + +Install the hooks locally: cd to the top-level of this repository and run `pre-commit install`. + +Run pre-commit manually: `pre-commit run --all-files` + ## Acknowledgment -The assets in this repository contain significant contributions and efforts from [Kevin Zakka](https://github.com/kevinzakka) and [Google Deepmind](https://github.com/google-deepmind), along with others in Hello Robot Inc. who helped us in modeling Stretch in Mujoco. Thank you for your contributions. +The assets in this repository contain significant contributions and efforts from [Kevin Zakka](https://github.com/kevinzakka) and [Google Deepmind](https://github.com/google-deepmind), along with others in Hello Robot Inc. who helped us in modeling Stretch in Mujoco. Thank you for your contributions. \ No newline at end of file diff --git a/stretch_mujoco/mujoco_server_camera_manager.py b/stretch_mujoco/mujoco_server_camera_manager.py index 5720b17..101f9d3 100644 --- a/stretch_mujoco/mujoco_server_camera_manager.py +++ b/stretch_mujoco/mujoco_server_camera_manager.py @@ -96,7 +96,7 @@ def _pull_camera_data(self): def _create_camera_renderer(self, for_camera: StretchCameras): settings = for_camera.initial_camera_settings - # Update mujoco's offscreen gl buffer size to accomodate bigger resolutions: + # Update mujoco's offscreen gl buffer size to accommodate bigger resolutions: offscreen_buffer_width = self.mujoco_server.mjmodel.vis.global_.offwidth offscreen_buffer_height = self.mujoco_server.mjmodel.vis.global_.offheight diff --git a/stretch_mujoco/mujoco_server_passive.py b/stretch_mujoco/mujoco_server_passive.py index e2cb115..ed40241 100644 --- a/stretch_mujoco/mujoco_server_passive.py +++ b/stretch_mujoco/mujoco_server_passive.py @@ -77,7 +77,7 @@ def _run_ui_simulation(self, show_viewer_ui: bool): ) # 1/Hz.Put the UI thread to sleep so that the physics thread can do work, to mitigate `viewer.lock()` locking physics thread. click.secho( - f"Using the Mujoco Passive Viewer. Note: UI thread and camera rendering is capped to {1/UI_FPS_CAP_RATE}Hz to increase performance. You can set this rate using the `camera_rate` arugment.", + f"Using the Mujoco Passive Viewer. Note: UI thread and camera rendering is capped to {1/UI_FPS_CAP_RATE}Hz to increase performance. You can set this rate using the `camera_rate` argument.", fg="green", )