5.0 Pixy2 Camera - SwollEngineAF/lipan GitHub Wiki


📷 Pixy2 Vision Integration

Welcome to the official wiki for Pixy2-based Object Detection & Robotic Control. This project integrates the Pixy2 CMUcam5 with a Raspberry Pi + Arduino setup to track coloured objects, control a 4-DOF robot arm, and drive a mobile platform.


📦 Repository Structure

pixy2/
├── src/
│   └── host/
│       └── libpixyusb2_examples/
│           └── get_blocks_cpp_demo/   # Main vision logic + serial interface
├── arduino/
│   └── robot_arm.ino                  # Arduino sketch to control servos
│   └── robot_drive.ino                # Arduino sketch for DC motor drive
└── README.md

🚀 How It Works

  1. Pixy2 tracks colour signatures (Signatures 1–5).

  2. Raspberry Pi:

    • Receives object data (x, y, width, height).

    • Maps pixel coordinates to PWM values.

    • Sends serial commands to:

      • Arduino 1: Move servos for arm base, shoulder, elbow, and gripper.

      • Arduino 2: Control differential drive based on object distance.

  3. Arduino:

    • Decodes commands like B:300, L:500, F, S, B for actuation.


🎯 Key Features

  • Real-time colour object detection

  • Depth approximation using pixel area

  • Automatic arm control based on target position

  • Motion control: Slow approach, auto-stop, and reverse on proximity

  • Supports 4-DOF arm + DC drive platform


🧠 Color Signatures

Signature Object Type Emoji
1 Unripe Fruit (Red) 🍅
2 Loose Fruit 🌰
3 Green Ball 🟢
4 Ripe Fruit 🍌
5 Blue Ball 🔵

🔧 Build & Run

On Raspberry Pi (Ubuntu 22.04):

cd ~/pixy2/src/host/libpixyusb2_examples/get_blocks_cpp_demo
make
./get_blocks_cpp_demo

Make sure Pixy2 is connected via USB and you've granted access:

sudo chmod 666 /dev/ttyUSB0
sudo chmod 666 /dev/ttyUSB1

📡 Serial Output Format

[Pi → Arduino] B:340   # Base rotation
[Pi → Arduino] L:450   # Left shoulder
[Pi → Arduino] R:440   # Right shoulder
[Pi → Arduino] A:370   # Arm/gripper
[Pi → Arduino] G:450   # Grip close
[Pi → Arduino] F       # Drive forward

🛠 Arduino Sketches

  • robot_arm.ino: Controls servo-based manipulator using mapped PWM

  • robot_drive.ino: Controls 4 DC motors using Adafruit Motor Shield v1 with speed variation based on object distance


🗂 Useful Links


🤝 Credits


Want me to generate it as a .md file or add a ROS 2 integration section next?

Sure Syahiid! Below is a clean and informative GitHub Wiki page for your Pixy2 fork, tailored to your robotics use-case with Raspberry Pi and Arduino integration — especially for object tracking, arm control, and mobility via serial commands.

📷 Pixy2 Vision Integration

Welcome to the official wiki for Pixy2-based Object Detection & Robotic Control. This project integrates the [Pixy2 CMUcam5](https://pixycam.com/pixy2/) with a Raspberry Pi + Arduino setup to track coloured objects, control a 4-DOF robot arm, and drive a mobile platform.


📦 Repository Structure

pixy2/
├── src/
│   └── host/
│       └── libpixyusb2_examples/
│           └── get_blocks_cpp_demo/   # Main vision logic + serial interface
├── arduino/
│   └── robot_arm.ino                  # Arduino sketch to control servos
│   └── robot_drive.ino                # Arduino sketch for DC motor drive
└── README.md

🚀 How It Works

  1. Pixy2 tracks colour signatures (Signatures 1–5).

  2. Raspberry Pi:

    • Receives object data (x, y, width, height).

    • Maps pixel coordinates to PWM values.

    • Sends serial commands to:

      • Arduino 1: Move servos for arm base, shoulder, elbow, and gripper.
      • Arduino 2: Control differential drive based on object distance.
  3. Arduino:

    • Decodes commands like B:300, L:500, F, S, B for actuation.

🎯 Key Features

  • Real-time colour object detection
  • Depth approximation using pixel area
  • Automatic arm control based on target position
  • Motion control: Slow approach, auto-stop, and reverse on proximity
  • Supports 4-DOF arm + DC drive platform

🧠 Color Signatures

Signature Object Type Emoji
1 Unripe Fruit (Red) 🍅
2 Loose Fruit 🌰
3 Green Ball 🟢
4 Ripe Fruit 🍌
5 Blue Ball 🔵

🔧 Build & Run

On Raspberry Pi (Ubuntu 22.04):

cd ~/pixy2/src/host/libpixyusb2_examples/get_blocks_cpp_demo
make
./get_blocks_cpp_demo

Make sure Pixy2 is connected via USB and you've granted access:

sudo chmod 666 /dev/ttyUSB0
sudo chmod 666 /dev/ttyUSB1

📡 Serial Output Format

[Pi → Arduino] B:340   # Base rotation
[Pi → Arduino] L:450   # Left shoulder
[Pi → Arduino] R:440   # Right shoulder
[Pi → Arduino] A:370   # Arm/gripper
[Pi → Arduino] G:450   # Grip close
[Pi → Arduino] F       # Drive forward

🛠 Arduino Sketches

  • robot_arm.ino: Controls servo-based manipulator using mapped PWM
  • robot_drive.ino: Controls 4 DC motors using Adafruit Motor Shield v1 with speed variation based on object distance

🗂 Useful Links


🤝 Credits


⚠️ **GitHub.com Fallback** ⚠️