Esempio n. 1
0
def car():
    op = request.form['op']
    if not op:
        return jsonify(status='400', mesg='no op.')
    else:
        move(op)
        return jsonify(status='200', mesg=op)
Esempio n. 2
0
File: board.py Progetto: gamda/chess
def main():
    z = board()
    m = move((e,2),(e,4))#move pawn
    z.makeMove(m)
    m = move((c,7),(c,5))# move pawn
    z.makeMove(m)
    print z.gameState()
Esempio n. 3
0
def move_and_add():

	move()	

	i = 0

	while i < 3:

		if global_variables.place_holder[i] > 0:

			if global_variables.place_holder[i] == global_variables.place_holder[i + 1]:

				global_variables.place_holder[i] += global_variables.place_holder[i + 1]

				global_variables.score += global_variables.place_holder[i]

				global_variables.place_holder[i + 1] = 0

				i += 2

			else:

				i += 1

		elif global_variables.place_holder[i] == 0:

			i +=2

	move()
Esempio n. 4
0
	def keepDisProcessing(self):
		print('keepDistanceProcessing')
		distanceGet = ultra.checkdist()
		if distanceGet > (self.rangeKeep/2+0.1):
			move.move(100, 'forward', 'no', 0.5)
		elif distanceGet < (self.rangeKeep/2-0.1):
			move.move(100, 'forward', 'no', 0.5)
		else:
			move.motorStop()
Esempio n. 5
0
    def run(self):
        print("Start FPV thread:" + self.name)
        step = 1
        while 1:
            # print(self.moving,":",self.speed, ":", self.command)
            if self.moving:
                move.move(step, self.speed, self.command)
                step += 1
                if step > 4:
                    step = 1
                time.sleep(0.08)

        print("退出线程:" + self.name)
Esempio n. 6
0
def main():
    #write the main function here that calls a forward kinematic function

    #input taken from user for 7 joint angles
    theta1 = float(input('Please enter a value joint 1 \n'))
    theta2 = float(input('Please enter a value joint 2 \n'))
    theta3 = float(input('Please enter a value joint 3 \n'))
    theta4 = float(input('Please enter a value joint 4 \n'))
    theta5 = float(input('Please enter a value joint 5 \n'))
    theta6 = float(input('Please enter a value joint 6 \n'))
    theta7 = float(input('Please enter a value joint 7 \n'))

    #compute the final pose using these 7 joint values
    T_1in0 = forward_kin(theta1, theta2, theta3, theta4, theta5, theta6,
                         theta7)

    #get the vrep clientID to communicate with vrep
    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
    if clientID == -1:
        raise Exception('Failed connecting to remote API server')

    #get the object handle for the dummy object
    result, dummy = vrep.simxGetObjectHandle(clientID, 'Dummy',
                                             vrep.simx_opmode_blocking)
    if result != vrep.simx_return_ok:
        raise Exception('could not get object handle for first joint')

    #compute euler angles to orient the dummy object using the rotation matrix embedded in T_1in0
    euAngle1 = -m.asin(T_1in0[2][0])
    euAngle2 = m.atan2(T_1in0[2][1] / m.cos(euAngle1),
                       T_1in0[2][2] / m.cos(euAngle1))
    euAngle3 = m.atan2(T_1in0[1][0] / m.cos(euAngle1),
                       T_1in0[0][0] / m.cos(euAngle1))

    print('\n Euler angles:', euAngle1, euAngle2, euAngle3, '\n')

    #set the position and orientation of a dummy object to the computed orientation and position of end effector
    # to verify the computation
    vrep.simxSetObjectOrientation(clientID, dummy, -1,
                                  [euAngle1, euAngle2, euAngle3],
                                  vrep.simx_opmode_oneshot)
    time.sleep(2)
    vrep.simxSetObjectPosition(clientID, dummy, -1,
                               [T_1in0[0][3], T_1in0[1][3], T_1in0[2][3]],
                               vrep.simx_opmode_oneshot)
    time.sleep(2)

    # move sawyer with the given theta inputs
    move(theta1, theta2, theta3, theta4, theta5, theta6, theta7)
Esempio n. 7
0
def main():
    # nomal array
    Data=[\
        [[0],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
        [[3],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
        [[4],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
    ]

    # numpy array
    npData=np.array([\
        [[1],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
        [[2],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
        [[5],[20.0,0.1],[20.0,0.1],[20.0,0.1]],\
    ])

    # class move(LEG_SERVOS=3, port='/dev/ttyS0', rate=115200)
    servo = move()
    try:
        # 従来型(file)
        servo.Action('zero.csv', 1.0)
        # 配列(普通の)
        print Data
        servo.Action(Data)
        # 配列(numpy)
        servo.Action(npData)
    except KeyboardInterrupt:
        servo.Close()
    time.sleep(1.0)
    servo.Close()
Esempio n. 8
0
def best_move(state, turn, depth):
    idx = 0
    if (turn == mv.NORTH_TURN):
        if (state.checkAllNorthHouseEmpty()):
            idx = mv.INVALID_INDEX
    else:
        if (state.checkAllSouthHouseEmpty()):
            idx = mv.INVALID_INDEX
    if idx == mv.INVALID_INDEX:
        return idx

    max_value = -9999
    if turn == mv.SOUTH_TURN:
        init = 0
    else:
        init = 8
    for i in range(init, init + 7):
        if state.board[i] != 0:
            next_state, next_turn = mv.move(state, turn, i)
            value = minimax(next_state, next_turn, depth - 1, turn, -999, 999,
                            turn)
            if max_value <= value:
                max_value = value
                idx = i
    return idx
    def ball_dust(self):
        self.ball_check_fg = 0
        servo = move()
        #demo_action

        for i in xrange(16):
            temp_str = "stand_up_normal/test" + str(i) + ".csv"
            servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_04/test" + str(j) + ".csv"
                servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_02/test" + str(j) + ".csv"
                servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_06/test" + str(j) + ".csv"
                servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_05/test" + str(j) + ".csv"
                servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_02/test" + str(15 - j) + ".csv"
                servo.Action(temp_str, 0.01)
        for i in xrange(2):
            for j in xrange(16):
                temp_str = "motion_07/test" + str(15 - j) + ".csv"
                servo.Action(temp_str, 0.01)

        servo.Action('Ball/BallDust.csv', 1.0)
        servo.Close()
Esempio n. 10
0
 def ball_catch(self):
     self.ball_check_fg = 0
     servo = move()
     servo.Action('Ball/BallCatch.csv', 1.0)
     servo.Close()
     if self.tof.ReadDistance() == 2:
         self.ball_check_fg = 1
Esempio n. 11
0
    def player_2_move(self, dt):
        if (self.Board.checkAllHouseEmpty()):
            self.add_win_lay()

        if (self.Board.checkAllNorthHouseEmpty()):
            self.Turn = m.SOUTH_TURN
            if (self.Mode == "MvR"):
                Clock.schedule_once(self.player_1_bot_move, DELAY_TIME)
        else:
            if (self.Mode == "RvP" or self.Mode == "MvR"):  #random bot
                bot_move = randombot.random_move(self.Board, self.Turn)
            else:  #minimax bot
                bot_move = minimax.best_move(self.Board, self.Turn,
                                             self.Difficulty)

            print("Player 2 move: " + str(bot_move))
            self.Board, self.Turn = m.move(self.Board, m.NORTH_TURN, bot_move)
            self.set_turn_lbl(self.Turn)
            self.draw_board()

            if (self.Board.checkAllHouseEmpty()):
                self.add_win_lay()
            else:
                if (self.Turn == m.NORTH_TURN):
                    Clock.schedule_once(self.player_2_move, DELAY_TIME)
                elif (self.Mode == "MvR"):
                    Clock.schedule_once(self.player_1_bot_move, DELAY_TIME)
                elif ((self.Mode == "MvP" or self.Mode == "RvP")
                      and self.Board.checkAllSouthHouseEmpty()):
                    self.Turn = m.NORTH_TURN
                    Clock.schedule_once(self.player_2_move, DELAY_TIME)
Esempio n. 12
0
    def player_1_move(self, hole_id):
        if (self.Board.checkAllHouseEmpty()):
            self.add_win_lay()

        if (self.Board.checkAllSouthHouseEmpty()):
            self.Turn = m.NORTH_TURN
            Clock.schedule_once(self.player_2_move, DELAY_TIME)
        else:
            if ((self.Mode == "MvP" or self.Mode == "RvP")
                    and self.Turn == m.SOUTH_TURN
                    and self.Board.board[hole_id] != 0):  #player move
                if (hole_id < 7):
                    self.Board, self.Turn = m.move(self.Board, m.SOUTH_TURN,
                                                   hole_id)

            print("Player 1 move: " + str(hole_id))
            self.set_turn_lbl(self.Turn)
            self.draw_board()

            if (self.Board.checkAllHouseEmpty()):
                self.add_win_lay()
            else:
                if (self.Turn != m.SOUTH_TURN):
                    Clock.schedule_once(self.player_2_move, DELAY_TIME)
                elif (self.Board.checkAllSouthHouseEmpty()):
                    self.Turn = m.NORTH_TURN
                    Clock.schedule_once(self.player_2_move, DELAY_TIME)
Esempio n. 13
0
def min(brd, aa= -64, depth=10, best=()):
    if depth == 0:
        return ((), calc(brd))
    val = 64
    bestmove = ()
    moves = brd.getMove(brd.w)
    if len(moves) == 0:
       return (bestmove, 64) 
    if best:
        moves.append(best)
    for i in range(len(moves)-1, -1, -1):
        if best and i < len(moves)-1 and moves[i] == best:
            continue;
        w = move(moves[i][0], moves[i][1], brd.w)
        tmp = Brd(brd.b, w)
        Rule.refresh(moves[i][1], tmp.w, tmp.b, tmp)
        response = max(tmp, val, depth - 1, best=())[1]
        if response < aa:
            bestmove = moves[i]
            val = response
            break
        if response < val:
            bestmove = moves[i]
            val = response
    if val == 64: #white lose anyway
        bestmove = moves[0]
    return (bestmove, val)     
Esempio n. 14
0
def max(brd, bb=64, depth=10, best=()):
    if depth == 0:
        return ((), calc(brd))  
    bestmove = () 
    val = -64  
    moves = brd.getMove(brd.b)
    if len(moves) == 0:
       return (bestmove, -64) 
    if len(best) > 0:
        moves.append(best)
    for i in range(len(moves)-1, -1, -1):
        if best and i < len(moves)-1 and moves[i] == best:
            continue;
        b = move(moves[i][0], moves[i][1], brd.b)
        tmp = Brd(b, brd.w)
        Rule.refresh(moves[i][1], tmp.b, tmp.w, tmp)
        response = min(tmp, val, depth - 1, best=())[1]
        if response > bb:
            bestmove = moves[i]
            val = response
            break;
        if response > val:
            bestmove = moves[i]
            val = response
    if val == -64: #black lose anyway
        bestmove = moves[0]
    return (bestmove, val)
Esempio n. 15
0
def mainAct(pl):
    clear()
    choice = pMenu([
        'hunt',
        'move',
        'heal',
        'party',
        'shop',
        'dex',
        'bank',
        pl.name,
        'save',
        'leave',
    ])
    if choice == 'hunt':
        if not pl.countawake():
            clear()
            print pl.name + ' is out of usable pokemon!'
            xxx = raw_input('\n\npress enter')
        else:
            hunt(pl)
    if choice == 'party':
        party(pl)
    if choice == pl.name:
        clear()
        print 'Status\n\n'
        print pl.name + '   $' + str(pl.money)
        for bt in pl.balls:
            if pl.balls[bt] > 0:
                print bt + ': ' + str(pl.balls[bt])
        print '\n'
        raw_input('enter to return')
        return 0
    if choice == 'shop':
        shop(pl)
    if choice == 'heal':
        heal(pl)
    if choice == 'dex':
        dexui(pl)
    if choice == 'bank':
        bank(pl)
    if choice == 'save':
        save(pl)
    if choice == 'leave':
        return 1
    if choice == 'move':
        move(pl)
Esempio n. 16
0
 def stand_up_before_turn(self, direction):
     servo = move()
     for i in xrange(16):
         if direction == 'r':
             temp_str = 'stand_before_turn_right/test' + str(i) + '.csv'
         if direction == 'l':
             temp_str = 'stand_before_turn_left/test' + str(i) + '.csv'
         servo.Action(temp_str, 0.01)
Esempio n. 17
0
def worker(move_lock,last_updated,q):
  global curr4, curr17
  while 1:
    dire = q.get()
    move_lock.acquire()
    curr4.value, curr17.value = move(curr4.value, curr17.value, dire)
    move_lock.release()
    last_updated.value = time()
Esempio n. 18
0
File: chess.py Progetto: gamda/chess
def movePiece(Board, currentGame, connection):
    nxtMove = move(currentGame.startPos, currentGame.endPos)
    if Board.makeMove(nxtMove):
        currentGame.waitingForPromotion = Board.canPromote()
        if currentGame.networkGame:
            connection.sendto(pickle.dumps(nxtMove), currentGame.connectTo)
        currentGame.saved = False
        return True
    else:
        return False
Esempio n. 19
0
def suspend(move_lock,last_updated,q):
  global curr4, curr17
  suspendtime = 600 # time in seconds after that the raspi will "suspend"
  while 1:
    sleep(1)
    while curr4.value > 1000:
      if last_updated.value + suspendtime < time():
        move_lock.acquire()
        curr4.value, curr17.value = move(curr4.value, curr17.value, "right")
        move_lock.release()
      else:
        break
      sleep(.25)
    while curr17.value > 1000:
      if last_updated.value + suspendtime < time():
        move_lock.acquire()
        curr4.value, curr17.value = move(curr4.value, curr17.value, "down")
        move_lock.release()
      else:
        break
      sleep(.25)
Esempio n. 20
0
    def _createMove(self, x, y):
        to_return = None
        if self._checkRanges(self.x, self.y) and self._checkRanges(x,y):
            if self.x != x and self.y != y:
                _move = move(self.board, False)
                _move.noInputInit(self.x, self.y, self)
                _move.setMove(x,y)
                _move.checkMove()
                if _move.isValidMove:
                    to_return = _move

        return to_return
Esempio n. 21
0
File: board.py Progetto: gamda/chess
    def _castle( self, moveToTry ):
        """If castle is possible, this function returns a move object
            with the start and end position of the respective rook to
            be moved. If that is the case, the player already provided
            the king's start and end position. If no castle is possible,
            the function returns false."""
        kingpos = self._chooseKing()
        kingcolor = self.pieces[kingpos].color

        if self.pieces[kingpos].hasMoved:
            return False # if king has moved, castle is not possible

        y = self.pieces[kingpos].pos[1]
        
        # check castle right
        if self._castleRight(moveToTry,kingpos): 
            return(move((h,y),(f,y)))
        # check castle left
        if self._castleLeft(moveToTry,kingpos):
            return(move((a,y),(d,y)))

        # otherwise, no castle is possible
        return False
Esempio n. 22
0
File: board.py Progetto: gamda/chess
 def validPieceMoves( self , piecepos ):
     """This function returns a list of valid moves for the piece
         contained in the given position. This function differs
         from the one contained in the piece object because it
         removes all the moves that will allow the king to be in
         check after the turn."""
     moves = self.pieces[piecepos].validMoves(self.squares)
     for j in moves[:]:
         movedBefore = True
         myMove = move(self.pieces[piecepos].pos,j)
         # move piece
         if hasattr( self.pieces[piecepos] , 'hasMoved' ):
             movedBefore = self.pieces[piecepos].hasMoved
         moveMade = self.makeMove( myMove )
         if( moveMade == True ):
             self.undo( )
             if hasattr( self.pieces[piecepos] , 'hasMoved' ):
                 if not movedBefore:
                     self.pieces[piecepos].hasMoved = False
         else:
             # player is in check after this move,
             # so move is not valid
             moves.remove(j)
     return moves
def migite_method():
    # 初期値
    illegal_counter = 0
    while( 1 ):
        chk_wall = rcg.check_wall_front()
        #chk_wall = WALL

        if chk_wall == SPACE :
            print 'space'
            mv.move( 0, 1 )
        else :
            print 'wall'
            illegal_counter = illegal_counter + 1
            if illegal_counter >= 10 :
                print 'turn left'
                mv.move( 90, 0 )
                illegal_counter = 0
                print illegal_counter
            else :
                print 'turn right'
                print illegal_counter
                mv.move( -90, 0 )
Esempio n. 24
0
from board import board
from move import move
from MinMax import MinMax

playboard = board()

player = int(raw_input("Player colour? (1=White, 2=Black)"))
print "Player is %s; computer is %s"%("Black" if player == 2 else "White", 
                                      "White" if player == 2 else "Black")

level = int(raw_input("Computer level? (1-?)"))

computer = MinMax(level, 1 if player == 2 else 2)
                                      
turn_token = 1
while 1:
    playboard.display()
    print "Score: %d"%playboard.score()
    if turn_token == player:
        move_object = None
        while move_object == None:
            move_string = raw_input("%s move? (ROW, COLUMN or ROW, COLUMN, TAKE_ROW, TAKE_COLUMN) "%
                                    ("White" if (turn_token == 1) else "Black"))
            move_object = move(turn_token, string = move_string)
    else:
        move_object = computer.move(playboard)
    turn_token = 2 if (turn_token == 1) else 1
    playboard.move(move_object)
Esempio n. 25
0
def moveb(frm, to, brd):
    brd.b = move(frm, to, brd.b)
    Rule.refresh(to, brd.b, brd.w, brd)
    return brd
Esempio n. 26
0
def movew(frm, to, brd): 
    brd.w = move(frm, to, brd.w)
    Rule.refresh(to, brd.w, brd.b, brd)
    return brd
Esempio n. 27
0
 def move(self, board):
     return move(self.token, 2, 2)
Esempio n. 28
0
def mini(
    x,
    q,
    qn,
    d,
    delta,
    finac,
    data,
    ausf,
    einf,
    m0,
    m1,
    m1c,
    m2,
    m2c,
    typ1_ges,
    typ2_ges,
    param,
    nap,
    step,
    dt,
    npts,
    x0,
    sr0,
    si0,
    resid0,
    residi0,
):
    #    import ipdb; ipdb.set_trace()
    xl = np.zeros(nap)
    xr = np.zeros(nap)

    xm, qm = move(x, q, nap)
    for k in range(nap):
        xl[k] = x[k] - step * d[k]
        xr[k] = x[k] + step * d[k]
    # left
    amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xl, param, delta, m1c, m2c)
    sysl, m0_l, m1_l, m2_l = def_sys_par(
        x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
    )
    sr, si, resid, residi = freqDamp2paz(sysl, sr0, si0, resid0, residi0, m0_l, m1_l, m2_l)
    sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_l, m1_l, m2_l, dt, npts)
    ql = quad(qn, sim, npts)
    # right
    amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xr, param, delta, m1c, m2c)
    sysr, m0_r, m1_r, m2_r = def_sys_par(
        x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
    )
    sr, si, resid, residi = freqDamp2paz(sysr, sr0, si0, resid0, residi0, m0_r, m1_r, m2_r)
    sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_r, m1_r, m2_r, dt, npts)
    qr = quad(qn, sim, npts)

    # maximum?
    if ql < qm and qr < qm:
        print "Maximum encountered! Try again with different start parameters!"
        sys.exit(1)

    while ql >= qm and qr >= qm and step >= 8.0 * finac:
        step = step / 8.0
        for k in range(nap):
            xl[k] = xm[k] - step * d[k]
            xr[k] = xm[k] + step * d[k]
        # left
        amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xl, param, delta, m1c, m2c)
        sysl, m0_l, m1_l, m2_l = def_sys_par(
            x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
        )
        sr, si, resid, residi = freqDamp2paz(sysl, sr0, si0, resid0, residi0, m0_l, m1_l, m2_l)
        sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_l, m1_l, m2_l, dt, npts)
        ql = quad(qn, sim, npts)
        # right
        amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xr, param, delta, m1c, m2c)
        sysr, m0_r, m1_r, m2_r = def_sys_par(
            x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
        )
        sr, si, resid, residi = freqDamp2paz(sysr, sr0, si0, resid0, residi0, m0_r, m1_r, m2_r)
        sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_r, m1_r, m2_r, dt, npts)
        qr = quad(qn, sim, npts)

        if ql < qm and qr < qm:
            print "Maximum encountered! Try again with different start parameters!"
            sys.exit(1)

    # witch side of the minimum?
    if ql < qm or qr < qm:
        if ql < qr:
            # turn around
            x, q = move(xl, ql, nap)
            xl, ql = move(xr, qr, nap)
            xr, qr = move(x, q, nap)
            for k in range(nap):
                d[k] = -d[k]
        if step > 1.0:
            x, q = move(xr, qr, nap)
            axi = step

            return x, q, step, axi, amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp

        else:
            step = 2.0 * step
            xm, qm = move(xr, qr, nap)
            for k in range(nap):
                xr[k] = xm[k] + step * d[k]
            # right
            amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xr, param, delta, m1c, m2c)
            sysr, m0_r, m1_r, m2_r = def_sys_par(
                x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
            )
            sr, si, resid, residi = freqDamp2paz(sysr, sr0, si0, resid0, residi0, m0_r, m1_r, m2_r)
            sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_r, m1_r, m2_r, dt, npts)
            qr = quad(qn, sim, npts)

            while qr < qm:
                if step > 1.0:
                    x, q = move(xr, qr, nap)
                    axi = step

                    return x, q, step, axi, amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp

                else:
                    step = 2.0 * step
                    xm, qm = move(xr, qr, nap)
                    for k in range(nap):
                        xr[k] = xm[k] + step * d[k]
                # right
                amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(xr, param, delta, m1c, m2c)
                sysr, m0_r, m1_r, m2_r = def_sys_par(
                    x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
                )
                sr, si, resid, residi = freqDamp2paz(sysr, sr0, si0, resid0, residi0, m0_r, m1_r, m2_r)
                sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_r, m1_r, m2_r, dt, npts)
                qr = quad(qn, sim, npts)

        # interpolate
        xi = (ql - qr) / (ql - 2.0 * qm + qr) / 2.0 * step
        axi = np.abs(xi)
        for k in range(nap):
            x[k] = xm[k] + xi * d[k]
        amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(x, param, delta, m1c, m2c)
        sysp, m0_i, m1_i, m2_i = def_sys_par(
            x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
        )
        sr, si, resid, residi = freqDamp2paz(sysp, sr0, si0, resid0, residi0, m0_i, m1_i, m2_i)
        sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_i, m1_i, m2_i, dt, npts)
        q = quad(qn, sim, npts)

        return x, q, step, axi, amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp

    if step < 8.0 * finac:
        xi = (ql - qr) / (ql - 2.0 * qm + qr) / 2.0 * step
        axi = np.abs(xi)
        for k in range(nap):
            x[k] = xm[k] + xi * d[k]
        amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp, nap = def_act_sys_par(x, param, delta, m1c, m2c)
        sysp, m0_i, m1_i, m2_i = def_sys_par(
            x0, dt, m0, m1, m2, amp, delay, sub, til, typ1_ges, typ2_ges, corn_freqs1, corn_freqs2, dmp
        )
        sr, si, resid, residi = freqDamp2paz(sysp, sr0, si0, resid0, residi0, m0_i, m1_i, m2_i)
        sim = ltisim(0, data, ausf, einf, delay, sub, til, sr, si, resid, residi, m0_i, m1_i, m2_i, dt, npts)
        q = quad(qn, sim, npts)

        return x, q, step, axi, amp, delay, sub, til, corn_freqs1, corn_freqs2, dmp

    print "Residual error..."
    print "Try again with other start parameters!"
    sys.exit(1)