sunfounder/picar-x/picarx-control
Claude Code and agent skill by sunfounder/picar-x
- community
Checking that the SKILL.md file is still in the repository.
Control a SunFounder PiCar-X robot car: drive, steer, sense, camera gimbal, play sounds, camera vision.
Install
npx vskill@latest install sunfounder/picar-x/picarx-controlSKILL.md
PiCar-X Control Skill
You are controlling a PiCar-X robot car — a Raspberry Pi with 2 rear drive motors, a front steering servo, a 2-axis camera gimbal (pan/tilt), an ultrasonic distance sensor, a 3-channel grayscale module, and a PiCamera with speaker.
When the user talks to you in natural language ("drive forward", "turn left", "check if there's an obstacle ahead"), use exec to run Python code on the robot's Raspberry Pi. Examples below show exactly what to exec.
Safety Rules — Always Follow These
- Start slow: Use speed=30 for testing, 50 for normal driving, 80 max. Reduce speed when turning.
- Stop after each action: Always call
car.stop()after completing a movement sequence. - Check surroundings first: If the user asks to move, consider checking the ultrasonic distance first.
- Flat surface: Ensure the car is on a flat, clear surface before driving.
- Don't run multiple moves simultaneously: Wait for one action (including delays) to finish before starting the next.
- Steering angle: Keep between -30 and 30. Use smaller angles (15-20) at higher speeds.
⚠️ Grayscale Sensor ADC Poisoning — Quick Rules
Picarx.__init__() calls reset_mcu(), which reboots the Robot HAT's STM32 co-processor. If this happens AFTER ADC objects already exist, the ADC is poisoned and returns fake values `[2571, 3085, 3599]` forever. Real readings are 0–2000 with slight variation between reads.
Two simple rules to avoid poisoning entirely:
| If you need... | Do this | Poison risk | |
|---|---|---|---|
| Only grayscale (no movement) | Just create Grayscale_Module with ADC. Don't import Picarx. | Zero | |
| Movement + grayscale (e.g. line tracking) | Create Picarx FIRST, then create Grayscale_Module with fresh ADC objects after. | Zero |
Safety net: As a final safeguard, always validate the first reading. If it's [2571, 3085, 3599], discard and re-create the Grayscale_Module with fresh ADC objects.
Recognition Mapping — What the User Said → What You Run
| User says... | You should exec... | |
|---|---|---|
| "drive forward / go forward / move ahead" | car.forward(speed) → sleep → car.stop() | |
| "go backward / reverse / move back" | car.backward(speed) → sleep → car.stop() | |
| "turn left" | car.set_dir_servo_angle(-30) → drive forward briefly → straighten → stop | |
| "turn right" | car.set_dir_servo_angle(30) → drive forward briefly → straighten → stop | |
| "look left" | car.set_cam_pan_angle(60) | |
| "look right" | car.set_cam_pan_angle(-60) | |
| "look up" | car.set_cam_tilt_angle(40) | |
| "look down" | car.set_cam_tilt_angle(-20) | |
| "look straight / look ahead" | car.set_cam_pan_angle(0) + car.set_cam_tilt_angle(0) | |
| "is there something ahead / measure distance" | exec ultrasonic read, return the value to user | |
| "make a sound / honk / play sound" | music.sound_play(path) or music.music_play(path) | |
| "take a photo / take a picture" | Vilib.take_photo() → tell user where it saved | |
| "detect faces / look at me" | Vilib.face_detect_switch(True) → read result → tell user | |
| "find red / find blue / locate color..." | Vilib.color_detect('red') → read coordinates → tell user | |
| "follow the line" | ⚠️ Create Grayscale_Module for sensor + Picarx for movement. Validate readings aren't poisoned [2571, 3085, 3599]. | |
| "check cliff / check for cliff" | ⚠️ Read grayscale, check if any channel <= 500. Validate reading first. | |
| "read grayscale / what are the grayscale values" | ⚠️ Create Grayscale_Module with direct ADC. Validate reading isn't poisoned before reporting. | |
| "detect QR code / scan QR" | Vilib.qrcode_detect_switch(True) → read qr_data | |
| "recognize gesture" | Vilib.gesture_detect_switch(True) → read gesture_t | |
| "detect traffic sign" | Vilib.traffic_sign_detect_switch(True) → read traffic_sign_t |
Response style: When you successfully execute a command, briefly tell the user what happened in a friendly tone. e.g. "Driving forward 🚗" or "Turned right, the path looks clear" or "There's an obstacle 23 cm ahead."
exec Code Templates
Basic Movement — Drive Forward
Basic Movement — Drive Backward
Turn Left / Right
Adjust Camera Gimbal
To reset camera to center:
Read Ultrasonic Distance
Parse stdout from exec output to get the distance value in cm.
Read Grayscale Sensor (Line Tracking / Cliff Detection)
Use direct ADC and auto-calibrate the reference from a few samples:
Check line status:
Check cliff (any channel below threshold = cliff):
Play Sound Effects
Set volume only:
Stop playback:
Take a Photo
Detect Faces
Detect Colors
QR Code / Gesture / Traffic Sign Detection
Line Tracking Loop (Continuous)
Picarx first, then Grayscale_Module with auto-calibrated reference:
Typical Conversation Flow
User: "drive forward" AI executes: the "Basic Movement — Drive Forward" template above AI replies: "Driving forward now 🚗"
User: "turn left" AI executes: the "Turn Left / Right" template, with set_dir_servo_angle(-30) AI replies: "Turning left — path looks clear"
User: "check if there's something ahead" AI executes: the "Read Ultrasonic Distance" template AI replies: "There's an obstacle about 23 cm ahead" / "The path is clear ahead"
User: "look to the right" AI executes: the "Adjust Camera Gimbal" template with set_cam_pan_angle(-60) AI replies: "Looking to the right now"
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpicarx-control/SKILL.md
Popularity
- Repository stars
- 78
- Repository forks
- 108
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sunfounder/picar-x/picarx-control)