forked from pollen-robotics/AmazingHand
-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor PythonExamples/AHControl to add configuration and unit tests #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb92a8a
Refactor PythonExamples to add configuration and unit tests
Juliaj eb5869e
Handtracking with webcam
Juliaj 7e9c612
Refactor to consolidate configuration for both rust code and python code
Juliaj 97ba096
Refactor mj_mink files
Juliaj a2f3697
Fix CI
Juliaj aebb365
Remove unused file
Juliaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: {} | ||
| pull_request: {} | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| lint-and-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: prefix-dev/setup-pixi@v0.9.4 | ||
| with: | ||
| cache: ${{ !env.ACT }} | ||
|
|
||
| - name: Install system deps for AHControl (Rust) | ||
| run: sudo apt-get update && sudo apt-get install -y libudev-dev pkg-config | ||
|
|
||
| - name: Run pre-commit | ||
| run: pixi run pre-commit run --all-files | ||
|
|
||
| - name: PythonExample unit tests | ||
| run: pixi run test-python-example | ||
|
|
||
| - name: Demo unit tests | ||
| run: pixi run test-demo | ||
|
|
||
| - name: Demo AHSimulation (mj_mink) unit tests | ||
| run: pixi run test-demo-mj-mink | ||
|
|
||
| - name: AHControl (Rust) unit tests | ||
| run: pixi run test-ahcontrol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| *.pyc | ||
| push.json | ||
| .pytest_cache/ | ||
|
|
||
| # Python package metadata (pip install -e) | ||
| *.egg-info/ | ||
|
|
||
| # Rust build output | ||
| target/ | ||
|
|
||
| # Dora / local output and logs | ||
| Demo/out/ | ||
| out/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # See https://pre-commit.com for usage. All hooks limited to PythonExample/. | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| files: ^PythonExample/ | ||
| - id: end-of-file-fixer | ||
| files: ^PythonExample/ | ||
| exclude: \.pytest_cache | ||
| - id: check-yaml | ||
| files: ^PythonExample/ | ||
| - id: check-added-large-files | ||
| args: ["--maxkb=1000"] | ||
| files: ^PythonExample/ | ||
| - id: check-merge-conflict | ||
| files: ^PythonExample/ | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.8.4 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix] | ||
| files: ^PythonExample/ | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: pytest | ||
| name: pytest | ||
| entry: bash -c 'cd PythonExample && PYTHONPATH= pixi run python -m pytest tests/ -v' | ||
| language: system | ||
| pass_filenames: false | ||
| files: ^PythonExample/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,39 @@ | ||
| # Motor control node | ||
|
|
||
| The motor configuration is set in a TOML file (cf. [r_hand.toml](config/r_hand.toml)). | ||
| In this file you can set the motors ID, and angle offsets for each finger. | ||
| Use canonical calibration from the repo `config/calibration/` (recommended): e.g. `--config ../../config/calibration/r_hand_team_julia.toml` when running from Demo/AHControl. See [canonical_hand_config_design.md](../../docs/canonical_hand_config_design.md). Finger order is read from `config/hand_geometry.toml` when using a calibration file under `config/calibration/`. Alternatively, a legacy TOML under AHControl `config/` (e.g. [r_hand.toml](config/r_hand.toml)) is still supported for motor IDs and angle offsets. | ||
|
|
||
| # Tools | ||
| - *change_id*: to help you change the id of a motor. `cargo run --bin=change_id -- -h` for a list of parameters | ||
| - *goto*: to move a single motor to a given position. `cargo run --bin=goto -- -h` for a list of parameters | ||
| - *get_zeros*: to help you set the motor zeros, it sets the motors in the compliant mode and write the TOML file to the console. `cargo run --bin=get_zeros -- -h` for a list of parameters | ||
| - *set_zeros*: to move the hand in the "zero" position according to the config file. `cargo run --bin=set_zeros -- -h` for a list of parameters | ||
|
|
||
| # Calibration | ||
|
|
||
| Full procedure (verify IDs, create calibration file, get_zeros, set_zeros, run with profile) is in [docs/canonical_hand_config_design.md](../../docs/canonical_hand_config_design.md) under "Calibration procedures". | ||
|
|
||
| # Commands | ||
|
|
||
| Run from the project root. If you use pixi for Rust, run `pixi shell` first. Set `PORT` to your serial device (e.g. `/dev/ttyACM0` on Linux, `COM3` on Windows). For canonical calibration use a file under `config/calibration/` (e.g. `config/calibration/r_hand_team_julia.toml`). | ||
|
|
||
| Linux: | ||
|
|
||
| ```bash | ||
| export PORT=/dev/ttyACM0 | ||
| export CFG="config/calibration/r_hand_team_julia.toml" | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=set_zeros -- --serialport $PORT --config $CFG | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=goto -- --serialport $PORT --id 1 --pos 0.0 | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=change_id -- --serialport $PORT --old-id 1 --new-id 2 | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=get_zeros -- --serialport $PORT --config $CFG | ||
| ``` | ||
|
|
||
| Windows (PowerShell): | ||
|
|
||
| ```powershell | ||
| $PORT = "COM3" | ||
| $CFG = "config/calibration/r_hand_team_krishan.toml" | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=set_zeros -- --serialport $PORT --config $CFG | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=goto -- --serialport $PORT --id 1 --pos 0.0 | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=change_id -- --serialport $PORT --old-id 1 --new-id 2 | ||
| cargo run --manifest-path Demo/Cargo.toml --bin=get_zeros -- --serialport $PORT --config $CFG | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using Rust vs. just python? or is this for future development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a refactoring, I wanted to make sure all demos (rust + python) still run. We can decide whether we want to use Rust for development. Rust is also new to me.