dlouapre HF Staff commited on
Commit
65da30d
·
0 Parent(s):

First commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +37 -0
  2. .idea/.gitignore +8 -0
  3. .idea/copilot.data.migration.agent.xml +6 -0
  4. .idea/copilot.data.migration.ask.xml +6 -0
  5. .idea/copilot.data.migration.ask2agent.xml +6 -0
  6. .idea/copilot.data.migration.edit.xml +6 -0
  7. .idea/inspectionProfiles/Project_Default.xml +6 -0
  8. .idea/misc.xml +4 -0
  9. .idea/modules.xml +8 -0
  10. .idea/rmscript_space_demo.iml +12 -0
  11. .idea/vcs.xml +7 -0
  12. Dockerfile +38 -0
  13. README.md +111 -0
  14. backend/README.md +44 -0
  15. backend/app.py +252 -0
  16. backend/pyproject.toml +14 -0
  17. backend/requirements.txt +4 -0
  18. backend/uv.lock +0 -0
  19. frontend/app.js +436 -0
  20. frontend/index.html +331 -0
  21. reachy_mini/.gitattributes +15 -0
  22. reachy_mini/.github/workflows/lint.yml +27 -0
  23. reachy_mini/.github/workflows/pytest.yml +28 -0
  24. reachy_mini/.github/workflows/wheels.yml +26 -0
  25. reachy_mini/.github/workflows/wheels.yml.bak +181 -0
  26. reachy_mini/.gitignore +256 -0
  27. reachy_mini/.pre-commit-config.yaml +10 -0
  28. reachy_mini/LICENSE +201 -0
  29. reachy_mini/MANIFEST.in +3 -0
  30. reachy_mini/README.md +246 -0
  31. reachy_mini/conftest.py +0 -0
  32. reachy_mini/pyproject.toml +111 -0
  33. reachy_mini/src/reachy_mini/__init__.py +4 -0
  34. reachy_mini/src/reachy_mini/apps/__init__.py +25 -0
  35. reachy_mini/src/reachy_mini/apps/app.py +169 -0
  36. reachy_mini/src/reachy_mini/apps/manager.py +185 -0
  37. reachy_mini/src/reachy_mini/apps/sources/__init__.py +4 -0
  38. reachy_mini/src/reachy_mini/apps/sources/hf_space.py +105 -0
  39. reachy_mini/src/reachy_mini/apps/sources/local_common_venv.py +61 -0
  40. reachy_mini/src/reachy_mini/apps/templates/README.md.j2 +11 -0
  41. reachy_mini/src/reachy_mini/apps/templates/index.html.j2 +235 -0
  42. reachy_mini/src/reachy_mini/apps/templates/main.py.j2 +50 -0
  43. reachy_mini/src/reachy_mini/apps/templates/pyproject.toml.j2 +18 -0
  44. reachy_mini/src/reachy_mini/apps/templates/style.css.j2 +411 -0
  45. reachy_mini/src/reachy_mini/apps/utils.py +30 -0
  46. reachy_mini/src/reachy_mini/assets/config/hardware_config.yaml +155 -0
  47. reachy_mini/src/reachy_mini/assets/firmware/CHANGELOG.md +15 -0
  48. reachy_mini/src/reachy_mini/assets/firmware/reachymini_ua_io16_lin_v2.1.2.bin +3 -0
  49. reachy_mini/src/reachy_mini/assets/firmware/reachymini_ua_io16_lin_v2.1.3.bin +3 -0
  50. reachy_mini/src/reachy_mini/assets/firmware/update.sh +9 -0
.dockerignore ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+
11
+ # Virtual environments (but not in backend/)
12
+ **/.venv/
13
+ **/venv/
14
+ **/ENV/
15
+ **/env/
16
+
17
+ # IDE
18
+ .vscode/
19
+ .idea/
20
+ *.swp
21
+ *.swo
22
+ *~
23
+
24
+ # OS
25
+ .DS_Store
26
+ Thumbs.db
27
+
28
+ # Git
29
+ .git/
30
+ .gitignore
31
+
32
+ # Tests
33
+ tests/
34
+ *.egg-info/
35
+
36
+ # Lock files
37
+ uv.lock
.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
.idea/copilot.data.migration.agent.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
.idea/copilot.data.migration.ask.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AskMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
.idea/copilot.data.migration.ask2agent.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Ask2AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
.idea/copilot.data.migration.edit.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EditMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="KubernetesApiProvider">{}</component>
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/rmscript_space_demo.iml" filepath="$PROJECT_DIR$/.idea/rmscript_space_demo.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/rmscript_space_demo.iml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$/reachy_mini" vcs="Git" />
6
+ </component>
7
+ </project>
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile for RMScript Web Demo on HuggingFace Spaces
2
+ FROM python:3.11-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy reachy_mini package source (dependency of rmscript)
13
+ COPY reachy_mini/ /app/reachy_mini/
14
+
15
+ # Install reachy_mini package
16
+ RUN pip install --no-cache-dir /app/reachy_mini
17
+
18
+ # Copy rmscript package source
19
+ COPY rmscript/ /app/rmscript/
20
+
21
+ # Install rmscript package with dependencies
22
+ RUN pip install --no-cache-dir /app/rmscript[scipy]
23
+
24
+ # Copy backend code
25
+ COPY backend/ /app/backend/
26
+
27
+ # Install backend dependencies
28
+ WORKDIR /app/backend
29
+ RUN pip install --no-cache-dir fastapi uvicorn[standard] pydantic
30
+
31
+ # Copy frontend code
32
+ COPY frontend/ /app/frontend/
33
+
34
+ # Expose port 7860 (required by HuggingFace Spaces)
35
+ EXPOSE 7860
36
+
37
+ # Run the FastAPI server
38
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: RMScript Web Demo
3
+ emoji: 🤖
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # RMScript Web Demo
12
+
13
+ Web-based IDE for writing, verifying, and executing rmscript code on Reachy Mini.
14
+
15
+ ## Architecture
16
+
17
+ - **Frontend** (`frontend/`): HTML/CSS/JavaScript editor with live compilation and robot control
18
+ - **Backend** (`backend/`): FastAPI server for rmscript compilation and validation
19
+ - **Robot**: Reachy Mini robot daemon running on localhost:8000
20
+
21
+ ## Quick Start
22
+
23
+ ### On HuggingFace Spaces
24
+
25
+ Just open the Space - the web IDE will load automatically.
26
+
27
+ **Requirements:**
28
+ - Reachy Mini daemon running on `localhost:8000` on your local machine
29
+ - Modern web browser with WebSocket support
30
+
31
+ ### Local Development
32
+
33
+ 1. Install rmscript package:
34
+ ```bash
35
+ cd rmscript
36
+ uv sync
37
+ ```
38
+
39
+ 2. Start backend server:
40
+ ```bash
41
+ cd backend
42
+ uv sync
43
+ uv run python app.py
44
+ ```
45
+
46
+ 3. Make sure your Reachy Mini daemon is running on `localhost:8000`
47
+
48
+ 4. Open `frontend/index.html` in your web browser
49
+
50
+ ## Features
51
+
52
+ - **Code Editor**: Write rmscript with syntax examples
53
+ - **Verify Button**: Check script validity without executing
54
+ - **Execute Button**: Compile and run script on connected robot
55
+ - **Live Compilation**: See IR (Intermediate Representation) of your script
56
+ - **Example Scripts**: Load pre-written examples (basic, complex, repeat)
57
+ - **Real-time Logging**: Console shows compilation errors, warnings, and execution progress
58
+
59
+ ## Usage
60
+
61
+ 1. Write rmscript in the editor (or load an example)
62
+ 2. Click "Verify" to check syntax and semantics
63
+ 3. Review any errors/warnings in the console
64
+ 4. Click "Execute" to run on the robot (robot must be connected)
65
+ 5. Watch execution progress in the Execution Info panel
66
+
67
+ ## Current Limitations
68
+
69
+ - Sound and picture actions are not yet implemented in execution
70
+
71
+ ## Deployment to HuggingFace Spaces
72
+
73
+ To deploy this demo to HuggingFace Spaces:
74
+
75
+ 1. **Prepare the repository structure:**
76
+ - Copy the `rmscript` and `reachy_mini` directories into the `rmscript_space_demo` directory:
77
+ ```bash
78
+ cd rmscript_space_demo
79
+ cp -r ../rmscript ./rmscript
80
+ cp -r ../reachy_mini ./reachy_mini
81
+ ```
82
+ - Your structure should be:
83
+ ```
84
+ rmscript_space_demo/
85
+ ├── Dockerfile
86
+ ├── README.md
87
+ ├── .dockerignore
88
+ ├── backend/
89
+ ├── frontend/
90
+ ├── rmscript/ ← copied source
91
+ └── reachy_mini/ ← copied source (dependency)
92
+ ```
93
+
94
+ 2. **Create a new Space:**
95
+ - Go to https://huggingface.co/new-space
96
+ - Select "Docker" as the SDK
97
+ - Push this directory to your Space repository
98
+
99
+ 3. **The Space will:**
100
+ - Build the Docker container
101
+ - Install rmscript and dependencies
102
+ - Serve the web IDE on port 7860
103
+
104
+ **Note:** The Space connects to your local robot daemon on `localhost:8000`. Make sure it's running when using the demo.
105
+
106
+ ## Development
107
+
108
+ To modify the demo:
109
+ - Frontend code: `frontend/app.js`
110
+ - Backend API: `backend/app.py`
111
+ - Styling: `frontend/index.html` (embedded CSS)
backend/README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RMScript Web Demo - Backend
2
+
3
+ FastAPI backend for compiling and validating rmscript code.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install dependencies with uv
9
+ uv sync
10
+ ```
11
+
12
+ ## Running
13
+
14
+ ```bash
15
+ uv run python app.py
16
+ ```
17
+
18
+ Or with uvicorn directly:
19
+
20
+ ```bash
21
+ uv run uvicorn app:app --reload --port 8001
22
+ ```
23
+
24
+ The API will be available at http://localhost:8001
25
+
26
+ ## API Endpoints
27
+
28
+ - `GET /` - API information
29
+ - `POST /api/verify` - Verify rmscript syntax (returns errors/warnings)
30
+ - `POST /api/compile` - Compile rmscript to IR (returns IR actions)
31
+
32
+ ## Example Usage
33
+
34
+ ```bash
35
+ # Verify a script
36
+ curl -X POST http://localhost:8001/api/verify \
37
+ -H "Content-Type: application/json" \
38
+ -d '{"source": "look left\nwait 1s\nlook right"}'
39
+
40
+ # Compile a script
41
+ curl -X POST http://localhost:8001/api/compile \
42
+ -H "Content-Type: application/json" \
43
+ -d '{"source": "look left\nwait 1s\nlook right"}'
44
+ ```
backend/app.py ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FastAPI backend for rmscript web demo."""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+ from typing import Any, Dict, List
6
+ from fastapi import FastAPI, HTTPException
7
+ from fastapi.middleware.cors import CORSMiddleware
8
+ from fastapi.responses import FileResponse
9
+ from fastapi.staticfiles import StaticFiles
10
+ from pydantic import BaseModel
11
+
12
+ from rmscript import compile_script
13
+
14
+ # Configure logging
15
+ logging.basicConfig(level=logging.INFO)
16
+ logger = logging.getLogger(__name__)
17
+
18
+ # Create FastAPI app
19
+ app = FastAPI(
20
+ title="RMScript Web Demo API",
21
+ description="Backend API for compiling and validating rmscript code",
22
+ version="1.0.0"
23
+ )
24
+
25
+ # Enable CORS for local development
26
+ app.add_middleware(
27
+ CORSMiddleware,
28
+ allow_origins=["*"], # In production, specify exact origins
29
+ allow_credentials=True,
30
+ allow_methods=["*"],
31
+ allow_headers=["*"],
32
+ )
33
+
34
+ # Set up paths for serving frontend
35
+ BACKEND_DIR = Path(__file__).parent
36
+ FRONTEND_DIR = BACKEND_DIR.parent / "frontend"
37
+
38
+ # Mount static files (CSS, JS)
39
+ if FRONTEND_DIR.exists():
40
+ app.mount("/static", StaticFiles(directory=str(FRONTEND_DIR)), name="static")
41
+
42
+
43
+ class ScriptInput(BaseModel):
44
+ """Input model for script compilation."""
45
+
46
+ source: str
47
+
48
+
49
+ class CompilationError(BaseModel):
50
+ """Compilation error model."""
51
+
52
+ line: int
53
+ column: int
54
+ message: str
55
+ severity: str
56
+
57
+
58
+ class VerifyResponse(BaseModel):
59
+ """Response model for script verification."""
60
+
61
+ success: bool
62
+ errors: List[Dict[str, Any]]
63
+ warnings: List[Dict[str, Any]]
64
+ name: str = ""
65
+ description: str = ""
66
+
67
+
68
+ class IRActionModel(BaseModel):
69
+ """Simplified IR action model for JSON serialization."""
70
+
71
+ type: str # "action", "wait", "picture", "sound"
72
+ duration: float = 0.0
73
+ # For movement actions
74
+ head_pose: List[List[float]] | None = None # 4x4 matrix as nested list
75
+ antennas: List[float] | None = None # [left, right] in radians
76
+ body_yaw: float | None = None # radians
77
+ # For sound actions
78
+ sound_name: str | None = None
79
+ blocking: bool = False
80
+ loop: bool = False
81
+ # Metadata
82
+ source_line: int = 0
83
+
84
+
85
+ class CompileResponse(BaseModel):
86
+ """Response model for script compilation."""
87
+
88
+ success: bool
89
+ errors: List[Dict[str, Any]]
90
+ warnings: List[Dict[str, Any]]
91
+ name: str = ""
92
+ description: str = ""
93
+ ir: List[IRActionModel]
94
+
95
+
96
+ @app.get("/")
97
+ async def root():
98
+ """Serve the frontend application."""
99
+ index_path = FRONTEND_DIR / "index.html"
100
+ if index_path.exists():
101
+ return FileResponse(index_path)
102
+ return {
103
+ "name": "RMScript Web Demo API",
104
+ "version": "1.0.0",
105
+ "endpoints": {
106
+ "/api/verify": "POST - Verify rmscript syntax and semantics",
107
+ "/api/compile": "POST - Compile rmscript to IR",
108
+ }
109
+ }
110
+
111
+
112
+ @app.post("/api/verify", response_model=VerifyResponse)
113
+ async def verify_script(input: ScriptInput):
114
+ """Verify rmscript without generating IR.
115
+
116
+ Args:
117
+ input: Script source code
118
+
119
+ Returns:
120
+ Verification result with errors and warnings
121
+
122
+ """
123
+ logger.info(f"Verifying script ({len(input.source)} chars)")
124
+
125
+ try:
126
+ result = compile_script(input.source)
127
+
128
+ # Convert errors and warnings to dict format
129
+ errors = [
130
+ {
131
+ "line": e.line,
132
+ "column": e.column,
133
+ "message": e.message,
134
+ "severity": e.severity
135
+ }
136
+ for e in result.errors
137
+ ]
138
+
139
+ warnings = [
140
+ {
141
+ "line": w.line,
142
+ "column": w.column,
143
+ "message": w.message,
144
+ "severity": w.severity
145
+ }
146
+ for w in result.warnings
147
+ ]
148
+
149
+ return VerifyResponse(
150
+ success=result.success,
151
+ errors=errors,
152
+ warnings=warnings,
153
+ name=result.name,
154
+ description=result.description
155
+ )
156
+
157
+ except Exception as e:
158
+ logger.error(f"Verification error: {e}")
159
+ raise HTTPException(status_code=500, detail=str(e))
160
+
161
+
162
+ @app.post("/api/compile", response_model=CompileResponse)
163
+ async def compile_rmscript(input: ScriptInput):
164
+ """Compile rmscript to intermediate representation.
165
+
166
+ Args:
167
+ input: Script source code
168
+
169
+ Returns:
170
+ Compilation result with IR
171
+
172
+ """
173
+ logger.info(f"Compiling script ({len(input.source)} chars)")
174
+
175
+ try:
176
+ from rmscript.ir import IRAction, IRWaitAction, IRPictureAction, IRPlaySoundAction
177
+
178
+ result = compile_script(input.source)
179
+
180
+ # Convert errors and warnings to dict format
181
+ errors = [
182
+ {
183
+ "line": e.line,
184
+ "column": e.column,
185
+ "message": e.message,
186
+ "severity": e.severity
187
+ }
188
+ for e in result.errors
189
+ ]
190
+
191
+ warnings = [
192
+ {
193
+ "line": w.line,
194
+ "column": w.column,
195
+ "message": w.message,
196
+ "severity": w.severity
197
+ }
198
+ for w in result.warnings
199
+ ]
200
+
201
+ # Convert IR to JSON-serializable format
202
+ ir_json = []
203
+ for action in result.ir:
204
+ if isinstance(action, IRAction):
205
+ ir_json.append(IRActionModel(
206
+ type="action",
207
+ duration=action.duration,
208
+ head_pose=action.head_pose.tolist() if action.head_pose is not None else None,
209
+ antennas=action.antennas if action.antennas is not None else None,
210
+ body_yaw=action.body_yaw,
211
+ source_line=action.source_line
212
+ ))
213
+ elif isinstance(action, IRWaitAction):
214
+ ir_json.append(IRActionModel(
215
+ type="wait",
216
+ duration=action.duration,
217
+ source_line=action.source_line
218
+ ))
219
+ elif isinstance(action, IRPictureAction):
220
+ ir_json.append(IRActionModel(
221
+ type="picture",
222
+ source_line=action.source_line
223
+ ))
224
+ elif isinstance(action, IRPlaySoundAction):
225
+ ir_json.append(IRActionModel(
226
+ type="sound",
227
+ duration=action.duration or 0.0,
228
+ sound_name=action.sound_name,
229
+ blocking=action.blocking,
230
+ loop=action.loop,
231
+ source_line=action.source_line
232
+ ))
233
+
234
+ logger.info(f"Compiled {len(ir_json)} IR actions")
235
+
236
+ return CompileResponse(
237
+ success=result.success,
238
+ errors=errors,
239
+ warnings=warnings,
240
+ name=result.name,
241
+ description=result.description,
242
+ ir=ir_json
243
+ )
244
+
245
+ except Exception as e:
246
+ logger.error(f"Compilation error: {e}")
247
+ raise HTTPException(status_code=500, detail=str(e))
248
+
249
+
250
+ if __name__ == "__main__":
251
+ import uvicorn
252
+ uvicorn.run(app, host="0.0.0.0", port=8001, log_level="info")
backend/pyproject.toml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rmscript-web-backend"
7
+ version = "1.0.0"
8
+ requires-python = ">=3.11"
9
+ dependencies = [
10
+ "fastapi>=0.104.0",
11
+ "uvicorn[standard]>=0.24.0",
12
+ "pydantic>=2.4.0",
13
+ "rmscript[reachy,scipy] @ file:///Users/david/projects/reachy-mini/rmscript",
14
+ ]
backend/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastapi>=0.104.0
2
+ uvicorn[standard]>=0.24.0
3
+ pydantic>=2.4.0
4
+ rmscript>=0.1.0
backend/uv.lock ADDED
The diff for this file is too large to render. See raw diff
 
frontend/app.js ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RMScript Web Demo - Frontend Application
2
+ // Connects to:
3
+ // - Backend API for compilation/verification
4
+ // - Robot WebSocket (localhost:8000) for execution
5
+
6
+ // Auto-detect backend URL based on environment
7
+ // If opened as file:// (local development), use localhost:8001
8
+ // If served from web server (production/Space), use relative URLs
9
+ const BACKEND_URL = window.location.protocol === 'file:'
10
+ ? 'http://localhost:8001'
11
+ : ''; // Use relative URLs when served from web server
12
+ const ROBOT_WS_URL = 'ws://localhost:8000/api/move/ws/set_target';
13
+
14
+ // Global state
15
+ const state = {
16
+ robotWs: null,
17
+ robotConnected: false,
18
+ currentIR: null,
19
+ isExecuting: false
20
+ };
21
+
22
+ // DOM elements
23
+ const elements = {
24
+ editor: document.getElementById('editor'),
25
+ compileStatus: document.getElementById('compileStatus'),
26
+ robotStatus: document.getElementById('robotStatus'),
27
+ console: document.getElementById('console'),
28
+ irDisplay: document.getElementById('irDisplay'),
29
+ executionInfo: document.getElementById('executionInfo'),
30
+ executeBtn: document.getElementById('executeBtn')
31
+ };
32
+
33
+ // Example scripts
34
+ const examples = {
35
+ basic: `DESCRIPTION Simple head movement
36
+ look left
37
+ wait 1s
38
+ look right
39
+ wait 1s
40
+ look center`,
41
+
42
+ complex: `DESCRIPTION Wave hello
43
+ look left
44
+ antenna both up
45
+ wait 1s
46
+ look right
47
+ antenna both down
48
+ wait 0.5s
49
+ look center`,
50
+
51
+ repeat: `DESCRIPTION Repeat demo
52
+ REPEAT 3
53
+ look left
54
+ wait 0.5s
55
+ look right
56
+ wait 0.5s
57
+ END
58
+ look center`
59
+ };
60
+
61
+ // Initialize robot WebSocket connection
62
+ function connectRobotWebSocket() {
63
+ log('Connecting to robot...', 'info');
64
+
65
+ state.robotWs = new WebSocket(ROBOT_WS_URL);
66
+
67
+ state.robotWs.onopen = () => {
68
+ state.robotConnected = true;
69
+ updateRobotStatus(true);
70
+ log('Robot connected!', 'success');
71
+ };
72
+
73
+ state.robotWs.onclose = () => {
74
+ state.robotConnected = false;
75
+ updateRobotStatus(false);
76
+ log('Robot disconnected. Reconnecting...', 'warning');
77
+ setTimeout(connectRobotWebSocket, 2000);
78
+ };
79
+
80
+ state.robotWs.onerror = (error) => {
81
+ log(`Robot connection error: ${error}`, 'error');
82
+ };
83
+
84
+ state.robotWs.onmessage = (event) => {
85
+ try {
86
+ const message = JSON.parse(event.data);
87
+ if (message.status === 'error') {
88
+ log(`Robot error: ${message.detail}`, 'error');
89
+ }
90
+ } catch (e) {
91
+ console.error('Failed to parse robot message:', e);
92
+ }
93
+ };
94
+ }
95
+
96
+ // Update robot connection status UI
97
+ function updateRobotStatus(connected) {
98
+ if (connected) {
99
+ elements.robotStatus.className = 'status connected';
100
+ elements.robotStatus.innerHTML = '<span><span class="status-dot green"></span>Connected</span>';
101
+ elements.executeBtn.disabled = false;
102
+ } else {
103
+ elements.robotStatus.className = 'status disconnected';
104
+ elements.robotStatus.innerHTML = '<span><span class="status-dot red"></span>Disconnected</span>';
105
+ elements.executeBtn.disabled = true;
106
+ }
107
+ }
108
+
109
+ // Update compile status UI
110
+ function updateCompileStatus(status, message) {
111
+ const dot = status === 'success' ? 'green' : status === 'error' ? 'red' : 'gray';
112
+ elements.compileStatus.className = `status ${status}`;
113
+ elements.compileStatus.innerHTML = `<span><span class="status-dot ${dot}"></span>${message}</span>`;
114
+ }
115
+
116
+ // Log to console
117
+ function log(message, type = 'info') {
118
+ const line = document.createElement('div');
119
+ line.className = `console-line ${type}`;
120
+ line.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
121
+ elements.console.appendChild(line);
122
+ elements.console.scrollTop = elements.console.scrollHeight;
123
+ }
124
+
125
+ // Clear console
126
+ function clearConsole() {
127
+ elements.console.innerHTML = '';
128
+ }
129
+
130
+ // Load example script
131
+ function loadExample(exampleName) {
132
+ if (examples[exampleName]) {
133
+ elements.editor.value = examples[exampleName];
134
+ log(`Loaded ${exampleName} example`, 'info');
135
+ }
136
+ }
137
+
138
+ // Clear editor
139
+ function clearEditor() {
140
+ elements.editor.value = '';
141
+ state.currentIR = null;
142
+ elements.irDisplay.innerHTML = '<div style="color: #999; text-align: center; padding: 20px;">No IR yet. Verify a script first!</div>';
143
+ updateCompileStatus('idle', 'Ready');
144
+ }
145
+
146
+ // Verify script (syntax and semantics only)
147
+ async function verifyScript() {
148
+ const source = elements.editor.value.trim();
149
+
150
+ if (!source) {
151
+ log('Editor is empty', 'warning');
152
+ return;
153
+ }
154
+
155
+ clearConsole();
156
+ log('Verifying script...', 'info');
157
+ updateCompileStatus('idle', 'Verifying...');
158
+
159
+ try {
160
+ const response = await fetch(`${BACKEND_URL}/api/verify`, {
161
+ method: 'POST',
162
+ headers: { 'Content-Type': 'application/json' },
163
+ body: JSON.stringify({ source })
164
+ });
165
+
166
+ const result = await response.json();
167
+
168
+ if (result.success) {
169
+ log('✓ Verification successful!', 'success');
170
+ if (result.name) log(` Name: ${result.name}`, 'info');
171
+ if (result.description) log(` Description: ${result.description}`, 'info');
172
+
173
+ if (result.warnings.length > 0) {
174
+ result.warnings.forEach(w => {
175
+ log(` Warning (line ${w.line}): ${w.message}`, 'warning');
176
+ });
177
+ }
178
+
179
+ updateCompileStatus('success', 'Valid script');
180
+ } else {
181
+ log('✗ Verification failed', 'error');
182
+ result.errors.forEach(e => {
183
+ log(` Error (line ${e.line}): ${e.message}`, 'error');
184
+ });
185
+ updateCompileStatus('error', 'Invalid script');
186
+ }
187
+ } catch (error) {
188
+ log(`Backend error: ${error.message}`, 'error');
189
+ updateCompileStatus('error', 'Backend error');
190
+ }
191
+ }
192
+
193
+ // Compile script to IR
194
+ async function compileScript() {
195
+ const source = elements.editor.value.trim();
196
+
197
+ if (!source) {
198
+ log('Editor is empty', 'warning');
199
+ return null;
200
+ }
201
+
202
+ log('Compiling script to IR...', 'info');
203
+ updateCompileStatus('idle', 'Compiling...');
204
+
205
+ try {
206
+ const response = await fetch(`${BACKEND_URL}/api/compile`, {
207
+ method: 'POST',
208
+ headers: { 'Content-Type': 'application/json' },
209
+ body: JSON.stringify({ source })
210
+ });
211
+
212
+ const result = await response.json();
213
+
214
+ if (result.success) {
215
+ log(`✓ Compiled ${result.ir.length} actions`, 'success');
216
+
217
+ if (result.warnings.length > 0) {
218
+ result.warnings.forEach(w => {
219
+ log(` Warning (line ${w.line}): ${w.message}`, 'warning');
220
+ });
221
+ }
222
+
223
+ state.currentIR = result.ir;
224
+ displayIR(result.ir);
225
+ updateCompileStatus('success', `${result.ir.length} actions ready`);
226
+ return result.ir;
227
+ } else {
228
+ log('✗ Compilation failed', 'error');
229
+ result.errors.forEach(e => {
230
+ log(` Error (line ${e.line}): ${e.message}`, 'error');
231
+ });
232
+ updateCompileStatus('error', 'Compilation failed');
233
+ return null;
234
+ }
235
+ } catch (error) {
236
+ log(`Backend error: ${error.message}`, 'error');
237
+ updateCompileStatus('error', 'Backend error');
238
+ return null;
239
+ }
240
+ }
241
+
242
+ // Display IR in the UI
243
+ function displayIR(ir) {
244
+ if (!ir || ir.length === 0) {
245
+ elements.irDisplay.innerHTML = '<div style="color: #999; text-align: center; padding: 20px;">No actions</div>';
246
+ return;
247
+ }
248
+
249
+ const html = ir.map((action, idx) => {
250
+ let details = '';
251
+
252
+ if (action.type === 'action') {
253
+ details = `Duration: ${action.duration}s`;
254
+ if (action.head_pose) details += ', Head movement';
255
+ if (action.antennas) details += `, Antennas: [${action.antennas.map(a => a.toFixed(2)).join(', ')}]`;
256
+ if (action.body_yaw !== null) details += `, Body yaw: ${action.body_yaw.toFixed(2)}`;
257
+ } else if (action.type === 'wait') {
258
+ details = `Wait ${action.duration}s`;
259
+ } else if (action.type === 'picture') {
260
+ details = 'Take picture';
261
+ } else if (action.type === 'sound') {
262
+ details = `Play "${action.sound_name}"`;
263
+ if (action.blocking) details += ' (blocking)';
264
+ if (action.loop) details += ' (loop)';
265
+ }
266
+
267
+ return `
268
+ <div class="ir-action">
269
+ <div class="ir-action-type">${idx + 1}. ${action.type.toUpperCase()}</div>
270
+ <div class="ir-action-details">${details}</div>
271
+ </div>
272
+ `;
273
+ }).join('');
274
+
275
+ elements.irDisplay.innerHTML = html;
276
+ }
277
+
278
+ // Execute compiled script on robot
279
+ async function executeScript() {
280
+ if (!state.robotConnected) {
281
+ log('Robot not connected!', 'error');
282
+ return;
283
+ }
284
+
285
+ if (state.isExecuting) {
286
+ log('Already executing a script', 'warning');
287
+ return;
288
+ }
289
+
290
+ // Always compile the current editor content before executing
291
+ const ir = await compileScript();
292
+ if (!ir) {
293
+ log('Cannot execute - compilation failed', 'error');
294
+ return;
295
+ }
296
+
297
+ // Execute IR actions sequentially
298
+ state.isExecuting = true;
299
+ elements.executeBtn.disabled = true;
300
+ clearExecutionInfo();
301
+ logExecution('Starting execution...', 'info');
302
+
303
+ try {
304
+ for (let i = 0; i < ir.length; i++) {
305
+ const action = ir[i];
306
+ logExecution(`Action ${i + 1}/${ir.length}: ${action.type}`, 'info');
307
+
308
+ if (action.type === 'action') {
309
+ await executeIRAction(action);
310
+ } else if (action.type === 'wait') {
311
+ await sleep(action.duration * 1000);
312
+ } else if (action.type === 'picture') {
313
+ logExecution('Picture action skipped (not implemented)', 'warning');
314
+ } else if (action.type === 'sound') {
315
+ logExecution('Sound action skipped (not implemented)', 'warning');
316
+ }
317
+ }
318
+
319
+ logExecution('✓ Execution complete!', 'success');
320
+ } catch (error) {
321
+ logExecution(`✗ Execution error: ${error.message}`, 'error');
322
+ } finally {
323
+ state.isExecuting = false;
324
+ if (state.robotConnected) {
325
+ elements.executeBtn.disabled = false;
326
+ }
327
+ }
328
+ }
329
+
330
+ // Extract euler angles (roll, pitch, yaw) from 3x3 rotation matrix
331
+ // Uses XYZ euler convention to match scipy's R.from_matrix().as_euler("xyz")
332
+ function matrixToEulerXYZ(rotMatrix) {
333
+ // Extract 3x3 rotation matrix from 4x4 pose matrix if needed
334
+ const R = rotMatrix;
335
+
336
+ // For XYZ euler order: R = Rz(yaw) * Ry(pitch) * Rx(roll)
337
+ // pitch = asin(-R[2][0])
338
+ // roll = atan2(R[2][1], R[2][2])
339
+ // yaw = atan2(R[1][0], R[0][0])
340
+
341
+ let pitch = Math.asin(-R[2][0]);
342
+
343
+ // Check for gimbal lock
344
+ if (Math.abs(Math.cos(pitch)) > 1e-6) {
345
+ // Normal case
346
+ const roll = Math.atan2(R[2][1], R[2][2]);
347
+ const yaw = Math.atan2(R[1][0], R[0][0]);
348
+ return { roll, pitch, yaw };
349
+ } else {
350
+ // Gimbal lock case
351
+ const roll = Math.atan2(-R[0][1], R[1][1]);
352
+ const yaw = 0;
353
+ return { roll, pitch, yaw };
354
+ }
355
+ }
356
+
357
+ // Execute a single IR action (send to robot)
358
+ async function executeIRAction(action) {
359
+ if (!state.robotWs || state.robotWs.readyState !== WebSocket.OPEN) {
360
+ throw new Error('Robot WebSocket not connected');
361
+ }
362
+
363
+ const message = {};
364
+
365
+ if (action.head_pose) {
366
+ // Extract translation from 4x4 matrix
367
+ const x = action.head_pose[0][3];
368
+ const y = action.head_pose[1][3];
369
+ const z = action.head_pose[2][3];
370
+
371
+ // Extract rotation (euler angles) from 3x3 rotation matrix portion
372
+ const euler = matrixToEulerXYZ(action.head_pose);
373
+
374
+ message.target_head_pose = {
375
+ x: x,
376
+ y: y,
377
+ z: z,
378
+ roll: euler.roll,
379
+ pitch: euler.pitch,
380
+ yaw: euler.yaw
381
+ };
382
+ }
383
+
384
+ if (action.antennas) {
385
+ message.target_antennas = action.antennas;
386
+ }
387
+
388
+ if (action.body_yaw !== null) {
389
+ message.target_body_yaw = action.body_yaw;
390
+ }
391
+
392
+ // Send to robot
393
+ state.robotWs.send(JSON.stringify(message));
394
+
395
+ // Wait for the action duration
396
+ await sleep(action.duration * 1000);
397
+ }
398
+
399
+ // Log execution info
400
+ function logExecution(message, type = 'info') {
401
+ const line = document.createElement('div');
402
+ line.className = `console-line ${type}`;
403
+ line.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
404
+ elements.executionInfo.appendChild(line);
405
+ elements.executionInfo.scrollTop = elements.executionInfo.scrollHeight;
406
+ }
407
+
408
+ // Clear execution info
409
+ function clearExecutionInfo() {
410
+ elements.executionInfo.innerHTML = '';
411
+ }
412
+
413
+ // Sleep helper
414
+ function sleep(ms) {
415
+ return new Promise(resolve => setTimeout(resolve, ms));
416
+ }
417
+
418
+ // Initialize application
419
+ function init() {
420
+ console.log('Initializing RMScript Web Demo');
421
+
422
+ // Connect to robot
423
+ connectRobotWebSocket();
424
+
425
+ // Load default example
426
+ loadExample('basic');
427
+
428
+ console.log('RMScript Web Demo ready');
429
+ }
430
+
431
+ // Start when DOM is loaded
432
+ if (document.readyState === 'loading') {
433
+ document.addEventListener('DOMContentLoaded', init);
434
+ } else {
435
+ init();
436
+ }
frontend/index.html ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>RMScript Web Demo</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
16
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
17
+ min-height: 100vh;
18
+ padding: 20px;
19
+ }
20
+
21
+ .container {
22
+ max-width: 1400px;
23
+ margin: 0 auto;
24
+ background: white;
25
+ border-radius: 20px;
26
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
27
+ overflow: hidden;
28
+ display: grid;
29
+ grid-template-columns: 1fr 1fr;
30
+ gap: 0;
31
+ }
32
+
33
+ .panel {
34
+ padding: 30px;
35
+ }
36
+
37
+ .panel.editor-panel {
38
+ border-right: 1px solid #e0e0e0;
39
+ }
40
+
41
+ h1 {
42
+ color: #333;
43
+ margin-bottom: 10px;
44
+ font-size: 24px;
45
+ }
46
+
47
+ .subtitle {
48
+ color: #666;
49
+ margin-bottom: 20px;
50
+ font-size: 14px;
51
+ }
52
+
53
+ .status {
54
+ padding: 12px;
55
+ border-radius: 8px;
56
+ margin-bottom: 15px;
57
+ font-size: 14px;
58
+ display: flex;
59
+ justify-content: space-between;
60
+ align-items: center;
61
+ }
62
+
63
+ .status.idle {
64
+ background: #f5f5f5;
65
+ color: #666;
66
+ }
67
+
68
+ .status.success {
69
+ background: #d4edda;
70
+ color: #155724;
71
+ }
72
+
73
+ .status.error {
74
+ background: #f8d7da;
75
+ color: #721c24;
76
+ }
77
+
78
+ .status.connected {
79
+ background: #d4edda;
80
+ color: #155724;
81
+ }
82
+
83
+ .status.disconnected {
84
+ background: #f8d7da;
85
+ color: #721c24;
86
+ }
87
+
88
+ .status-dot {
89
+ width: 10px;
90
+ height: 10px;
91
+ border-radius: 50%;
92
+ margin-right: 8px;
93
+ display: inline-block;
94
+ }
95
+
96
+ .status-dot.green {
97
+ background: #28a745;
98
+ box-shadow: 0 0 10px #28a745;
99
+ }
100
+
101
+ .status-dot.red {
102
+ background: #dc3545;
103
+ }
104
+
105
+ .status-dot.gray {
106
+ background: #999;
107
+ }
108
+
109
+ .editor {
110
+ width: 100%;
111
+ min-height: 400px;
112
+ padding: 15px;
113
+ font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
114
+ font-size: 14px;
115
+ border: 2px solid #e0e0e0;
116
+ border-radius: 8px;
117
+ resize: vertical;
118
+ margin-bottom: 15px;
119
+ line-height: 1.5;
120
+ }
121
+
122
+ .editor:focus {
123
+ outline: none;
124
+ border-color: #667eea;
125
+ }
126
+
127
+ .button-group {
128
+ display: flex;
129
+ gap: 10px;
130
+ margin-bottom: 20px;
131
+ }
132
+
133
+ button {
134
+ background: #667eea;
135
+ color: white;
136
+ border: none;
137
+ padding: 12px 24px;
138
+ border-radius: 8px;
139
+ font-size: 14px;
140
+ font-weight: 600;
141
+ cursor: pointer;
142
+ transition: all 0.2s;
143
+ flex: 1;
144
+ }
145
+
146
+ button:hover:not(:disabled) {
147
+ background: #5568d3;
148
+ transform: translateY(-2px);
149
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
150
+ }
151
+
152
+ button:active:not(:disabled) {
153
+ transform: translateY(0);
154
+ }
155
+
156
+ button:disabled {
157
+ opacity: 0.5;
158
+ cursor: not-allowed;
159
+ }
160
+
161
+ button.secondary {
162
+ background: #6c757d;
163
+ }
164
+
165
+ button.secondary:hover:not(:disabled) {
166
+ background: #5a6268;
167
+ }
168
+
169
+ button.danger {
170
+ background: #dc3545;
171
+ }
172
+
173
+ button.danger:hover:not(:disabled) {
174
+ background: #c82333;
175
+ }
176
+
177
+ .console {
178
+ background: #1e1e1e;
179
+ color: #d4d4d4;
180
+ padding: 15px;
181
+ border-radius: 8px;
182
+ font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
183
+ font-size: 12px;
184
+ max-height: 300px;
185
+ overflow-y: auto;
186
+ line-height: 1.6;
187
+ }
188
+
189
+ .console-line {
190
+ margin-bottom: 4px;
191
+ }
192
+
193
+ .console-line.error {
194
+ color: #f48771;
195
+ }
196
+
197
+ .console-line.warning {
198
+ color: #dcdcaa;
199
+ }
200
+
201
+ .console-line.success {
202
+ color: #4ec9b0;
203
+ }
204
+
205
+ .console-line.info {
206
+ color: #9cdcfe;
207
+ }
208
+
209
+ .section-title {
210
+ font-size: 16px;
211
+ font-weight: 600;
212
+ color: #333;
213
+ margin-bottom: 10px;
214
+ text-transform: uppercase;
215
+ letter-spacing: 0.5px;
216
+ }
217
+
218
+ .example-buttons {
219
+ display: flex;
220
+ gap: 8px;
221
+ margin-bottom: 15px;
222
+ flex-wrap: wrap;
223
+ }
224
+
225
+ .example-buttons button {
226
+ flex: 0 1 auto;
227
+ padding: 8px 16px;
228
+ font-size: 12px;
229
+ }
230
+
231
+ .ir-display {
232
+ background: #f8f9fa;
233
+ padding: 15px;
234
+ border-radius: 8px;
235
+ max-height: 300px;
236
+ overflow-y: auto;
237
+ font-size: 13px;
238
+ margin-top: 15px;
239
+ }
240
+
241
+ .ir-action {
242
+ background: white;
243
+ padding: 10px;
244
+ margin-bottom: 8px;
245
+ border-radius: 4px;
246
+ border-left: 4px solid #667eea;
247
+ }
248
+
249
+ .ir-action-type {
250
+ font-weight: 600;
251
+ color: #667eea;
252
+ margin-bottom: 4px;
253
+ }
254
+
255
+ .ir-action-details {
256
+ font-size: 12px;
257
+ color: #666;
258
+ font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
259
+ }
260
+ </style>
261
+ </head>
262
+ <body>
263
+ <div class="container">
264
+ <!-- Left Panel: Editor -->
265
+ <div class="panel editor-panel">
266
+ <h1>🤖 RMScript Editor</h1>
267
+ <p class="subtitle">Write and test your rmscript code</p>
268
+
269
+ <div id="compileStatus" class="status idle">
270
+ <span><span class="status-dot gray"></span>Ready</span>
271
+ </div>
272
+
273
+ <div class="section-title">Examples</div>
274
+ <div class="example-buttons">
275
+ <button class="secondary" onclick="loadExample('basic')">Basic</button>
276
+ <button class="secondary" onclick="loadExample('complex')">Complex</button>
277
+ <button class="secondary" onclick="loadExample('repeat')">Repeat</button>
278
+ <button class="secondary" onclick="clearEditor()">Clear</button>
279
+ </div>
280
+
281
+ <textarea id="editor" class="editor" placeholder="DESCRIPTION My robot script
282
+ look left
283
+ wait 1s
284
+ look right"></textarea>
285
+
286
+ <div class="button-group">
287
+ <button onclick="verifyScript()">✓ Verify</button>
288
+ <button id="executeBtn" onclick="executeScript()" disabled>▶ Execute</button>
289
+ </div>
290
+
291
+ <div class="section-title">Console</div>
292
+ <div id="console" class="console">
293
+ <div class="console-line info">Ready. Write some rmscript and click Verify!</div>
294
+ </div>
295
+ </div>
296
+
297
+ <!-- Right Panel: Robot Control -->
298
+ <div class="panel">
299
+ <h1>🔗 Robot Connection</h1>
300
+ <p class="subtitle">Connect to Reachy Mini on localhost:8000</p>
301
+
302
+ <div id="robotStatus" class="status disconnected">
303
+ <span><span class="status-dot red"></span>Disconnected</span>
304
+ </div>
305
+
306
+ <div class="section-title">Compiled IR</div>
307
+ <div id="irDisplay" class="ir-display">
308
+ <div style="color: #999; text-align: center; padding: 20px;">
309
+ No IR yet. Verify a script first!
310
+ </div>
311
+ </div>
312
+
313
+ <div class="section-title" style="margin-top: 20px;">Execution Info</div>
314
+ <div id="executionInfo" class="console" style="max-height: 150px;">
315
+ <div class="console-line info">Ready to execute when robot is connected</div>
316
+ </div>
317
+ </div>
318
+ </div>
319
+
320
+ <!-- Load app.js with path that works both locally (file://) and on server -->
321
+ <script>
322
+ // Auto-detect correct path for app.js
323
+ const scriptSrc = window.location.protocol === 'file:'
324
+ ? './app.js' // Local file access
325
+ : '/static/app.js'; // Served from web server
326
+ const script = document.createElement('script');
327
+ script.src = scriptSrc;
328
+ document.head.appendChild(script);
329
+ </script>
330
+ </body>
331
+ </html>
reachy_mini/.gitattributes ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.png filter=lfs diff=lfs merge=lfs -text
2
+ *.jpg filter=lfs diff=lfs merge=lfs -text
3
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
4
+ *.gif filter=lfs diff=lfs merge=lfs -text
5
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
6
+ *.avi filter=lfs diff=lfs merge=lfs -text
7
+ *.zip filter=lfs diff=lfs merge=lfs -text
8
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.pdf filter=lfs diff=lfs merge=lfs -text
10
+ *.obj filter=lfs diff=lfs merge=lfs -text
11
+ *.stl filter=lfs diff=lfs merge=lfs -text
12
+ *.npz filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.bin filter=lfs diff=lfs merge=lfs -text
15
+ *.svg filter=lfs diff=lfs merge=lfs -text
reachy_mini/.github/workflows/lint.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Linters
2
+ on: [ push, pull_request ]
3
+ jobs:
4
+ ruff:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v4
8
+ - uses: astral-sh/ruff-action@v3
9
+ with:
10
+ version: "0.12.0"
11
+
12
+ mypy:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Set up Python 3.10
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.10"
20
+ cache: 'pip' # caching pip dependencies
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install .[dev]
25
+ - name : Lint with mypy
26
+ run : |
27
+ mypy --install-types --non-interactive
reachy_mini/.github/workflows/pytest.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Pytest
2
+ on: [pull_request]
3
+ jobs:
4
+ pytest:
5
+ runs-on: ${{ matrix.os }}
6
+ strategy:
7
+ matrix:
8
+ os: [ubuntu-latest, macos-latest]
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ with:
12
+ lfs: "true"
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.10"
16
+ cache: "pip"
17
+ - name: Install system dependencies (Ubuntu)
18
+ if: matrix.os == 'ubuntu-latest'
19
+ run: sudo apt-get update && sudo apt-get install -y libportaudio2
20
+ - name: Install dependencies
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ pip install .[dev]
24
+ - name: Run tests
25
+ run: |
26
+ pytest -vv -m 'not audio and not video and not audio_gstreamer and not video_gstreamer and not wireless and not wireless_gstreamer' --tb=short
27
+ env:
28
+ MUJOCO_GL: disable
reachy_mini/.github/workflows/wheels.yml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v5
15
+ with:
16
+ lfs: true
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v6
19
+ with:
20
+ python-version: "3.10"
21
+ - name: Install build dependencies
22
+ run: pip install build
23
+ - name: Build distribution
24
+ run: python -m build
25
+ - name: Publish
26
+ uses: pypa/[email protected]
reachy_mini/.github/workflows/wheels.yml.bak ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Release Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ linux:
11
+ runs-on: ${{ matrix.platform.runner }}
12
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
13
+ strategy:
14
+ matrix:
15
+ platform:
16
+ - runner: ubuntu-22.04
17
+ target: x86_64
18
+ - runner: ubuntu-22.04
19
+ target: x86
20
+ - runner: ubuntu-22.04
21
+ target: aarch64
22
+ - runner: ubuntu-22.04
23
+ target: armv7
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: |
29
+ 3.8
30
+ 3.9
31
+ 3.10
32
+ 3.11
33
+ 3.12
34
+ 3.13
35
+ - name: Build wheels
36
+ run: |
37
+ pip install build
38
+ python -m build --wheel --outdir dist
39
+ - name: Upload wheels
40
+ uses: actions/upload-artifact@v4
41
+ with:
42
+ name: wheels-linux-${{ matrix.platform.target }}
43
+ path: dist/*.whl
44
+
45
+ musllinux:
46
+ runs-on: ${{ matrix.platform.runner }}
47
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
48
+ strategy:
49
+ matrix:
50
+ platform:
51
+ - runner: ubuntu-22.04
52
+ target: x86_64
53
+ - runner: ubuntu-22.04
54
+ target: x86
55
+ - runner: ubuntu-22.04
56
+ target: aarch64
57
+ - runner: ubuntu-22.04
58
+ target: armv7
59
+ steps:
60
+ - uses: actions/checkout@v4
61
+ - uses: actions/setup-python@v5
62
+ with:
63
+ python-version: |
64
+ 3.8
65
+ 3.9
66
+ 3.10
67
+ 3.11
68
+ 3.12
69
+ 3.13
70
+ - name: Build wheels
71
+ run: |
72
+ pip install build
73
+ python -m build --wheel --outdir dist
74
+ - name: Upload wheels
75
+ uses: actions/upload-artifact@v4
76
+ with:
77
+ name: wheels-musllinux-${{ matrix.platform.target }}
78
+ path: dist/*.whl
79
+
80
+ windows:
81
+ runs-on: ${{ matrix.platform.runner }}
82
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
83
+ strategy:
84
+ matrix:
85
+ platform:
86
+ - runner: windows-latest
87
+ target: x64
88
+ - runner: windows-latest
89
+ target: x86
90
+ steps:
91
+ - uses: actions/checkout@v4
92
+ - uses: actions/setup-python@v5
93
+ with:
94
+ python-version: |
95
+ 3.8
96
+ 3.9
97
+ 3.10
98
+ 3.11
99
+ 3.12
100
+ 3.13
101
+ architecture: ${{ matrix.platform.target }}
102
+ - name: Build wheels
103
+ run: |
104
+ pip install build
105
+ python -m build --wheel --outdir dist
106
+ - name: Upload wheels
107
+ uses: actions/upload-artifact@v4
108
+ with:
109
+ name: wheels-windows-${{ matrix.platform.target }}
110
+ path: dist/*.whl
111
+
112
+ macos:
113
+ runs-on: ${{ matrix.platform.runner }}
114
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
115
+ strategy:
116
+ matrix:
117
+ platform:
118
+ - runner: macos-13
119
+ target: x86_64
120
+ - runner: macos-14
121
+ target: aarch64
122
+ steps:
123
+ - uses: actions/checkout@v4
124
+ - uses: actions/setup-python@v5
125
+ with:
126
+ python-version: |
127
+ 3.8
128
+ 3.9
129
+ 3.10
130
+ 3.11
131
+ 3.12
132
+ 3.13
133
+ - name: Build wheels
134
+ run: |
135
+ pip install build
136
+ python -m build --wheel --outdir dist
137
+ - name: Upload wheels
138
+ uses: actions/upload-artifact@v4
139
+ with:
140
+ name: wheels-macos-${{ matrix.platform.target }}
141
+ path: dist/*.whl
142
+
143
+ sdist:
144
+ runs-on: ubuntu-latest
145
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
146
+ steps:
147
+ - uses: actions/checkout@v4
148
+ - name: Build sdist
149
+ run: |
150
+ pip install build
151
+ python -m build --sdist --outdir dist
152
+ - name: Upload sdist
153
+ uses: actions/upload-artifact@v4
154
+ with:
155
+ name: wheels-sdist
156
+ path: dist/*.tar.gz
157
+
158
+ release:
159
+ name: Release
160
+ runs-on: ubuntu-latest
161
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
162
+ needs: [linux, musllinux, windows, macos, sdist]
163
+ permissions:
164
+ id-token: write
165
+ contents: write
166
+ attestations: write
167
+ steps:
168
+ - uses: actions/download-artifact@v4
169
+ with:
170
+ pattern: wheels-*
171
+ merge-multiple: true
172
+ path: dist
173
+ - name: Generate artifact attestation
174
+ uses: actions/attest-build-provenance@v1
175
+ with:
176
+ subject-path: 'dist/*'
177
+ - name: Publish to PyPI
178
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
179
+ uses: pypa/gh-action-pypi-publish@release/v1
180
+ with:
181
+ packages-dir: dist/
reachy_mini/.gitignore ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ .idea/**/workspace.xml
186
+ .idea/**/tasks.xml
187
+ .idea/**/usage.statistics.xml
188
+ .idea/**/dictionaries
189
+ .idea/**/shelf
190
+ .idea/**/dataSources/
191
+ .idea/**/dataSources.ids
192
+ .idea/**/dataSources.local.xml
193
+ .idea/**/sqlDataSources.xml
194
+ .idea/**/dynamic.xml
195
+ .idea/**/uiDesigner.xml
196
+ .idea/**/dbnavigator.xml
197
+ .idea/**/contentModel.xml
198
+
199
+ # Abstra
200
+ # Abstra is an AI-powered process automation framework.
201
+ # Ignore directories containing user credentials, local state, and settings.
202
+ # Learn more at https://abstra.io/docs
203
+ .abstra/
204
+
205
+ # Visual Studio Code
206
+ .vscode/*
207
+ !.vscode/settings.json
208
+ !.vscode/tasks.json
209
+ !.vscode/launch.json
210
+ !.vscode/extensions.json
211
+ !.vscode/*.code-snippets
212
+ !*.code-workspace
213
+
214
+ # Ruff stuff:
215
+ .ruff_cache/
216
+
217
+ # PyPI configuration file
218
+ .pypirc
219
+
220
+ # Marimo
221
+ marimo/_static/
222
+ marimo/_lsp/
223
+ __marimo__/
224
+
225
+ # Streamlit
226
+ .streamlit/secrets.toml
227
+
228
+ # General for macOS
229
+ .DS_Store
230
+ __MACOSX/
231
+ .AppleDouble
232
+ .LSOverride
233
+ Icon[]
234
+
235
+ # General for Linux
236
+ *~
237
+ .fuse_hidden*
238
+ .directory
239
+ .Trash-*
240
+ .nfs*
241
+ nohup.out
242
+
243
+ # General for Windows
244
+ Thumbs.db
245
+ Thumbs.db:encryptable
246
+ ehthumbs.db
247
+ ehthumbs_vista.db
248
+ [Dd]esktop.ini
249
+ *.stackdump
250
+ $RECYCLE.BIN/
251
+ *.lnk
252
+
253
+ # Project specific ignores
254
+ src/reachy_mini_dashboard/installed_apps/*
255
+ examples/debug/measures/*
256
+ .DS_Store
reachy_mini/.pre-commit-config.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ # Ruff version. Make sure it matches the version in .github/workflows/lint.yml.
4
+ rev: v0.12.0
5
+ hooks:
6
+ # Run the linter.
7
+ - id: ruff-check
8
+ args: ["--select", "I", "--select", "D", "--ignore", "D203", "--ignore", "D213"]
9
+ # Run the formatter.
10
+ - id: ruff-format
reachy_mini/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Pollen Robotics
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
reachy_mini/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ recursive-include src/reachy_mini/assets *
2
+ recursive-include src/reachy_mini/templates *
3
+ recursive-include src/reachy_mini/descriptions *
reachy_mini/README.md ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reachy Mini
2
+
3
+ > ⚠️ Reachy Mini is still in beta. Expect bugs, some of them we won't fix right away if they are not a priority.
4
+
5
+ [Reachy Mini](https://www.pollen-robotics.com/reachy-mini/) is an expressive, open-source robot designed for human-robot interaction, creative coding, and AI experimentation. We made it to be affordable, easy to use, hackable and cute, so that you can focus on building cool AI applications!
6
+
7
+ [![Reachy Mini Hello](/docs/assets/reachy_mini_hello.gif)](https://www.pollen-robotics.com/reachy-mini/)
8
+
9
+ ### Versions Lite & Wireless
10
+
11
+ Reachy Mini's hardware comes in two flavors:
12
+ - **Reachy Mini lite**: where the robot is directly connected to your computer via USB. And the code that controls the robot (the daemon) runs on your computer.
13
+ - **Reachy Mini wireless**: where an Raspberry Pi is embedded in the robot, and the code that controls the robot (the daemon) runs on the Raspberry Pi. You can connect to it via Wi-Fi from your computer (see [Wireless Setup](./docs/wireless-version.md)).
14
+
15
+ There is also a simulated version of Reachy Mini in [MuJoCo](https://mujoco.org) that you can use to prototype your applications before deploying them on the real robot. It behaves like the lite version where the daemon runs on your computer.
16
+
17
+ ## Assembly guide
18
+
19
+ 📖 Follow our step-by-step [Assembly Guide](https://huggingface.co/spaces/pollen-robotics/Reachy_Mini_Assembly_Guide).
20
+
21
+ Most builders finish in about 3 hours, our current speed record is 43 minutes. The guide walks you through every step with clear visuals so you can assemble Reachy Mini confidently from start to finish. Enjoy the build!
22
+
23
+ ▶️ View the [Assembly Video](https://youtu.be/_r0cHySFbeY?si=6Mw4js8HSUs4cwoJ).
24
+
25
+ ## Software overview
26
+
27
+ This repository provides everything you need to control Reachy Mini, both in simulation and on the real robot. It consists of two main parts:
28
+
29
+ - **The 😈 Daemon 😈**: A background service that manages communication with the robot's motors and sensors, or with the simulation environment. It should be running before you can control the robot. It can run either for the simulation (MuJoCo) or for the real robot.
30
+ - **🐍 SDK & 🕸️ API** to control the robot's main features (head, antennas, camera, speakers, microphone, etc.) and connect with your AI experimentation. Depending on your preferences and needs, there is a [Python SDK](#using-the-python-sdk) and a [HTTP REST API](#using-the-rest-api).
31
+
32
+ Using the [Python SDK](#using-the-python-sdk), making your robot move only require a few lines of code, as illustrated in the example below:
33
+
34
+ ```python
35
+ from reachy_mini import ReachyMini
36
+ from reachy_mini.utils import create_head_pose
37
+
38
+ with ReachyMini() as reachy_mini:
39
+ # Move the head up (10mm on z-axis) and roll it 15 degrees
40
+ pose = create_head_pose(z=10, roll=15, degrees=True, mm=True)
41
+ reachy_mini.goto_target(head=pose, duration=2.0)
42
+
43
+ # Reset to default pose
44
+ pose = create_head_pose()
45
+ reachy_mini.goto_target(head=pose, duration=2.0)
46
+ ```
47
+
48
+ and using the [REST API](#using-the-rest-api), reading the current state of the robot:
49
+
50
+ ```bash
51
+ curl 'http://localhost:8000/api/state/full'
52
+ ```
53
+
54
+ Those two examples above assume that the daemon is already running (either in simulation or on the real robot) locally.
55
+
56
+ ## Installation of the daemon and Python SDK
57
+
58
+ As mentioned above, before being able to use the robot, you need to run the daemon that will handle the communication with the motors.
59
+
60
+ We support and test on Linux and macOS. It's also working on Windows, but it is less tested at the moment. Do not hesitate to open an issue if you encounter any problem.
61
+
62
+ The daemon is built in Python, so you need to have Python installed on your computer (versions from 3.10 to 3.13 are supported). We recommend using a virtual environment to avoid dependency conflicts with your other Python projects.
63
+
64
+ You can install Reachy Mini from the source code or from PyPI.
65
+
66
+ First, make sure `git-lfs` is installed on your system:
67
+
68
+ - On Linux: `sudo apt install git-lfs`
69
+ - On macOS: `brew install git-lfs`
70
+ - On Windows: [Follow the instructions here](https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage?platform=windows)
71
+
72
+ From PyPI, you can install the package with:
73
+
74
+ ```bash
75
+ pip install reachy-mini
76
+ ```
77
+
78
+ From the source code, you can install the package with:
79
+
80
+ ```bash
81
+ git clone https://github.com/pollen-robotics/reachy_mini
82
+ pip install -e ./reachy_mini
83
+ ```
84
+
85
+ *Note that uv users can directly run the daemon with:*
86
+ ```bash
87
+ uv run reachy-mini-daemon
88
+ ```
89
+
90
+ The same package provides both the daemon and the Python SDK.
91
+
92
+
93
+ ## Run the reachy mini daemon
94
+
95
+ Before being able to use the robot, you need to run the daemon that will handle the communication with the motors. This daemon can run either in simulation (MuJoCo) or on the real robot.
96
+
97
+ ```bash
98
+ reachy-mini-daemon
99
+ ```
100
+
101
+ or run it via the Python module:
102
+
103
+ ```bash
104
+ python -m reachy_mini.daemon.app.main
105
+ ```
106
+
107
+ Additional argument for both simulation and real robot:
108
+
109
+ ```bash
110
+ --localhost-only: (default behavior). The server will only accept connections from localhost.
111
+ ```
112
+
113
+ or
114
+
115
+ ```bash
116
+ --no-localhost-only: If set, the server will accept connections from any connection on the local network.
117
+ ```
118
+
119
+ ### In simulation ([MuJoCo](https://mujoco.org))
120
+
121
+ You first have to install the optional dependency `mujoco`.
122
+
123
+ ```bash
124
+ pip install reachy-mini[mujoco]
125
+ ```
126
+
127
+ Then run the daemon with the `--sim` argument.
128
+
129
+ ```bash
130
+ reachy-mini-daemon --sim
131
+ ```
132
+
133
+ Additional arguments:
134
+
135
+ ```bash
136
+ --scene <empty|minimal> : (Default empty). Choose between a basic empty scene, or a scene with a table and some objects.
137
+ ```
138
+
139
+ <img src="https://www.pollen-robotics.com/wp-content/uploads/2025/06/Reachy_mini_simulation.gif" width="250" alt="Reachy Mini in MuJoCo">
140
+
141
+
142
+ *Note: On OSX in order to run mujoco, you need to use mjpython (see [here](https://mujoco.readthedocs.io/en/stable/python.html#passive-viewer)). So, you should run the daemon with:*
143
+
144
+ ```bash
145
+ mjpython -m reachy_mini.daemon.app.main --sim
146
+ ```
147
+
148
+ ### For the lite version (connected via USB)
149
+
150
+ It should automatically detect the serial port of the robot. If it does not, you can specify it manually with the `-p` option:
151
+
152
+ ```bash
153
+ reachy-mini-daemon -p <serial_port>
154
+ ```
155
+
156
+ ### Usage
157
+
158
+ For more information about the daemon and its options, you can run:
159
+
160
+ ```bash
161
+ reachy-mini-daemon --help
162
+ ```
163
+
164
+ ### Dashboard
165
+
166
+ You can access a simple dashboard to monitor the robot's status at [http://localhost:8000/](http://localhost:8000/) when the daemon is running. This lets you turn your robot on and off, run some basic movements, and browse spaces for Reachy Mini!
167
+
168
+ ![Reachy Mini Dashboard](docs/assets/dashboard.png)
169
+
170
+ ## Run the demo & awesome apps
171
+
172
+ Conversational demo for the Reachy Mini robot combining LLM realtime APIs, vision pipelines, and choreographed motion libraries: [reachy_mini_conversation_demo](https://github.com/pollen-robotics/reachy_mini_conversation_demo).
173
+
174
+ You can find more awesome apps and demos for Reachy Mini on [Hugging Face spaces](https://huggingface.co/spaces?q=reachy_mini)!
175
+
176
+ ## Using the Python SDK
177
+
178
+ The API is designed to be simple and intuitive. You can control the robot's features such as the head, antennas, camera, speakers, and microphone. For instance, to move the head of the robot, you can use the `goto_target` method as shown in the example below:
179
+
180
+ ```python
181
+ from reachy_mini import ReachyMini
182
+ from reachy_mini.utils import create_head_pose
183
+
184
+ with ReachyMini() as reachy_mini:
185
+ # Move the head up (10mm on z-axis) and roll it 15 degrees
186
+ pose = create_head_pose(z=10, roll=15, degrees=True, mm=True)
187
+ reachy_mini.goto_target(head=pose, duration=2.0)
188
+
189
+ # Reset to default pose
190
+ pose = create_head_pose()
191
+ reachy_mini.goto_target(head=pose, duration=2.0)
192
+ ```
193
+
194
+ For a full description of the SDK, please refer to the [Python SDK documentation](./docs/python-sdk.md).
195
+
196
+ ## Using the REST API
197
+
198
+ The daemon also provides a REST API via [fastapi](https://fastapi.tiangolo.com/) that you can use to control the robot and get its state. The API is accessible via HTTP and WebSocket.
199
+
200
+ By default, the API server runs on `http://localhost:8000`. The API is documented using OpenAPI, and you can access the documentation at `http://localhost:8000/docs` when the daemon is running.
201
+
202
+ More information about the API can be found in the [HTTP API documentation](./docs/rest-api.md).
203
+
204
+ ## Open source & contribution
205
+
206
+ This project is actively developed and maintained by the [Pollen Robotics team](https://www.pollen-robotics.com) and the [Hugging Face team](https://huggingface.co/).
207
+
208
+ We welcome contributions from the community! If you want to report a bug or request a feature, please open an issue on GitHub. If you want to contribute code, please fork the repository and submit a pull request.
209
+
210
+ ### 3D models
211
+
212
+ TODO
213
+
214
+ ### Contributing
215
+
216
+ Development tools are available in the optional dependencies.
217
+
218
+ ```bash
219
+ pip install -e .[dev]
220
+ pre-commit install
221
+ ```
222
+
223
+ Your files will be checked before any commit. Checks may also be manually run with
224
+
225
+ ```bash
226
+ pre-commit run --all-files
227
+ ```
228
+
229
+ Checks are performed by Ruff. You may want to [configure your IDE to support it](https://docs.astral.sh/ruff/editors/setup/).
230
+
231
+ ## Troubleshooting
232
+
233
+ see [dedicated section](docs/troubleshooting.md)
234
+
235
+ ## License
236
+
237
+ This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
238
+
239
+ The robot design files are licensed under the [TODO](TODO) license.
240
+
241
+ ### Simulation model used
242
+
243
+ - https://polyhaven.com/a/food_apple_01
244
+ - https://polyhaven.com/a/croissant
245
+ - https://polyhaven.com/a/wooden_table_02
246
+ - https://polyhaven.com/a/rubber_duck_toy
reachy_mini/conftest.py ADDED
File without changes
reachy_mini/pyproject.toml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "reachy_mini"
7
+ version = "1.1.1"
8
+ authors = [{ name = "Pollen Robotics", email = "[email protected]" }]
9
+ description = ""
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "numpy>=2.2.5",
14
+ "scipy>=1.15.3, <2.0.0",
15
+ "reachy_mini_motor_controller>=1.4.2",
16
+ "eclipse-zenoh>=1.4.0",
17
+ "opencv-python<=5.0",
18
+ "cv2_enumerate_cameras>=1.2.1",
19
+ "psutil",
20
+ "jinja2",
21
+ "uvicorn[standard]",
22
+ "fastapi",
23
+ "pyserial",
24
+ "huggingface-hub==0.34.4",
25
+ "sounddevice==0.5.1",
26
+ "soundfile==0.13.1",
27
+ "reachy-mini-rust-kinematics>=1.0.2",
28
+ "asgiref",
29
+ "aiohttp",
30
+ "log-throttling==0.0.3",
31
+ "pyusb>=1.2.1",
32
+ "libusb_package>=1.0.26.3",
33
+ "pip>=25",
34
+ ]
35
+
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest",
40
+ "pytest-asyncio",
41
+ "ruff==0.12.0",
42
+ "onshape-to-robot==1.7.6",
43
+ "mujoco==3.3.0",
44
+ "placo==0.9.14",
45
+ "pre-commit",
46
+ "mypy==1.18.2",
47
+ "rustypot>=1.4.0",
48
+ "types-requests",
49
+ "rerun-sdk>=0.27.2",
50
+ "urdf-parser-py==0.0.4",
51
+ ]
52
+ examples = ["pynput"]
53
+ mujoco = ["mujoco==3.3.0"]
54
+ nn_kinematics = ["onnxruntime==1.22.1"]
55
+ placo_kinematics = ["placo==0.9.14"]
56
+ gstreamer = ["PyGObject>=3.42.2,<=3.46.0", "gst-signalling>=1.1.2"]
57
+ rerun = ["rerun-sdk>=0.27.2", "urdf-parser-py==0.0.4"]
58
+ wireless-version = [
59
+ "semver>=3,<4",
60
+ "nmcli>=1.5",
61
+ "pollen_BMI088_imu_library",
62
+ "gpiozero>=2.0.0",
63
+ "lgpio>=0.2.2.0",
64
+ ]
65
+
66
+ [project.scripts]
67
+ reachy-mini-daemon = "reachy_mini.daemon.app.main:main"
68
+ reachy-mini-apps-helper = "reachy_mini.apps.app:main"
69
+
70
+ [tool.setuptools]
71
+ package-dir = { "" = "src" }
72
+ include-package-data = true
73
+
74
+
75
+ [tool.setuptools.packages.find]
76
+ where = ["src"]
77
+
78
+
79
+ [tool.setuptools.package-data]
80
+ reachy_mini = ["**/*"] # Inclut tous les fichiers non .py
81
+
82
+ [tool.ruff]
83
+ exclude = [
84
+ "src/reachy_mini/__init__.py",
85
+ "build/*",
86
+ "conftest.py",
87
+ "src/reachy_mini_dashboard/*",
88
+ "tests/*",
89
+ ]
90
+ lint.extend-select = ["I", "D"]
91
+ lint.ignore = [
92
+ "D203", # Incompatible with D211
93
+ "D213", # Incompatible with D212
94
+ ]
95
+
96
+ [tool.pytest.ini_options]
97
+ testpaths = ["tests"]
98
+ markers = [
99
+ "audio: mark test as requiring audio hardware",
100
+ "audio_gstreamer: mark test as requiring GStreamer for audio",
101
+ "video: mark test as requiring video hardware",
102
+ "video_gstreamer: mark test as requiring GStreamer for video",
103
+ "wireless: mark test as requiring wireless Reachy Mini",
104
+ "wireless_gstreamer: mark test as requiring GStreamer for wireless Reachy Mini",
105
+ ]
106
+
107
+ [tool.mypy]
108
+ python_version = "3.10"
109
+ files = ["src/"]
110
+ ignore_missing_imports = true
111
+ strict = true
reachy_mini/src/reachy_mini/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Reachy Mini SDK."""
2
+
3
+ from reachy_mini.apps.app import ReachyMiniApp # noqa: F401
4
+ from reachy_mini.reachy_mini import ReachyMini # noqa: F401
reachy_mini/src/reachy_mini/apps/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Metadata about apps."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from enum import Enum
5
+ from typing import Any, Dict
6
+
7
+
8
+ class SourceKind(str, Enum):
9
+ """Kinds of app source."""
10
+
11
+ HF_SPACE = "hf_space"
12
+ DASHBOARD_SELECTION = "dashboard_selection"
13
+ LOCAL = "local"
14
+ INSTALLED = "installed"
15
+
16
+
17
+ @dataclass
18
+ class AppInfo:
19
+ """Metadata about an app."""
20
+
21
+ name: str
22
+ source_kind: SourceKind
23
+ description: str = ""
24
+ url: str | None = None
25
+ extra: Dict[str, Any] = field(default_factory=dict)
reachy_mini/src/reachy_mini/apps/app.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Reachy Mini Application Base Class.
2
+
3
+ This module provides a base class for creating Reachy Mini applications.
4
+ It includes methods for running the application, stopping it gracefully,
5
+ and creating a new app project with a specified name and path.
6
+
7
+ It uses Jinja2 templates to generate the necessary files for the app project.
8
+ """
9
+
10
+ import os
11
+ import threading
12
+ import traceback
13
+ from abc import ABC, abstractmethod
14
+ from pathlib import Path
15
+ from typing import Any, Dict
16
+
17
+ from jinja2 import Environment, FileSystemLoader
18
+
19
+ from reachy_mini.reachy_mini import ReachyMini
20
+
21
+
22
+ class ReachyMiniApp(ABC):
23
+ """Base class for Reachy Mini applications."""
24
+
25
+ custom_app_url: str | None = None
26
+
27
+ def __init__(self) -> None:
28
+ """Initialize the Reachy Mini app."""
29
+ self.stop_event = threading.Event()
30
+ self.error: str = ""
31
+
32
+ def wrapped_run(self, *args: Any, **kwargs: Any) -> None:
33
+ """Wrap the run method with Reachy Mini context management."""
34
+ try:
35
+ with ReachyMini(*args, **kwargs) as reachy_mini:
36
+ self.run(reachy_mini, self.stop_event)
37
+ except Exception:
38
+ self.error = traceback.format_exc()
39
+ raise
40
+
41
+ @abstractmethod
42
+ def run(self, reachy_mini: ReachyMini, stop_event: threading.Event) -> None:
43
+ """Run the main logic of the app.
44
+
45
+ Args:
46
+ reachy_mini (ReachyMini): The Reachy Mini instance to interact with.
47
+ stop_event (threading.Event): An event that can be set to stop the app gracefully.
48
+
49
+ """
50
+ pass
51
+
52
+ def stop(self) -> None:
53
+ """Stop the app gracefully."""
54
+ self.stop_event.set()
55
+ print("App is stopping...")
56
+
57
+
58
+ def make_app_project(app_name: str, path: Path) -> None:
59
+ """Create a new Reachy Mini app project with the given name at the specified path.
60
+
61
+ Args:
62
+ app_name (str): The name of the app to create.
63
+ path (Path): The directory where the app project will be created.
64
+
65
+ """
66
+ TEMPLATE_DIR = Path(__file__).parent / "templates"
67
+ env = Environment(loader=FileSystemLoader(TEMPLATE_DIR))
68
+
69
+ def render_template(filename: str, context: Dict[str, str]) -> str:
70
+ template = env.get_template(filename)
71
+ return template.render(context)
72
+
73
+ base_path = Path(path).resolve() / app_name
74
+ if base_path.exists():
75
+ print(f"❌ Folder {base_path} already exists.")
76
+ return
77
+
78
+ module_name = app_name.replace("-", "_")
79
+ class_name = "".join(word.capitalize() for word in module_name.split("_"))
80
+ class_name_display = " ".join(word.capitalize() for word in module_name.split("_"))
81
+
82
+ base_path.mkdir()
83
+ (base_path / module_name).mkdir()
84
+
85
+ # Generate files
86
+ context = {
87
+ "app_name": app_name,
88
+ "package_name": app_name,
89
+ "module_name": module_name,
90
+ "class_name": class_name,
91
+ "class_name_display": class_name_display,
92
+ }
93
+
94
+ (base_path / module_name / "__init__.py").touch()
95
+ (base_path / module_name / "main.py").write_text(
96
+ render_template("main.py.j2", context)
97
+ )
98
+ (base_path / "pyproject.toml").write_text(
99
+ render_template("pyproject.toml.j2", context)
100
+ )
101
+ (base_path / "README.md").write_text(render_template("README.md.j2", context))
102
+
103
+ (base_path / "index.html").write_text(render_template("index.html.j2", context))
104
+ (base_path / "style.css").write_text(render_template("style.css.j2", context))
105
+
106
+ print(f"✅ Created app in {base_path}/")
107
+
108
+
109
+ def publish_app(app_path: str, hf_space_url: Path) -> None:
110
+ """Publish the app to the Reachy Mini app store.
111
+
112
+ Args:
113
+ app_path (str): Local path to the app to publish.
114
+ hf_space_url (Path): Url to the space on Hugging Face.
115
+
116
+ """
117
+ # Placeholder for publishing logic
118
+ assert os.path.exists(app_path), f"App path {app_path} does not exist."
119
+ print(f"Publishing app from {app_path} to {hf_space_url}...")
120
+ os.system(
121
+ f"cd {app_path} && git init && git remote add space {hf_space_url} && git add . && git commit -m 'Initial commit' && git push -f space main:main"
122
+ )
123
+ print("✅ App published successfully.")
124
+
125
+
126
+ def main() -> None:
127
+ """Run the command line interface to create a new Reachy Mini app project."""
128
+ import argparse
129
+
130
+ parser = argparse.ArgumentParser(
131
+ description="Create a new Reachy Mini app project."
132
+ )
133
+ subparsers = parser.add_subparsers(
134
+ dest="command", help="Available commands", required=True
135
+ )
136
+
137
+ make_parser = subparsers.add_parser("make", help="Make a new app project")
138
+ make_parser.add_argument(
139
+ "--option", type=str, help="An option for the make command"
140
+ )
141
+ make_parser.add_argument("app_name", type=str, help="Name of the app to create.")
142
+ make_parser.add_argument(
143
+ "path",
144
+ type=Path,
145
+ default=Path.cwd(),
146
+ help="Path where the app project will be created.",
147
+ )
148
+
149
+ publish_parser = subparsers.add_parser(
150
+ "publish", help="Publish the app to the Reachy Mini app store"
151
+ )
152
+ publish_parser.add_argument(
153
+ "app_path", type=str, help="Local path to the app to publish."
154
+ )
155
+ publish_parser.add_argument(
156
+ "hf_space_url", type=Path, help="Url to the space on Hugging Face."
157
+ )
158
+
159
+ args = parser.parse_args()
160
+
161
+ if args.command == "make":
162
+ make_app_project(args.app_name, args.path)
163
+
164
+ elif args.command == "publish":
165
+ publish_app(args.app_path, args.hf_space_url)
166
+
167
+
168
+ if __name__ == "__main__":
169
+ main()
reachy_mini/src/reachy_mini/apps/manager.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """App management for Reachy Mini."""
2
+
3
+ import asyncio
4
+ import logging
5
+ from dataclasses import dataclass
6
+ from enum import Enum
7
+ from importlib.metadata import entry_points
8
+ from threading import Thread
9
+ from typing import TYPE_CHECKING, Any, Optional
10
+
11
+ from pydantic import BaseModel
12
+
13
+ from . import AppInfo, SourceKind
14
+ from .sources import hf_space, local_common_venv
15
+
16
+ if TYPE_CHECKING:
17
+ from .app import ReachyMiniApp
18
+
19
+
20
+ class AppState(str, Enum):
21
+ """Status of a running app."""
22
+
23
+ STARTING = "starting"
24
+ RUNNING = "running"
25
+ DONE = "done"
26
+ STOPPING = "stopping"
27
+ ERROR = "error"
28
+
29
+
30
+ class AppStatus(BaseModel):
31
+ """Status of an app."""
32
+
33
+ info: AppInfo
34
+ state: AppState
35
+ error: str | None = None
36
+
37
+
38
+ @dataclass
39
+ class RunningApp:
40
+ """Information about a running app."""
41
+
42
+ app: "ReachyMiniApp"
43
+ thread: Thread
44
+ status: AppStatus
45
+
46
+
47
+ class AppManager:
48
+ """Manager for Reachy Mini apps."""
49
+
50
+ def __init__(self) -> None:
51
+ """Initialize the AppManager."""
52
+ self.current_app = None # type: RunningApp | None
53
+ self.logger = logging.getLogger("reachy_mini.apps.manager")
54
+
55
+ async def close(self) -> None:
56
+ """Clean up the AppManager, stopping any running app."""
57
+ if self.is_app_running():
58
+ await self.stop_current_app()
59
+
60
+ # App lifecycle management
61
+ # Only one app can be started at a time for now
62
+ def is_app_running(self) -> bool:
63
+ """Check if an app is currently running."""
64
+ return self.current_app is not None and self.current_app.status.state in (
65
+ AppState.STARTING,
66
+ AppState.RUNNING,
67
+ AppState.ERROR,
68
+ )
69
+
70
+ async def start_app(self, app_name: str, *args: Any, **kwargs: Any) -> AppStatus:
71
+ """Start the app, raises RuntimeError if an app is already running."""
72
+ if self.is_app_running():
73
+ raise RuntimeError("An app is already running")
74
+
75
+ (ep,) = entry_points(group="reachy_mini_apps", name=app_name)
76
+ app = ep.load()()
77
+
78
+ def wrapped_run() -> None:
79
+ assert self.current_app is not None
80
+
81
+ try:
82
+ self.current_app.status.state = AppState.RUNNING
83
+ self.logger.getChild("runner").info(f"App {app_name} is running")
84
+ app.wrapped_run(*args, **kwargs)
85
+ self.current_app.status.state = AppState.DONE
86
+ self.logger.getChild("runner").info(f"App {app_name} finished")
87
+ except Exception as e:
88
+ self.logger.getChild("runner").error(
89
+ f"An error occurred in the app {app_name}: {e}"
90
+ )
91
+ self.logger.getChild("runner").error(
92
+ f"Exception details: '{app.error}'",
93
+ )
94
+ self.current_app.status.state = AppState.ERROR
95
+ self.current_app.status.error = str(app.error)
96
+
97
+ self.current_app = RunningApp(
98
+ status=AppStatus(
99
+ info=AppInfo(name=app_name, source_kind=SourceKind.INSTALLED),
100
+ state=AppState.STARTING,
101
+ error=None,
102
+ ),
103
+ app=app,
104
+ thread=Thread(target=wrapped_run),
105
+ )
106
+ self.logger.getChild("runner").info(f"Starting app {app_name}")
107
+ self.current_app.thread.start()
108
+
109
+ return self.current_app.status
110
+
111
+ async def stop_current_app(self, timeout: float | None = 5.0) -> None:
112
+ """Stop the current app."""
113
+ if not self.is_app_running():
114
+ raise RuntimeError("No app is currently running")
115
+
116
+ assert self.current_app is not None
117
+
118
+ self.current_app.status.state = AppState.STOPPING
119
+ self.logger.getChild("runner").info(
120
+ f"Stopping app {self.current_app.status.info.name}"
121
+ )
122
+ self.current_app.app.stop()
123
+ self.current_app.thread.join(timeout)
124
+
125
+ if self.current_app.thread.is_alive():
126
+ self.logger.getChild("runner").warning(
127
+ "The app did not stop within the timeout"
128
+ )
129
+ else:
130
+ self.logger.getChild("runner").info("App stopped successfully")
131
+
132
+ self.current_app = None
133
+
134
+ async def restart_current_app(self) -> AppStatus:
135
+ """Restart the current app."""
136
+ if not self.is_app_running():
137
+ raise RuntimeError("No app is currently running")
138
+
139
+ assert self.current_app is not None
140
+
141
+ app_info = self.current_app.status.info
142
+
143
+ await self.stop_current_app()
144
+ await self.start_app(app_info.name)
145
+
146
+ return self.current_app.status
147
+
148
+ async def current_app_status(self) -> Optional[AppStatus]:
149
+ """Get the current status of the app."""
150
+ if self.current_app is not None:
151
+ return self.current_app.status
152
+ return None
153
+
154
+ # Apps management interface
155
+ async def list_all_available_apps(self) -> list[AppInfo]:
156
+ """List available apps (parallel async)."""
157
+ results = await asyncio.gather(
158
+ *[self.list_available_apps(kind) for kind in SourceKind]
159
+ )
160
+ return sum(results, [])
161
+
162
+ async def list_available_apps(self, source: SourceKind) -> list[AppInfo]:
163
+ """List available apps for given source kind."""
164
+ if source == SourceKind.HF_SPACE:
165
+ return await hf_space.list_all_apps()
166
+ elif source == SourceKind.DASHBOARD_SELECTION:
167
+ return await hf_space.list_available_apps()
168
+ elif source == SourceKind.INSTALLED:
169
+ return await local_common_venv.list_available_apps()
170
+ elif source == SourceKind.LOCAL:
171
+ return []
172
+ else:
173
+ raise NotImplementedError(f"Unknown source kind: {source}")
174
+
175
+ async def install_new_app(self, app: AppInfo, logger: logging.Logger) -> None:
176
+ """Install a new app by name."""
177
+ success = await local_common_venv.install_package(app, logger)
178
+ if success != 0:
179
+ raise RuntimeError(f"Failed to install app '{app.name}'")
180
+
181
+ async def remove_app(self, app_name: str, logger: logging.Logger) -> None:
182
+ """Remove an installed app by name."""
183
+ success = await local_common_venv.uninstall_package(app_name, logger)
184
+ if success != 0:
185
+ raise RuntimeError(f"Failed to uninstall app '{app_name}'")
reachy_mini/src/reachy_mini/apps/sources/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Specific app sources.
2
+
3
+ For the moment, only huggingface spaces is implemented.
4
+ """
reachy_mini/src/reachy_mini/apps/sources/hf_space.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Hugging Face Spaces app source."""
2
+
3
+ import asyncio
4
+ import json
5
+ from typing import Any, Dict
6
+
7
+ import aiohttp
8
+
9
+ from .. import AppInfo, SourceKind
10
+
11
+ # Constants
12
+ AUTHORIZED_APP_LIST_URL = "https://huggingface.co/datasets/pollen-robotics/reachy-mini-official-app-store/raw/main/app-list.json"
13
+ HF_SPACES_API_URL = "https://huggingface.co/api/spaces"
14
+ HF_SPACES_FILTER_URL = "https://huggingface.co/api/spaces?filter=reachy_mini&sort=likes&direction=-1&limit=50&full=true"
15
+ REQUEST_TIMEOUT = aiohttp.ClientTimeout(total=30)
16
+
17
+
18
+ async def _fetch_space_data(
19
+ session: aiohttp.ClientSession, space_id: str
20
+ ) -> Dict[str, Any] | None:
21
+ """Fetch data for a single space from Hugging Face API."""
22
+ url = f"{HF_SPACES_API_URL}/{space_id}"
23
+ try:
24
+ async with session.get(url, timeout=REQUEST_TIMEOUT) as response:
25
+ if response.status == 200:
26
+ data: Dict[str, Any] = await response.json()
27
+ return data
28
+ else:
29
+ return None
30
+ except (aiohttp.ClientError, asyncio.TimeoutError):
31
+ return None
32
+
33
+
34
+ async def list_available_apps() -> list[AppInfo]:
35
+ """List apps available on Hugging Face Spaces."""
36
+ async with aiohttp.ClientSession(timeout=REQUEST_TIMEOUT) as session:
37
+ # Fetch the list of authorized app IDs
38
+ try:
39
+ async with session.get(AUTHORIZED_APP_LIST_URL) as response:
40
+ response.raise_for_status()
41
+ text = await response.text()
42
+ authorized_ids = json.loads(text)
43
+ except (aiohttp.ClientError, json.JSONDecodeError):
44
+ return []
45
+
46
+ if not isinstance(authorized_ids, list):
47
+ return []
48
+
49
+ # Filter to only string elements
50
+ authorized_ids = [
51
+ space_id for space_id in authorized_ids if isinstance(space_id, str)
52
+ ]
53
+
54
+ # Fetch data for each space in parallel
55
+ tasks = [_fetch_space_data(session, space_id) for space_id in authorized_ids]
56
+ spaces_data = await asyncio.gather(*tasks)
57
+
58
+ # Build AppInfo list from fetched data
59
+ apps = []
60
+ for item in spaces_data:
61
+ if item is None or "id" not in item:
62
+ continue
63
+
64
+ apps.append(
65
+ AppInfo(
66
+ name=item["id"].split("/")[-1],
67
+ description=item.get("cardData", {}).get("short_description", ""),
68
+ url=f"https://huggingface.co/spaces/{item['id']}",
69
+ source_kind=SourceKind.HF_SPACE,
70
+ extra=item,
71
+ )
72
+ )
73
+
74
+ return apps
75
+
76
+
77
+ async def list_all_apps() -> list[AppInfo]:
78
+ """List all apps available on Hugging Face Spaces (including unofficial ones)."""
79
+ async with aiohttp.ClientSession(timeout=REQUEST_TIMEOUT) as session:
80
+ try:
81
+ async with session.get(HF_SPACES_FILTER_URL) as response:
82
+ response.raise_for_status()
83
+ data: list[Dict[str, Any]] = await response.json()
84
+ except (aiohttp.ClientError, json.JSONDecodeError, asyncio.TimeoutError):
85
+ return []
86
+
87
+ if not isinstance(data, list):
88
+ return []
89
+
90
+ apps = []
91
+ for item in data:
92
+ if item is None or "id" not in item:
93
+ continue
94
+
95
+ apps.append(
96
+ AppInfo(
97
+ name=item["id"].split("/")[-1],
98
+ description=item.get("cardData", {}).get("short_description", ""),
99
+ url=f"https://huggingface.co/spaces/{item['id']}",
100
+ source_kind=SourceKind.HF_SPACE,
101
+ extra=item,
102
+ )
103
+ )
104
+
105
+ return apps
reachy_mini/src/reachy_mini/apps/sources/local_common_venv.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utilities for local common venv apps source."""
2
+
3
+ import logging
4
+ import sys
5
+ from importlib.metadata import entry_points
6
+
7
+ from .. import AppInfo, SourceKind
8
+ from ..utils import running_command
9
+
10
+
11
+ async def list_available_apps() -> list[AppInfo]:
12
+ """List apps available from entry points."""
13
+ entry_point_apps = list(entry_points(group="reachy_mini_apps"))
14
+
15
+ apps = []
16
+
17
+ for ep in entry_point_apps:
18
+ custom_app_url = None
19
+ try:
20
+ app = ep.load()
21
+ custom_app_url = app.custom_app_url
22
+ except Exception as e:
23
+ logging.getLogger("reachy_mini.apps").warning(
24
+ f"Could not load app '{ep.name}' from entry point: {e}"
25
+ )
26
+ apps.append(
27
+ AppInfo(
28
+ name=ep.name,
29
+ source_kind=SourceKind.INSTALLED,
30
+ extra={"custom_app_url": custom_app_url},
31
+ )
32
+ )
33
+
34
+ return apps
35
+
36
+
37
+ async def install_package(app: AppInfo, logger: logging.Logger) -> int:
38
+ """Install a package given an AppInfo object, streaming logs."""
39
+ if app.source_kind == SourceKind.HF_SPACE:
40
+ target = f"git+{app.url}" if app.url is not None else app.name
41
+ elif app.source_kind == SourceKind.LOCAL:
42
+ target = app.extra.get("path", app.name)
43
+ else:
44
+ raise ValueError(f"Cannot install app from source kind '{app.source_kind}'")
45
+
46
+ return await running_command(
47
+ [sys.executable, "-m", "pip", "install", target],
48
+ logger=logger,
49
+ )
50
+
51
+
52
+ async def uninstall_package(app_name: str, logger: logging.Logger) -> int:
53
+ """Uninstall a package given an app name."""
54
+ existing_apps = await list_available_apps()
55
+ if app_name not in [app.name for app in existing_apps]:
56
+ raise ValueError(f"Cannot uninstall app '{app_name}': it is not installed")
57
+
58
+ return await running_command(
59
+ [sys.executable, "-m", "pip", "uninstall", "-y", app_name],
60
+ logger=logger,
61
+ )
reachy_mini/src/reachy_mini/apps/templates/README.md.j2 ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: {{ class_name_display }}
3
+ emoji: 👋
4
+ colorFrom: red
5
+ colorTo: blue
6
+ sdk: static
7
+ pinned: false
8
+ short_description: Write your description here
9
+ tags:
10
+ - reachy_mini
11
+ ---
reachy_mini/src/reachy_mini/apps/templates/index.html.j2 ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width" />
7
+ <title> {{ class_name_display }} </title>
8
+ <link rel="stylesheet" href="style.css" />
9
+ </head>
10
+
11
+ <body>
12
+ <div class="hero">
13
+ <div class="hero-content">
14
+ <div class="app-icon">🤖⚡</div>
15
+ <h1> {{ class_name_display }} </h1>
16
+ <p class="tagline">Enter your tagline here</p>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="container">
21
+ <div class="main-card">
22
+ <div class="app-preview">
23
+ <div class="preview-image">
24
+ <div class="camera-feed">🛠️</div>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </div>
29
+
30
+ <div class="download-section">
31
+ <div class="download-card">
32
+ <h2>Install This App</h2>
33
+
34
+ <div class="dashboard-config">
35
+ <label for="dashboardUrl">Your Reachy Dashboard URL:</label>
36
+ <input type="url" id="dashboardUrl" value="http://localhost:8000"
37
+ placeholder="http://your-reachy-ip:8000" />
38
+ </div>
39
+
40
+ <button id="installBtn" class="install-btn primary">
41
+ <span class="btn-icon">📥</span>
42
+ Install {{ class_name_display }} to Reachy Mini
43
+ </button>
44
+
45
+ <div id="installStatus" class="install-status"></div>
46
+
47
+ </div>
48
+ </div>
49
+
50
+ <div class="footer">
51
+ <p>
52
+ 🤖 {{ class_name_display }} •
53
+ <a href="https://github.com/pollen-robotics" target="_blank">Pollen Robotics</a> •
54
+ <a href="https://huggingface.co/spaces/pollen-robotics/Reachy_Mini_Apps" target="_blank">Browse More
55
+ Apps</a>
56
+ </p>
57
+ </div>
58
+ </div>
59
+
60
+ <script>
61
+ // Get the current Hugging Face Space URL as the repository URL
62
+ function getCurrentSpaceUrl() {
63
+ // Get current page URL and convert to repository format
64
+ const currentUrl = window.location.href;
65
+
66
+ // Remove any trailing slashes and query parameters
67
+ const cleanUrl = currentUrl.split('?')[0].replace(/\/$/, '');
68
+
69
+ return cleanUrl;
70
+ }
71
+
72
+ // Parse TOML content to extract project name
73
+ function parseTomlProjectName(tomlContent) {
74
+ try {
75
+ const lines = tomlContent.split('\n');
76
+ let inProjectSection = false;
77
+
78
+ for (const line of lines) {
79
+ const trimmedLine = line.trim();
80
+
81
+ // Check if we're entering the [project] section
82
+ if (trimmedLine === '[project]') {
83
+ inProjectSection = true;
84
+ continue;
85
+ }
86
+
87
+ // Check if we're entering a different section
88
+ if (trimmedLine.startsWith('[') && trimmedLine !== '[project]') {
89
+ inProjectSection = false;
90
+ continue;
91
+ }
92
+
93
+ // If we're in the project section, look for the name field
94
+ if (inProjectSection && trimmedLine.startsWith('name')) {
95
+ const match = trimmedLine.match(/name\s*=\s*["']([^"']+)["']/);
96
+ if (match) {
97
+ // Convert to lowercase and replace invalid characters for app naming
98
+ return match[1].toLowerCase().replace(/[^a-z0-9-_]/g, '-');
99
+ }
100
+ }
101
+ }
102
+
103
+ throw new Error('Project name not found in pyproject.toml');
104
+ } catch (error) {
105
+ console.error('Error parsing pyproject.toml:', error);
106
+ return 'unknown-app';
107
+ }
108
+ }
109
+
110
+ // Fetch and parse pyproject.toml from the current space
111
+ async function getAppNameFromCurrentSpace() {
112
+ try {
113
+ // Fetch pyproject.toml from the current space
114
+ const response = await fetch('./pyproject.toml');
115
+ if (!response.ok) {
116
+ throw new Error(`Failed to fetch pyproject.toml: ${response.status}`);
117
+ }
118
+
119
+ const tomlContent = await response.text();
120
+ return parseTomlProjectName(tomlContent);
121
+ } catch (error) {
122
+ console.error('Error fetching app name from current space:', error);
123
+ // Fallback to extracting from URL if pyproject.toml is not accessible
124
+ const url = getCurrentSpaceUrl();
125
+ const parts = url.split('/');
126
+ const spaceName = parts[parts.length - 1];
127
+ return spaceName.toLowerCase().replace(/[^a-z0-9-_]/g, '-');
128
+ }
129
+ }
130
+
131
+ async function installToReachy() {
132
+ const dashboardUrl = document.getElementById('dashboardUrl').value.trim();
133
+ const statusDiv = document.getElementById('installStatus');
134
+ const installBtn = document.getElementById('installBtn');
135
+
136
+ if (!dashboardUrl) {
137
+ showStatus('error', 'Please enter your Reachy dashboard URL');
138
+ return;
139
+ }
140
+
141
+ try {
142
+ installBtn.disabled = true;
143
+ installBtn.innerHTML = '<span class="btn-icon">⏳</span>Installing...';
144
+ showStatus('loading', 'Connecting to your Reachy dashboard...');
145
+
146
+ // Test connection
147
+ const testResponse = await fetch(`${dashboardUrl}/api/status`, {
148
+ method: 'GET',
149
+ mode: 'cors',
150
+ });
151
+
152
+ if (!testResponse.ok) {
153
+ throw new Error('Cannot connect to dashboard. Make sure the URL is correct and the dashboard is running.');
154
+ }
155
+
156
+ showStatus('loading', 'Reading app configuration...');
157
+
158
+ // Get app name from pyproject.toml in current space
159
+ const appName = await getAppNameFromCurrentSpace();
160
+
161
+ // Get current space URL as repository URL
162
+ const repoUrl = getCurrentSpaceUrl();
163
+
164
+ showStatus('loading', `Starting installation of "${appName}"...`);
165
+
166
+ // Start installation
167
+ const installResponse = await fetch(`${dashboardUrl}/api/install`, {
168
+ method: 'POST',
169
+ mode: 'cors',
170
+ headers: {
171
+ 'Content-Type': 'application/json',
172
+ },
173
+ body: JSON.stringify({
174
+ url: repoUrl,
175
+ name: appName
176
+ })
177
+ });
178
+
179
+ const result = await installResponse.json();
180
+
181
+ if (installResponse.ok) {
182
+ showStatus('success', `✅ Installation started for "${appName}"! Check your dashboard for progress.`);
183
+ setTimeout(() => {
184
+ showStatus('info', `Open your dashboard at ${dashboardUrl} to see the installed app.`);
185
+ }, 3000);
186
+ } else {
187
+ throw new Error(result.detail || 'Installation failed');
188
+ }
189
+
190
+ } catch (error) {
191
+ console.error('Installation error:', error);
192
+ showStatus('error', `❌ ${error.message}`);
193
+ } finally {
194
+ installBtn.disabled = false;
195
+ installBtn.innerHTML = '<span class="btn-icon">📥</span>Install App to Reachy';
196
+ }
197
+ }
198
+
199
+ function showStatus(type, message) {
200
+ const statusDiv = document.getElementById('installStatus');
201
+ statusDiv.className = `install-status ${type}`;
202
+ statusDiv.textContent = message;
203
+ statusDiv.style.display = 'block';
204
+ }
205
+
206
+ function copyToClipboard() {
207
+ const repoUrl = document.getElementById('repoUrl').textContent;
208
+ navigator.clipboard.writeText(repoUrl).then(() => {
209
+ showStatus('success', '📋 Repository URL copied to clipboard!');
210
+ }).catch(() => {
211
+ showStatus('error', 'Failed to copy URL. Please copy manually.');
212
+ });
213
+ }
214
+
215
+ // Update the displayed repository URL on page load
216
+ document.addEventListener('DOMContentLoaded', () => {
217
+ // Auto-detect local dashboard
218
+ const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
219
+ if (isLocalhost) {
220
+ document.getElementById('dashboardUrl').value = 'http://localhost:8000';
221
+ }
222
+
223
+ // Update the repository URL display if element exists
224
+ const repoUrlElement = document.getElementById('repoUrl');
225
+ if (repoUrlElement) {
226
+ repoUrlElement.textContent = getCurrentSpaceUrl();
227
+ }
228
+ });
229
+
230
+ // Event listeners
231
+ document.getElementById('installBtn').addEventListener('click', installToReachy);
232
+ </script>
233
+ </body>
234
+
235
+ </html>
reachy_mini/src/reachy_mini/apps/templates/main.py.j2 ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import threading
2
+
3
+ from reachy_mini import ReachyMini, ReachyMiniApp
4
+ from reachy_mini.utils import create_head_pose
5
+
6
+
7
+ class {{ class_name }}(ReachyMiniApp):
8
+ # Optional: URL to a custom configuration page for the app
9
+ # eg. "http://localhost:8042/settings"
10
+ custom_app_url: str | None = None
11
+
12
+ def run(self, reachy_mini: ReachyMini, stop_event: threading.Event):
13
+ # Write your code here
14
+ # ReachyMini is already initialized and connected
15
+ # Check the stop_event to gracefully exit the loop
16
+ # Example:
17
+ # import time
18
+ # import numpy as np
19
+ #
20
+ # t0 = time.time()
21
+ #
22
+ # while not stop_event.is_set():
23
+ # t = time.time() - t0
24
+ #
25
+ # yaw = 30 * np.sin(2 * np.pi * 0.5 * t)
26
+ # head_pose = create_head_pose(yaw=yaw, degrees=True)
27
+ #
28
+ # reachy_mini.set_target(head=head_pose)
29
+ #
30
+ # time.sleep(0.01)
31
+
32
+ print("This is a placeholder for your app logic.")
33
+
34
+
35
+ if __name__ == "__main__":
36
+ # You can run the app directly from this script
37
+ with ReachyMini() as mini:
38
+ app = {{ class_name }}()
39
+
40
+ stop = threading.Event()
41
+
42
+ try:
43
+ print("Running '{{ app_name }}' a ReachyMiniApp...")
44
+ print("Press Ctrl+C to stop the app.")
45
+ app.run(mini, stop)
46
+ print("App has stopped.")
47
+
48
+ except KeyboardInterrupt:
49
+ print("Stopping the app...")
50
+ stop.set()
reachy_mini/src/reachy_mini/apps/templates/pyproject.toml.j2 ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+
6
+ [project]
7
+ name = "{{ app_name }}"
8
+ version = "0.1.0"
9
+ description = "Add your description here"
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "reachy-mini"
14
+ ]
15
+ keywords = ["reachy-mini-app"]
16
+
17
+ [project.entry-points."reachy_mini_apps"]
18
+ {{ app_name }} = "{{ module_name }}.main:{{ class_name }}"
reachy_mini/src/reachy_mini/apps/templates/style.css.j2 ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ body {
8
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
9
+ line-height: 1.6;
10
+ color: #333;
11
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
12
+ min-height: 100vh;
13
+ }
14
+
15
+ .hero {
16
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
17
+ color: white;
18
+ padding: 4rem 2rem;
19
+ text-align: center;
20
+ }
21
+
22
+ .hero-content {
23
+ max-width: 800px;
24
+ margin: 0 auto;
25
+ }
26
+
27
+ .app-icon {
28
+ font-size: 4rem;
29
+ margin-bottom: 1rem;
30
+ display: inline-block;
31
+ }
32
+
33
+ .hero h1 {
34
+ font-size: 3rem;
35
+ font-weight: 700;
36
+ margin-bottom: 1rem;
37
+ background: linear-gradient(45deg, #fff, #f0f9ff);
38
+ background-clip: text;
39
+ -webkit-background-clip: text;
40
+ -webkit-text-fill-color: transparent;
41
+ }
42
+
43
+ .tagline {
44
+ font-size: 1.25rem;
45
+ opacity: 0.9;
46
+ max-width: 600px;
47
+ margin: 0 auto;
48
+ }
49
+
50
+ .container {
51
+ max-width: 1200px;
52
+ margin: 0 auto;
53
+ padding: 0 2rem;
54
+ position: relative;
55
+ z-index: 2;
56
+ }
57
+
58
+ .main-card {
59
+ background: white;
60
+ border-radius: 20px;
61
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
62
+ margin-top: -2rem;
63
+ overflow: hidden;
64
+ margin-bottom: 3rem;
65
+ }
66
+
67
+ .app-preview {
68
+ background: linear-gradient(135deg, #1e3a8a, #3b82f6);
69
+ padding: 3rem;
70
+ color: white;
71
+ text-align: center;
72
+ position: relative;
73
+ }
74
+
75
+ .preview-image {
76
+ background: #000;
77
+ border-radius: 15px;
78
+ padding: 2rem;
79
+ max-width: 500px;
80
+ margin: 0 auto;
81
+ position: relative;
82
+ overflow: hidden;
83
+ }
84
+
85
+ .camera-feed {
86
+ font-size: 4rem;
87
+ margin-bottom: 1rem;
88
+ opacity: 0.7;
89
+ }
90
+
91
+ .detection-overlay {
92
+ position: absolute;
93
+ top: 50%;
94
+ left: 50%;
95
+ transform: translate(-50%, -50%);
96
+ width: 100%;
97
+ }
98
+
99
+ .bbox {
100
+ background: rgba(34, 197, 94, 0.9);
101
+ color: white;
102
+ padding: 0.5rem 1rem;
103
+ border-radius: 8px;
104
+ font-size: 0.9rem;
105
+ font-weight: 600;
106
+ margin: 0.5rem;
107
+ display: inline-block;
108
+ border: 2px solid #22c55e;
109
+ }
110
+
111
+ .app-details {
112
+ padding: 3rem;
113
+ }
114
+
115
+ .app-details h2 {
116
+ font-size: 2rem;
117
+ color: #1e293b;
118
+ margin-bottom: 2rem;
119
+ text-align: center;
120
+ }
121
+
122
+ .template-info {
123
+ display: grid;
124
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
125
+ gap: 2rem;
126
+ margin-bottom: 3rem;
127
+ }
128
+
129
+ .info-box {
130
+ background: #f0f9ff;
131
+ border: 2px solid #e0f2fe;
132
+ border-radius: 12px;
133
+ padding: 2rem;
134
+ }
135
+
136
+ .info-box h3 {
137
+ color: #0c4a6e;
138
+ margin-bottom: 1rem;
139
+ font-size: 1.2rem;
140
+ }
141
+
142
+ .info-box p {
143
+ color: #0369a1;
144
+ line-height: 1.6;
145
+ }
146
+
147
+ .how-to-use {
148
+ background: #fefce8;
149
+ border: 2px solid #fde047;
150
+ border-radius: 12px;
151
+ padding: 2rem;
152
+ margin-top: 3rem;
153
+ }
154
+
155
+ .how-to-use h3 {
156
+ color: #a16207;
157
+ margin-bottom: 1.5rem;
158
+ font-size: 1.3rem;
159
+ text-align: center;
160
+ }
161
+
162
+ .steps {
163
+ display: flex;
164
+ flex-direction: column;
165
+ gap: 1.5rem;
166
+ }
167
+
168
+ .step {
169
+ display: flex;
170
+ align-items: flex-start;
171
+ gap: 1rem;
172
+ }
173
+
174
+ .step-number {
175
+ background: #eab308;
176
+ color: white;
177
+ width: 2rem;
178
+ height: 2rem;
179
+ border-radius: 50%;
180
+ display: flex;
181
+ align-items: center;
182
+ justify-content: center;
183
+ font-weight: bold;
184
+ flex-shrink: 0;
185
+ }
186
+
187
+ .step h4 {
188
+ color: #a16207;
189
+ margin-bottom: 0.5rem;
190
+ font-size: 1.1rem;
191
+ }
192
+
193
+ .step p {
194
+ color: #ca8a04;
195
+ }
196
+
197
+ .download-card {
198
+ background: white;
199
+ border-radius: 20px;
200
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
201
+ padding: 3rem;
202
+ text-align: center;
203
+ }
204
+
205
+ .download-card h2 {
206
+ font-size: 2rem;
207
+ color: #1e293b;
208
+ margin-bottom: 1rem;
209
+ }
210
+
211
+ .download-card>p {
212
+ color: #64748b;
213
+ font-size: 1.1rem;
214
+ margin-bottom: 2rem;
215
+ }
216
+
217
+ .dashboard-config {
218
+ margin-bottom: 2rem;
219
+ text-align: left;
220
+ max-width: 400px;
221
+ margin-left: auto;
222
+ margin-right: auto;
223
+ }
224
+
225
+ .dashboard-config label {
226
+ display: block;
227
+ color: #374151;
228
+ font-weight: 600;
229
+ margin-bottom: 0.5rem;
230
+ }
231
+
232
+ .dashboard-config input {
233
+ width: 100%;
234
+ padding: 0.75rem 1rem;
235
+ border: 2px solid #e5e7eb;
236
+ border-radius: 8px;
237
+ font-size: 0.95rem;
238
+ transition: border-color 0.2s;
239
+ }
240
+
241
+ .dashboard-config input:focus {
242
+ outline: none;
243
+ border-color: #667eea;
244
+ }
245
+
246
+ .install-btn {
247
+ background: linear-gradient(135deg, #667eea, #764ba2);
248
+ color: white;
249
+ border: none;
250
+ padding: 1.25rem 3rem;
251
+ border-radius: 16px;
252
+ font-size: 1.2rem;
253
+ font-weight: 700;
254
+ cursor: pointer;
255
+ transition: all 0.3s ease;
256
+ display: inline-flex;
257
+ align-items: center;
258
+ gap: 0.75rem;
259
+ margin-bottom: 2rem;
260
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
261
+ }
262
+
263
+ .install-btn:hover:not(:disabled) {
264
+ transform: translateY(-3px);
265
+ box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
266
+ }
267
+
268
+ .install-btn:disabled {
269
+ opacity: 0.7;
270
+ cursor: not-allowed;
271
+ transform: none;
272
+ }
273
+
274
+ .manual-option {
275
+ background: #f8fafc;
276
+ border-radius: 12px;
277
+ padding: 2rem;
278
+ margin-top: 2rem;
279
+ }
280
+
281
+ .manual-option h3 {
282
+ color: #1e293b;
283
+ margin-bottom: 1rem;
284
+ font-size: 1.2rem;
285
+ }
286
+
287
+ .manual-option>p {
288
+ color: #64748b;
289
+ margin-bottom: 1rem;
290
+ }
291
+
292
+ .btn-icon {
293
+ font-size: 1.1rem;
294
+ }
295
+
296
+ .install-status {
297
+ padding: 1rem;
298
+ border-radius: 8px;
299
+ font-size: 0.9rem;
300
+ text-align: center;
301
+ display: none;
302
+ margin-top: 1rem;
303
+ }
304
+
305
+ .install-status.success {
306
+ background: #dcfce7;
307
+ color: #166534;
308
+ border: 1px solid #bbf7d0;
309
+ }
310
+
311
+ .install-status.error {
312
+ background: #fef2f2;
313
+ color: #dc2626;
314
+ border: 1px solid #fecaca;
315
+ }
316
+
317
+ .install-status.loading {
318
+ background: #dbeafe;
319
+ color: #1d4ed8;
320
+ border: 1px solid #bfdbfe;
321
+ }
322
+
323
+ .install-status.info {
324
+ background: #e0f2fe;
325
+ color: #0369a1;
326
+ border: 1px solid #7dd3fc;
327
+ }
328
+
329
+ .manual-install {
330
+ background: #1f2937;
331
+ border-radius: 8px;
332
+ padding: 1rem;
333
+ margin-bottom: 1rem;
334
+ display: flex;
335
+ align-items: center;
336
+ gap: 1rem;
337
+ }
338
+
339
+ .manual-install code {
340
+ color: #10b981;
341
+ font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
342
+ font-size: 0.85rem;
343
+ flex: 1;
344
+ overflow-x: auto;
345
+ }
346
+
347
+ .copy-btn {
348
+ background: #374151;
349
+ color: white;
350
+ border: none;
351
+ padding: 0.5rem 1rem;
352
+ border-radius: 6px;
353
+ font-size: 0.8rem;
354
+ cursor: pointer;
355
+ transition: background-color 0.2s;
356
+ }
357
+
358
+ .copy-btn:hover {
359
+ background: #4b5563;
360
+ }
361
+
362
+ .manual-steps {
363
+ color: #6b7280;
364
+ font-size: 0.9rem;
365
+ line-height: 1.8;
366
+ }
367
+
368
+ .footer {
369
+ text-align: center;
370
+ padding: 2rem;
371
+ color: white;
372
+ opacity: 0.8;
373
+ }
374
+
375
+ .footer a {
376
+ color: white;
377
+ text-decoration: none;
378
+ font-weight: 600;
379
+ }
380
+
381
+ .footer a:hover {
382
+ text-decoration: underline;
383
+ }
384
+
385
+ /* Responsive Design */
386
+ @media (max-width: 768px) {
387
+ .hero {
388
+ padding: 2rem 1rem;
389
+ }
390
+
391
+ .hero h1 {
392
+ font-size: 2rem;
393
+ }
394
+
395
+ .container {
396
+ padding: 0 1rem;
397
+ }
398
+
399
+ .app-details,
400
+ .download-card {
401
+ padding: 2rem;
402
+ }
403
+
404
+ .features-grid {
405
+ grid-template-columns: 1fr;
406
+ }
407
+
408
+ .download-options {
409
+ grid-template-columns: 1fr;
410
+ }
411
+ }
reachy_mini/src/reachy_mini/apps/utils.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utility functions for Reachy Mini apps manager."""
2
+
3
+ import asyncio
4
+ import logging
5
+
6
+
7
+ async def running_command(command: list[str], logger: logging.Logger) -> int:
8
+ """Run a shell command and stream its output to the provided logger."""
9
+ logger.info(f"Running command: {' '.join(command)}")
10
+
11
+ proc = await asyncio.create_subprocess_exec(
12
+ *command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
13
+ )
14
+
15
+ assert proc.stdout is not None # for mypy
16
+ assert proc.stderr is not None # for mypy
17
+
18
+ # Stream output line by line
19
+ while True:
20
+ line = await proc.stdout.readline()
21
+ if not line:
22
+ break
23
+ logger.info(line.decode().rstrip())
24
+
25
+ # Also log any remaining stderr
26
+ err = await proc.stderr.read()
27
+ if err:
28
+ logger.error(err.decode().rstrip())
29
+
30
+ return await proc.wait()
reachy_mini/src/reachy_mini/assets/config/hardware_config.yaml ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: beta
2
+
3
+ serial:
4
+ baudrate: 1000000
5
+
6
+ # Limits measured on the robot (in degrees)
7
+ # s1
8
+ # lower : -48° : -546
9
+ # upper : +80° : 910
10
+
11
+ # s2
12
+ # lower: +70° : 796
13
+ # upper: -80° : -910
14
+
15
+ # s3
16
+ # lower: -48° : -546
17
+ # upper: +80° : 910
18
+
19
+ # s4
20
+ # lower: +48° : 546
21
+ # upper: -80° : -910
22
+
23
+ # s5
24
+ # lower: -70° : -796
25
+ # upper: +80° : 910
26
+
27
+ # s6
28
+ # lower : +48° : 546
29
+ # upper : -80° : -910
30
+
31
+ # s1:
32
+ # lower: 2048 - 546 : 1502
33
+ # upper: 2048 + 910 : 2958
34
+
35
+ # s2:
36
+ # lower: 2048 - 910 : 1138
37
+ # upper: 2048 + 796 : 2844
38
+
39
+ # s3:
40
+ # lower: 2048 - 546 : 1502
41
+ # upper: 2048 + 910 : 2958
42
+
43
+ # s4:
44
+ # lower: 2048 - 910 : 1138
45
+ # upper: 2048 + 546 : 2594
46
+
47
+ # s5:
48
+ # lower: 2048 - 796 : 1252
49
+ # upper: 2048 + 910 : 2958
50
+
51
+ # s6:
52
+ # lower: 2048 - 910 : 1138
53
+ # upper: 2048 + 546 : 2594
54
+
55
+
56
+ motors:
57
+ - body_rotation:
58
+ id: 10
59
+ offset: 0
60
+ lower_limit: 0
61
+ upper_limit: 4095
62
+ return_delay_time: 0
63
+ shutdown_error: 52
64
+ pid:
65
+ - 400
66
+ - 0
67
+ - 0
68
+ - stewart_1:
69
+ id: 11
70
+ offset: 1024
71
+ lower_limit: 1502
72
+ upper_limit: 2958
73
+ return_delay_time: 0
74
+ shutdown_error: 52
75
+ pid:
76
+ - 400
77
+ - 0
78
+ - 0
79
+ - stewart_2:
80
+ id: 12
81
+ offset: -1024
82
+ lower_limit: 1138
83
+ upper_limit: 2844
84
+ return_delay_time: 0
85
+ shutdown_error: 52
86
+ pid:
87
+ - 400
88
+ - 0
89
+ - 0
90
+ - stewart_3:
91
+ id: 13
92
+ offset: 1024
93
+ lower_limit: 1502
94
+ upper_limit: 2958
95
+ return_delay_time: 0
96
+ shutdown_error: 52
97
+ pid:
98
+ - 400
99
+ - 0
100
+ - 0
101
+ - stewart_4:
102
+ id: 14
103
+ offset: -1024
104
+ lower_limit: 1138
105
+ upper_limit: 2594
106
+ return_delay_time: 0
107
+ shutdown_error: 52
108
+ pid:
109
+ - 400
110
+ - 0
111
+ - 0
112
+ - stewart_5:
113
+ id: 15
114
+ offset: 1024
115
+ lower_limit: 1252
116
+ upper_limit: 2958
117
+ return_delay_time: 0
118
+ shutdown_error: 52
119
+ pid:
120
+ - 400
121
+ - 0
122
+ - 0
123
+ - stewart_6:
124
+ id: 16
125
+ offset: -1024
126
+ lower_limit: 1138
127
+ upper_limit: 2594
128
+ return_delay_time: 0
129
+ shutdown_error: 52
130
+ pid:
131
+ - 400
132
+ - 0
133
+ - 0
134
+ - right_antenna:
135
+ id: 17
136
+ offset: 0
137
+ lower_limit: 0
138
+ upper_limit: 4095
139
+ return_delay_time: 0
140
+ shutdown_error: 52
141
+ pid:
142
+ - 400
143
+ - 0
144
+ - 400
145
+ - left_antenna:
146
+ id: 18
147
+ offset: 0
148
+ lower_limit: 0
149
+ upper_limit: 4095
150
+ return_delay_time: 0
151
+ shutdown_error: 52
152
+ pid:
153
+ - 400
154
+ - 0
155
+ - 400
reachy_mini/src/reachy_mini/assets/firmware/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog of Reachy Mini Audio Firmware
2
+
3
+
4
+ ## 2.1.3
5
+
6
+ *For Beta units only*
7
+
8
+ Fixes the initialization issue on Reachy Mini beta hardware. An additional 2-second delay is added during initialization to prevent the XMOS chip from starting before the other components.
9
+
10
+ There is no need to apply this firmware to the Lite and Wireless versions, as the issue is fixed at the hardware level.
11
+
12
+ ## 2.1.2
13
+
14
+ Improved parameters for acoustic echo cancellation (AEC).
15
+ PP_DTSENSITIVE is set to 1 by default.
reachy_mini/src/reachy_mini/assets/firmware/reachymini_ua_io16_lin_v2.1.2.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:661429a93b155cdbfed1e6c214820fd42e3372a08c3930f14fcd4e6db5be6796
3
+ size 933888
reachy_mini/src/reachy_mini/assets/firmware/reachymini_ua_io16_lin_v2.1.3.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e35fa9a43a4e75890fd6299e62e85310d8081087e6a9702aaef0c81bd3af283
3
+ size 933888
reachy_mini/src/reachy_mini/assets/firmware/update.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Firmware update script for Reachy Mini
3
+ # Usage: ./update.sh <firmware_file>
4
+ firmware="$1"
5
+ if [ -z "$firmware" ]; then
6
+ echo "Usage: $0 <firmware_file>"
7
+ exit 1
8
+ fi
9
+ dfu-util -R -e -a 1 -D "$firmware"