Help with Pi Pan/Tilt Face tracker

I recently purchased the Adafruit Pan/Tilt camera mount with two servoces and a small driver board. The instructions on here:

http://learn.pimoroni.com/tutorial/electromechanical/building-a-pan-tilt-face-tracker

I found an error in the last instruction which could not be completed as the specified file is not present in the download, it turns out the correct instruction should be:

sudo ./facetracker.py

However, having now run that I get:

Traceback (most recent call last):
File “./facetracker.py”, line 4, in
from paltile import *
File “/home/pi/PanTiltFacetracker/pantile.py”, line 1, in

from Adafruit_PWM_Servo_Driver import PWM
File “/home/pi/PanTiltFacetracker/Adafruit_PWM_Servo_Driver.py”,
line 5, in
from Adafruit_I2C_import Adafruit_I2C
File “/home/pi/PanTiltFacetracker/Adafruit_I2C.py”, line 3, in

import smbus
ImortError: No module named smbus

Can anyone help?

Try:

sudo apt-get install python-smbus

Thank you, just tried this, it installed fine, then ran:

    sudo ./facetracker.py

Response now:

    Traceback (most recent call last):
      File "./facetracker.py", line 4, in <module>
        from pantile import *
      File "/home/pi/PanTiltFacetracker/pantilt.py", line 1, in <module>
        from Adafruit_PWM_Servo_Driver import PWM
       File "/home/pi/PanTiltFacetracker/Adafruit_PWM_Servo_Driver.py", line 11, in <module>
         class PWM:
       File "/home/pi/PanTileFacetracker/Adafruit_PWM_Servo_Driver.py", line 35, in PWM
         general_call_i2c = Adafruit_I2C(0x00)
       File "/home/pi/PanTiltFacetracker/Adafruit_I2C.py", line 36, in __init__
         self.bus = smbus.SMBus(busnum if busnum >= 0 else Adafruit_I2C.getPiI2CBusNumber())
    IOError: [Errno 2] No such file or directory

what Pi is this on, and running what version of Raspbian (or other OS should that be the case)?

Raspberry Pi 3 Model B

Running Raspbian GNU/Linux 8 (jessie)

yes, I have the same. The problem is the probe for board revision not being adequate for the Pi 3.

I would simply comment out line 36 and uncomment line 35 in Adafruit_I2C.py, so that the init method reads:

def __init__(self, address, busnum=-1, debug=False):
    self.address = address
    # By default, the correct I2C bus is auto-detected using /proc/cpuinfo
    # Alternatively, you can hard-code the bus version below:
    # self.bus = smbus.SMBus(0); # Force I2C0 (early 256MB Pi's)
    self.bus = smbus.SMBus(1); # Force I2C1 (512MB Pi's)
    # self.bus = smbus.SMBus(busnum if busnum >= 0 else Adafruit_I2C.getPiI2CBusNumber())
    self.debug = debug

Thank you, the application now runs, however what should I be seeing ? The camera window is visible and I see myself, but when I move around shouldn’t the arm track me? Nothing is happening, no servo’s are moving.

Yes, that’s very much the idea I believe. But there’s a bunch of reasons that would lead to nothing happening, I think you need to tell us more about how you got to this point, maybe check your wiring too, I guess it can’t hurt.

… that said I’m not the best person to answer from here on as I don’t have the kit, nor a clear idea on testing procedure for simple servo action, bypassing the camera tracking aspect itself (which I suspect is where you’ll find the answer).

I followed the instructions on at:

http://learn.pimoroni.com/tutorial/electromechanical/building-a-pan-tilt-face-tracker

I hear you, but checking that your servo board works in a more stripped down environment might be useful as a first step. For example, try the following and see if that shines some light on the matter:

https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/overview

I’m not sure this will help, but I spent an hour assembling a version of the Face Tracker that uses the latest Adafruit libraries.

I still recommend you try the simpletest(.py) mentioned in the Adafruit tutorial, but if that works and you feel so inclined you could try the revision of facetracker.py (or to be more accurate pantilt.py) I knocked together:

note that you must install the adafruit libraries as follows:

sudo pip install adafruit-gpio
sudo pip install adafruit-pca9685

well, it’s an unnecessary step if you followed the tutorial I linked to earlier, but if you go straight to my repo to try then you’ll need to install them.

As stated earlier, I don’t have a board to test, so I have no idea if it works at all, but I’m hopeful it would - at the very least - detect the correct bus on your Pi3, and do as much as the current version. YMMV.

I’ve attached a photo showing the connections to the board and the Pi, I’m not sure if the servo’s are connected correctly, there was no documentation included with the product.
https://www.facebook.com/photo.php?fbid=10154788847528448&set=a.10150278402768448.402610.751163447&type=3&theater

I downloaded the updated PanTiltFacetracker from your link and ran ./pantilt.py I got:

Tiny mini Pan/Tilt library
By default, tilt is on channel 1
and pan is on channel 0
: No such file or directory
./pantilt.py: line 7: syntax error near unexpected token ‘(’
./pantilt.py: line 7: ‘servo = PWM.PCA9685()’

pantilt.py does not have an interpreter specified, so you can’t just run it that way… at the very least you’d need to call it as an argument to python. Otherwise it will be treated as a shell script, resulting in what you see.

But anyhow, you should preferably just call facetracker.py as normal, and not pantilt.py, since that is the program you are trying to get running ultimately:

sudo python ./facetracker.py

… I couldn’t access your pictures, they show up as private here.

Can I email the image to you?

I can run facetracker.py, just nothing from the servo’s

I think you should be able to upload the pic here. But I’ll check in the morning to be sure you have the right to do so, as I’ve never really looked into it.

Hopefully this image will help.

Your wiring to the Pi seems correct, but the servo side has no power supply in your pic.

See https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/hooking-it-up which goes into some details about power.

Thank you, I did wonder what the terminals were for…a small note / instruction with the product would have save so much time.

I will try this tonight.

Ok, I have a seperate 5V power supply wired as shown in the picture, apart from an initial power on jitter, where the servo’s seem to move randomly for a few milliseconds, there is no other activity, when I start:

     sudo python facetracker.py

I get a video image showing what the camera is looking at but no servo activity at all.