Table of Contents

Building libpixyusb on Linux

1. Introduction

The libpixyusb library provides a software application programming interface (API) for communicating
with Pixy over USB. This allows you to write software that interfaces with Pixy like the PixyMon application.

The following procedure will outline the steps required for building the libpixyusb library and some example projects using the library. This procedure assumes the following:

The Mint-17 distribution of Linux can be downloaded here: http://www.linuxmint.com

Instructions for updating the Pixy firmware are here: Uploading New Firmware

Although this procedure uses Linux Mint-17, it should work with any Linux distribution that uses the Debian package manager (e.g. Ubuntu).

2. Procedure

2.1. Install dependencies for building libpixyusb

Start the terminal application:

2.1.1. Install git

In the terminal window type:

sudo apt-get install git

2.1.2. Install libusb-1.0-0-dev

In the terminal window type:

sudo apt-get install libusb-1.0-0-dev

2.1.3. Install g++ (compiler)

In the terminal window type:

sudo apt-get install g++

2.1.4. Install libboost

In the terminal window type:

sudo apt-get install libboost-all-dev

This step will take some time. Time for a refreshing drink?

2.1.5. Install cmake

In the terminal window type:

sudo apt-get install cmake

2.2. Build and install libpixyusb

2.2.1 Download Pixy source code

In the terminal window type:

git clone https://github.com/charmedlabs/pixy.git

2.2.2. Build the library

In the terminal window type:

cd pixy/scripts
./build_libpixyusb.sh

2.2.3. Install the library

Installing the library files requires root privileges.

In the terminal window type:

sudo ./install_libpixyusb.sh

3. Example projects

Before trying the examples below, connect Pixy to your Linux system using a USB Mini cable:

e0e66b6f1b2c5231027c1d03c811e16207772021.jpg

3.1. hello_pixy: A Simple IO Example

The example does the following:

3.1.1. Build the 'hello_pixy' example

In the terminal window type:

/pixy/scripts/build_hello_pixy.sh

3.1.2. Start the example

To start the libpixyusb example, run 'hello_pixy' as root.

In the terminal window type:

cd /pixy/build/hello_pixy
sudo ./hello_pixy

Block data received from Pixy is displayed in stdout.

3.2. pan_tilt: An Object Tracking Example

This example does the following:

Before starting the tracking demo, make sure you've set color signature '0'. Look here: Teach_Pixy_an_Object_2

3.2.1. Build the 'pan_tilt' example

In the terminal window type:

/pixy/scripts/build_pantilt_c_demo.sh

3.2.2. Start the example

To start the pantilt demo, run 'pantilt' as root.

cd ../build/pantilt_in_c
sudo ./pantilt_c

ecd3c47f5b3959e279d1678becdfbbbc9854009c.jpg

Pixy should track objects that have color signature '0' programmed. If the tracking is not smooth try the following:

Note: If this example freezes, make sure that your version of libusb is at least 1.0.9.

3. Comments

We welcome your thoughts and feedback! Please let us know how we can improve.