コード例 #1
0
def main():
    # Call the logs function to start logging.
    functions.logs()

    # Create the Updater and pass the bot token.
    updater = Updater(token=TOKEN, use_context=True)
    dispatcher = updater.dispatcher

    # Call the function that contains the handlers for the commands.
    functions.handlersProcess(updater, dispatcher)
コード例 #2
0
def main():
    # Call the logs function to start logging.
    functions.logs()

    # Create the Updater and pass the bot token.
    f = open("TOKEN", "r")
    TOKEN=f.readline().rstrip()
    f.close()
    updater = Updater(token=TOKEN, use_context=True)
    dispatcher = updater.dispatcher

    # Call the function that contains the handlers for the commands.
    functions.handlers(updater, dispatcher)
コード例 #3
0
ファイル: main.py プロジェクト: aniolm9/TheMistressBot
def main():
    # Call the logs function to start logging.
    functions.logs()

    # Create the Updater and pass the bot token.
    updater = Updater(token=TOKEN)
    dispatcher = updater.dispatcher
    jobqueue = updater.job_queue

    # Call the function that controls the jobs.
    functions.jobsManager(jobqueue)

    # Call the function that contains the handlers for the commands.
    functions.handlersProcess(updater, dispatcher)
コード例 #4
0
def error(update, context):
    logger = functions.logs()
    logger.warning('Update "%s" caused error "%s"', update, context.error)
コード例 #5
0
def drink(s, num, homepos, timelog, countlog, freqlog, commandlog, positionlog,
          keylog, keytimelog):
    #レーザーを床に撃つ:3
    #ws.Beep(1000, 300)
    #num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num, timelog, countlog, freqlog, commandlog)
    """
    #進行方向調整
    theta0 = MeasureTheta(homepos[2])
    print "theta0:", theta0

    DisToTable = MeasureDistance(1.2, 1)
    print "DisToTable:", DisToTable
    """
    """
    #前進:4
    time.sleep(2.0)
    ws.Beep(1000, 300)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num, timelog, countlog, freqlog, commandlog)
    
    m.moveTo(1.4, 0.0, 0.0, 8.0)
    time.sleep(2.0)
    
    positionlog.append(l.getRobotPosition(True))
    #position = l.getRobotPosition(True)
    print "position:", positionlog
    """

    #肩調節の姿勢へ:6
    ws.Beep(1000, 300)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num, timelog, countlog, freqlog, commandlog)

    position = l.getRobotPosition(True)
    positionlog.append(l.getRobotPosition(True))
    #print "position2:", positionlog[2]

    #------------------肩調節----------------------------------

    ThetaDis = Aiming(position[2], s, num, timelog, countlog, freqlog,
                      commandlog, keylog, keytimelog, positionlog)

    #------------手首調節開始:11----------------------
    time.sleep(1.0)
    ws.Beep(1000, 300)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num)

    #----------------つかむ準備姿勢:14-----------------------
    #ws.Beep(1000, 300)
    #num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num)
    m.setAngles(jointnames, pos.Rsearch_curtain, 0.2)
    time.sleep(2.0)

    SPERDis = ReachingPet(ThetaDis[1])

    #手を伸ばす
    m.setAngles([jointnames[6], jointnames[9], jointnames[10], jointnames[11]],
                [SPERDis[0], SPERDis[1], -0.5, 1.0], 0.2)
    time.sleep(1.5)

    #手を下ろす
    SPtheta2 = SPERDis[0] + 0.65
    print "SPtheta2:", SPtheta2

    m.setAngles(jointnames[6], SPtheta2, 0.05)
    time.sleep(3.0)

    #持ち上げる
    m.setAngles([jointnames[9], jointnames[10], jointnames[11]],
                [1.0, 1.0, 0.0], 0.05)
    time.sleep(3.0)
    m.setAngles([jointnames[6], jointnames[9]], [1.0, 1.5], 0.1)
    time.sleep(1.0)

    #近づいた分戻って補正:18
    ws.Beep(1000, 300)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    #num = timer(num)

    #m.moveTo(-d2*math.cos(theta1[0]), -d2*math.sin(theta1[0]), 0.0)
    m.moveTo(-SPERDis[2], 0.0, 0.0)

    m.moveTo(0.0, 0.0, -(l.getRobotPosition(True)[2] - homepos[2]))

    time.sleep(2.0)

    #回転の補正
    #m.moveTo(0.0, 0.0, -theta1)
    #m.moveTo(0.0, 0.0, (position1[2]-position[2])+math.radians(3.3))
    #position = l.getRobotPosition(True)
    #print position
    #併進移動の補正
    #m.moveTo(position1[0]-position[0], position1[1]-position[1], 0.0)
    #position = l.getRobotPosition(True)
    #print (position)

    #終了
    ws.Beep(1000, 300)
    time.sleep(1.0)
    ws.Beep(1000, 300)
    time.sleep(1.0)
    ws.Beep(1000, 700)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)

    #csvファイルへ書き込み
    now = datetime.datetime.now()
    filename = "log" + now.strftime("%Y%m%d%H%M%S") + ".csv"
    with open(filename, "w") as f:
        writer = csv.writer(f, lineterminator="\n")
        writer.writerow(commandlog)
        writer.writerow(timelog)
        writer.writerow(countlog)
        writer.writerow(freqlog)
        writer.writerow(keylog)
        writer.writerow(keytimelog)

    del commandlog[1:]
    del timelog[1:]
    del countlog[1:]
    del freqlog[1:]
    del keylog[1:]
    del keytimelog[1:]
コード例 #6
0
def Aiming(PosTheta, s, num, timelog, countlog, freqlog, commandlog, keylog,
           keytimelog, positionlog):
    frag = 0

    m.setAngles(jointnames, pos.b2, 0.2)
    time.sleep(2.0)

    ws.Beep(1000, 300)
    num = func.logs(s, num, timelog, countlog, freqlog, commandlog)
    keylog.append("start")
    keytimelog.append(time.time() - s)

    print("command 0:OK, 2:down, 4:left, 5:stop, 6:right, 8:up")

    while (1):
        x = g()  #デバッグ用
        """
        x = DB.toPepper
        time.sleep(delay)
        idx = DB.toPepper
        if(x != idx):   #一瞬だけ出力されるような間違ったコマンドを排除
            continue
        """
        if (str(x) == "2"):  #右 5の次に入力すると停止 4の次に入力すると掴みに行く
            keylog.append(x)
            keytimelog.append(time.time() - s)
            num = func.logs(s, num, timelog, countlog, freqlog, commandlog)

            if (frag == 0 or frag == 2):
                print "right", x
                m.moveToward(0.0, 0.0, -0.1)
                frag = 2

            elif (frag == 5):
                print "stop", x
                m.moveToward(0.0, 0.0, 0.0)
                frag = 0

            elif (frag == 1):
                print "stop", x
                frag = 9

        elif (str(x) == "5"):  #左 2の次に入力すると停止
            keylog.append(x)
            keytimelog.append(time.time() - s)
            num = func.logs(s, num, timelog, countlog, freqlog, commandlog)

            if (frag == 0 or frag == 5):
                print "left", x
                m.moveToward(0.0, 0.0, 0.1)
                frag = 5

            elif (frag == 2):
                print "stop", x
                m.moveToward(0.0, 0.0, 0.0)
                frag = 0

        elif (str(x) == "3"):  #上 4の次に入力すると停止
            keylog.append(x)
            keytimelog.append(time.time() - s)
            num = func.logs(s, num, timelog, countlog, freqlog, commandlog)

            if (frag == 1 or frag == 3):
                print "up", x
                m.setAngles(jointnames[10], -1.5, 0.01)
                frag = 3

            elif (frag == 4):
                print "stop", x
                phi = m.getAngles(jointnames[10], False)[0]
                m.setAngles(jointnames[10], phi, 0.5)
                Distance = (0.05 * math.cos(math.radians(phi * 60)) +
                            0.1) / math.tan(math.radians(
                                phi * 60)) + 0.05 * math.sin(
                                    math.radians(phi * 60)) + 0.06
                frag = 1

        elif (str(x) == "4"):  #下 3の次に入力すると停止 2or5の次に入力するとレーザーを横に
            keylog.append(x)
            keytimelog.append(time.time() - s)
            num = func.logs(s, num, timelog, countlog, freqlog, commandlog)

            if (frag == 1 or frag == 4):
                print "down", x
                m.setAngles(jointnames[10], 1.5, 0.01)
                frag = 4

            elif (frag == 3):
                print "stop", x
                phi = m.getAngles(jointnames[10], False)[0]
                m.setAngles(jointnames[10], phi, 0.5)
                Distance = (0.05 * math.cos(math.radians(phi * 60)) +
                            0.1) / math.tan(math.radians(
                                phi * 60)) + 0.05 * math.sin(
                                    math.radians(phi * 60)) + 0.06
                frag = 1

            elif (frag == 0):
                print "change", x
                m.setAngles([jointnames[8], jointnames[10]], [0.0, 1.0], 0.2)
                frag = 1

        else:
            if (frag == 9):
                break
            print "no input", x

    Theta = 0
    return [Theta, Distance]