ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to get the Pixy camera working on ROS ?

asked 2014-05-15 07:33:07 -0500

updated 2014-05-16 04:05:31 -0500

I'm trying to get the Pixy camera working with ROS (Hydro) on Ubuntu 12.04 x64.

Overview

If you haven't heard about the Pixy yet, it's a camera with embedded vision processing that does mainly fast blob tracking.

It is provided with a software and a GUI written in C++ and Qt, called PixyMon. So I thought it could be great to convert it to a ROS package ! Of course I could connect the Pixy to an Arduino and get some data from a serial link, but I'd like to use the direct USB link to the Pixy, no arduino, and have all the capability of PixyMon within ROS. PixyMon allows you to interact with the Pixy, change its parameters (lightness, contrast...), get the camera image, detected blobs position/size, record new colors...so I'd like to have a ROS wrapper for all of this.

Explanation of the issue

So far I can build and link and execute PixyMon as a ROS package, it detects my Pixy but cannot connect to it, PixyMon terminal shows :

Pixy detected.
error: Unable to connect to device.

and the terminal from where I execute the node shows :

libusb_bulk_write -7
libusb_bulk_write -7
interpreter finished
destroying interpreter...
done
libusb_bulk_write -7
libusb_bulk_write -7

And they all repeat. A click on Parameters button give a segmentation fault and crash. So somewhere something is not using the right libraries, or not the right Qt version, or the different parts of the project are not linked properly I suspect.

Here are the steps I followed to convert PixyMon into a ROS package

So I basically created an empty Qt package, and paste PixyMon (that means common and host folders) inside src folder. My package.xml contains this for Qt project :

<buildtool_depend>catkin</buildtool_depend>
<build_depend>qt_build</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>libqt4-dev</build_depend>
<run_depend>qt_build</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>libqt4-dev</run_depend>

My CMakeLists.xml is as follow (I removed all comments) :

cmake_minimum_required(VERSION 2.8.9)
project(pixymon)

find_package(catkin REQUIRED COMPONENTS qt_build roscpp)
find_package(Qt4 COMPONENTS QtCore QtGui QtWidgets)
include_directories(
    ${catkin_INCLUDE_DIRS} 
    src/common 
    src/host/pixymon
    /usr/include/libusb-1.0)
link_directories(
    src/common 
    src/host/pixymon)
catkin_package()

file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/host/pixymon/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/host/pixymon/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/host/pixymon/*.h)
QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/common/*.cpp)
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/host/pixymon/*.cpp)

add_executable(pixymon ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
add_library(chirp src/common/chirp.cpp)
add_library(qqueue src/common/qqueue.cpp)
add_library(blob src/common/blob.cpp)
add_library(blobs src/common/blobs.cpp)
target_link_libraries(blobs blob)
target_link_libraries(pixymon ${QT_LIBRARIES} ${catkin_LIBRARIES} chirp qqueue blobs /usr/lib/x86_64-linux-gnu/libusb-1.0.so)
install(TARGETS pixymon RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

I can build and execute the normal Pixymon project provided for the Pixy and it workd well, it is building using Qt5 with the .pro file. But it seems ... (more)

edit retag flag offensive close merge delete

Comments

1

This looks sort of reasonable. Without hacking on it a lot, it's hard to say for sure. I suspect most of your build process is fine, or you would have symbol errors at link time or at startup. Have you tried running your node in gdb? Does it have a debug mode that you can enable?

ahendrix gravatar image ahendrix  ( 2014-05-16 06:39:51 -0500 )edit

Thank you for your reply. Yes I agree the build process should be ok. I tried to run the node in gdb but it doesn't give me more information. Actually, all the error written in the terminal are written by qDebug calls. The error "libusb_bulk_write -7" cause the problem, I'll try to trace it back.

Cyril Jourdan gravatar image Cyril Jourdan  ( 2014-05-20 22:51:25 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-08-22 15:45:14 -0500

mjstn gravatar image

I too am very interested and have approached this in a 'hack' sort of way as my 1st cut but hope to implement a true ROS node with Pixy as my next step. I am not suggesting this is clean, I am only putting it forth as an unclean alternative that some may benefit from till a clean solution is devised.

My solution is that I have hacked the linux (Raspberry PI) hello code to stuff it's results to shared memory segment. My current ROS node then inspects this shared memory with both processes only accessing the shared memory segment using a system V semaphore so it is safe for the producer (hello code) and consumer (ROS node). My ROS node then inspects memory and passes what it finds over via a ROS topic to my main node which is the end consumer of the Pixy object recognition data. All this then means the pixy.h and pixydef.h includes and a definition of the named shared memory segment of my own .h file are all the ROS node need see as it compiles. This works but I agree is a bit of a 'hack' if you will as I have to start the pixy converted 'hello' process outside of my roslaunch config file.

Just a thought and maybe it will be a reasonable short term solution for others in the mean time as we strive to get the code to operate as a true ROS node which of course is the 'right' way to deal with this issue.

edit flag offensive delete link more
0

answered 2015-04-15 11:41:30 -0500

You might check out libpixyusb, which makes direct communictation with Pixy over USB fairly easy ---

http://cmucam.org/projects/cmucam5/wi... http://charmedlabs.github.io/pixy/pix...

I'm not sure if you're running Windows or Linux. Linux is well-tested. Windows isn't so much (for libpixyusb).

edit flag offensive delete link more
0

answered 2014-11-06 09:35:08 -0500

jeskesen gravatar image

Hi, I've taken the recently released libpixyusb from Charmed Labs' pixy repository & made a ROS node around it. At the time of this writing, it only supports USB streaming of plain signiture & color-code block data. It will also subscribe to a servo command topic and move the servos for pan-tilt... though I don't have any demo for that (yet).

Here is a link to my source code. I welcome any feedback and/or collaboration from interested users. I've already created a to-do list on the github page of features I'd like to add. Please feel free to add suggestions there.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-05-15 07:33:07 -0500

Seen: 3,769 times

Last updated: Nov 06 '14