skills/personal/picar-x-behavior/SKILL.md
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. Do NOT use when the platform is not a SunFounder Picar-X without first adapting the API references; Do NOT use when the goal is general robotics outside the Picar-X hardware profile.
npx skillsauth add michaelalber/ai-toolkit picar-x-behaviorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"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>
step: [DEFINE | IMPLEMENT | TEST_STATIC | TEST_DYNAMIC | COMPOSE | DEPLOY]
behavior_name: [e.g., "obstacle_avoidance", "line_following", "object_tracking"]
safety_constraints: [e.g., "max_speed=30, emergency_stop=enabled"]
control_loop_hz: [number, e.g., 20]
last_action: [what was just done]
next_action: [what should happen next]
blockers: [any issues]
</picar-behavior-state>
Example:
<picar-behavior-state>
step: TEST_STATIC
behavior_name: obstacle_avoidance
safety_constraints: max_speed=30, emergency_stop=enabled, min_distance=25cm
control_loop_hz: 20
last_action: Implemented ObstacleAvoidance.update() with ultrasonic threshold logic
next_action: Write pytest tests with mocked ultrasonic sensor
blockers: none
</picar-behavior-state>
## Behavior: [Name]
**Goal**: [One sentence description]
**Inputs**:
| Sensor | Read Method | Expected Range |
|--------|------------|----------------|
| [sensor] | [method] | [range] |
**Outputs**:
| Actuator | Write Method | Bounded Range |
|----------|-------------|---------------|
| [actuator] | [method] | [range] |
**Safety Constraints**:
- Max speed: [value]
- Servo bounds: [min, max]
- Timeout: [seconds]
- Emergency stop: [trigger condition]
**Control Loop**:
1. Read [sensors]
2. Compute [decision]
3. Write [actuators]
4. Repeat at [Hz]
<picar-behavior-state>
step: DEFINE
behavior_name: [name]
safety_constraints: [constraints]
control_loop_hz: [hz]
last_action: Behavior defined
next_action: Implement behavior class
blockers: none
</picar-behavior-state>
## Test Results: [Behavior Name]
**Test Type**: [Static | Dynamic]
**Date**: [date]
### Static Tests
| Test | Description | Result |
|------|-------------|--------|
| [test_name] | [what it checks] | PASS/FAIL |
### Dynamic Tests (if applicable)
| Test | Environment | Speed | Duration | Result | Notes |
|------|-------------|-------|----------|--------|-------|
| [test_name] | [description] | [value] | [seconds] | PASS/FAIL | [observations] |
**Safety Verification**:
- [ ] Emergency stop triggered correctly
- [ ] Speed limits respected
- [ ] Servo bounds enforced
- [ ] Timeout watchdog fired on stall
<picar-behavior-state>
step: [TEST_STATIC | TEST_DYNAMIC]
behavior_name: [name]
safety_constraints: [constraints]
control_loop_hz: [hz]
last_action: [tests completed]
next_action: [proceed to next step or fix failures]
blockers: [any test failures]
</picar-behavior-state>
Before writing ANY behavior logic:
EmergencyStop behavior exists and is testedNo robot behavior is safe without a verified emergency stop.
Before sending ANY command to real motors or servos:
If static tests do not cover the command, DO NOT run it on hardware.
When moving from static to dynamic testing:
Untested speed levels are forbidden in production.
Before using ANY sensor reading to make a control decision:
Garbage-in-garbage-out kills robots. Validate first.
| Anti-Pattern | Why It's Dangerous | Correct Approach | |--------------|--------------------|------------------| | Monolithic control loop | Untestable, fragile, cannot compose | Break into isolated behaviors with single responsibility | | Set-and-forget motor commands | Robot runs away if control loop crashes | Use watchdog timeouts; motors stop if not refreshed | | Raw sensor values in decisions | Noise causes erratic behavior | Apply filtering (moving average, median) before thresholds | | Testing only on hardware | Slow iteration, risk of damage | Static tests with mocks first; hardware tests second | | Shared mutable state between behaviors | Race conditions, unpredictable priority | Each behavior gets immutable sensor snapshot, produces commands | | No speed ramp on startup | Sudden motion, wheel slip, mechanical stress | Ramp speed gradually over 0.5-1 second | | Hardcoded calibration values | Different robots have different offsets | Load calibration from config file; provide calibration routine | | Camera processing in control loop | Blocks the sense-act loop, drops control Hz | Run vision in separate thread/process; read latest result |
Problem: Motor current draw spikes or robot is not moving despite speed > 0
Actions:
1. Immediately set speed to 0
2. Wait 1 second
3. Check ultrasonic for obstacle at contact distance (<5cm)
4. If obstacle: back up slowly, then re-plan
5. If no obstacle: possible mechanical jam -- stop and alert operator
6. Log the stall event with sensor snapshot
Problem: Ultrasonic returns -1 or out-of-range, grayscale returns all zeros
Actions:
1. Mark sensor as unreliable in behavior state
2. Reduce speed to minimum (10)
3. If ultrasonic failed: stop forward motion, rely on other sensors or stop
4. If grayscale failed: abandon line following, switch to obstacle avoidance or stop
5. Log the failure with timestamp and last known good reading
6. Do NOT continue at full speed with degraded sensing
Problem: Two behaviors issue contradictory commands (e.g., turn left vs turn right)
Actions:
1. Priority system resolves: highest priority behavior wins
2. If same priority: stop and log the conflict
3. Review behavior conditions -- they should be mutually exclusive at same priority
4. Add guard conditions to prevent simultaneous activation
5. Re-test the composed system with the conflict scenario
Problem: Robot moving unexpectedly or not responding to stop commands
Actions:
1. Physical intervention: pick up the robot or block its path
2. Kill the Python process (Ctrl+C or kill signal)
3. If software stop fails: disconnect battery
4. Post-mortem: check watchdog configuration, verify emergency stop wiring
5. Add the failure scenario to test suite before re-running
6. Never re-run without understanding why the runaway occurred
Problem: Lost connection to Raspberry Pi during dynamic test
Actions:
1. Watchdog timeout MUST trigger automatic stop (this is why watchdogs exist)
2. If watchdog was not configured: physically stop the robot
3. Reconnect and check logs for what happened after disconnect
4. Verify watchdog timeout is set to <= 2 seconds for all future runs
5. Consider running critical behaviors locally on the Pi, not over network
sensor-integration -- Use for building and calibrating sensor pipelines (ultrasonic filtering, grayscale normalization, camera capture). Feed processed sensor data into Picar-X behaviors.edge-cv-pipeline -- Use for building computer vision pipelines (object detection, lane detection, sign recognition) that run on the Raspberry Pi. Vision behaviors consume CV pipeline outputs.tdd / tdd-agent -- Apply TDD discipline when implementing behavior classes. Write failing tests for sensor-to-actuator logic before implementing the behavior. Especially valuable for static tests with mocked hardware.jetson-deploy -- If offloading heavy CV inference to a Jetson device, use this skill for deployment. The Picar-X communicates with the Jetson over the network for inference results.development
Interviews the user relentlessly about a plan, decision, or idea — one question at a time, each with a recommended answer. Shared engine behind "grill-me" and "grill-with-docs". Use on any "grill" trigger phrase or to stress-test thinking. Do NOT use to build the plan; it ends at shared understanding, not implementation.
testing
Runs a relentless interview to sharpen a plan or design, capturing the decisions as ADRs and a glossary along the way. Use when the user wants to be grilled AND wants the session to leave durable domain documentation behind. Do NOT use for a throwaway stress-test with no artifacts; use grill-me instead.
tools
OWASP-based security review of Vue/TypeScript front-ends. Detects framework (Vite/Vue CLI/Nuxt), entry points, and data flows; scans the OWASP Top 10 (2025) mapped to Vue client-side risks (raw-HTML XSS via v-html, URL/protocol injection, bundled secrets, insecure token storage, dependency CVEs, missing CSP, open redirects, router guard bypass); emits an exec summary plus graded findings. Use to audit Vue for vulnerabilities. Not for architecture grading (vue-architecture-checklist).
tools
Analyzes legacy Vue codebases and produces actionable modernization plans. Primary migration paths include Options API to Composition API, Vue 2 to Vue 3, Vue CLI to Vite, JavaScript to TypeScript, Vue Test Utils/Karma/Mocha to Vitest + Vue Testing Library, legacy Vuex to Pinia, and removed-in-Vue-3 pattern cleanup (filters, event bus, `$listeners`). Does NOT perform the migration — assesses, quantifies risk, and plans.