(edit - I forgot to mention which version of python I’m using - it’s 2.7)
I’m trying to follow objects with the pan/tilt servos via python and I’m kinda stumped. I had it working fine on a raspberry pi 3, but I’ve switched to another ARM platform - an odroid C2 running a fairly lean Debian Jessie. The pantilt_in_c works fine - it controls the servos and follows an object, so I know that there’s nothing wrong with my pixy or my servos or my computer hardware. It works straight out of the “build_pantilt_c_demo.sh” gate.
The pan_tilt.py code has a couple of bugs, but I had to fix those when on the raspberry pi, and they’re not the issue. The issue is I’m getting the following (also tried this as root):
$ python pan_tilt.py + Pixy Tracking Demo Started + frame 0: Error: pixy_rcs_set_position() [-152] Pixy Error: Invalid command
The servos never budge when that pixy_rcs_set_position() function is called, and it’s returning a -152 which I figure means something like “I tried to move the servo and I couldn’t”.
I also tried this on a completely other OS - the official full-blown-bloated Ubuntu, got the exact same result.
The build of the python module appears to have worked fine. It did issue few warnings about unusued variables, signed/unsigned integer comparisons, and “warning: deleting object of polymorphic class type ‘ChirpReceiver’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]”.
Anywho… I’m stumped. Has anyone here got any suggestions? Otherwise, I’m going to have to result to having python issue shell commands to get the thing following in C, and then parse the results to get the X:Y positions of the servos so that the python code can then do things based upon where the pixy is looking.
For what it’s worth, This will fix the syntax errors from a misnamed variable in the pan_tilt.py source:
sed -ie "s/\([^_]\)result/\\1set_position_result/" pan_tilt.py
Thanks very much for any advice.
This may be a bit much, but here’s the result of my build. I’d be interested in knowing if any of these warnings are critical.
$ ./build_pantilt_python_demo.sh
mkdir: cannot create directory ‘/home/nshaver/build/pixy/build/’: File exists
$ ./build_pantilt_python_demo.sh
mkdir: cannot create directory ‘/home/nshaver/build/pixy/build/’: File exists
Building libpixyusb SWIG module
running build_ext
building 'pixy’ extension
creating build
creating build/temp.linux-aarch64-2.7
creating src
creating src/common
creating src/common/src
creating src/host
creating src/host/libpixyusb
creating src/host/libpixyusb/src
creating src/host/libpixyusb/src/utils
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX_=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c pixy_wrap.cxx -o build/temp.linux-aarch64-2.7/pixy_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/common/src/chirp.cpp -o build/temp.linux-aarch64-2.7/…/…/src/common/src/chirp.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
…/…/src/common/src/chirp.cpp: In member function ‘int Chirp::setLink(Link*)’:
…/…/src/common/src/chirp.cpp:100:83: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
m_buf = (uint8_t )m_link->getFlags(LINK_FLAG_INDEX_SHARED_MEMORY_LOCATION);
^
…/…/src/common/src/chirp.cpp: In member function ‘int Chirp::recvFull(uint8_t, ChirpProc*, bool)’:
…/…/src/common/src/chirp.cpp:1274:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res<sizeof(uint32_t))
^
…/…/src/common/src/chirp.cpp: In member function ‘int Chirp::recvData()’:
…/…/src/common/src/chirp.cpp:1342:9: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (res<(int)chunk+3)
^
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/host/libpixyusb/src/pixy.cpp -o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/pixy.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
…/…/src/host/libpixyusb/src/pixy.cpp: In function ‘int pixy_get_firmware_version(uint16_t*, uint16_t*, uint16_t*)’:
…/…/src/host/libpixyusb/src/pixy.cpp:435:16: warning: unused variable ‘chirp_response’ [-Wunused-variable]
int chirp_response;
^
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/host/libpixyusb/src/chirpreceiver.cpp -o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/chirpreceiver.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/host/libpixyusb/src/pixyinterpreter.cpp -o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/pixyinterpreter.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp: In member function ‘void PixyInterpreter::close()’:
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp:70:12: warning: deleting object of polymorphic class type ‘ChirpReceiver’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete receiver_;
^
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp: In member function ‘int PixyInterpreter::get_blocks(int, Block*)’:
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp:90:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
number_of_blocks_to_copy = (max_blocks >= blocks_.size() ? blocks_.size() : max_blocks);
^
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp: In member function ‘void PixyInterpreter::interpret_CCB1(const void**)’:
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp:222:18: warning: unused variable ‘index’ [-Wunused-variable]
uint32_t index;
^
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp: In member function ‘void PixyInterpreter::interpret_CCB2(const void**)’:
…/…/src/host/libpixyusb/src/pixyinterpreter.cpp:245:18: warning: unused variable ‘index’ [-Wunused-variable]
uint32_t index;
^
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/host/libpixyusb/src/usblink.cpp -o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/usblink.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D__LINUX__=1 -I/usr/include/libusb-1.0 -I/usr/local/include/libusb-1.0 -I…/…/src/common/inc -I…/…/src/host/libpixyusb/src/utils -I…/…/src/host/libpixyusb/include -I/usr/include/python2.7 -c …/…/src/host/libpixyusb/src/utils/timer.cpp -o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/utils/timer.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-aarch64-2.7/pixy_wrap.o build/temp.linux-aarch64-2.7/…/…/src/common/src/chirp.o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/pixy.o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/chirpreceiver.o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/pixyinterpreter.o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/usblink.o build/temp.linux-aarch64-2.7/…/…/src/host/libpixyusb/src/utils/timer.o -lboost_thread -lboost_system -lboost_chrono -lpthread -lusb-1.0 -o /home/nshaver/build/pixy/build/pantilt_in_python/_pixy.so
Build complete
To run the get_blocks libpixyusb SWIG example execute the following commands:
cd …/build/pantilt_in_python
python pan_tilt.py