Face reference
robot.face
The Face Engine - the robot's primary expressive system.
This package groups every piece of the new face-based architecture:
- :class:
FaceModeland the component value types in :mod:robot.face.components- the immutable data the renderer draws. - :class:
FaceRenderer- display-agnostic pixel art. - :class:
EmotionEngine- pure functionemotion_name -> FaceModel, the single source of truth for "what does emotion X look like?". - :class:
FaceAnimator- the 30 FPS orchestrator that combines rendering, theming, and the legacy per-eye state machine. - :mod:
robot.face.themes- pluggable visual styles (Minimal, Cute, Pixel, Retro LCD, Wireframe).
The architecture diagram::
Behavior Engine
│
▼
Emotion Engine
│
▼
Face Model ────────────────┐
│ │
▼ ▼
Face Renderer Body Language Engine
│ │
▼ ▼
Display Driver Servo Controller
BUILTIN_THEMES = {'minimal': MinimalTheme, 'cute': CuteTheme, 'pixel': PixelTheme, 'retro_lcd': RetroLcdTheme, 'vector': VectorTheme, 'wireframe': WireframeTheme}
module-attribute
EMOTION_DEFS = {'neutral': _EmotionDef(eyes=NEUTRAL_EYES, eyelids=NEUTRAL_EYELIDS, eyebrows=NEUTRAL_EYEBROWS, mouth=NEUTRAL_MOUTH, cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=NEUTRAL_HINT), 'happy': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.05), openness=0.85), Eye(gaze=Gaze(0.0, 0.05), openness=0.85)), eyelids=Eyelids(top=0.05, bottom=0.25), eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.3), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.3)), mouth=Mouth(shape=MouthShape.SMILE, openness=0.3, width=0.6), cheeks=Cheeks(state=CheekState.SOFT, intensity=0.6), overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.CURIOUS, arm_pose=ArmPose.OPEN, intensity=0.7)), 'curious': _EmotionDef(eyes=(Eye(gaze=Gaze(0.2, 0.1), openness=1.0, highlight=Gaze(0.4, 0.4)), Eye(gaze=Gaze(0.2, 0.1), openness=1.0, highlight=Gaze(0.4, 0.4))), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.6), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.6)), mouth=Mouth(shape=MouthShape.OPEN, openness=0.2, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=Overlay(kind=OverlayKind.QUESTION, position=Point(0.7, -0.5)), body_hint=BodyLanguageHint(head_tilt=HeadTilt.CURIOUS, arm_pose=ArmPose.POINT, intensity=0.6)), 'thinking': _EmotionDef(eyes=(Eye(gaze=Gaze(0.2, 0.3), openness=0.85), Eye(gaze=Gaze(0.2, 0.3), openness=0.85)), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.WORRIED, raise_amount=0.2, angle=0.2), Eyebrow(shape=EyebrowShape.WORRIED, raise_amount=0.2, angle=-0.2)), mouth=Mouth(shape=MouthShape.NEUTRAL, openness=0.0, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.THINKING, arm_pose=ArmPose.RELAXED, intensity=0.5)), 'sleepy': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.0), openness=0.15), Eye(gaze=Gaze(0.0, 0.0), openness=0.15)), eyelids=Eyelids(top=0.65, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.SLEEPY), Eyebrow(shape=EyebrowShape.SLEEPY)), mouth=Mouth(shape=MouthShape.OPEN, openness=0.1, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.SLEEPY, arm_pose=ArmPose.DOWN, intensity=0.7)), 'embarrassed': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.3), openness=0.7, highlight=Gaze(-0.3, -0.3)), Eye(gaze=Gaze(0.0, -0.3), openness=0.7, highlight=Gaze(-0.3, -0.3))), eyelids=Eyelids(top=0.1, bottom=0.05), eyebrows=(Eyebrow(shape=EyebrowShape.WORRIED, angle=0.3), Eyebrow(shape=EyebrowShape.WORRIED, angle=-0.3)), mouth=Mouth(shape=MouthShape.SMILE, openness=0.2, width=0.5, asymmetry=0.3), cheeks=Cheeks(state=CheekState.BRIGHT, intensity=0.9), overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.SAD, arm_pose=ArmPose.SHRUG, intensity=0.5)), 'excited': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.1), openness=1.2, highlight=Gaze(0.0, 0.0)), Eye(gaze=Gaze(0.0, -0.1), openness=1.2, highlight=Gaze(0.0, 0.0))), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.8), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.8)), mouth=Mouth(shape=MouthShape.SMILE_OPEN, openness=0.6, width=0.7), cheeks=Cheeks(state=CheekState.SOFT, intensity=0.4), overlay=Overlay(kind=OverlayKind.SPARKLE, position=Point(-0.5, -0.4), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.EXCITED, arm_pose=ArmPose.WIDE, intensity=1.0, gestures=('bounce',))), 'sad': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.3), openness=0.65, pupil_dilation=0.7), Eye(gaze=Gaze(0.0, -0.3), openness=0.65, pupil_dilation=0.7)), eyelids=Eyelids(top=0.35, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.SAD, angle=0.4), Eyebrow(shape=EyebrowShape.SAD, angle=-0.4)), mouth=Mouth(shape=MouthShape.FROWN, openness=0.0, width=0.5), cheeks=Cheeks(state=CheekState.COLD, intensity=0.4), overlay=Overlay(kind=OverlayKind.TEAR, position=Point(-0.3, 0.1), size=0.2), body_hint=BodyLanguageHint(head_tilt=HeadTilt.SAD, arm_pose=ArmPose.DOWN, intensity=0.7)), 'surprised': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.0), openness=1.0, pupil_dilation=0.2), Eye(gaze=Gaze(0.0, 0.0), openness=1.0, pupil_dilation=0.2)), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=1.0), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=1.0)), mouth=Mouth(shape=MouthShape.WIDE_OPEN, openness=0.9, width=0.6), cheeks=NEUTRAL_CHEEKS, overlay=Overlay(kind=OverlayKind.EXCLAIM, position=Point(0.6, -0.5), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.EXCITED, arm_pose=ArmPose.SHRUG, intensity=0.8, gestures=('bounce',))), 'angry': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.1), openness=0.7, pupil_dilation=0.2), Eye(gaze=Gaze(0.0, -0.1), openness=0.7, pupil_dilation=0.2)), eyelids=Eyelids(top=0.3, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.ANGRY, angle=0.7), Eyebrow(shape=EyebrowShape.ANGRY, angle=-0.7)), mouth=Mouth(shape=MouthShape.FROWN, openness=0.2, width=0.5), cheeks=Cheeks(state=CheekState.BRIGHT, intensity=0.5), overlay=Overlay(kind=OverlayKind.ANGER, position=Point(0.5, -0.5), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.SHRUG, intensity=0.7))}
module-attribute
__all__ = ['BUILTIN_THEMES', 'EMOTION_DEFS', 'ArmPose', 'BodyLanguageHint', 'CuteTheme', 'EmotionEngine', 'FaceAnimator', 'FaceModel', 'FaceRenderer', 'HeadTilt', 'MinimalTheme', 'PixelTheme', 'RetroLcdTheme', 'Theme', 'WireframeTheme', 'get_theme']
module-attribute
ArmPose
Bases: Enum
Discrete arm-pose hints.
Source code in src/robot/face/model.py
DOWN = 'down'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
POINT = 'point'
class-attribute
instance-attribute
RELAXED = 'relaxed'
class-attribute
instance-attribute
SHRUG = 'shrug'
class-attribute
instance-attribute
WAVING = 'waving'
class-attribute
instance-attribute
WIDE = 'wide'
class-attribute
instance-attribute
BodyLanguageHint
dataclass
A high-level body-language request produced by the EmotionEngine.
Source code in src/robot/face/model.py
arm_pose = ArmPose.RELAXED
class-attribute
instance-attribute
gestures = ()
class-attribute
instance-attribute
head_tilt = HeadTilt.NEUTRAL
class-attribute
instance-attribute
intensity = 1.0
class-attribute
instance-attribute
__init__(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.RELAXED, intensity=1.0, gestures=())
CuteTheme
Source code in src/robot/face/themes/cute.py
name = 'cute'
class-attribute
instance-attribute
palette = FacePalette(background=(255, 240, 245), sclera=(255, 255, 255), iris=(180, 100, 180), pupil=(40, 20, 50), eyelid=(230, 200, 220), eyebrow=(120, 70, 120), mouth=(255, 90, 130), cheek=(255, 160, 200), blush=(255, 120, 160), outline=(80, 50, 80), highlight=(255, 255, 255))
class-attribute
instance-attribute
EmotionEngine
Produces :class:FaceModel + :class:BodyLanguageHint from an emotion.
Source code in src/robot/face/emotions.py
__init__(palette=None, width=240, height=240)
available()
build(name)
Build the :class:FaceModel for name with default geometry.
Source code in src/robot/face/emotions.py
get(name)
register(name, definition)
FaceAnimator
dataclass
Drive a single circular face display at 30 FPS.
Source code in src/robot/face/animator.py
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 | |
DEFAULT_FPS = 30
class-attribute
bus = None
class-attribute
instance-attribute
clock
instance-attribute
current
property
display
instance-attribute
emotions
instance-attribute
fps = DEFAULT_FPS
class-attribute
instance-attribute
frame_count
property
height = 240
class-attribute
instance-attribute
is_running
property
renderer
instance-attribute
theme
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(renderer, display, clock, emotions, theme, fps=DEFAULT_FPS, bus=None, width=240, height=240)
__post_init__()
Source code in src/robot/face/animator.py
bounce()
double_blink()
drift(amplitude=0.1, speed=0.6)
eyebrow_raise(amount=0.6)
Source code in src/robot/face/animator.py
look(x, y, duration_s=0.25)
look_center(duration_s=0.25)
look_down(duration_s=0.25)
look_left(duration_s=0.25)
look_right(duration_s=0.25)
look_up(duration_s=0.25)
mouth_open(duration_s=0.3)
reset()
Source code in src/robot/face/animator.py
run_forever()
async
Source code in src/robot/face/animator.py
set_emotion(name, intensity=1.0)
Animate to the given emotion over ~0.3s.
Calling this method clears any running speaking and thinking animations (they are interruptible). The wake animation is not cleared -- it plays to completion.
Source code in src/robot/face/animator.py
set_speaking_animation(animation)
Set (or clear) the speaking animation that drives mouth shapes.
set_thinking_animation(animation)
Set (or clear) the thinking animation that drives gaze shifts.
set_wake_animation(animation)
smile_grow()
Animate the mouth from NEUTRAL to SMILE over 0.4s.
Source code in src/robot/face/animator.py
step(drift=True)
Advance one frame and push to the display.
The rendering pipeline applies overrides in priority order:
- Eye drift + blink state (from :class:
EyeAnimator). - Thinking animation gaze override.
- Timeline-based emotion interpolation.
- Speaking animation mouth override.
- Wake animation full override (highest priority).
Source code in src/robot/face/animator.py
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 | |
stop()
FaceModel
dataclass
The full face, captured at one instant.
All values are immutable. Use the helper methods to build new models with a single field changed (this is what the renderer animates).
Source code in src/robot/face/model.py
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 | |
accessory = field(default_factory=Accessory)
class-attribute
instance-attribute
body_hint = field(default_factory=BodyLanguageHint)
class-attribute
instance-attribute
bounce = 0.0
class-attribute
instance-attribute
cheeks = field(default_factory=Cheeks)
class-attribute
instance-attribute
eyelids = field(default_factory=Eyelids)
class-attribute
instance-attribute
height = 240
class-attribute
instance-attribute
left_eye = field(default_factory=Eye)
class-attribute
instance-attribute
left_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
mouth = field(default_factory=Mouth)
class-attribute
instance-attribute
overlay = field(default_factory=Overlay)
class-attribute
instance-attribute
palette = field(default_factory=FacePalette)
class-attribute
instance-attribute
right_eye = field(default_factory=Eye)
class-attribute
instance-attribute
right_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
squash = 1.0
class-attribute
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(width=240, height=240, left_eye=Eye(), right_eye=Eye(), eyelids=Eyelids(), left_eyebrow=Eyebrow(), right_eyebrow=Eyebrow(), mouth=Mouth(), cheeks=Cheeks(), overlay=Overlay(), accessory=Accessory(), palette=FacePalette(), bounce=0.0, squash=1.0, body_hint=BodyLanguageHint())
with_accessory(accessory)
with_body_hint(body_hint)
with_cheeks(cheeks)
with_eyebrows(left=None, right=None)
with_eyelids(eyelids)
with_eyes(left_eye=None, right_eye=None)
with_mouth(mouth)
with_overlay(overlay)
with_palette(palette)
with_transform(bounce=None, squash=None)
FaceRenderer
Render a :class:FaceModel to an RGB888 frame.
Source code in src/robot/face/renderer.py
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | |
height
property
width
property
__init__(width=240, height=240)
render(model)
Render model into a new RGB888 frame.
Source code in src/robot/face/renderer.py
HeadTilt
Bases: Enum
Discrete head-tilt hints the body-language engine understands.
Source code in src/robot/face/model.py
CURIOUS = 'curious'
class-attribute
instance-attribute
EXCITED = 'excited'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
MinimalTheme
The default minimal theme.
Source code in src/robot/face/themes/minimal.py
name = 'minimal'
class-attribute
instance-attribute
palette = FacePalette(background=(10, 10, 20), sclera=(245, 245, 235), iris=(40, 110, 200), pupil=(10, 10, 20), eyelid=(20, 20, 30), eyebrow=(40, 30, 30), mouth=(180, 60, 80), cheek=(255, 130, 130), blush=(255, 90, 90), outline=(10, 10, 10), highlight=(255, 255, 255))
class-attribute
instance-attribute
PixelTheme
Source code in src/robot/face/themes/pixel.py
name = 'pixel'
class-attribute
instance-attribute
palette = FacePalette(background=(15, 15, 25), sclera=(255, 255, 240), iris=(70, 140, 220), pupil=(15, 15, 25), eyelid=(30, 30, 45), eyebrow=(60, 40, 40), mouth=(220, 70, 90), cheek=(255, 140, 140), blush=(255, 90, 90), outline=(0, 0, 0), highlight=(255, 255, 255))
class-attribute
instance-attribute
__init__(grid=8)
apply(model)
Source code in src/robot/face/themes/pixel.py
RetroLcdTheme
Source code in src/robot/face/themes/retro_lcd.py
name = 'retro_lcd'
class-attribute
instance-attribute
palette = FacePalette(background=(0, 0, 0), sclera=(40, 180, 60), iris=(100, 255, 130), pupil=(0, 0, 0), eyelid=(20, 60, 30), eyebrow=(40, 180, 60), mouth=(40, 180, 60), cheek=(40, 180, 60), blush=(40, 180, 60), outline=(0, 0, 0), highlight=(180, 255, 200))
class-attribute
instance-attribute
Theme
Bases: Protocol
A visual style applied to a :class:FaceModel.
Source code in src/robot/face/themes/base.py
name
property
Human-readable theme name.
palette
property
The colour palette the theme uses.
WireframeTheme
Source code in src/robot/face/themes/wireframe.py
name = 'wireframe'
class-attribute
instance-attribute
palette = FacePalette(background=(0, 0, 0), sclera=(0, 0, 0), iris=(0, 0, 0), pupil=(255, 255, 255), eyelid=(0, 0, 0), eyebrow=(255, 255, 255), mouth=(255, 255, 255), cheek=(0, 0, 0), blush=(0, 0, 0), outline=(255, 255, 255), highlight=(255, 255, 255))
class-attribute
instance-attribute
get_theme(name)
Look up a built-in theme by name (case-insensitive).
Source code in src/robot/face/themes/__init__.py
Model
robot.face.model
The :class:FaceModel - a complete, immutable snapshot of the face.
The model is the contract between the :class:EmotionEngine,
:class:FaceAnimator, and :class:FaceRenderer. Every layer reads /
writes this single value type.
Two eyes (left + right) are explicitly separate so asymmetric expressions (winks, side-glances) are first-class.
__all__ = ['ArmPose', 'BodyLanguageHint', 'FaceModel', 'HeadTilt']
module-attribute
Accessory
dataclass
A persistent decoration (vs. an :class:Overlay which is transient).
Source code in src/robot/face/components.py
color = (255, 255, 255)
class-attribute
instance-attribute
kind = AccessoryKind.NONE
class-attribute
instance-attribute
opacity = 1.0
class-attribute
instance-attribute
__init__(kind=AccessoryKind.NONE, color=(255, 255, 255), opacity=1.0)
ArmPose
Bases: Enum
Discrete arm-pose hints.
Source code in src/robot/face/model.py
DOWN = 'down'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
POINT = 'point'
class-attribute
instance-attribute
RELAXED = 'relaxed'
class-attribute
instance-attribute
SHRUG = 'shrug'
class-attribute
instance-attribute
WAVING = 'waving'
class-attribute
instance-attribute
WIDE = 'wide'
class-attribute
instance-attribute
BodyLanguageHint
dataclass
A high-level body-language request produced by the EmotionEngine.
Source code in src/robot/face/model.py
arm_pose = ArmPose.RELAXED
class-attribute
instance-attribute
gestures = ()
class-attribute
instance-attribute
head_tilt = HeadTilt.NEUTRAL
class-attribute
instance-attribute
intensity = 1.0
class-attribute
instance-attribute
__init__(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.RELAXED, intensity=1.0, gestures=())
Cheeks
dataclass
Cheek rendering - base + accent colour, intensity.
Source code in src/robot/face/components.py
intensity = 0.0
class-attribute
instance-attribute
state = CheekState.NONE
class-attribute
instance-attribute
__init__(state=CheekState.NONE, intensity=0.0)
Eye
dataclass
A single eye. The face has two of them.
Source code in src/robot/face/components.py
asymmetric = False
class-attribute
instance-attribute
gaze = field(default_factory=Gaze)
class-attribute
instance-attribute
highlight = field(default_factory=lambda: Gaze(0.3, 0.3))
class-attribute
instance-attribute
openness = 1.0
class-attribute
instance-attribute
pupil_dilation = 0.5
class-attribute
instance-attribute
__init__(gaze=Gaze(), openness=1.0, pupil_dilation=0.5, highlight=(lambda: Gaze(0.3, 0.3))(), asymmetric=False)
Eyebrow
dataclass
A single eyebrow.
Source code in src/robot/face/components.py
angle = 0.0
class-attribute
instance-attribute
raise_amount = 0.0
class-attribute
instance-attribute
shape = EyebrowShape.NEUTRAL
class-attribute
instance-attribute
__init__(shape=EyebrowShape.NEUTRAL, raise_amount=0.0, angle=0.0)
Eyelids
dataclass
Vertical eyelid positions, 0.0 = retracted, 1.0 = fully closed.
Source code in src/robot/face/components.py
bottom = 0.0
class-attribute
instance-attribute
top = 0.0
class-attribute
instance-attribute
__init__(top=0.0, bottom=0.0)
FaceModel
dataclass
The full face, captured at one instant.
All values are immutable. Use the helper methods to build new models with a single field changed (this is what the renderer animates).
Source code in src/robot/face/model.py
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 | |
accessory = field(default_factory=Accessory)
class-attribute
instance-attribute
body_hint = field(default_factory=BodyLanguageHint)
class-attribute
instance-attribute
bounce = 0.0
class-attribute
instance-attribute
cheeks = field(default_factory=Cheeks)
class-attribute
instance-attribute
eyelids = field(default_factory=Eyelids)
class-attribute
instance-attribute
height = 240
class-attribute
instance-attribute
left_eye = field(default_factory=Eye)
class-attribute
instance-attribute
left_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
mouth = field(default_factory=Mouth)
class-attribute
instance-attribute
overlay = field(default_factory=Overlay)
class-attribute
instance-attribute
palette = field(default_factory=FacePalette)
class-attribute
instance-attribute
right_eye = field(default_factory=Eye)
class-attribute
instance-attribute
right_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
squash = 1.0
class-attribute
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(width=240, height=240, left_eye=Eye(), right_eye=Eye(), eyelids=Eyelids(), left_eyebrow=Eyebrow(), right_eyebrow=Eyebrow(), mouth=Mouth(), cheeks=Cheeks(), overlay=Overlay(), accessory=Accessory(), palette=FacePalette(), bounce=0.0, squash=1.0, body_hint=BodyLanguageHint())
with_accessory(accessory)
with_body_hint(body_hint)
with_cheeks(cheeks)
with_eyebrows(left=None, right=None)
with_eyelids(eyelids)
with_eyes(left_eye=None, right_eye=None)
with_mouth(mouth)
with_overlay(overlay)
with_palette(palette)
with_transform(bounce=None, squash=None)
FacePalette
dataclass
All colours the renderer can use. Themes override these.
mode selects a renderer rendering style. The default "face"
draws the full eye stack (sclera + iris + pupil + highlight +
eyelids + eyebrows + mouth). The "vector" mode draws two
filled rounded-squares for eyes and a thin horizontal bar for
the mouth - the Anki Vector 2.0 minimalist look.
Source code in src/robot/face/components.py
background = (10, 10, 20)
class-attribute
instance-attribute
blush = (255, 90, 90)
class-attribute
instance-attribute
cheek = (255, 130, 130)
class-attribute
instance-attribute
eyebrow = (40, 30, 30)
class-attribute
instance-attribute
eyelid = (20, 20, 30)
class-attribute
instance-attribute
highlight = (255, 255, 255)
class-attribute
instance-attribute
iris = (40, 110, 200)
class-attribute
instance-attribute
mode = PALETTE_MODE_FACE
class-attribute
instance-attribute
mouth = (180, 60, 80)
class-attribute
instance-attribute
outline = (10, 10, 10)
class-attribute
instance-attribute
pupil = (10, 10, 20)
class-attribute
instance-attribute
sclera = (245, 245, 235)
class-attribute
instance-attribute
__init__(background=(10, 10, 20), sclera=(245, 245, 235), iris=(40, 110, 200), pupil=(10, 10, 20), eyelid=(20, 20, 30), eyebrow=(40, 30, 30), mouth=(180, 60, 80), cheek=(255, 130, 130), blush=(255, 90, 90), outline=(10, 10, 10), highlight=(255, 255, 255), mode=PALETTE_MODE_FACE)
HeadTilt
Bases: Enum
Discrete head-tilt hints the body-language engine understands.
Source code in src/robot/face/model.py
CURIOUS = 'curious'
class-attribute
instance-attribute
EXCITED = 'excited'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
Mouth
dataclass
The mouth, parameterised.
Source code in src/robot/face/components.py
asymmetry = 0.0
class-attribute
instance-attribute
openness = 0.0
class-attribute
instance-attribute
shape = MouthShape.NEUTRAL
class-attribute
instance-attribute
width = 0.5
class-attribute
instance-attribute
__init__(shape=MouthShape.NEUTRAL, openness=0.0, width=0.5, asymmetry=0.0)
Overlay
dataclass
A floating symbol rendered on top of the face.
Source code in src/robot/face/components.py
color = (255, 255, 255)
class-attribute
instance-attribute
kind = OverlayKind.NONE
class-attribute
instance-attribute
position = field(default_factory=lambda: Point(0.0, -0.5))
class-attribute
instance-attribute
rotation = 0.0
class-attribute
instance-attribute
size = 0.3
class-attribute
instance-attribute
__init__(kind=OverlayKind.NONE, position=(lambda: Point(0.0, -0.5))(), size=0.3, rotation=0.0, color=(255, 255, 255))
Components
robot.face.components
Reusable face components.
A face is a composition of small, independent components. Each component
is an immutable value type so the :class:FaceModel itself is also
immutable - that makes the renderer deterministic and unit-testable.
The components live at three levels:
- eyes (left/right) - gaze vector, openness, pupil dilation, etc.
- face features - eyebrows, mouth, cheeks, all parameterised.
- overlays - sparkles, hearts, tears, sweat drop, blush, accessories.
They are off-screen by default and turned on by the
:class:
EmotionEnginewhen an emotion needs them.
PALETTE_MODE_FACE = 'face'
module-attribute
PALETTE_MODE_VECTOR = 'vector'
module-attribute
__all__ = ['PALETTE_MODE_FACE', 'PALETTE_MODE_VECTOR', 'Accessory', 'AccessoryKind', 'CheekState', 'Cheeks', 'Eye', 'Eyebrow', 'EyebrowShape', 'Eyelids', 'FacePalette', 'Gaze', 'Mouth', 'MouthShape', 'Overlay', 'OverlayKind', 'Point']
module-attribute
Accessory
dataclass
A persistent decoration (vs. an :class:Overlay which is transient).
Source code in src/robot/face/components.py
color = (255, 255, 255)
class-attribute
instance-attribute
kind = AccessoryKind.NONE
class-attribute
instance-attribute
opacity = 1.0
class-attribute
instance-attribute
__init__(kind=AccessoryKind.NONE, color=(255, 255, 255), opacity=1.0)
AccessoryKind
Bases: str, Enum
Source code in src/robot/face/components.py
BANDAGE = 'bandage'
class-attribute
instance-attribute
BOW_TIE = 'bow_tie'
class-attribute
instance-attribute
CROWN = 'crown'
class-attribute
instance-attribute
GLASSES = 'glasses'
class-attribute
instance-attribute
HAT = 'hat'
class-attribute
instance-attribute
HEART_EYES = 'heart_eyes'
class-attribute
instance-attribute
MUSTACHE = 'mustache'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
SUNGLASSES = 'sunglasses'
class-attribute
instance-attribute
CheekState
Bases: str, Enum
Source code in src/robot/face/components.py
BRIGHT = 'bright'
class-attribute
instance-attribute
COLD = 'cold'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
SOFT = 'soft'
class-attribute
instance-attribute
Cheeks
dataclass
Cheek rendering - base + accent colour, intensity.
Source code in src/robot/face/components.py
intensity = 0.0
class-attribute
instance-attribute
state = CheekState.NONE
class-attribute
instance-attribute
__init__(state=CheekState.NONE, intensity=0.0)
Eye
dataclass
A single eye. The face has two of them.
Source code in src/robot/face/components.py
asymmetric = False
class-attribute
instance-attribute
gaze = field(default_factory=Gaze)
class-attribute
instance-attribute
highlight = field(default_factory=lambda: Gaze(0.3, 0.3))
class-attribute
instance-attribute
openness = 1.0
class-attribute
instance-attribute
pupil_dilation = 0.5
class-attribute
instance-attribute
__init__(gaze=Gaze(), openness=1.0, pupil_dilation=0.5, highlight=(lambda: Gaze(0.3, 0.3))(), asymmetric=False)
Eyebrow
dataclass
A single eyebrow.
Source code in src/robot/face/components.py
angle = 0.0
class-attribute
instance-attribute
raise_amount = 0.0
class-attribute
instance-attribute
shape = EyebrowShape.NEUTRAL
class-attribute
instance-attribute
__init__(shape=EyebrowShape.NEUTRAL, raise_amount=0.0, angle=0.0)
EyebrowShape
Bases: str, Enum
Source code in src/robot/face/components.py
ANGRY = 'angry'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
RAISED = 'raised'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
WORRIED = 'worried'
class-attribute
instance-attribute
Eyelids
dataclass
Vertical eyelid positions, 0.0 = retracted, 1.0 = fully closed.
Source code in src/robot/face/components.py
bottom = 0.0
class-attribute
instance-attribute
top = 0.0
class-attribute
instance-attribute
__init__(top=0.0, bottom=0.0)
FacePalette
dataclass
All colours the renderer can use. Themes override these.
mode selects a renderer rendering style. The default "face"
draws the full eye stack (sclera + iris + pupil + highlight +
eyelids + eyebrows + mouth). The "vector" mode draws two
filled rounded-squares for eyes and a thin horizontal bar for
the mouth - the Anki Vector 2.0 minimalist look.
Source code in src/robot/face/components.py
background = (10, 10, 20)
class-attribute
instance-attribute
blush = (255, 90, 90)
class-attribute
instance-attribute
cheek = (255, 130, 130)
class-attribute
instance-attribute
eyebrow = (40, 30, 30)
class-attribute
instance-attribute
eyelid = (20, 20, 30)
class-attribute
instance-attribute
highlight = (255, 255, 255)
class-attribute
instance-attribute
iris = (40, 110, 200)
class-attribute
instance-attribute
mode = PALETTE_MODE_FACE
class-attribute
instance-attribute
mouth = (180, 60, 80)
class-attribute
instance-attribute
outline = (10, 10, 10)
class-attribute
instance-attribute
pupil = (10, 10, 20)
class-attribute
instance-attribute
sclera = (245, 245, 235)
class-attribute
instance-attribute
__init__(background=(10, 10, 20), sclera=(245, 245, 235), iris=(40, 110, 200), pupil=(10, 10, 20), eyelid=(20, 20, 30), eyebrow=(40, 30, 30), mouth=(180, 60, 80), cheek=(255, 130, 130), blush=(255, 90, 90), outline=(10, 10, 10), highlight=(255, 255, 255), mode=PALETTE_MODE_FACE)
Gaze
dataclass
2D gaze target normalised in [-1, 1].
Source code in src/robot/face/components.py
Mouth
dataclass
The mouth, parameterised.
Source code in src/robot/face/components.py
asymmetry = 0.0
class-attribute
instance-attribute
openness = 0.0
class-attribute
instance-attribute
shape = MouthShape.NEUTRAL
class-attribute
instance-attribute
width = 0.5
class-attribute
instance-attribute
__init__(shape=MouthShape.NEUTRAL, openness=0.0, width=0.5, asymmetry=0.0)
MouthShape
Bases: str, Enum
Source code in src/robot/face/components.py
CLOSED = 'closed'
class-attribute
instance-attribute
FROWN = 'frown'
class-attribute
instance-attribute
GRIN = 'grin'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
SMILE = 'smile'
class-attribute
instance-attribute
SMILE_OPEN = 'smile_open'
class-attribute
instance-attribute
TONGUE = 'tongue'
class-attribute
instance-attribute
WIDE_OPEN = 'wide_open'
class-attribute
instance-attribute
Overlay
dataclass
A floating symbol rendered on top of the face.
Source code in src/robot/face/components.py
color = (255, 255, 255)
class-attribute
instance-attribute
kind = OverlayKind.NONE
class-attribute
instance-attribute
position = field(default_factory=lambda: Point(0.0, -0.5))
class-attribute
instance-attribute
rotation = 0.0
class-attribute
instance-attribute
size = 0.3
class-attribute
instance-attribute
__init__(kind=OverlayKind.NONE, position=(lambda: Point(0.0, -0.5))(), size=0.3, rotation=0.0, color=(255, 255, 255))
OverlayKind
Bases: str, Enum
Source code in src/robot/face/components.py
ANGER = 'anger'
class-attribute
instance-attribute
EXCLAIM = 'exclaim'
class-attribute
instance-attribute
HEART = 'heart'
class-attribute
instance-attribute
MUSIC = 'music'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
QUESTION = 'question'
class-attribute
instance-attribute
SPARKLE = 'sparkle'
class-attribute
instance-attribute
STAR = 'star'
class-attribute
instance-attribute
SWEAT = 'sweat'
class-attribute
instance-attribute
TEAR = 'tear'
class-attribute
instance-attribute
Point
dataclass
Renderer
robot.face.renderer
The :class:FaceRenderer - display-agnostic pixel art.
The renderer takes a :class:FaceModel and produces an
:class:EyeFrame (an RGB888 buffer). It knows nothing about displays,
themes, or animation - it just rasterises the model it is given.
The drawing layers (z-order, back to front) are:
- Background - solid colour from the palette.
- Bounce / squash transform - translate / scale the entire face
based on the model's
bounceandsquashfields. - Cheeks - soft circular blush patches.
- Sclera (eyes) - filled circles clipped to the panel.
- Eyelids - horizontal bands that cover the eyes.
- Iris - coloured discs shifted by gaze offset.
- Pupil - dark discs on top of the iris.
- Eye highlight - small catch-light.
- Eyebrows - short bars above each eye.
- Mouth - the mouth shape as a small filled curve.
- Overlay - sparkles, hearts, tears, sweat, etc.
- Accessory - glasses, hat, etc.
PALETTE_MODE_VECTOR = 'vector'
module-attribute
__all__ = ['FaceRenderer']
module-attribute
AccessoryKind
Bases: str, Enum
Source code in src/robot/face/components.py
BANDAGE = 'bandage'
class-attribute
instance-attribute
BOW_TIE = 'bow_tie'
class-attribute
instance-attribute
CROWN = 'crown'
class-attribute
instance-attribute
GLASSES = 'glasses'
class-attribute
instance-attribute
HAT = 'hat'
class-attribute
instance-attribute
HEART_EYES = 'heart_eyes'
class-attribute
instance-attribute
MUSTACHE = 'mustache'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
SUNGLASSES = 'sunglasses'
class-attribute
instance-attribute
CheekState
Bases: str, Enum
Source code in src/robot/face/components.py
BRIGHT = 'bright'
class-attribute
instance-attribute
COLD = 'cold'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
SOFT = 'soft'
class-attribute
instance-attribute
EyeFrame
dataclass
An RGB888 image to push to the display.
Attributes
width, height:
Pixel dimensions.
pixels:
Row-major RGB888 buffer of length width * height * 3.
Source code in src/robot/interfaces/display.py
height
instance-attribute
pixels
instance-attribute
width
instance-attribute
__init__(width, height, pixels)
EyebrowShape
Bases: str, Enum
Source code in src/robot/face/components.py
ANGRY = 'angry'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
RAISED = 'raised'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
WORRIED = 'worried'
class-attribute
instance-attribute
FaceModel
dataclass
The full face, captured at one instant.
All values are immutable. Use the helper methods to build new models with a single field changed (this is what the renderer animates).
Source code in src/robot/face/model.py
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 | |
accessory = field(default_factory=Accessory)
class-attribute
instance-attribute
body_hint = field(default_factory=BodyLanguageHint)
class-attribute
instance-attribute
bounce = 0.0
class-attribute
instance-attribute
cheeks = field(default_factory=Cheeks)
class-attribute
instance-attribute
eyelids = field(default_factory=Eyelids)
class-attribute
instance-attribute
height = 240
class-attribute
instance-attribute
left_eye = field(default_factory=Eye)
class-attribute
instance-attribute
left_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
mouth = field(default_factory=Mouth)
class-attribute
instance-attribute
overlay = field(default_factory=Overlay)
class-attribute
instance-attribute
palette = field(default_factory=FacePalette)
class-attribute
instance-attribute
right_eye = field(default_factory=Eye)
class-attribute
instance-attribute
right_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
squash = 1.0
class-attribute
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(width=240, height=240, left_eye=Eye(), right_eye=Eye(), eyelids=Eyelids(), left_eyebrow=Eyebrow(), right_eyebrow=Eyebrow(), mouth=Mouth(), cheeks=Cheeks(), overlay=Overlay(), accessory=Accessory(), palette=FacePalette(), bounce=0.0, squash=1.0, body_hint=BodyLanguageHint())
with_accessory(accessory)
with_body_hint(body_hint)
with_cheeks(cheeks)
with_eyebrows(left=None, right=None)
with_eyelids(eyelids)
with_eyes(left_eye=None, right_eye=None)
with_mouth(mouth)
with_overlay(overlay)
with_palette(palette)
with_transform(bounce=None, squash=None)
FaceRenderer
Render a :class:FaceModel to an RGB888 frame.
Source code in src/robot/face/renderer.py
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | |
height
property
width
property
__init__(width=240, height=240)
render(model)
Render model into a new RGB888 frame.
Source code in src/robot/face/renderer.py
MouthShape
Bases: str, Enum
Source code in src/robot/face/components.py
CLOSED = 'closed'
class-attribute
instance-attribute
FROWN = 'frown'
class-attribute
instance-attribute
GRIN = 'grin'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
SMILE = 'smile'
class-attribute
instance-attribute
SMILE_OPEN = 'smile_open'
class-attribute
instance-attribute
TONGUE = 'tongue'
class-attribute
instance-attribute
WIDE_OPEN = 'wide_open'
class-attribute
instance-attribute
OverlayKind
Bases: str, Enum
Source code in src/robot/face/components.py
ANGER = 'anger'
class-attribute
instance-attribute
EXCLAIM = 'exclaim'
class-attribute
instance-attribute
HEART = 'heart'
class-attribute
instance-attribute
MUSIC = 'music'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
QUESTION = 'question'
class-attribute
instance-attribute
SPARKLE = 'sparkle'
class-attribute
instance-attribute
STAR = 'star'
class-attribute
instance-attribute
SWEAT = 'sweat'
class-attribute
instance-attribute
TEAR = 'tear'
class-attribute
instance-attribute
_Raster
dataclass
A mutable RGB888 image buffer.
Source code in src/robot/face/renderer.py
height
instance-attribute
pixels = field(default_factory=bytearray)
class-attribute
instance-attribute
width
instance-attribute
__init__(width, height, pixels=bytearray())
Animator
robot.face.animator
The :class:FaceAnimator - drives the face at 30 FPS.
This is the high-level component the application boots. It owns:
- the per-eye :class:
EyeAnimator(the existing state machine), - a :class:
FaceRenderer, - a single :class:
Display(one circular TFT), - the active :class:
Theme.
It runs at 30 FPS (configurable), produces one :class:FaceModel per
frame, applies the theme, renders to an :class:EyeFrame, and pushes
it to the display.
Animations are driven by timelines built on the existing
:mod:robot.animation framework (easing + parallel + queue + easing).
The animator exposes small explicit commands (blink, smile, …) and
each command internally composes a :class:Timeline that drives the
intermediate :class:FaceModel snapshots.
__all__ = ['FaceAnimator']
module-attribute
_log = get_logger('face.animator')
module-attribute
Cheeks
dataclass
Cheek rendering - base + accent colour, intensity.
Source code in src/robot/face/components.py
intensity = 0.0
class-attribute
instance-attribute
state = CheekState.NONE
class-attribute
instance-attribute
__init__(state=CheekState.NONE, intensity=0.0)
Clock
Bases: Protocol
Minimal time abstraction.
Source code in src/robot/utils/clock.py
monotonic()
now()
Display
Bases: Protocol
A single display the eye engine can render to.
Source code in src/robot/interfaces/display.py
height
property
Height of the framebuffer in pixels.
width
property
Width of the framebuffer in pixels.
clear()
async
close()
async
fill(color)
async
EmotionEngine
Produces :class:FaceModel + :class:BodyLanguageHint from an emotion.
Source code in src/robot/face/emotions.py
__init__(palette=None, width=240, height=240)
available()
build(name)
Build the :class:FaceModel for name with default geometry.
Source code in src/robot/face/emotions.py
get(name)
register(name, definition)
Eye
dataclass
A single eye. The face has two of them.
Source code in src/robot/face/components.py
asymmetric = False
class-attribute
instance-attribute
gaze = field(default_factory=Gaze)
class-attribute
instance-attribute
highlight = field(default_factory=lambda: Gaze(0.3, 0.3))
class-attribute
instance-attribute
openness = 1.0
class-attribute
instance-attribute
pupil_dilation = 0.5
class-attribute
instance-attribute
__init__(gaze=Gaze(), openness=1.0, pupil_dilation=0.5, highlight=(lambda: Gaze(0.3, 0.3))(), asymmetric=False)
EyeAnimator
State machine that produces :class:EyeRenderState for one eye.
The animator exposes a small, explicit API. Every method that changes state is a "command" - the actual movement happens over the next several frames, interpolated smoothly.
Use :meth:step to advance one frame; the caller (a
:class:DualEyeAnimator or a test) decides the frame interval.
Source code in src/robot/eye_engine/animation.py
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 | |
DEFAULT_FPS = 30
class-attribute
instance-attribute
emotion
property
frame_count
property
height
property
openness
property
side = side
instance-attribute
width
property
__init__(side, width=240, height=240, fps=DEFAULT_FPS)
Source code in src/robot/eye_engine/animation.py
blink()
Trigger a single blink (interrupts any current blink).
double_blink()
Trigger two quick blinks in succession.
Source code in src/robot/eye_engine/animation.py
drift(amplitude=0.15, speed=0.6)
Apply a slow, smooth gaze drift.
Call this once per frame from the caller; it advances an internal phase. The drift is sinusoidal and looks like an idle glance around the current gaze target.
Source code in src/robot/eye_engine/animation.py
look(x, y, duration_s=0.25)
Smoothly move the gaze to (x, y) over duration_s seconds.
x and y are in [-1, 1].
Source code in src/robot/eye_engine/animation.py
look_center(duration_s=0.25)
look_down(duration_s=0.25)
look_left(duration_s=0.25)
look_right(duration_s=0.25)
look_up(duration_s=0.25)
render_state()
Return the current :class:EyeRenderState without advancing.
Source code in src/robot/eye_engine/animation.py
reset()
Stop any running animation and return to the neutral state.
Source code in src/robot/eye_engine/animation.py
set_emotion(emotion, intensity=1.0)
Set the resting emotion (overrides eyelid/iris defaults).
Source code in src/robot/eye_engine/animation.py
step()
Advance one frame and return the current render state.
Source code in src/robot/eye_engine/animation.py
wink()
Close this eye briefly while the other eye stays open (independent mode).
EyeFrame
dataclass
An RGB888 image to push to the display.
Attributes
width, height:
Pixel dimensions.
pixels:
Row-major RGB888 buffer of length width * height * 3.
Source code in src/robot/interfaces/display.py
height
instance-attribute
pixels
instance-attribute
width
instance-attribute
__init__(width, height, pixels)
EyeSide
Bases: str, Enum
Which physical eye the animator drives.
Source code in src/robot/eye_engine/animation.py
BOTH = 'both'
class-attribute
instance-attribute
LEFT = 'left'
class-attribute
instance-attribute
RIGHT = 'right'
class-attribute
instance-attribute
Eyebrow
dataclass
A single eyebrow.
Source code in src/robot/face/components.py
angle = 0.0
class-attribute
instance-attribute
raise_amount = 0.0
class-attribute
instance-attribute
shape = EyebrowShape.NEUTRAL
class-attribute
instance-attribute
__init__(shape=EyebrowShape.NEUTRAL, raise_amount=0.0, angle=0.0)
EyebrowShape
Bases: str, Enum
Source code in src/robot/face/components.py
ANGRY = 'angry'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
RAISED = 'raised'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
WORRIED = 'worried'
class-attribute
instance-attribute
Eyelids
dataclass
Vertical eyelid positions, 0.0 = retracted, 1.0 = fully closed.
Source code in src/robot/face/components.py
bottom = 0.0
class-attribute
instance-attribute
top = 0.0
class-attribute
instance-attribute
__init__(top=0.0, bottom=0.0)
FaceAnimator
dataclass
Drive a single circular face display at 30 FPS.
Source code in src/robot/face/animator.py
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 | |
DEFAULT_FPS = 30
class-attribute
bus = None
class-attribute
instance-attribute
clock
instance-attribute
current
property
display
instance-attribute
emotions
instance-attribute
fps = DEFAULT_FPS
class-attribute
instance-attribute
frame_count
property
height = 240
class-attribute
instance-attribute
is_running
property
renderer
instance-attribute
theme
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(renderer, display, clock, emotions, theme, fps=DEFAULT_FPS, bus=None, width=240, height=240)
__post_init__()
Source code in src/robot/face/animator.py
bounce()
double_blink()
drift(amplitude=0.1, speed=0.6)
eyebrow_raise(amount=0.6)
Source code in src/robot/face/animator.py
look(x, y, duration_s=0.25)
look_center(duration_s=0.25)
look_down(duration_s=0.25)
look_left(duration_s=0.25)
look_right(duration_s=0.25)
look_up(duration_s=0.25)
mouth_open(duration_s=0.3)
reset()
Source code in src/robot/face/animator.py
run_forever()
async
Source code in src/robot/face/animator.py
set_emotion(name, intensity=1.0)
Animate to the given emotion over ~0.3s.
Calling this method clears any running speaking and thinking animations (they are interruptible). The wake animation is not cleared -- it plays to completion.
Source code in src/robot/face/animator.py
set_speaking_animation(animation)
Set (or clear) the speaking animation that drives mouth shapes.
set_thinking_animation(animation)
Set (or clear) the thinking animation that drives gaze shifts.
set_wake_animation(animation)
smile_grow()
Animate the mouth from NEUTRAL to SMILE over 0.4s.
Source code in src/robot/face/animator.py
step(drift=True)
Advance one frame and push to the display.
The rendering pipeline applies overrides in priority order:
- Eye drift + blink state (from :class:
EyeAnimator). - Thinking animation gaze override.
- Timeline-based emotion interpolation.
- Speaking animation mouth override.
- Wake animation full override (highest priority).
Source code in src/robot/face/animator.py
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 | |
stop()
FaceModel
dataclass
The full face, captured at one instant.
All values are immutable. Use the helper methods to build new models with a single field changed (this is what the renderer animates).
Source code in src/robot/face/model.py
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 | |
accessory = field(default_factory=Accessory)
class-attribute
instance-attribute
body_hint = field(default_factory=BodyLanguageHint)
class-attribute
instance-attribute
bounce = 0.0
class-attribute
instance-attribute
cheeks = field(default_factory=Cheeks)
class-attribute
instance-attribute
eyelids = field(default_factory=Eyelids)
class-attribute
instance-attribute
height = 240
class-attribute
instance-attribute
left_eye = field(default_factory=Eye)
class-attribute
instance-attribute
left_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
mouth = field(default_factory=Mouth)
class-attribute
instance-attribute
overlay = field(default_factory=Overlay)
class-attribute
instance-attribute
palette = field(default_factory=FacePalette)
class-attribute
instance-attribute
right_eye = field(default_factory=Eye)
class-attribute
instance-attribute
right_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
squash = 1.0
class-attribute
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(width=240, height=240, left_eye=Eye(), right_eye=Eye(), eyelids=Eyelids(), left_eyebrow=Eyebrow(), right_eyebrow=Eyebrow(), mouth=Mouth(), cheeks=Cheeks(), overlay=Overlay(), accessory=Accessory(), palette=FacePalette(), bounce=0.0, squash=1.0, body_hint=BodyLanguageHint())
with_accessory(accessory)
with_body_hint(body_hint)
with_cheeks(cheeks)
with_eyebrows(left=None, right=None)
with_eyelids(eyelids)
with_eyes(left_eye=None, right_eye=None)
with_mouth(mouth)
with_overlay(overlay)
with_palette(palette)
with_transform(bounce=None, squash=None)
FaceRenderer
Render a :class:FaceModel to an RGB888 frame.
Source code in src/robot/face/renderer.py
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | |
height
property
width
property
__init__(width=240, height=240)
render(model)
Render model into a new RGB888 frame.
Source code in src/robot/face/renderer.py
FrameProfiler
Measures frame rendering performance and reports budget compliance.
Parameters
target_fps:
The desired frame rate used to compute the per-frame budget.
window:
Rolling window size (number of recent frames kept for statistics).
report_interval:
Publish a :class:FrameStatsReport event every this many frames.
Set to 0 to disable periodic reports.
bus:
Optional event bus for publishing :class:FrameStatsReport events.
enabled:
When False, :meth:record_frame is a no-op.
Source code in src/robot/performance/frame_profiler.py
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 | |
enabled = enabled
instance-attribute
__init__(target_fps=30, window=100, report_interval=100, bus=None, enabled=True)
Source code in src/robot/performance/frame_profiler.py
record_frame(start, end)
Record the timing of a single frame.
start and end must be monotonic timestamps
(time.monotonic() values). This method is a fast no-op when
self.enabled is False.
Source code in src/robot/performance/frame_profiler.py
reset()
stats()
Return a snapshot of current frame performance statistics.
Source code in src/robot/performance/frame_profiler.py
Gaze
dataclass
2D gaze target normalised in [-1, 1].
Source code in src/robot/face/components.py
InMemoryEventBus
An async pub/sub bus for in-process events with handler priority.
Critical handlers have their exceptions propagated; non-critical handlers have their exceptions logged and isolated.
Source code in src/robot/events/bus.py
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 | |
__init__()
__repr__()
close()
async
publish(event)
async
Publish an event to all subscribers.
Source code in src/robot/events/bus.py
subscribe(event_type, handler)
Subscribe a non-critical handler for events of event_type.
Source code in src/robot/events/bus.py
subscribe_critical(event_type, handler)
Subscribe a critical handler for events of event_type.
Source code in src/robot/events/bus.py
unsubscribe(event_type, handler)
Unsubscribe a previously-registered handler.
Source code in src/robot/events/bus.py
Mouth
dataclass
The mouth, parameterised.
Source code in src/robot/face/components.py
asymmetry = 0.0
class-attribute
instance-attribute
openness = 0.0
class-attribute
instance-attribute
shape = MouthShape.NEUTRAL
class-attribute
instance-attribute
width = 0.5
class-attribute
instance-attribute
__init__(shape=MouthShape.NEUTRAL, openness=0.0, width=0.5, asymmetry=0.0)
MouthShape
Bases: str, Enum
Source code in src/robot/face/components.py
CLOSED = 'closed'
class-attribute
instance-attribute
FROWN = 'frown'
class-attribute
instance-attribute
GRIN = 'grin'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
SMILE = 'smile'
class-attribute
instance-attribute
SMILE_OPEN = 'smile_open'
class-attribute
instance-attribute
TONGUE = 'tongue'
class-attribute
instance-attribute
WIDE_OPEN = 'wide_open'
class-attribute
instance-attribute
SpeakingAnimation
dataclass
Produces a sequence of mouth shapes for lip-synced speech.
The animation converts text into a sequence of :class:VisemeFrame
objects, one per phoneme, with timing that approximates natural
speech cadence.
Usage::
anim = SpeakingAnimation(text="Hello there!")
while anim.has_frames:
frame = anim.step(dt=0.033)
face_model = face_model.with_mouth(
Mouth(shape=MouthShape.NEUTRAL, openness=frame.openness, width=frame.width)
)
Source code in src/robot/face/animations/speaking.py
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 | |
default_phoneme_duration = 0.08
class-attribute
instance-attribute
has_frames
property
Whether there are still frames to animate.
pause_duration = 0.15
class-attribute
instance-attribute
sentence_pause_duration = 0.25
class-attribute
instance-attribute
speed = 1.0
class-attribute
instance-attribute
text = ''
class-attribute
instance-attribute
total_duration
property
Total animation duration in seconds.
__init__(text='', default_phoneme_duration=0.08, pause_duration=0.15, sentence_pause_duration=0.25, speed=1.0)
__post_init__()
from_visemes(visemes, speed=1.0)
classmethod
Create an animation from an explicit viseme sequence.
Each tuple is (viseme, duration_s).
Source code in src/robot/face/animations/speaking.py
reset()
step(dt)
Advance the animation by dt seconds.
Returns the current :class:VisemeFrame. If the animation has
finished, returns :class:Viseme.IDLE frame.
Source code in src/robot/face/animations/speaking.py
Theme
Bases: Protocol
A visual style applied to a :class:FaceModel.
Source code in src/robot/face/themes/base.py
name
property
Human-readable theme name.
palette
property
The colour palette the theme uses.
ThinkingDotsAnimation
dataclass
Produces a sequence of gaze positions for the "thinking dots" effect.
The animation advances through keyframes each time :meth:step
is called, returning the current gaze position. The caller is
responsible for applying the gaze to the face model and publishing
any events.
Source code in src/robot/face/animations/thinking_dots.py
current_position
property
Return the current gaze (x, y) without advancing.
pattern = _THINKING_PATTERN
class-attribute
instance-attribute
__init__(pattern=_THINKING_PATTERN, _index=0, _elapsed=0.0)
reset()
step(dt)
Advance the animation by dt seconds and return the current gaze.
Parameters
dt: Time elapsed since the last call, in seconds.
Source code in src/robot/face/animations/thinking_dots.py
Timeline
Builder-style helper for declaring animations.
Source code in src/robot/animation/timelines.py
__init__(animations=None)
build()
parallel(*children)
queue(*children)
run()
async
tween(from_value, to_value, duration_s, easing=linear, on_update=None)
Source code in src/robot/animation/timelines.py
WakeAnimation
dataclass
Produces a sequence of :class:WakeFrame objects for the wake animation.
Usage::
anim = WakeAnimation()
while not anim.done:
frame = anim.step(dt=0.033)
# Apply frame to face model...
Source code in src/robot/face/animations/wake.py
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 | |
done
property
Whether the animation has completed.
__init__(_phase=WakePhase.EYES_OPEN, _elapsed=0.0)
reset()
step(dt)
Advance the animation by dt seconds and return the current frame.
Source code in src/robot/face/animations/wake.py
WakeFrame
dataclass
A single frame of the wake animation.
Provides target values for the face model at a given animation time. The caller interpolates between the current state and this target.
Source code in src/robot/face/animations/wake.py
eye_openness = 1.0
class-attribute
instance-attribute
eyebrow_raise = 0.0
class-attribute
instance-attribute
eyebrow_shape = EyebrowShape.NEUTRAL
class-attribute
instance-attribute
eyelid_top = 0.0
class-attribute
instance-attribute
gaze
instance-attribute
mouth_openness = 0.0
class-attribute
instance-attribute
mouth_shape = MouthShape.NEUTRAL
class-attribute
instance-attribute
mouth_width = 0.5
class-attribute
instance-attribute
phase = WakePhase.IDLE
class-attribute
instance-attribute
__init__(gaze, eye_openness=1.0, eyelid_top=0.0, mouth_shape=MouthShape.NEUTRAL, mouth_openness=0.0, mouth_width=0.5, eyebrow_shape=EyebrowShape.NEUTRAL, eyebrow_raise=0.0, phase=WakePhase.IDLE)
_ease_in_out(t)
_ease_out(t)
_interp(a, b, t)
_interp_cheeks(a, b, t)
_interp_eye(a, b, t)
Source code in src/robot/face/animator.py
_interp_eyebrow(a, b, t)
Source code in src/robot/face/animator.py
_interp_eyelids(a, b, t)
_interp_mouth(a, b, t)
Source code in src/robot/face/animator.py
get_logger(name)
Return a bound logger for the given module name.
The name is prefixed with robot. if it doesn't already start with it,
so log records naturally form a hierarchy. The name is also bound into
the event context as logger_name so :func:_capture_to_ring_buffer
can record it; :func:_strip_logger_name removes it before rendering so
the stdout JSON output stays unchanged.
Source code in src/robot/logging.py
Emotions
robot.face.emotions
The :class:EmotionEngine - produces a :class:FaceModel from an emotion.
The engine is a pure function EmotionName -> (FaceModel, BodyLanguageHint).
It never touches rendering, servos, displays, or animation state. This
is the single source of truth for "what does emotion X look like?".
Emotions are built from a small set of reusable face component presets (eye defaults, mouth shape, eyebrow shape, …) so that adding a new emotion is a one-line change.
EMOTION_DEFS = {'neutral': _EmotionDef(eyes=NEUTRAL_EYES, eyelids=NEUTRAL_EYELIDS, eyebrows=NEUTRAL_EYEBROWS, mouth=NEUTRAL_MOUTH, cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=NEUTRAL_HINT), 'happy': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.05), openness=0.85), Eye(gaze=Gaze(0.0, 0.05), openness=0.85)), eyelids=Eyelids(top=0.05, bottom=0.25), eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.3), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.3)), mouth=Mouth(shape=MouthShape.SMILE, openness=0.3, width=0.6), cheeks=Cheeks(state=CheekState.SOFT, intensity=0.6), overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.CURIOUS, arm_pose=ArmPose.OPEN, intensity=0.7)), 'curious': _EmotionDef(eyes=(Eye(gaze=Gaze(0.2, 0.1), openness=1.0, highlight=Gaze(0.4, 0.4)), Eye(gaze=Gaze(0.2, 0.1), openness=1.0, highlight=Gaze(0.4, 0.4))), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.6), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.6)), mouth=Mouth(shape=MouthShape.OPEN, openness=0.2, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=Overlay(kind=OverlayKind.QUESTION, position=Point(0.7, -0.5)), body_hint=BodyLanguageHint(head_tilt=HeadTilt.CURIOUS, arm_pose=ArmPose.POINT, intensity=0.6)), 'thinking': _EmotionDef(eyes=(Eye(gaze=Gaze(0.2, 0.3), openness=0.85), Eye(gaze=Gaze(0.2, 0.3), openness=0.85)), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.WORRIED, raise_amount=0.2, angle=0.2), Eyebrow(shape=EyebrowShape.WORRIED, raise_amount=0.2, angle=-0.2)), mouth=Mouth(shape=MouthShape.NEUTRAL, openness=0.0, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.THINKING, arm_pose=ArmPose.RELAXED, intensity=0.5)), 'sleepy': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.0), openness=0.15), Eye(gaze=Gaze(0.0, 0.0), openness=0.15)), eyelids=Eyelids(top=0.65, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.SLEEPY), Eyebrow(shape=EyebrowShape.SLEEPY)), mouth=Mouth(shape=MouthShape.OPEN, openness=0.1, width=0.4), cheeks=NEUTRAL_CHEEKS, overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.SLEEPY, arm_pose=ArmPose.DOWN, intensity=0.7)), 'embarrassed': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.3), openness=0.7, highlight=Gaze(-0.3, -0.3)), Eye(gaze=Gaze(0.0, -0.3), openness=0.7, highlight=Gaze(-0.3, -0.3))), eyelids=Eyelids(top=0.1, bottom=0.05), eyebrows=(Eyebrow(shape=EyebrowShape.WORRIED, angle=0.3), Eyebrow(shape=EyebrowShape.WORRIED, angle=-0.3)), mouth=Mouth(shape=MouthShape.SMILE, openness=0.2, width=0.5, asymmetry=0.3), cheeks=Cheeks(state=CheekState.BRIGHT, intensity=0.9), overlay=NEUTRAL_OVERLAY, body_hint=BodyLanguageHint(head_tilt=HeadTilt.SAD, arm_pose=ArmPose.SHRUG, intensity=0.5)), 'excited': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.1), openness=1.2, highlight=Gaze(0.0, 0.0)), Eye(gaze=Gaze(0.0, -0.1), openness=1.2, highlight=Gaze(0.0, 0.0))), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.8), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=0.8)), mouth=Mouth(shape=MouthShape.SMILE_OPEN, openness=0.6, width=0.7), cheeks=Cheeks(state=CheekState.SOFT, intensity=0.4), overlay=Overlay(kind=OverlayKind.SPARKLE, position=Point(-0.5, -0.4), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.EXCITED, arm_pose=ArmPose.WIDE, intensity=1.0, gestures=('bounce',))), 'sad': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.3), openness=0.65, pupil_dilation=0.7), Eye(gaze=Gaze(0.0, -0.3), openness=0.65, pupil_dilation=0.7)), eyelids=Eyelids(top=0.35, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.SAD, angle=0.4), Eyebrow(shape=EyebrowShape.SAD, angle=-0.4)), mouth=Mouth(shape=MouthShape.FROWN, openness=0.0, width=0.5), cheeks=Cheeks(state=CheekState.COLD, intensity=0.4), overlay=Overlay(kind=OverlayKind.TEAR, position=Point(-0.3, 0.1), size=0.2), body_hint=BodyLanguageHint(head_tilt=HeadTilt.SAD, arm_pose=ArmPose.DOWN, intensity=0.7)), 'surprised': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, 0.0), openness=1.0, pupil_dilation=0.2), Eye(gaze=Gaze(0.0, 0.0), openness=1.0, pupil_dilation=0.2)), eyelids=NEUTRAL_EYELIDS, eyebrows=(Eyebrow(shape=EyebrowShape.RAISED, raise_amount=1.0), Eyebrow(shape=EyebrowShape.RAISED, raise_amount=1.0)), mouth=Mouth(shape=MouthShape.WIDE_OPEN, openness=0.9, width=0.6), cheeks=NEUTRAL_CHEEKS, overlay=Overlay(kind=OverlayKind.EXCLAIM, position=Point(0.6, -0.5), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.EXCITED, arm_pose=ArmPose.SHRUG, intensity=0.8, gestures=('bounce',))), 'angry': _EmotionDef(eyes=(Eye(gaze=Gaze(0.0, -0.1), openness=0.7, pupil_dilation=0.2), Eye(gaze=Gaze(0.0, -0.1), openness=0.7, pupil_dilation=0.2)), eyelids=Eyelids(top=0.3, bottom=0.0), eyebrows=(Eyebrow(shape=EyebrowShape.ANGRY, angle=0.7), Eyebrow(shape=EyebrowShape.ANGRY, angle=-0.7)), mouth=Mouth(shape=MouthShape.FROWN, openness=0.2, width=0.5), cheeks=Cheeks(state=CheekState.BRIGHT, intensity=0.5), overlay=Overlay(kind=OverlayKind.ANGER, position=Point(0.5, -0.5), size=0.3), body_hint=BodyLanguageHint(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.SHRUG, intensity=0.7))}
module-attribute
NEUTRAL_CHEEKS = Cheeks(state=CheekState.NONE, intensity=0.0)
module-attribute
NEUTRAL_EYEBROWS = (Eyebrow(shape=EyebrowShape.NEUTRAL), Eyebrow(shape=EyebrowShape.NEUTRAL))
module-attribute
NEUTRAL_EYELIDS = Eyelids(top=0.0, bottom=0.0)
module-attribute
NEUTRAL_EYES = (Eye(gaze=Gaze(0.0, 0.0)), Eye(gaze=Gaze(0.0, 0.0)))
module-attribute
NEUTRAL_HINT = BodyLanguageHint(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.RELAXED, intensity=0.5)
module-attribute
NEUTRAL_MOUTH = Mouth(shape=MouthShape.NEUTRAL, openness=0.0, width=0.5, asymmetry=0.0)
module-attribute
NEUTRAL_OVERLAY = Overlay(kind=OverlayKind.NONE)
module-attribute
__all__ = ['EMOTION_DEFS', 'EmotionEngine']
module-attribute
ArmPose
Bases: Enum
Discrete arm-pose hints.
Source code in src/robot/face/model.py
DOWN = 'down'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
POINT = 'point'
class-attribute
instance-attribute
RELAXED = 'relaxed'
class-attribute
instance-attribute
SHRUG = 'shrug'
class-attribute
instance-attribute
WAVING = 'waving'
class-attribute
instance-attribute
WIDE = 'wide'
class-attribute
instance-attribute
BodyLanguageHint
dataclass
A high-level body-language request produced by the EmotionEngine.
Source code in src/robot/face/model.py
arm_pose = ArmPose.RELAXED
class-attribute
instance-attribute
gestures = ()
class-attribute
instance-attribute
head_tilt = HeadTilt.NEUTRAL
class-attribute
instance-attribute
intensity = 1.0
class-attribute
instance-attribute
__init__(head_tilt=HeadTilt.NEUTRAL, arm_pose=ArmPose.RELAXED, intensity=1.0, gestures=())
CheekState
Bases: str, Enum
Source code in src/robot/face/components.py
BRIGHT = 'bright'
class-attribute
instance-attribute
COLD = 'cold'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
SOFT = 'soft'
class-attribute
instance-attribute
Cheeks
dataclass
Cheek rendering - base + accent colour, intensity.
Source code in src/robot/face/components.py
intensity = 0.0
class-attribute
instance-attribute
state = CheekState.NONE
class-attribute
instance-attribute
__init__(state=CheekState.NONE, intensity=0.0)
EmotionEngine
Produces :class:FaceModel + :class:BodyLanguageHint from an emotion.
Source code in src/robot/face/emotions.py
__init__(palette=None, width=240, height=240)
available()
build(name)
Build the :class:FaceModel for name with default geometry.
Source code in src/robot/face/emotions.py
get(name)
register(name, definition)
Eye
dataclass
A single eye. The face has two of them.
Source code in src/robot/face/components.py
asymmetric = False
class-attribute
instance-attribute
gaze = field(default_factory=Gaze)
class-attribute
instance-attribute
highlight = field(default_factory=lambda: Gaze(0.3, 0.3))
class-attribute
instance-attribute
openness = 1.0
class-attribute
instance-attribute
pupil_dilation = 0.5
class-attribute
instance-attribute
__init__(gaze=Gaze(), openness=1.0, pupil_dilation=0.5, highlight=(lambda: Gaze(0.3, 0.3))(), asymmetric=False)
Eyebrow
dataclass
A single eyebrow.
Source code in src/robot/face/components.py
angle = 0.0
class-attribute
instance-attribute
raise_amount = 0.0
class-attribute
instance-attribute
shape = EyebrowShape.NEUTRAL
class-attribute
instance-attribute
__init__(shape=EyebrowShape.NEUTRAL, raise_amount=0.0, angle=0.0)
EyebrowShape
Bases: str, Enum
Source code in src/robot/face/components.py
ANGRY = 'angry'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
RAISED = 'raised'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
WORRIED = 'worried'
class-attribute
instance-attribute
Eyelids
dataclass
Vertical eyelid positions, 0.0 = retracted, 1.0 = fully closed.
Source code in src/robot/face/components.py
bottom = 0.0
class-attribute
instance-attribute
top = 0.0
class-attribute
instance-attribute
__init__(top=0.0, bottom=0.0)
FaceModel
dataclass
The full face, captured at one instant.
All values are immutable. Use the helper methods to build new models with a single field changed (this is what the renderer animates).
Source code in src/robot/face/model.py
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 | |
accessory = field(default_factory=Accessory)
class-attribute
instance-attribute
body_hint = field(default_factory=BodyLanguageHint)
class-attribute
instance-attribute
bounce = 0.0
class-attribute
instance-attribute
cheeks = field(default_factory=Cheeks)
class-attribute
instance-attribute
eyelids = field(default_factory=Eyelids)
class-attribute
instance-attribute
height = 240
class-attribute
instance-attribute
left_eye = field(default_factory=Eye)
class-attribute
instance-attribute
left_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
mouth = field(default_factory=Mouth)
class-attribute
instance-attribute
overlay = field(default_factory=Overlay)
class-attribute
instance-attribute
palette = field(default_factory=FacePalette)
class-attribute
instance-attribute
right_eye = field(default_factory=Eye)
class-attribute
instance-attribute
right_eyebrow = field(default_factory=Eyebrow)
class-attribute
instance-attribute
squash = 1.0
class-attribute
instance-attribute
width = 240
class-attribute
instance-attribute
__init__(width=240, height=240, left_eye=Eye(), right_eye=Eye(), eyelids=Eyelids(), left_eyebrow=Eyebrow(), right_eyebrow=Eyebrow(), mouth=Mouth(), cheeks=Cheeks(), overlay=Overlay(), accessory=Accessory(), palette=FacePalette(), bounce=0.0, squash=1.0, body_hint=BodyLanguageHint())
with_accessory(accessory)
with_body_hint(body_hint)
with_cheeks(cheeks)
with_eyebrows(left=None, right=None)
with_eyelids(eyelids)
with_eyes(left_eye=None, right_eye=None)
with_mouth(mouth)
with_overlay(overlay)
with_palette(palette)
with_transform(bounce=None, squash=None)
FacePalette
dataclass
All colours the renderer can use. Themes override these.
mode selects a renderer rendering style. The default "face"
draws the full eye stack (sclera + iris + pupil + highlight +
eyelids + eyebrows + mouth). The "vector" mode draws two
filled rounded-squares for eyes and a thin horizontal bar for
the mouth - the Anki Vector 2.0 minimalist look.
Source code in src/robot/face/components.py
background = (10, 10, 20)
class-attribute
instance-attribute
blush = (255, 90, 90)
class-attribute
instance-attribute
cheek = (255, 130, 130)
class-attribute
instance-attribute
eyebrow = (40, 30, 30)
class-attribute
instance-attribute
eyelid = (20, 20, 30)
class-attribute
instance-attribute
highlight = (255, 255, 255)
class-attribute
instance-attribute
iris = (40, 110, 200)
class-attribute
instance-attribute
mode = PALETTE_MODE_FACE
class-attribute
instance-attribute
mouth = (180, 60, 80)
class-attribute
instance-attribute
outline = (10, 10, 10)
class-attribute
instance-attribute
pupil = (10, 10, 20)
class-attribute
instance-attribute
sclera = (245, 245, 235)
class-attribute
instance-attribute
__init__(background=(10, 10, 20), sclera=(245, 245, 235), iris=(40, 110, 200), pupil=(10, 10, 20), eyelid=(20, 20, 30), eyebrow=(40, 30, 30), mouth=(180, 60, 80), cheek=(255, 130, 130), blush=(255, 90, 90), outline=(10, 10, 10), highlight=(255, 255, 255), mode=PALETTE_MODE_FACE)
Gaze
dataclass
2D gaze target normalised in [-1, 1].
Source code in src/robot/face/components.py
HeadTilt
Bases: Enum
Discrete head-tilt hints the body-language engine understands.
Source code in src/robot/face/model.py
CURIOUS = 'curious'
class-attribute
instance-attribute
EXCITED = 'excited'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
Mouth
dataclass
The mouth, parameterised.
Source code in src/robot/face/components.py
asymmetry = 0.0
class-attribute
instance-attribute
openness = 0.0
class-attribute
instance-attribute
shape = MouthShape.NEUTRAL
class-attribute
instance-attribute
width = 0.5
class-attribute
instance-attribute
__init__(shape=MouthShape.NEUTRAL, openness=0.0, width=0.5, asymmetry=0.0)
MouthShape
Bases: str, Enum
Source code in src/robot/face/components.py
CLOSED = 'closed'
class-attribute
instance-attribute
FROWN = 'frown'
class-attribute
instance-attribute
GRIN = 'grin'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
OPEN = 'open'
class-attribute
instance-attribute
SMILE = 'smile'
class-attribute
instance-attribute
SMILE_OPEN = 'smile_open'
class-attribute
instance-attribute
TONGUE = 'tongue'
class-attribute
instance-attribute
WIDE_OPEN = 'wide_open'
class-attribute
instance-attribute
Overlay
dataclass
A floating symbol rendered on top of the face.
Source code in src/robot/face/components.py
color = (255, 255, 255)
class-attribute
instance-attribute
kind = OverlayKind.NONE
class-attribute
instance-attribute
position = field(default_factory=lambda: Point(0.0, -0.5))
class-attribute
instance-attribute
rotation = 0.0
class-attribute
instance-attribute
size = 0.3
class-attribute
instance-attribute
__init__(kind=OverlayKind.NONE, position=(lambda: Point(0.0, -0.5))(), size=0.3, rotation=0.0, color=(255, 255, 255))
OverlayKind
Bases: str, Enum
Source code in src/robot/face/components.py
ANGER = 'anger'
class-attribute
instance-attribute
EXCLAIM = 'exclaim'
class-attribute
instance-attribute
HEART = 'heart'
class-attribute
instance-attribute
MUSIC = 'music'
class-attribute
instance-attribute
NONE = 'none'
class-attribute
instance-attribute
QUESTION = 'question'
class-attribute
instance-attribute
SPARKLE = 'sparkle'
class-attribute
instance-attribute
STAR = 'star'
class-attribute
instance-attribute
SWEAT = 'sweat'
class-attribute
instance-attribute
TEAR = 'tear'
class-attribute
instance-attribute
Point
dataclass
_EmotionDef
dataclass
A complete emotional expression: face presets + body hint.