예제 #1
0
def GetData():
    BFRMR1serialport.sendserial([255, 255, GETDATA, 0, 0, 0, 0, 0])  # send command to get sensor data from robot
    while True:
        a = BFRMR1serialport.getserial(10)  # wait here until data is received to confirm command complete
        if a is not None:
            break
    return a  # return data packet
예제 #2
0
def RobotMove(direction, encodercount, speed, SonarThreshold, IRThreshold):

    # 3.4 degrees = 1 encoder count for a turn
    BFRMR1serialport.sendserial(
        [255, 255, direction, encodercount, speed, SonarThreshold, IRThreshold, 0]
    )  # send command to move head
    while True:
        a = BFRMR1serialport.getserial(10)  # wait here until data is received to confirm command complete
        if a is not None:
            break

    return a  # return data packet
예제 #3
0
def SonarScan(Tilt, StartAngle, EndAngle, Steps, Speed):
    print "Sonar Scan"
    ServoStart = int(128 - (StartAngle * 1.45))  # convert from angle to value between 0 and 255
    ServoEnd = int(128 - (EndAngle * 1.45))  # convert from angle to value between 0 and 255
    ServoTilt = int(128 + (Tilt * 1.45))  # convert from angle to value between 0 and 255
    BFRMR1serialport.sendserial(
        [255, 255, SONARSCAN, ServoTilt, ServoStart, ServoEnd, Steps, Speed]
    )  # send command to start sonar scan
    while True:
        a = BFRMR1serialport.getserial(Steps + 2)  # wait here until data is received to confirm command complete
        if a is not None:
            break
    return a  # return data packet
예제 #4
0
def HeadMove(pan, tilt, speed):

    panservovalue = int(128 - (pan * 1.45))  # convert from angle to value between 0 and 255
    tiltservovalue = int(128 + (tilt * 1.45))
    if speed <= 10:
        BFRMR1serialport.sendserial(
            [255, 255, HEADMOVE, panservovalue, tiltservovalue, speed, 0, 0]
        )  # send command to move head
        while True:
            a = BFRMR1serialport.getserial(10)  # wait here until data is received to confirm command complete
            if a is not None:
                break
        return a  # return data packet
    else:
        print "Speed out of range. Value should be between 0 and 10"
예제 #5
0
def PlayTone(toneselection):
    BFRMR1serialport.sendserial([255, 255, PLAYTONE, toneselection, 0, 0, 0, 0])  # send command to play a tone
    return