Beispiel #1
0
    def testtxrx(self):
        [smnr, mtrn] = prop.serialcomm()

        print 'Testing serial comm'
        mtrn.write('D')
        smnr.write('D')

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        print "Tilt down"
        smnr.write('T')
        time.sleep(3)
        print "Go back"
        smnr.write('G')
        time.sleep(3)
        print "Pan Left"
        smnr.write('H')
        time.sleep(3)
        print "Pan Right"
        smnr.write('F')
        time.sleep(3)
        print "Go back"
        smnr.write('G')

        for i in range(1, 10000):
            mtrn.write('A1200')
            smnr.write('S')

            rsp = mtrn.read(250)
            rsp = smnr.read(250)

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port
        print "Done"
Beispiel #2
0
    def testunplugged(self):
        raw_input("Unplug the boards.")

        [smnr, mtrn] = prop.serialcomm()

        self.assertEqual(smnr, None)
        self.assertEqual(mtrn, None)
Beispiel #3
0
    def testunplugged(self):
        raw_input("Unplug the boards.")

        [smnr, mtrn] = prop.serialcomm()

        self.assertEqual(smnr,None)
        self.assertEqual(mtrn,None)
Beispiel #4
0
def doserial():
    retries = 1
    ssmr = None
    mtrn = None
    while (retries < 5):
        try:
            if system_platform == "Darwin":
                [ssmr, mtrn] = prop.serialcomm('/dev/cu.usbmodem14101')
            else:
                [ssmr, mtrn] = prop.serialcomm()
            print 'Connection established'
            return [ssmr, mtrn]
        except Exception as e:
            print 'Error while establishing serial connection.'
            retries = retries + 1

    return [ssmr, mtrn]
Beispiel #5
0
    def test(self):
        [smnr, mtrn] = prop.serialcomm()
        print smnr.read(250)
        print mtrn.read(250)

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        self.assertEqual(whoisthis(smnr)[0:4], 'SSMR')
        self.assertEqual(whoisthis(mtrn)[0:4], 'MTRN')

        smnr.close()
        mtrn.close()
Beispiel #6
0
    def test(self):
        [smnr, mtrn] = prop.serialcomm()
        print smnr.read(250)
        print mtrn.read(250)


        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        self.assertEqual(whoisthis(smnr)[0:4],'SSMR')
        self.assertEqual(whoisthis(mtrn)[0:4],'MTRN')

        smnr.close()
        mtrn.close()
Beispiel #7
0
def doserial():
    retries = 1
    ssmr = None
    mtrn = None
    while (retries < 5):
        try:
            [ssmr, mtrn] = prop.serialcomm()
            print 'Connection established'
            return [ssmr, mtrn]
        except Exception as e:
            print 'Error while establishing serial connection.'
            retries = retries + 1

    return [ssmr, mtrn]
Beispiel #8
0
    def testtxrx(self):
        [smnr, mtrn] = prop.serialcomm()

        print 'Testing serial comm'
        mtrn.write('D')
        smnr.write('D')

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        for i in range(1, 10000):
            mtrn.write('A1200')
            smnr.write('S')

            rsp = mtrn.read(250)
            rsp = smnr.read(250)

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port
        print "Done"
Beispiel #9
0
    def testtxrx(self):
        [smnr, mtrn] = prop.serialcomm()
        
        print 'Testing serial comm'
        mtrn.write('D')
        smnr.write('D')

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        for i in range(1,10000):
            mtrn.write('A1200')
            smnr.write('S')

            rsp = mtrn.read(250)
            rsp = smnr.read(250)
            
        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port
        print "Done"
Beispiel #10
0
    def testtxrx(self):
        [smnr, mtrn] = prop.serialcomm()
        
        print 'Testing serial comm'
        mtrn.write('D')
        smnr.write('D')

        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port

        print "Tilt down"
        smnr.write('T')
        time.sleep(3)
        print "Go back"
        smnr.write('G')
        time.sleep(3)
        print "Pan Left"
        smnr.write('H')
        time.sleep(3)
        print "Pan Right"
        smnr.write('F')
        time.sleep(3)
        print "Go back"
        smnr.write('G')
        

        for i in range(1,10000):
            mtrn.write('A1200')
            smnr.write('S')

            rsp = mtrn.read(250)
            rsp = smnr.read(250)
            
        print "SMNR Serial Port:", smnr.port
        print "MTRN Serial Port:", mtrn.port
        print "Done"
Beispiel #11
0
                self.sensors = new_values
                #self.f.write( str(new_values[0]) + ' ' + str(new_values[1]) + ' ' + str(new_values[2]) + ' ' + str(new_values[3]) + ' ' + str(new_values[4]) + ' ' + str(new_values[5]) + ' ' + str(new_values[6]) + ' ' + str(new_values[7]) + ' ' + str(new_values[8]) + ' ' + str(new_values[9]) + ' ' + str(new_values[10]) + ' ' + str(new_values[11]) + ' ' + str(new_values[12]) + ' ' +  str(new_values[13]) + ' ' + str(new_values[14]) + '\n')
                self.f.write(' '.join(map(str, new_values)) + '\n')
                return new_values

    def close(self):
        self.f.close()
        self.sock.close()

    def restart(self):
        self.close()
        self.start()


if __name__ == "__main__":
    [ssmr, mtrn] = prop.serialcomm('/dev/cu.usbmodem1421')

    # Weird, long values (4) should go first.
    #sensorimotor = Sensorimotor('motorneuron',26,'hhffffhhh')
    sensorimotor = Sensorimotor('sensorimotor', 52, 'ffffffhhhhhhhhhhhhhh')
    sensorimotor.ip = sys.argv[1]
    sensorimotor.start()
    sensorimotor.cleanbuffer(ssmr)

    while True:
        sens = sensorimotor.picksensorsample(ssmr)
        mots = None
        sensorimotor.sensorlocalburst = 10000
        sensorimotor.sensorburst = 10
        if (sens != None):
            sensorimotor.send(sensorimotor.data)
Beispiel #12
0
from struct import *
import os

import socket
import sys

import Proprioceptive as prop

import Configuration

from Fps import Fps

import SensorimotorLogger as Senso

if __name__ == "__main__":
    [ssmr, mtrn] = prop.serialcomm()

    # Weird, long values (4) should go first.
    #sensorimotor = Sensorimotor('motorneuron',26,'hhffffhhh')
    sensorimotor = Senso.Sensorimotor('sensorimotor',16,'fffhh')
    sensorimotor.sensorlocalburst=100
    sensorimotor.sensorburst=10
    sensorimotor.updatefreq=10
    sensorimotor.ip = sys.argv[1]
    sensorimotor.start()
    sensorimotor.init(ssmr)
    print (sensorimotor.mapping)
    print (sensorimotor.length)
    sensorimotor.cleanbuffer(ssmr)

    fps = Fps()
    def sendsensorsample(self, smnr, mtrn):
        # read  Embed this in a loop.
        self.counter=self.counter+1
        if (self.counter>500):
            smnr.write('P')
            smnr.write('S')
            self.counter=0
        myByte = smnr.read(1)
        if myByte == 'S':
          data = smnr.read(38)
          myByte = smnr.read(1)
          if myByte == 'E':
              # is  a valid message struct
              new_values = unpack('ffffffhhhhhhh', data)
              print new_values
              sent = self.sock.sendto(data, self.server_address)
              self.f.write( str(new_values[6]) + ' ' + str(new_values[7]) + ' ' + str(new_values[8]) + '\n')

    def close(self):
        self.f.close()

if __name__ == "__main__":
    [smnr, mtrn] = prop.serialcomm()

    sensorimotor = Sensorimotor()
    sensorimotor.start()
    sensorimotor.cleanbuffer(smnr,mtrn)

    while True:
        sensorimotor.sendsensorsample(smnr,mtrn)
Beispiel #14
0
# Shinkeybot truly does nothing until it gets the remote controlling connection
print 'Multicasting my own IP address:' + myip
while True:
    noticer.send()
    try:
        data, address = sock.recvfrom(1)
        if (len(data)>0):
            break
    except:
        data = None

# Open connection to tilt sensor.
hidraw = prop.setupsensor()
# Open serial connection to MotorUnit and Sensorimotor Arduinos.
[ssmr, mtrn] = prop.serialcomm()

# Instruct the Sensorimotor Cortex to stop wandering.
ssmr.write('C')

tgt = -300
wristpos=48

elbowpos = 150

# Pan and tilt
visualpos = [90,95]

sensesensor = 0

# Connect remotely to any client that is waiting for sensor loggers.
Beispiel #15
0
            self.data = readsomething(ser, self.length)
            myByte = readsomething(ser, 1)
            if len(myByte) >= 1 and myByte == 'E':
                # is  a valid message struct
                #new_values = unpack('ffffffhhhhhhhhhh', data)
                new_values = unpack(self.mapping, self.data)
                #print new_values
                self.sensors = new_values
                #self.f.write( str(new_values[0]) + ' ' + str(new_values[1]) + ' ' + str(new_values[2]) + ' ' + str(new_values[3]) + ' ' + str(new_values[4]) + ' ' + str(new_values[5]) + ' ' + str(new_values[6]) + ' ' + str(new_values[7]) + ' ' + str(new_values[8]) + ' ' + str(new_values[9]) + ' ' + str(new_values[10]) + ' ' + str(new_values[11]) + ' ' + str(new_values[12]) + ' ' +  str(new_values[13]) + ' ' + str(new_values[14]) + '\n')
                self.f.write(' '.join(map(str, new_values)) + '\n')
                return new_values

    def close(self):
        self.f.close()
        self.sock.close()

    def restart(self):
        self.close()
        self.start()


if __name__ == "__main__":
    [smnr, mtrn] = prop.serialcomm()

    sensorimotor = Sensorimotor()
    sensorimotor.start()
    sensorimotor.cleanbuffer(smnr)

    while True:
        sensorimotor.sendsensorsample(smnr)