File size: 28,315 Bytes
9c0ad15
5c85958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c0ad15
 
5c85958
 
 
 
 
 
 
9c0ad15
 
 
 
 
 
5c85958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c0ad15
 
 
5c85958
 
9c0ad15
 
 
 
5c85958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cfc5581
5c85958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f06f9b5
f5977e4
f06f9b5
 
5c85958
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
import { useMemo, useState } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import {
  Box,
  Container,
  Typography,
  Button,
  Grid,
  Accordion,
  AccordionSummary,
  AccordionDetails,
  Stack,
  Link,
  Chip,
  Tabs,
  Tab,
  Alert,
  Divider,
} from '@mui/material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import hljs from 'highlight.js/lib/common';
import 'highlight.js/styles/github-dark.css';

import Layout from '../components/Layout';
import PageHero from '../components/PageHero';

// Code Block component with copy functionality
function CodeBlock({ code, language = 'bash', title }) {
  const [copied, setCopied] = useState(false);
  const highlighted = useMemo(() => {
    if (language && hljs.getLanguage(language)) {
      return hljs.highlight(code, { language, ignoreIllegals: true }).value;
    }
    return hljs.highlightAuto(code).value;
  }, [code, language]);

  const handleCopy = async () => {
    await navigator.clipboard.writeText(code);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };

  return (
    <Box
      sx={{
        position: 'relative',
        backgroundColor: '#0d1117',
        borderRadius: 2,
        overflow: 'hidden',
        my: 2,
        border: '1px solid rgba(255,255,255,0.1)',
      }}
    >
      <Box
        sx={{
          display: 'flex',
          justifyContent: 'space-between',
          alignItems: 'center',
          px: 2,
          py: 1,
          backgroundColor: 'rgba(255,255,255,0.03)',
          borderBottom: '1px solid rgba(255,255,255,0.1)',
        }}
      >
        <Typography variant="caption" sx={{ color: 'rgba(255,255,255,0.5)', fontFamily: 'monospace' }}>
          {title || language}
        </Typography>
        <Button
          size="small"
          onClick={handleCopy}
          startIcon={copied ? <CheckCircleIcon /> : <ContentCopyIcon />}
          sx={{
            color: copied ? '#22c55e' : 'rgba(255,255,255,0.6)',
            fontSize: 12,
            minWidth: 'auto',
          }}
        >
          {copied ? 'Copied!' : 'Copy'}
        </Button>
      </Box>
      <Box
        component="pre"
        sx={{
          m: 0,
          p: 2,
          overflow: 'auto',
          fontFamily: '"JetBrains Mono", "Fira Code", monospace',
          fontSize: 13,
          lineHeight: 1.7,
          color: '#e6edf3',
          '& code': {
            display: 'block',
          },
        }}
      >
        <code
          className={`hljs language-${language}`}
          dangerouslySetInnerHTML={{ __html: highlighted }}
        />
      </Box>
    </Box>
  );
}

// Tab Panel
function TabPanel({ children, value, index }) {
  return (
    <div hidden={value !== index} style={{ paddingTop: 16 }}>
      {value === index && children}
    </div>
  );
}

// Section component
function Section({ id, step, title, children }) {
  return (
    <Box id={id} sx={{ mb: 10, scrollMarginTop: 100 }}>
      <Box sx={{ mb: 3 }}>
        {step && (
          <Typography 
            variant="overline" 
            sx={{ 
              color: 'text.secondary',
              letterSpacing: 2,
              fontSize: 12,
              fontWeight: 600,
            }}
          >
            {step}
          </Typography>
        )}
        <Typography variant="h3" sx={{ mt: step ? 0.5 : 0 }}>{title}</Typography>
      </Box>
      {children}
    </Box>
  );
}

export default function Build() {
  const [osTab, setOsTab] = useState(0);

  return (
    <Layout transparentHeader>
      <PageHero
        eyebrow="Developer Guide"
        title="Create with Reachy Mini"
        subtitle="Create amazing experiences with Python or JavaScript. Control movements, access sensors, build apps, and share them with the community."
        accentColor="#764ba2"
        stickers={[
          { src: '/assets/reachies/hacker.png', size: 260, top: 10, left: 100, rotation: -12 },
          { src: '/assets/reachies/student.png', size: 220, bottom: 0, right: 120, rotation: 8 },
        ]}
        primitives={[
          { type: 'squareOutline', color: '#764ba2', size: 90, top: 60, right: 180, rotation: 20 },
          { type: 'circle', color: '#667eea', size: 50, bottom: 80, left: 120 },
        ]}
      >
        <Button
          variant="contained"
          href="#install"
          sx={{
            background: 'linear-gradient(135deg, #764ba2 0%, #667eea 100%)',
          }}
        >
          Install SDK
        </Button>
        <Button
          variant="outlined"
          href="https://github.com/pollen-robotics/reachy_mini"
          target="_blank"
          endIcon={<OpenInNewIcon />}
          sx={{
            borderColor: 'rgba(255,255,255,0.3)',
            color: 'white',
            '&:hover': {
              borderColor: 'white',
              backgroundColor: 'rgba(255,255,255,0.1)',
            },
          }}
        >
          GitHub
        </Button>
      </PageHero>

      {/* Main Content */}
      <Container maxWidth="lg" sx={{ py: 10 }}>
        {/* Prerequisites notice */}
        <Box
          sx={{
            mb: 6,
            p: 4,
            borderRadius: 3,
            bgcolor: '#f5f5f7',
            display: 'flex',
            alignItems: 'center',
            gap: 4,
          }}
        >
          <Box
            component="img"
            src="/assets/reachy-stop.svg"
            alt=""
            sx={{
              width: 120,
              height: 120,
              flexShrink: 0,
            }}
          />
          <Box>
            <Typography variant="h5" sx={{ fontWeight: 700, mb: 1, color: '#1d1d1f' }}>
              Before you start
            </Typography>
            <Typography sx={{ fontSize: 15, color: '#86868b', lineHeight: 1.6 }}>
              Make sure you have assembled your Reachy Mini and connected it.
              If not, follow the{' '}
              <Link component={RouterLink} to="/getting-started" sx={{ color: '#1d1d1f', fontWeight: 600 }}>
                Getting Started guide
              </Link>{' '}
              first.
            </Typography>
          </Box>
        </Box>

        {/* Section: Install SDK */}
        <Section id="install" step="Step 1" title="Install the SDK">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            The Reachy Mini SDK is a Python package that lets you control the robot programmatically.
            It includes both the daemon (background service) and the control API.
          </Typography>

          {/* Prerequisites */}
          <Box sx={{ mb: 4 }}>
            <Box sx={{ p: 4 }}>
              <Typography variant="h5" sx={{ mb: 3 }}>
                Prerequisites
              </Typography>

              <Grid container spacing={3}>
                <Grid size={{ xs: 12, md: 4 }}>
                  <Stack direction="row" spacing={1} alignItems="center" sx={{ mb: 1 }}>
                    <CheckCircleIcon sx={{ color: 'text.secondary', fontSize: 20 }} />
                    <Typography variant="h6">Python 3.10 - 3.13</Typography>
                  </Stack>
                  <Typography variant="body2" color="text.secondary">
                    We recommend using a virtual environment.
                  </Typography>
                </Grid>

                <Grid size={{ xs: 12, md: 4 }}>
                  <Stack direction="row" spacing={1} alignItems="center" sx={{ mb: 1 }}>
                    <CheckCircleIcon sx={{ color: 'text.secondary', fontSize: 20 }} />
                    <Typography variant="h6">Git LFS</Typography>
                  </Stack>
                  <Typography variant="body2" color="text.secondary">
                    Required for large model files.
                  </Typography>
                </Grid>

                <Grid size={{ xs: 12, md: 4 }}>
                  <Stack direction="row" spacing={1} alignItems="center" sx={{ mb: 1 }}>
                    <CheckCircleIcon sx={{ color: 'text.secondary', fontSize: 20 }} />
                    <Typography variant="h6">Reachy Mini connected</Typography>
                  </Stack>
                  <Typography variant="body2" color="text.secondary">
                    USB (Lite) or Wi-Fi (Wireless).
                  </Typography>
                </Grid>
              </Grid>

              <Divider sx={{ my: 3 }} />

              <Typography variant="subtitle2" sx={{ mb: 2 }}>
                Install Git LFS
              </Typography>
              <Tabs value={osTab} onChange={(_, v) => setOsTab(v)} sx={{ mb: 2 }}>
                <Tab label="Linux" />
                <Tab label="macOS" />
                <Tab label="Windows" />
              </Tabs>

              <TabPanel value={osTab} index={0}>
                <CodeBlock code="sudo apt install git-lfs" />
              </TabPanel>
              <TabPanel value={osTab} index={1}>
                <CodeBlock code="brew install git-lfs" />
              </TabPanel>
              <TabPanel value={osTab} index={2}>
                <Typography variant="body2" color="text.secondary">
                  Download from{' '}
                  <Link href="https://git-lfs.com" target="_blank">
                    git-lfs.com
                  </Link>
                </Typography>
              </TabPanel>
            </Box>
          </Box>

          {/* Installation */}
          <Box sx={{ mb: 4 }}>
            <Box sx={{ p: 4 }}>
              <Typography variant="h5" sx={{ mb: 3 }}>
                Install Reachy Mini
              </Typography>

              <CodeBlock
                title="Terminal"
                code={`# Create a virtual environment
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\\Scripts\\activate

# Install the SDK
pip install reachy-mini`}
              />

              <Alert severity="success" sx={{ mt: 2 }}>
                <Typography variant="body2">
                  <strong>uv users:</strong> Run <code>uv run reachy-mini-daemon</code> directly without manual setup.
                </Typography>
              </Alert>
            </Box>
          </Box>

          {/* Linux udev */}
          <Accordion>
            <AccordionSummary expandIcon={<ExpandMoreIcon />}>
              <Typography fontWeight={600}>🐧 Linux: Set up udev rules (required for USB connection)</Typography>
            </AccordionSummary>
            <AccordionDetails>
              <CodeBlock
                code={`# Create udev rules
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d3", MODE="0666", GROUP="dialout"
SUBSYSTEM=="tty", ATTRS{idVendor}=="38fb", ATTRS{idProduct}=="1001", MODE="0666", GROUP="dialout"' \\
| sudo tee /etc/udev/rules.d/99-reachy-mini.rules

# Reload rules and add user to dialout group
sudo udevadm control --reload-rules && sudo udevadm trigger
sudo usermod -aG dialout $USER

# Log out and back in for changes to take effect`}
              />
            </AccordionDetails>
          </Accordion>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* Section: First Script */}
        <Section id="first-script" step="Step 2" title="Your First Script">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Before running any script, you need to start the daemon. The daemon handles communication 
            with the robot's motors and sensors.
          </Typography>

          <Grid container spacing={3}>
            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    1. Start the Daemon
                  </Typography>
                  <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                    Open a terminal and run:
                  </Typography>
                  <CodeBlock code="reachy-mini-daemon" />
                  <Typography variant="body2" color="text.secondary" sx={{ mt: 2 }}>
                    For simulation (no robot needed):
                  </Typography>
                  <CodeBlock code="pip install reachy-mini[mujoco]
reachy-mini-daemon --sim" />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    2. Run Your First Script
                  </Typography>
                  <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                    In another terminal, create <code>hello.py</code>:
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`from reachy_mini import ReachyMini

with ReachyMini() as mini:
    print("Connected!")
    print(f"Robot state: {mini.state}")`}
                  />
                  <CodeBlock code="python hello.py" />
                </Box>
              </Box>
            </Grid>
          </Grid>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* Section: Control the Robot */}
        <Section id="control" step="Step 3" title="Control the Robot">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Use <code>goto_target</code> for smooth movements and <code>set_target</code> for immediate control.
          </Typography>

          <Grid container spacing={3}>
            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    Move the Head
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`from reachy_mini import ReachyMini
from reachy_mini.utils import create_head_pose

with ReachyMini() as mini:
    # Move head up and tilt
    pose = create_head_pose(
        z=10,      # 10mm up
        roll=15,   # 15Β° tilt
        degrees=True, 
        mm=True
    )
    mini.goto_target(head=pose, duration=2.0)
    
    # Reset to default
    mini.goto_target(
        head=create_head_pose(), 
        duration=1.0
    )`}
                  />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    Control Antennas & Body
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`import numpy as np
from reachy_mini import ReachyMini
from reachy_mini.utils import create_head_pose

with ReachyMini() as mini:
    # Move everything at once
    mini.goto_target(
        head=create_head_pose(y=-10, mm=True),
        antennas=np.deg2rad([45, 45]),
        body_yaw=np.deg2rad(30),
        duration=2.0,
    )
    
    # Make antennas wave
    for _ in range(3):
        mini.goto_target(
            antennas=np.deg2rad([60, 20]),
            duration=0.3
        )
        mini.goto_target(
            antennas=np.deg2rad([20, 60]),
            duration=0.3
        )`}
                  />
                </Box>
              </Box>
            </Grid>
          </Grid>

          <Box sx={{ mt: 3 }}>
            <Box sx={{ p: 4 }}>
              <Typography variant="h6" sx={{ mb: 2 }}>
                Motor Control Modes
              </Typography>
              <Grid container spacing={3}>
                <Grid size={{ xs: 12, md: 4 }}>
                  <Typography variant="subtitle2" color="primary.main" sx={{ mb: 1 }}>
                    enable_motors()
                  </Typography>
                  <Typography variant="body2" color="text.secondary">
                    Powers motors ON. Robot holds position firmly.
                  </Typography>
                </Grid>
                <Grid size={{ xs: 12, md: 4 }}>
                  <Typography variant="subtitle2" color="primary.main" sx={{ mb: 1 }}>
                    disable_motors()
                  </Typography>
                  <Typography variant="body2" color="text.secondary">
                    Powers motors OFF. Robot is completely limp.
                  </Typography>
                </Grid>
                <Grid size={{ xs: 12, md: 4 }}>
                  <Typography variant="subtitle2" color="primary.main" sx={{ mb: 1 }}>
                    make_motors_compliant()
                  </Typography>
                  <Typography variant="body2" color="text.secondary">
                    Motors ON but soft. Great for teaching-by-demonstration.
                  </Typography>
                </Grid>
              </Grid>
            </Box>
          </Box>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* Section: Access Sensors */}
        <Section id="sensors" step="Step 4" title="Access Sensors">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Reachy Mini has a camera, microphones, speaker, and accelerometer (wireless version).
          </Typography>

          <Grid container spacing={3}>
            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    πŸ“· Camera
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`import cv2
from reachy_mini import ReachyMini

with ReachyMini() as mini:
    # Get a frame (numpy array)
    frame = mini.media.get_frame()
    
    # Display with OpenCV
    cv2.imshow("Reachy View", frame)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    
    # Or save to file
    cv2.imwrite("snapshot.jpg", frame)`}
                  />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    🎀 Microphone
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`from reachy_mini import ReachyMini

with ReachyMini() as mini:
    # Get audio sample
    sample = mini.media.get_audio_sample()
    
    # sample is a numpy array
    # Process with your favorite 
    # audio/speech library`}
                  />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    πŸ”Š Speaker
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`from reachy_mini import ReachyMini

with ReachyMini() as mini:
    # Play audio file
    mini.media.play_audio("hello.wav")
    
    # Or use TTS (with external lib)
    # and play the generated audio`}
                  />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    πŸ“ Accelerometer (Wireless only)
                  </Typography>
                  <CodeBlock
                    language="python"
                    code={`from reachy_mini import ReachyMini

with ReachyMini() as mini:
    # Get accelerometer data
    accel = mini.sensors.accelerometer
    
    print(f"X: {accel.x}")
    print(f"Y: {accel.y}")
    print(f"Z: {accel.z}")`}
                  />
                </Box>
              </Box>
            </Grid>
          </Grid>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* Section: Create an App */}
        <Section id="create-app" step="Step 5" title="Create an App">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Package your code as a Reachy Mini app that can be installed from the dashboard.
          </Typography>

          <Box sx={{ mb: 4 }}>
            <Box sx={{ p: 4 }}>
              <Typography variant="h6" sx={{ mb: 2 }}>
                Generate App Template
              </Typography>
              <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                Use the built-in generator to create a complete project structure:
              </Typography>
              <CodeBlock code="reachy-mini-make-app my_awesome_app" />
              <Typography variant="body2" color="text.secondary" sx={{ mt: 2 }}>
                This creates: <code>pyproject.toml</code>, <code>README.md</code>, and the main app file.
              </Typography>
            </Box>
          </Box>

          <Box sx={{ mb: 4 }}>
            <Box sx={{ p: 4 }}>
              <Typography variant="h6" sx={{ mb: 2 }}>
                App Structure
              </Typography>
              <CodeBlock
                language="python"
                title="my_awesome_app/app.py"
                code={`from reachy_mini.apps.app import ReachyMiniApp
from reachy_mini import ReachyMini

class MyAwesomeApp(ReachyMiniApp):
    """My first Reachy Mini app!"""
    
    def run(self, reachy_mini: ReachyMini, stop_event):
        \"\"\"Main app logic. Called when the app starts.\"\"\"
        
        while not stop_event.is_set():
            # Your code here
            # Check stop_event periodically to allow clean shutdown
            
            # Example: wave antennas
            reachy_mini.goto_target(
                antennas=[0.5, -0.5],
                duration=0.5
            )
            reachy_mini.goto_target(
                antennas=[-0.5, 0.5],
                duration=0.5
            )`}
              />
            </Box>
          </Box>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* Section: Publish to HF */}
        <Section id="publish" step="Step 6" title="Publish to Hugging Face">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Share your app with the community on Hugging Face Spaces. Apps published there 
            can be installed directly from the Reachy Mini dashboard.
          </Typography>

          <Grid container spacing={3}>
            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    1. Create a Space
                  </Typography>
                  <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                    Go to Hugging Face and create a new Space:
                  </Typography>
                  <Button
                    variant="outlined"
                    href="https://huggingface.co/new-space"
                    target="_blank"
                    endIcon={<OpenInNewIcon />}
                  >
                    Create New Space
                  </Button>
                  <Typography variant="body2" color="text.secondary" sx={{ mt: 2 }}>
                    Choose "Gradio" or "Static" as the SDK.
                  </Typography>
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box sx={{ height: '100%' }}>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    2. Add the reachy_mini tag
                  </Typography>
                  <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                    In your Space's <code>README.md</code>, add this tag:
                  </Typography>
                  <CodeBlock
                    language="yaml"
                    code={`---
title: My Awesome App
emoji: πŸ€–
tags:
  - reachy_mini  # This makes it discoverable!
---`}
                  />
                </Box>
              </Box>
            </Grid>
          </Grid>

          <Alert severity="success" sx={{ mt: 4 }}>
            <Typography variant="body2">
              <strong>That's it!</strong> Your app will now appear in the Reachy Mini dashboard's app store
              and on the{' '}
              <Link component={RouterLink} to="/apps">
                Apps page
              </Link>
              .
            </Typography>
          </Alert>
        </Section>

        <Divider sx={{ my: 8 }} />

        {/* REST API Section */}
        <Section id="rest-api" title="REST API">
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4, maxWidth: 700 }}>
            Prefer HTTP? The daemon exposes a REST API for language-agnostic control.
          </Typography>

          <Grid container spacing={3}>
            <Grid size={{ xs: 12, md: 6 }}>
              <Box>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    Get Robot State
                  </Typography>
                  <CodeBlock
                    language="bash"
                    code={`curl http://localhost:8000/api/state/full`}
                  />
                </Box>
              </Box>
            </Grid>

            <Grid size={{ xs: 12, md: 6 }}>
              <Box>
                <Box sx={{ p: 4 }}>
                  <Typography variant="h6" sx={{ mb: 2 }}>
                    API Documentation
                  </Typography>
                  <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
                    Full OpenAPI docs available when daemon is running:
                  </Typography>
                  <Button
                    variant="outlined"
                    href="http://localhost:8000/docs"
                    target="_blank"
                    endIcon={<OpenInNewIcon />}
                  >
                    Open API Docs
                  </Button>
                </Box>
              </Box>
            </Grid>
          </Grid>
        </Section>

        {/* Next Steps */}
        <Box
          sx={{
            mt: 10,
            p: 6,
            borderRadius: 4,
            background: 'linear-gradient(135deg, rgba(118, 75, 162, 0.1) 0%, rgba(102, 126, 234, 0.1) 100%)',
            border: '1px solid rgba(118, 75, 162, 0.2)',
            textAlign: 'center',
          }}
        >
          <Typography variant="h4" sx={{ mb: 2 }}>
            Ready to explore more?
          </Typography>
          <Typography variant="body1" color="text.secondary" sx={{ mb: 4 }}>
            Check out the full documentation and community apps for inspiration.
          </Typography>
          <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} justifyContent="center">
            <Button
              variant="contained"
              href="https://github.com/pollen-robotics/reachy_mini/blob/main/docs/python-sdk.md"
              target="_blank"
              endIcon={<OpenInNewIcon />}
            >
              Full SDK Documentation
            </Button>
            <Button
              variant="outlined"
              component={RouterLink}
              to="/apps"
            >
              Browse Community Apps
            </Button>
            <Button
              variant="outlined"
              component="a"
              href="https://github.com/pollen-robotics/reachy_mini/blob/develop/docs/troubleshooting.md"
              target="_blank"
              rel="noopener noreferrer"
            >
              FAQ
            </Button>
          </Stack>
        </Box>
      </Container>
    </Layout>
  );
}