This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
wiki:v2:building_the_libpixyusb_example_on_linux [2018/06/29 02:59] pixycam |
wiki:v2:building_the_libpixyusb_example_on_linux [2018/07/12 00:54] jfrench [Start the example] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Building libpixyusb on Linux ====== | ||
- | ====== 1. Introduction ====== | + | ====== 1.0. Introduction ====== |
- | The libpixyusb library provides a software application programming interface (API) for communicating\\ | + | The libpixyusb2 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. | + | with Pixy2 over USB. This allows you to write software that interfaces with Pixy2 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 following procedure will outline the steps required for building the libpixyusb2 library and some example projects using the library. This procedure assumes the following: |
- | * Your system has Linux Mint-17 installed | + | * Your system has Linux (Mint or similar) installed |
- | * Pixy firmware has been updated to 2.0.8 | + | |
* Your system is connected to the internet | * Your system is connected to the internet | ||
- | * libpixyusb version is 0.3 | ||
- | * libusb version 1.0.9 | ||
- | The Mint-17 distribution of Linux can be downloaded here: http://www.linuxmint.com | + | The Mint-18 distribution of Linux can be downloaded here: http://www.linuxmint.com |
- | Instructions for updating the Pixy firmware are here: [[wiki:v2:Uploading_New_Firmware|Uploading New Firmware]] | + | Although this procedure uses Linux Mint-18, it //should// work with any Linux distribution that uses the Debian package manager (e.g. Ubuntu). |
- | Although this procedure uses Linux Mint-17, it //should// work with any Linux distribution that uses the Debian package manager (e.g. Ubuntu). | ||
+ | ====== 2.0. Procedure ====== | ||
- | ====== 2. Procedure ====== | + | ===== 2.1. Install dependencies for building libpixyusb2 ===== |
- | + | ||
- | + | ||
- | ===== 2.1. Install dependencies for building libpixyusb ===== | + | |
Start the terminal application: | Start the terminal application: | ||
{{wiki:img:78184a8b63cf10782c18339b791db9f85a0d8bc0.png?400}} | {{wiki:img:78184a8b63cf10782c18339b791db9f85a0d8bc0.png?400}} | ||
- | |||
- | |||
- | ==== 2.1.1. Install git ==== | ||
In the terminal window type: | In the terminal window type: | ||
- | ''%%sudo apt-get install git%%'' | + | ''%%sudo apt-get install git libusb-1.0-0-dev g++%%'' |
+ | ===== 2.2. Build libpixyusb2 ===== | ||
- | ==== 2.1.2. Install libusb-1.0-0-dev ==== | + | ==== 2.2.1. Download Pixy2 source code ==== |
In the terminal window type: | In the terminal window type: | ||
- | ''%%sudo apt-get install libusb-1.0-0-dev%%'' | + | ''%%git clone https://github.com/charmedlabs/pixy2%%'' |
- | + | ||
- | {{wiki:img:da64e20cd40baefbd00b8bb4fce081a0f9b76abd.png?400}} | + | |
- | + | ||
- | + | ||
- | ==== 2.1.3. Install g++ (compiler) ==== | + | |
- | + | ||
- | In the terminal window type: | + | |
- | + | ||
- | ''%%sudo apt-get install g++%%'' | + | |
- | + | ||
- | {{wiki:img:208f77c0feb60df1b578d0a67c31972a6e32e285.png?400}} | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== 2.2. Build and install libpixyusb ===== | + | |
- | + | ||
- | + | ||
- | ==== 2.2.1 Download Pixy source code ==== | + | |
- | + | ||
- | In the terminal window type: | + | |
- | + | ||
- | ''%%git clone https://github.com/charmedlabs/pixy2.git%%'' | + | |
- | + | ||
- | {{wiki:img:dcf634a40148751c2a5f59668335e326013c2183.png?400}} | + | |
+ | {{:wiki:v2:git_clone.png?400|}} | ||
==== 2.2.2. Build the library ==== | ==== 2.2.2. Build the library ==== | ||
In the terminal window type: | In the terminal window type: | ||
- | ''%%cd pixy/scripts%%''\\ | + | ''%%cd pixy2/scripts && ./build_libpixyusb2.sh%%'' |
- | ''%%./build_libpixyusb2.sh%%'' | + | |
- | {{wiki:img:a636c182eec2a7d020e836738a7d629fa4b5bb13.png?400}} | + | {{:undefined:build_libpixyusb2.png?400|}} |
+ | ====== 2.3. Example projects ====== | ||
- | ====== 3. Example projects ====== | + | Before trying the examples below, connect Pixy2 to your Linux system using a USB Micro-B cable: |
- | Before trying the examples below, connect Pixy2 to your Linux system using a USB Mini cable. | + | {{wiki:v2:img_5268_result.jpg?400|}} |
- | ===== 3.1. get_blocks: A Simple IO Example ===== | + | ===== 2.3.1. Color Identification Example (GetBlocksCPPDemo) ===== |
The example does the following: | The example does the following: | ||
- Connects to Pixy2 using USB | - Connects to Pixy2 using USB | ||
- | - Block information is displayed (as shown in the image above) if color signatures have been set and if the signatures are currently being detected by Pixy. | + | - Displays firmware version installed on Pixy2 |
+ | - Block information is displayed (as shown in the image above) if color signatures have been set and if the signatures are currently being detected by Pixy2. | ||
- | + | ==== Build the 'get_blocks_cpp_demo' example ==== | |
- | ==== 3.1.1. Build the 'get_blocks' example ==== | + | |
In the terminal window type: | In the terminal window type: | ||
- | ''%%/pixy/scripts/build_get_blocks_cpp_demo.sh%%'' | + | ''%%./build_get_blocks_cpp_demo.sh%%'' |
+ | {{:wiki:v2:build_get_blocks.png?400|}} | ||
- | ==== 3.1.2. Start the example ==== | + | ==== Start the example ==== |
- | To start the libpixyusb2 example, run 'hello_pixy' as root. | + | To start the get blocks example, run 'get\_blocks\_cpp\_demo' as root. |
In the terminal window type: | In the terminal window type: | ||
- | ''%%cd /pixy/build/hello_pixy%%''\\ | + | ''%%cd ../build/get_blocks_cpp_demo/%%''\\ |
- | ''%%sudo ./hello_pixy%%'' | + | ''%%sudo ./get_blocks_cpp_demo%%'' |
+ | {{:wiki:v2:get_blocks_demo.png?400|}} | ||
- | Block data received from Pixy is displayed in stdout. | + | Block data received from Pixy2 is displayed in stdout. |
- | + | ===== 2.3.2. Line Identification Example (GetLinesCPPDemo) ===== | |
- | /* | + | |
- | ===== 3.2. pan_tilt: An Object Tracking Example ===== | + | |
This example does the following: | This example does the following: | ||
- | - Connects to Pixy using USB | + | - Connects to Pixy2 using USB |
- | - Pixy will track objects with color signature '0' | + | - Configures Pixy2 for line feature identification |
- | Before starting the tracking demo, make sure you've set color signature '0'. Look here: [[wiki:v2:Teach_Pixy_an_Object_2|Teach_Pixy_an_Object_2]] | + | ==== Build the 'get_lines_cpp_demo' example ==== |
- | + | ||
- | + | ||
- | ==== 3.2.1. Build the 'pan_tilt' example ==== | + | |
In the terminal window type: | In the terminal window type: | ||
- | ''%%/pixy/scripts/build_pantilt_c_demo.sh%%'' | + | ''%%./pixy2/scripts/build_get_lines_cpp_demo.sh%%'' |
- | + | ||
- | + | ||
- | ==== 3.2.2. Start the example ==== | + | |
- | + | ||
- | To start the pan_tilt demo, run 'pan_tilt' as root. | + | |
- | + | ||
- | ''%%cd ../build/pantilt_in_c%%''\\ | + | |
- | ''%%sudo ./pantilt_c%%'' | + | |
- | + | ||
- | {{wiki:img:ecd3c47f5b3959e279d1678becdfbbbc9854009c.jpg?400}} | + | |
- | + | ||
- | Pixy should track objects that have color signature '0' programmed. If the tracking is not smooth try the following: | + | |
- | * Use Pixymon to verify that Pixy is getting a good lock on the object. | + | ==== Start the example ==== |
- | * Try making adjustments to the ambient lighting. | + | |
- | Note: If this example freezes, make sure that your version of libusb is at least 1.0.9. | + | To start the pan_tilt demo, run 'get\_lines\_cpp\_demo' as root. |
+ | ''%%cd ./pixy2/build/get_lines_cpp_demo%%''\\ | ||
+ | ''%%sudo ./get_lines_cpp_demo%%'' | ||
- | ====== 3. Comments ====== | + | {{:wiki:v2:get_lines_demo.png?400|}} |
- | We welcome your thoughts and feedback! Please let us know how we can improve. | + | ====== 3.0. Comments ====== |
- | */ | + | |
+ | We welcome your thoughts and feedback! Please let us know how we can improve... | ||