Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
Pack pro mobile lgnchugrkz
Walabot
×1
Unitek USB3.0 4-Port Hub
×1
Power Sonic Model PS-640 F1 6 Volt 4.5 AmpHr Battery Supply
×1
Servo (generic)
Personally modified Futaba S3003 for continuous rotation. If using a different brand of servo research the number of spline teeth for your attachment of the Servo Spline Gear.
×1
Servo Spline Gear
32 Pitch 25T 12 Teeth (Acetyl). After testing, it appears that metal would be the best material for the gears.
×1
Plain Bore Gear with Hub
32 Pitch 48 Teeth (Acetyl). After testing, it appears that metal would be the best material for the gears.
×1
Computer Monitor
This additional monitor will be placed on the turntable and rotate on the TV stand. Its size is for the Technical Demonstration.
×1
M5X30 Bolt and Nut
×4
Openbuilds nylon spacer
OpenBuilds Nylon Spacer
M5X6mm
×8
Double%20v%20wheel%e2%84%a2%20kit
OpenBuilds Delrin V Wheel Kit
The exact parts are not these, but they are very similar.
×4
Software apps and online services:
Sublime Text
Or any other generic text editor.
Hand tools and fabrication machines:
3drag
3D Printer (generic)
09507 01
Soldering iron (generic)

Custom parts and enclosures

basePlate
This is the plate that the 4 stands and clamps slot into. There is also a spot for the potentiometer and servo to be held.
baseClamp
This holds the wheel bearing assembly and connects it to the basePlate.
baseStand
This is a generic stand that slots into the basePlate.
baseStandMagnet
This is the stand with a slot for a metal disk to hold the Walabot magnetically.
potentiometerAdapter
This part connects the gear of the turnTable to the potentiometer.
turnTable
This is the top rotating surface.

Schematics

Diagram
Use this for wiring the electronics.

No document.

Code

trackingTV.pyPython
This is the code that runs on the Raspberry Pi
from imp import load_source
import wiringpi
import math
import time

servo = 1                   # The pin the servo signal wire is connected to
totalDegrees = 130          # Range of the servo +-(130/2)

lastAveragePosition = 0     # Previous average position of targets from Walabot
lastMoveTime = time.time()  # When the servo was moved last
minimumAverageDelta = 10    # Amount of degrees required for servo to move
maximumStillTime = 10       # Maximum amount of time servo will be still for
servoSpeed = 20             # Speed of servo in degrees/second (only tells servo when to turn off after setting position)

turntableAxisOffset = 10    # cm's of space between axis of turntable and Walabot origin point
                            # Allows angles to be calculated for direct aiming of turntable

# Sets up the servo pin with wiringpi library

def startServo():
    wiringpi.pinMode(servo, wiringpi.PWM_OUTPUT)
    wiringpi.pwmSetMode(wiringpi.PWM_MODE_MS)
    wiringpi.pwmSetClock(384)
    wiringpi.pwmSetRange(1000)

# Sets the position of the servo (degrees)

def setServo(deg):
    value = deg / totalDegrees / 2 + 0.5
    wiringpi.pwmWrite(servo, int(123.6 * (value) + 14 * (1 - value)))

# Stops the servo from moving

def stopServo():
    wiringpi.pwmWrite(servo, 0)
    wiringpi.pinMode(servo, 0)

# Connect to the Walabot, if failed wait and try again

def connect():
    while True:
        try:
            bot.ConnectAny()
        except bot.WalabotError as err:
            time.sleep(1)
        else:
            print("Connected")
            return

# Setup Walabot profile and scanning area

def setup():
    bot.SetProfile(bot.PROF_SENSOR)
    bot.SetArenaR(10, 300, 2)
    bot.SetArenaTheta(-1, 1, 1)
    bot.SetArenaPhi(-40, 40, 2)
    bot.SetThreshold(60)
    bot.SetDynamicImageFilter(bot.FILTER_TYPE_NONE)
    print("Configured")

# Begin Walabot calibration

def calibrate():
    bot.Start()
    bot.StartCalibration()
    print("Calibrating")
    while bot.GetStatus()[0] == bot.STATUS_CALIBRATING:
        bot.Trigger()
    print("Ready")

# Disconnect Walabot

def disconnect():
    bot.Stop()
    bot.Disconnect()
    print("Disconnected")

# Main function
# Scans for targets
# Averages position
# Moves servo to position

def function():
    global lastAveragePosition, lastMoveTime

    # Get targets from Walabot
    
    bot.Trigger()
    targets = bot.GetSensorTargets()
    average = 0
    count = len(targets)

    # Find average position of all targets
    
    for target in targets:
        angle = math.degrees(math.atan(target.yPosCm / (target.zPosCm + turntableAxisOffset)))
        average += angle

    # If any targets found, determine if should move the servo
    
    if count != 0:
        average /= count
        delta = abs(average - lastAveragePosition)

        # Only move servo if targets moved at least minimumAverageDelta degrees
        # Or it has been >= maximumStillTime since the last servo move

        if delta >= minimumAverageDelta or time.time() - lastMoveTime >= maximumStillTime:
            print("Move: " + str(average) + "\n")
            lastMoveTime = time.time()
            startServo()
            setServo(average)
            time.sleep(delta / servoSpeed)
            stopServo()
        lastAveragePosition = average

# Main code start
# Setup Walabot library

bot = load_source("WalabotAPI", "/usr/share/walabot/python/WalabotAPI.py")
bot.Init()
bot.SetSettingsFolder()

# The Walabot setup process

connect()
setup()
calibrate()

# Setup WiringPi library and servo

wiringpi.wiringPiSetup()
startServo()

# Make sure turntable starts at 0 degree position

setServo(0)
time.sleep(2)
stopServo()

# Main loop execute main function repeatedly

try:
    while True:
        function()
except KeyboardInterrupt:
    stopServo()
    disconnect()
    

Credits

48zqvwvonbwdjuxmbbpz
Scott Mendenhall

Mechanical Engineering Student at UNC Charlotte

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Banana pi BPI-M2 Zero quad core singel-board computer
Advanced
  • 250
  • 4

Protip

Banana PI BPI-M2 Zero is the open source hardware platform,Banana PI BPI-M2 Zero is an quad core version of Banana Pi,it support WIFI on boa

Slot Car Track
Advanced
  • 48
  • 1

Slot Car Race Track!!! HURRY!!!!!!!!!!!!!!!!!!!!!!

A Sudoku Solver's Robot
Advanced
  • 2,491
  • 16

Full instructions

Sudoku-robot is a robot that solves and fills Sudoku grids!

Coffeebot: A Bot That Gets Coffee for You
Advanced
  • 748
  • 7

Coffeebot is a coffee delivery robot with one click on the app.

Raspberry Pi - Powered Candy Dispenser
Advanced
  • 2,004
  • 11

Full instructions

Make a candy machine that can give candy with a push of a button or a tweet!

Home Monitoring System Based on LattePanda, ZigBee and Azure
Advanced
  • 782
  • 2

Full instructions

Design your home monitoring system with LattePanda (with Windows 10 Home x64 OS), CC2530 ZigBee devices, and Microsoft Azure services.

Sign up / LoginProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlog