Esempio n. 1
0
class ShowTimeThread (Thread):

    def __init__(self):
        Thread.__init__(self)
        self.c = 1
        self.servo = Servo(12)

    def run(self):
        global milltime
        while True:
            if milltime == 0:
                continue
            dt = datetime.fromtimestamp(milltime)
            lcd.printString(dt.strftime('%Y/%m/%d'), 0, 0)         
            lcd.printString(dt.strftime('%H:%M'), 0, 1)
            self.servo.write(90 + (30 * self.c))
            self.c *= -1
            time.sleep(1)
Esempio n. 2
0
class Turret:
    # see diagrams
    # servo_pan = Servo(10)
    # servo_tilt = Servo(11)
    turret_count = 0
    servo_tilt = Servo(11)
    servo_pan = Servo(10)

    def parse_turret_config(self):
        path = pathlib.Path('scanbot.cfg')
        if path.is_file():
            print("Reading turret config file...")
            config = configparser.ConfigParser()
            config.read('scanbot.cfg')
            tilt_servo_min = config['TURRET']['Tilt Servo Min']
            tilt_servo_max = config['TURRET']['Tilt Servo Max']
            tilt_servo_mid = config['TURRET']['Tilt Servo Mid']
            pan_servo_min = config['TURRET']['Pan Servo Min']
            pan_servo_max = config['TURRET']['Pan Servo Max']
            pan_servo_mid = config['TURRET']['Pan Servo Mid']

        else:
            print("Couldn't find turret config file. Creating a new one...")

            config = configparser.RawConfigParser()
            config['LOGGER'] = {}
            config['LOGGER']['IP'] = '192.168.1.1'
            config['LOGGER']['Username'] = '******'
            config['LOGGER']['Password'] = '******'
            config['LOGGER']['SSH Run Command'] = './Logger'

            config['NAVIO'] = {}
            config['NAVIO']['IP'] = '192.168.1.1'
            config['NAVIO']['Username'] = '******'
            config['NAVIO']['Password'] = '******'
            config['NAVIO']['SSH Run Command'] = './Logger'

            config['TURRET'] = {}
            config['TURRET']['Tilt Servo Min'] = '0'
            config['TURRET']['Tilt Servo Max'] = '255'
            config['TURRET']['Tilt Servo Mid'] = '127'
            config['TURRET']['Pan Servo Min'] = '0'
            config['TURRET']['Pan Servo Max'] = '255'
            config['TURRET']['Pan Servo Mid'] = '127'

            with open('scanbot.cfg', 'w') as configfile:
                config.write(configfile)

            sys.exit(
                "Please edit \"scanbot.cfg\" with correct information. The program will now stop."
            )

        print("Parsed the following data:")
        print("Tilt Servo Min: " + tilt_servo_min)
        print("Tilt Servo Max: " + tilt_servo_max)
        print("Tilt Servo Mid: " + tilt_servo_mid)
        print("Pan Servo Min: " + pan_servo_min)
        print("Pan Servo Max: " + pan_servo_max)
        print("Pan Servo Mid: " + pan_servo_mid)

        return [
            tilt_servo_min, tilt_servo_max, tilt_servo_mid, pan_servo_min,
            pan_servo_max, pan_servo_mid
        ]

    def __init__(self):
        Turret.turret_count += 1
        servo_vars = self.parse_turret_config()
        self.tilt_servo_min = servo_vars[0]
        self.tilt_servo_max = servo_vars[1]
        self.tilt_servo_mid = servo_vars[2]
        self.pan_servo_min = servo_vars[3]
        self.pan_servo_max = servo_vars[4]
        self.pan_servo_max = servo_vars[5]

    def left90(self):
        pass

    def right90(self):
        pass

    def left180(self):
        # servo_tile.write()
        # servo_left.write()
        pass

    def right180(self):
        # servo_tile.write()
        # servo_left.write()
        pass

    def mid(self):
        Turret.servo_tilt.write(self.tilt_servo_mid)

    def left(self):
        Turret.servo_pan.write(self.pan_servo_min)

    def right(self):
        Turret.servo_pan.write(self.pan_servo_max)

    def servo_demo(self):
        for move in [0, 90, 180, 90, 0]:
            servo_tilt.write(move)
            time.sleep(1)

        for move in [0, 90, 180, 90, 0]:
            servo_rotation.write(move)
            time.sleep(1)

    def write_pwm_pan(self, pwm_input, last_pwm_input):
        #for input in range 1097-1894, coef is 0.229 and 1097 should be substracted
        if (1090 < pwm_input < 1900):
            if (not ((last_pwm_input - 20) <= pwm_input <=
                     (last_pwm_input + 20))):
                Turret.servo_pan.write((pwm_input - 1097) * 0.229)
        else:
            print('Bad radio input')

    def write_pwm_tilt(self, pwm_input, last_pwm_input):
        # for input in range 1097-1894, coef is 0.229 and 1097 should be substracted
        if (1090 < pwm_input < 1900):
            if (not ((last_pwm_input - 20) <= pwm_input <=
                     (last_pwm_input + 20))):
                Turret.servo_tilt.write((pwm_input - 1097) * 0.229)
        else:
            print('Bad radio input')

    def home():
        # go to default pos
        pass
Esempio n. 3
0
FACE_DETECTION_STATUS_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(FACE_DETECTION_STATUS_PIN, GPIO.OUT)



### Setup of servo controls via arduino board ###

SERVO_X_ARDUINO_PIN = 8
SERVO_Y_ARDUINO_PIN = 9

try:
  connection = SerialManager()
  ArduinoApi(connection=connection)
  servo_x = Servo(SERVO_X_ARDUINO_PIN)
  servo_y = Servo(SERVO_Y_ARDUINO_PIN)

except Exception as e:
  print e
  sys.exit(0)



def create_video_stream():
  camera = picamera.PiCamera()
  camera.resolution = (320, 240)
  camera.framerate = 20
  camera.rotation = 180 # flip picture as camera is mounted upside-down

  v_stream = picamera.PiCameraCircularIO(camera, size=17000000)
Esempio n. 4
0
"""
An entire file for you to expand. Add methods here, and the client should be
able to call them with json-rpc without any editing to the pipeline.
"""
from nanpy import (Servo, ArduinoApi, SerialManager)
from time import sleep

lightsPin = 7
ledState = False

servo = Servo(9)
servo.write(0)

tempPin = 6

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

a.pinMode(lightsPin, a.OUTPUT)
a.pinMode(tempPin, a.OUTPUT)


def toggle_led(on):
    if on:
        a.digitalWrite(lightsPin, a.HIGH)
    else:
        a.digitalWrite(lightsPin, a.LOW)
servoPin = 3
angleInc = 45

currentAngle = 0

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

#Setup arduino pins like in arduino IDE

a.pinMode(buttonPin, a.INPUT)
servo = Servo(m)

try:
    while True:
        buttonState = a.digitalRead(buttonPin)
        print("Current Angle: {}".format(currentAngle))
        servo[currentServo].write(currentAngle)
        currentAngle += angleInc
        if currentAngle > 180:
            currentAngle = 0
        sleep(1)

except:
    print("Servo EXITING")
    servo.detach()
from nanpy import (ArduinoApi, SerialManager)
import serial  #for the sensor input function for the snsory control
from nanpy import Servo  # imort servo function
import time
import pyttsx  # For the speech synthesys function speaking function enable
import sklearn
import csv  # csv data communication
import progressbar  # Progress bar
import speech_recognition as sr
engine = pyttsx.init()
#voices = engine.getProperty('voices')
#for voice in voices:
#    engine.setProperty('voice',voice.id)
#   print voice.id
# Servo input function
servo = Servo(2)  # Finger 1
servo2 = Servo(3)  # Finger 2
servo3 = Servo(4)  # Finger 3
servo4 = Servo(5)  # Finger 4
servo5 = Servo(6)  # Finger 5
servo6 = Servo(9)  # Finger 6

try:
    Handfinger = SerialManager(
        '/dev/ttyACM0',
        115200)  # Hand serial checker and hand shake connection
    Handcontrol = ArduinoApi(connection=Handfinger)
    engine.say("Hardware serial connected 100 percent")
    engine.runAndWait()
    for i in progressbar.progressbar(range(100)):
        time.sleep(0.02)
Esempio n. 7
0
global speed
speed = 220
global spd
spd = 0
global target
target = 0
global rotating_speed
global flag
flag = 0
rotating_speed = 100
print 'a'
c = SerialManager(device='/dev/ttyACM0')
a = ArduinoApi(connection=c)
print 'b'
myservo = Servo( 17, connection = c)
dirA = 8
dirB = 10
pwmA = 9
pwmB = 11
stp = 2
dir = 3
MS1 = 4
MS2 = 5
EN  = 6
a.pinMode(stp, a.OUTPUT);
a.pinMode(dir, a.OUTPUT);
a.digitalWrite(MS1, a.HIGH);
a.digitalWrite(MS2, a.HIGH);
a.pinMode(EN, a.OUTPUT);
a.digitalWrite(EN, a.LOW)
Esempio n. 8
0
from mcpi import minecraft
from nanpy import Servo, SerialManager
import time

mc = minecraft.Minecraft.create()

def get_angle(pos_player, max_alt=180):
    angle = pos_player.y * (90.0/max_alt) + 90
    return int(angle)

connection = SerialManager(
    device='/dev/ttyACM0',
    rtscts=True
)
servo = Servo(
    7,
    connection=connection
)

while True:
    pos_player = mc.player.getPos()
    angle = get_angle(pos_player)
    servo.write(angle)
Esempio n. 9
0
from nanpy import (ArduinoApi, SerialManager)
from time import sleep

connection = SerialManager()
a = ArduinoApi(connection=connection)

from nanpy import Servo

MIN_PULSE_LENGTH = 1000
MAX_PULSE_LENGTH = 2000
motA = Servo(4)
motA.attached()
motA.writeMicroseconds(0)
val = input("Enter your value: ")


def min_throttle():
    print("Sending minimum throttle")
    motA.writeMicroseconds(MIN_PULSE_LENGTH)


def max_throttle():
    print("Sending maximum throttle")
    motA.writeMicroseconds(MAX_PULSE_LENGTH)


def test_run():
    print("Running test in 3 \n")
    sleep(1)
    print(" 2\n")
    sleep(1)
Esempio n. 10
0
sample_map = collections.OrderedDict((
    ('316', 1570 + 855),
    ('OREAS 74a', 1570 + 640),
    ('6063', 1570 + 420),
    ('NIST 2710a', 1570 + 222),
    ('PVC High', 1570),
    ('Gold Plating', 1570 - 230),
    ('PVC Low', 1570 - 450),
    ('304', 1570 - 670),
    ('Pure Gold', 1570 - 878)
))

connection = SerialManager(device='/dev/ttyUSB0')
a = ArduinoApi(connection=connection)
servo = Servo(3)
servo.writeMicroseconds(1570 + 855)

host = "0.0.0.0"
port = 7777

s = socket(AF_INET, SOCK_STREAM)
s.bind((host, port))
s.listen(5)
print("Sample Changer ready")

while True:
    print("Waiting for client...")
    q, addr = s.accept()

    print("Connected client: %s" % (addr, ))
import face_recognition
import cv2
import PIL
import struct
import redis
import numpy as np
import os
from nanpy import SerialManager
connection = SerialManager(device='/dev/ttyACM0')
from nanpy import Servo
import time
servo = Servo(7)
url = 'http://10.42.0.202:8080/video'
r = redis.Redis(host='localhost', port=6379, db=0)
os.chdir("/home/badboy17g/HackoHolics/Module_Loader/modules")
prev = 0


def fromRedis(r, n):
    encoded = r.get(n)
    h, w = struct.unpack('>II', encoded[:8])
    a = np.frombuffer(encoded, dtype=np.uint8, offset=8).reshape(h, w, 3)
    return a


while True:
    a = 0
    b = 0
    img = fromRedis(r, 'image')
    img = cv2.resize(img, (360, 200))
    cv2.imwrite('image.jpg', img)
Esempio n. 12
0
from time import sleep
from datetime import datetime
from sh import gphoto2 as gp
import signal, os, subprocess
from nanpy  import ArduinoApi, SerialManager
from nanpy import Servo

# Arduino
light_pin = 13
servo = Servo(7)


#shoot_date = datetime.now().strftime("%Y-%m-%d")
shoot_time = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
picID = "shol_"
frame_counter = 0
clear_cmd = ["--folder", "/store_00020001/DCIM/100CANON", "-R", "--delete-all-files"]
triger_cmd = ["--trigger-capture"]
download_cmd = [ "--get-all-files"]
row_format ="{:>33} {:>6} {:>15}" 
main_dir_name = picID + shoot_time # "shol_2020-02-15_15:32:03" # 
frame_name =  picID +  "{0:0=4d}".format(frame_counter) 
save_location = "/home/shooresh/sholapse/sholapse/images/" + main_dir_name

lighting_time = 14  # cieling(actual lighting time on the camera) + 1
frame_interval_time = 3600  # lighting_time + move_stack + move_stack back + move_frame + n = opperation_time < frame_interval_time, effective frame_interval_time -= opperation_time 


def kill_gphoto2_process():
    p = subprocess.Popen(["ps", "-A"], stdout=subprocess.PIPE)
    out, err = p.communicate()
Esempio n. 13
0
from time import sleep
from nanpy import Servo
from nanpy.arduinotree import ArduinoTree
from nanpy.i2c import I2C_Master
import logging
import math
import numpy as np
from nanpy.wire import Wire

connection = SerialManager()
a = ArduinoApi(connection=connection)
wire = Wire(connection=connection)

MIN_PULSE_LENGTH = 1000
MAX_PULSE_LENGTH = 2000
motA = Servo(0)
motB = Servo(0)
motC = Servo(0)
motD = Servo(0)

motA.attached()
motB.attached()
motC.attached()
motD.attached()

motA.writeMicroseconds(0)
motB.writeMicroseconds(0)
motC.writeMicroseconds(0)
motD.writeMicroseconds(0)

sleep(1)  # /*Give some delay, 7s, to have time to connect
Esempio n. 14
0
from nanpy import (ArduinoApi, SerialManager, Servo)
from time import sleep
import sys

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
    a.pinMode(13, a.OUTPUT)
    servo = Servo(9)

except:
    print("Can't connect to arduino")
    sys.exit(0)

try:
    while True:
        a.digitalWrite(13, a.HIGH)
        servo.write(90)
        sleep(0.1)
        a.digitalWrite(13, a.LOW)
        servo.write(80)
        sleep(0.1)

except Exception:
    a.digitalWrite(13, a.LOW)
    servo.write(90)
    sys.exit(0)
Esempio n. 15
0
    'direction': 4,
    'step': 5,
    'sleep': 6,
    'dispense': 3,
    'reset': 2,
    'photocell': 5,  # A5
    'limit': 7,
    'ms1': 9,
    'ms2': 10,
    'ms3': 12,
    'gate': 13
}

CONNECTION = SerialManager(device='/dev/ttyUSB0')
A = ArduinoApi(connection=CONNECTION)
SERVO = Servo(PINS['gate'])
JOBS = []
SCHED = sched.scheduler(time.time, time.sleep)


def toggle(a):
    time.sleep(SLEEP_TIME)  # .75
    if a.digitalRead(PINS['sleep']) == a.HIGH:
        print("Sleeping")
        a.digitalWrite(PINS['sleep'], a.LOW)
    elif a.digitalRead(PINS['sleep']) == a.LOW:
        print("Awake")
        a.digitalWrite(PINS['sleep'], a.HIGH)


def translate(a, ccw, steps):
Esempio n. 16
0
for i in range(6):
    number = "";
    try:
        number = int(input("Enter ServoPWM pin number: "))
    except:
        print("End of user input!")
        break
    servoPins.append(number)


#Setup arduino pins like in arduino IDE

servos = []
for i in range(len(servoPins)):
    servos.append(Servo(servoPins[i]))
    servos[i].write(0)

try:
    while True:
        try:
            while True:
                for i in range(len(servos)):
                    print("Current State: ",i,": ", servos[i].read())
        except KeyboardInterrupt:
            serv = input("What servo? : ")
            change = input("What change? : ")
            servos[serv].write(change)
            print("Changed!")
            
except:
Esempio n. 17
0
import numpy as np
import cv2
import scipy
import pandas as pd  # for the data function file
import csv  # the csv file writer for the data that keep on the system for learning function
from nanpy import (ArduinoApi, SerialManager
                   )  # Serial manager function for the hardware control
from nanpy import Servo
import serial
import os
import sys
import smbus  # i2c interface library on the rpi
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
# Sensor and the Actuator parameter
# Leg servo
Servo1 = Servo(2)
Servo2 = Servo(3)
Servo3 = Servo(4)
Servo4 = Servo(5)
# body rotation servo
Servo5 = Servo(8)
# tail tentacle movement of machanism function
Servo6 = Servo(9)  # X
Servo7 = Servo(10)  # Y
# Analog Sensors Reader sensing
Sensing1 = 0
Sensing2 = 0
Sensing3 = 0
Sensing4 = 0
# Angle Read potentiometer
AnglefrontLeft = 0
Esempio n. 18
0
import serial
import cv2  # Computer vision system function for the robotic arm
import time
Tk = Tkinter.Tk()
Tk2 = Tkinter.Tk()
Tk.geometry("1023x750")
Tk2.geometry('640x480')
#ser = serial.Serial("/dev/ttyUSB2",115200) # Serial communication for the sensor
#ser1 = serial.Serial("/dev/ttyUSB0",115200)
connection = SerialManager()
a = ArduinoApi(connection=connection)
Tk.title("Operating environment and Visionsystem reporter"
         )  # Operating control for the robotic arm
Tk2.title(
    "Mannual guild for robotic arm")  #Mannual guild line for the robotic arm
servo3e = Servo(3)
servo3u = Servo(4)
servo1u = Servo(5)
servo1e = Servo(8)
servo2u = Servo(9)
servo2e = Servo(10)
a.pinMode(11, a.OUTPUT)
a.pinMode(12, a.OUTPUT)
a.pinMode(2, a.OUTPUT)
a.pinMode(6, a.OUTPUT)
a.digitalWrite(11, a.HIGH)


def StepperFoward():
    a.digitalWrite(2, a.LOW)
    for i in range(0, 450, 1):
from nanpy import (ArduinoApi, SerialManager, Servo)
import urllib.request

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

counter = 0
servo = Servo(3)
link = "http://192.168.1.85:1337/"
f = urllib.request.urlopen(link)
servo.write(0)

while (True):
    f = urllib.request.urlopen(link)
    myfile = f.read()
    full_rot_bool = True

    if (full_rot_bool):
        servo.write(180)
        full_rot_bool = False

    else:
        servo.write(0)
        full_rot_bool = True
sleepTime = .5

servoPin = 3
buttonPin = 8
buttonState = 0
servoRun = servoIncriment

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

#Setup arduino pins like in arduino IDE

servo = Servo(servoPin)
a.pinMode(buttonPin, a.INPUT)
servo.write(0)

try:
    while True:
        buttonState = a.digitalRead(buttonPin)
        print(" Button State: {}".format(buttonState))
        if buttonState:
            if servoRun > 180:
                servoRun = 0
            servo.write(servoRun)
            print("Servo Runs to: {}".format(servoRun))
            servoRun += servoIncriment
            sleep(sleepTime)
        buttonState = False
numPins = len(servoPins)
currentServo = 0
currentAngle = 0
servo = []

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

#Setup arduino pins like in arduino IDE

a.pinMode(buttonPin, a.INPUT)
for m in servoPins:
    servo.append(Servo(m))

try:
    while True:
        buttonState = a.digitalRead(buttonPin)
        print(" Button State: {} Current Servo: {} Current Angle: {}".format(
            buttonState, currentServo, currentAngle))
        if buttonState:
            servo[currentServo].write(0)
            currentAngle = 0
            currentServo += 1
            if currentServo > numPins:
                currentServo = 0
            sleep(1)
        buttonState = False
        servo[currentServo].write(currentAngle)
Esempio n. 22
0
def main():

    # GPIO setup
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(FACE_DETECTION_STATUS_PIN, GPIO.OUT)

    # Serial connection setup (for the servos)
    connection = SerialManager()
    ArduinoApi(connection=connection)
    servo_x = Servo(SERVO_X_ARDUINO_PIN)
    servo_y = Servo(SERVO_Y_ARDUINO_PIN)

    # Threaded Video stream setup
    vs = create_video_stream(CAMERA_RESOLUTION, CAMERA_FRAMERATE,
                             CAMERA_ROTATION)
    camera_center = map(lambda x: x / 2,
                        CAMERA_RESOLUTION)  # from camera resolution

    # Face detection Haar cascade file
    face_cascade = cv2.CascadeClassifier(
        '/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml')

    # Initial pan-tilt angles
    angle_x = 90
    angle_y = 90
    servo_x.write(angle_x)
    servo_y.write(angle_y)

    def stop():
        vs.stop()
        GPIO.output(FACE_DETECTION_STATUS_PIN, False)
        GPIO.cleanup()
        connection.close()

    def exit_handler(signum, frame):
        stop()
        print "\nBye!"
        sys.exit(0)

    # Clean manual stop
    signal.signal(signal.SIGINT, exit_handler)

    while True:

        try:
            # grab the frame from the threaded video stream
            frame = vs.read()

            # Convert to grayscale
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

            # Look for faces in the image
            faces = face_cascade.detectMultiScale(gray, 1.5, 2)

            if faces is not ():
                # Display face detection on a led
                GPIO.output(FACE_DETECTION_STATUS_PIN, True)

                # Look for the biggest face
                biggest_face = get_biggest_face(faces)

                # Compute pan-tilt angle to adjust centring
                ax, ay = get_compensation_angle(biggest_face, camera_center,
                                                CAMERA_RESOLUTION,
                                                CAMERA_ANGLE_OF_VIEW)

                # Update angles values
                angle_x = angle_x + ax
                angle_y = angle_y + ay
                servo_x.write(angle_x)
                servo_y.write(angle_y)

            else:
                GPIO.output(FACE_DETECTION_STATUS_PIN, False)

        except Exception as e:
            print e
            stop()
            sys.exit(1)
Esempio n. 23
0
#!/user/bin/env python
# Author code: Mr.Chanapai Chuadchum 
# Describesion: Robotic Arm opensource 
import sys # import the system function
import numpy as np # Math for the analytic the matrix kinematrix
import math # The math for the calculation function of the kinematic framework
import scipy  # Function for the machinelearning learning from the csv file fun$
import csv # Record the map of the position movement
from nanpy import(ArduinoApi,SerialManager) # Robotic arm control serial functi$
from nanpy import Servo
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
               # Robotic Arm Sensory input and the control function
# Servo part for the robotic arm
servo3e = Servo(3)
servo3u = Servo(4)
servo1u = Servo(5)
servo1e = Servo(8)
servo2u = Servo(9)
servo2e = Servo(10)
          # Servo for the robotic wrist of the arm
servoWrist= Servo(43) # Wrist servo
servowristrotate = Servo(44) # Wrist rotate servo
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
try:
   connectionHand = SerialManager('/dev/ttyACM0',115200) # Serial manager funct$
   a = ArduinoApi(connection=connectionHand) # The connection hand function for$
except:
    print("Please check Serial Hand connection")
try:
   connectionBody = SerialManager('/dev/ttyACM1',115200) #Serial Mamnanger S
   b = ArduinoApi(connection=connectionBody) # The connection Body function for$
from nanpy import Servo
import time

#Setup

frHip = Servo(6) #hip
frKnee = Servo(5)#knee
frFoot = Servo(4)#foot

flHip = Servo(3) #hip
flKnee = Servo(2)#knee
flFoot = Servo(13)#foot

brHip = Servo(12) #hip
brKnee = Servo(11)#knee
brFoot = Servo(10)#foot

blHip = Servo(9) #hip
blKnee = Servo(8)#knee
blFoot = Servo(7)#foot


time.sleep(2)
print "Zeroing"



  #F +80                  #F -90
  #K +95                  #K -100
#Front left             #Front Right
  #K -95                  #K +100
Esempio n. 25
0
#!/usr/bin/env python

# Author: Andrea Stagi <*****@*****.**>
# Description: move a servo motor
# Dependencies: None

from nanpy import Servo
import time

servo = Servo(7)
for move in [0, 90, 180, 90, 0]:
    servo.write(move)
    time.sleep(1)
Esempio n. 26
0
from nanpy import Servo
import time

#Setup

frHip = Servo(6)  #hip
frKnee = Servo(5)  #knee
frFoot = Servo(4)  #foot

flHip = Servo(3)  #hip
flKnee = Servo(2)  #knee
flFoot = Servo(13)  #foot

brHip = Servo(12)  #hip
brKnee = Servo(11)  #knee
brFoot = Servo(10)  #foot

blHip = Servo(9)  #hip
blKnee = Servo(8)  #knee
blFoot = Servo(7)  #foot

# Zero
time.sleep(1)
print "Zeroing"

frHip.write(100)
frKnee.write(100)  #lower is forward
frFoot.write(90)  #lower is forward

flHip.write(100)
flKnee.write(95)  #lower is back
Esempio n. 27
0
import sox
import rospkg
from time import sleep
from std_msgs.msg import Bool
from std_msgs.msg import String
import os
from nanpy import ArduinoApi
from nanpy import SerialManager
from nanpy import Servo

import logging
logging.basicConfig(level=logging.DEBUG)
SERVO_PAN = 7
SERVO_TILT = 8
connection = SerialManager(device='/dev/ttyACM0')
panservo=Servo(SERVO_PAN)
tiltservo=Servo(SERVO_TILT)
panservo.write(40)
tiltservo.write(55)
sleep(1)
panservo.write(40)
tiltservo.write(55)
sleep(1)
panservo.write(40)
tiltservo.write(55)

r = sr.Recognizer()
rospack = rospkg.RosPack()
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
Esempio n. 28
0
     Shoulder.write(AngleShoulderoutput)
def Elbow(event):     
     AngleElbowoutput = math.degrees(math.acos(((math.pow(120,2)+math.pow(120,2))-(math.pow(x.get(),2)+math.pow(y.get(),2)))/(2*120*120))) #Elbow
     Elbow.write(AngleElbowoutput) 
def Wrist(event):
     AngleWristoutput = (180-(math.degrees(math.asin((z.get()+100)/120)))-(math.degrees(math.acos(((math.pow(120,2)+math.pow(120,2))-(math.pow(x.get(),2)+math.pow(y.get(),2)))/(2*120*120)))))
     Wrist.write(AngleWristoutput)
def WristRot(event):
     AngleWristRotoutput = WristsRots.write(WristRot.get())
     WristRot.write(AngleWristRotoutput)
def Gripper(event):
     AngleGripperoutput = Grippers.write(Gripper.get())
     Gripper.write(AngleGripperoutput)                    

       # Servo controller pin 
Bases = Servo(2) 
Shoulders = Servo(3)
Elbows = Servo(4)
WristRots = Servo(5)
Wrists = Servo(8)
Grippers = Servo(9)
Master = Tk()
# Base set scale
Base = Scale(Master,from_=0,to=180, orient=HORIZONTAL,command=RunServo)
Base.set(0)
Base.pack()
Shoulder = Scale(Master,from_=0,to=180, orient=HORIZONTAL,command=RunServo1)
Shoulder.set(0)
Shoulder.pack()
Elbow = Scale(Master,from_=0,to=180, orient=HORIZONTAL,command=RunServo2)
Elbow.set(0)
Esempio n. 29
-1
 def __init__(self):
     Thread.__init__(self)
     self.c = 1
     self.servo = Servo(12)