Skip to content

Commit 5253919

Browse files
committed
Add code
1 parent 6b73e99 commit 5253919

39 files changed

+3324
-0
lines changed

.github/workflows/ruff.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: ruff_CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# schedule actions once a week
10+
- cron: "0 0 * * 0"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 1
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install ruff
26+
# Update output format to enable automatic inline annotations.
27+
- name: Run Ruff
28+
run: ruff check --output-format=github .

.github/workflows/unit_tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: unit_tests_CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# schedule actions once a week
10+
- cron: "0 0 * * 0"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
- name: Install dependencies
23+
run: |
24+
pip install uv
25+
uv pip install --system -e .
26+
uv pip install --system pytest
27+
# run pytest on the codebase
28+
- name: Test with pytest
29+
run: pytest

.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$PYTHON_EXTENSIONS
5+
6+
# Virtual environment
7+
venv/
8+
env/
9+
10+
# Distribution / packaging
11+
*.egg-info/
12+
dist/
13+
build/
14+
15+
# Logs and debugging
16+
logs/
17+
*.log
18+
debug.log
19+
nohup.out
20+
21+
# IDE / Editor files
22+
.vscode/
23+
.idea/
24+
*.swp
25+
*.swo
26+
27+
# Jupyter Notebook checkpoints
28+
.ipynb_checkpoints/
29+
30+
# OS-specific files
31+
.DS_Store
32+
Thumbs.db
33+
34+
# Test coverage reports
35+
.coverage
36+
coverage.xml
37+
htmlcov/
38+
*.cover
39+
*.pycover
40+
*.pyc
41+
.tox/
42+
43+
# Docker / Container related
44+
*.dockerfile
45+
*.containerignore
46+
47+
# Compiled files
48+
*.o
49+
*.so
50+
*.a
51+
*.out
52+
53+
# Temporary files
54+
*.tmp
55+
*.cache
56+
*.pid
57+
*.lock
58+
59+
# Ignore Mujoco-related compiled binaries if applicable
60+
mjkey.txt
61+
mjmodel.xml
62+
63+
# SSH / sensitive files (double-check before committing!)
64+
*.pem
65+
*.crt
66+
*.key
67+
68+
# Ignore user-specific configs
69+
config.json
70+
config.yaml
71+
72+
# Ignore large data files (if applicable)
73+
data/
74+
datasets/
75+
*.csv
76+
*.h5
77+
*.npz
78+
*.pickle
79+
80+
# Ignore backup files
81+
*.bak
82+
*.old
83+
84+
# Ignore Python Poetry files (if using)
85+
poetry.lock
86+
87+
# Ignore i2rt and egg metadata
88+
i2rt.egg-info/
89+
90+
# Ignore temporary scripts or generated files
91+
scripts/temp_*/
92+

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.6.8
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
types_or: [ python, pyi, jupyter ]
9+
args: [ --fix ]
10+
# Sort imports
11+
- id: ruff
12+
args: ["check", "--select", "I", "--fix"]
13+
# Run the formatter.
14+
- id: ruff-format
15+
types_or: [ python, pyi, jupyter ]
16+
17+
# cleanup notebooks
18+
- repo: https://github.com/kynan/nbstripout
19+
rev: 0.7.1
20+
hooks:
21+
- id: nbstripout

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) I2RT Robotics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# I2RT Python API
2+
3+
A Python client library for interacting with [I2RT](https://i2rt.com/) products, designed with simplicity and extensibility in mind.
4+
5+
[![I2RT](https://github.com/user-attachments/assets/025ac3f0-7af1-4e6f-ab9f-7658c5978f92)](https://i2rt.com/)
6+
## Features
7+
8+
- Plug and play python interface for I2RT robots
9+
- Real-time robot control via CAN bus communication
10+
- Support for directly communicating with motor (DM series motors)
11+
- Visualization and gravity compensation using MuJoCo physics engine
12+
13+
## Installation
14+
15+
```bash
16+
pip install -e .
17+
```
18+
19+
## CAN Usage
20+
Plug in the CAN device and run the following command to check the available CAN devices.
21+
```bash
22+
ls -l /sys/class/net/can*
23+
```
24+
25+
This should give you something like this
26+
```bash
27+
lrwxrwxrwx 1 root root 0 Jul 15 14:35 /sys/class/net/can0 -> ../../devices/platform/soc/your_can_device/can0
28+
```
29+
30+
Where can0 is the CAN device name.
31+
32+
You need to bring up the CAN interface with
33+
```bash
34+
sudo ip link set can0 up type can bitrate 1000000
35+
```
36+
37+
We have provided a convenience script to reset all CAN devices. Simply run
38+
```bash
39+
sh scripts/reset_all_can.sh
40+
```
41+
42+
## YAM Robot Arm Usage
43+
44+
### Getting started
45+
```python
46+
from i2rt.robots.motor_chain_robot import get_yam_robot
47+
48+
# Get a robot instance
49+
robot = get_yam_robot(channel="can0")
50+
51+
# Get the current joint positions
52+
joint_pos = robot.get_joint_pos()
53+
54+
# Command the robot to move to a new joint position
55+
target_pos = np.array([0, 0, 0, 0, 0, 0, 0])
56+
57+
# Command the robot to move to the target position
58+
robot.command_joint_pos(target_pos)
59+
```
60+
61+
### Running the arm and visualizing it
62+
To launch the follower robot run.
63+
```bash
64+
python scripts/minimum_gello.py --mode follower
65+
```
66+
67+
To launch the robot mujoco visualizer run
68+
```bash
69+
python scripts/minimum_gello.py --mode visualizer
70+
```
71+
72+
### Running the arm on controlling it leader follower style
73+
This requires 2 robot arms.
74+
75+
To launch the follower robot run
76+
```bash
77+
python scripts/minimum_gello.py --mode follower --can_channel can0
78+
```
79+
80+
To launch the leader robot run
81+
```bash
82+
python scripts/minimum_gello.py --mode leader --can_channel can0
83+
```
84+
85+
## Flow Base Usage
86+
87+
### Running the demo
88+
You can control your flow base using a game controller.
89+
To run the joystick demo, run the following command.
90+
```bash
91+
python i2rt/flow_base/flow_base_controller.py
92+
```
93+
94+
### Getting started
95+
```python
96+
from i2rt.flow_base.flow_base_controller import Vehicle
97+
98+
# Get a robot instance
99+
vehicle = Vehicle()
100+
vehicle.start_control()
101+
102+
# move forward slowly for 1 second
103+
start_time = time.time()
104+
while time.time() - start_time < 1:
105+
user_cmd = (0.1, 0, 0)
106+
vehicle.set_target_velocity(user_cmd, frame="local")
107+
```
108+
109+
## Contributing
110+
We welcome contributions! Please make a PR.
111+
112+
## License
113+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
114+
115+
## Support
116+
- Contact: support@i2rt.com
117+
118+
## Acknowledgments
119+
- [TidyBot++](https://github.com/jimmyyhwu/tidybot2) - Flow base hardware and code is inspired by TidyBot++
120+
- [GELLO](https://github.com/wuphilipp/gello_software) - Robot arm teleop is inspired by GELLO

i2rt/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""i2rt code base"""

0 commit comments

Comments
 (0)