Build composable robot behaviors for SunFounder Picar-X. Use when creating autonomous driving behaviors, sensor-reactive patterns, and behavior trees for the Picar-X robot platform.
"The world is its own best model. The trick is to sense it appropriately and often enough." -- Rodney Brooks, Intelligence Without Representation
This skill builds composable, safe robot behaviors for the SunFounder Picar-X platform. Behaviors are small, testable units of reactive control that combine into complex autonomous systems through well-defined composition patterns.
Non-Negotiable Constraints:
| Principle | Description | Priority |
|---|---|---|
| Safety Constraints | Hard limits on speed, servo range, and runtime; emergency stop always accessible | Critical |
| Behavior Isolation | Each behavior reads sensors and produces actuator commands independently; no hidden shared state | Critical |
| Composability | Behaviors combine through priority, sequence, and parallel patterns with predictable results | Critical |
| Reactive Control | Sense-act loops run at fixed frequency; behaviors respond to current sensor state, not stale data | High |
| Graceful Degradation | If a sensor fails, the robot reduces capability rather than crashing or acting on garbage data | High |
| Deterministic Startup | Robot always starts in a known safe state: speed zero, servos centered, sensors polled | High |
| Timeout Watchdogs | Every motor command expires after a bounded interval; no "set and forget" drive commands | High |
| Testability | Every behavior can be tested with mocked hardware; real-hardware tests are optional second pass | High |
| Observability | Behaviors log decisions, sensor readings, and actuator commands for post-run analysis | Medium |
| Resource Awareness | Respect Raspberry Pi CPU/memory limits; camera processing and control loops share resources | Medium |
┌──────────────────────────────────────────────────────────────────┐
│ │
│ ┌────────┐ ┌───────────┐ ┌─────────────┐ ┌───────────┐ │
│ ─>│ DEFINE │──>│ IMPLEMENT │──>│ TEST_STATIC │──>│TEST_DYNAMIC│ │
│ └────────┘ └───────────┘ └─────────────┘ └───────────┘ │
│ │ │
│ ┌─────────┐ ┌────────┐ │ │
│ │ DEPLOY │<─────│COMPOSE │<────────────────────┘ │
│ └─────────┘ └────────┘ │
│ │ ▲ │
│ └────────────────┘ (add more behaviors) │
│ │
└──────────────────────────────────────────────────────────────────┘
Before ANY dynamic test or deployment, verify:
┌─────────────────────────────────────────────────┐
│ Pre-Flight Hardware Safety Check │
├─────────────────────────────────────────────────┤
│ [ ] Battery charged and securely connected │
│ [ ] Wheels off ground OR in bounded test area │
│ [ ] Emergency stop mechanism verified working │
│ [ ] Servo range calibration confirmed │
│ [ ] Ultrasonic sensor returning valid readings │
│ [ ] Camera stream active (if vision behavior) │
│ [ ] Max speed set to TEST level (<=30) │
│ [ ] Watchdog timeout configured (<2 seconds) │
│ [ ] Clear path / no obstacles in test zone │
│ [ ] Operator within physical reach of robot │
└─────────────────────────────────────────────────┘
Behavior base classsetup(), update(), and teardown() methodsupdate()teardown() always stops motors and centers servosupdate() produces correct actuator commands for given sensor inputsteardown() issues stop commandspytest -- all tests must pass before proceedingMaintain state across conversation turns using this block:
<picar-behavior-state>