Ejemplo n.º 1
0
def step1(robot):
    #    move( robot, 20, 30 )
    move(robot, -20, 20)
    robot.wait(1.0)
    robot.update(cmd=jumpCmd(1), ackRequest=True)
    robot.wait(5.0)
    move(robot, 20, 10)
    move(robot, 0, 10)
    move(robot, -20, 5)
    robot.wait(1.0)
Ejemplo n.º 2
0
def step1( robot ):
#    move( robot, 20, 30 )
    move( robot, -20, 20 )
    robot.wait(1.0)
    robot.update( cmd=jumpCmd(1), ackRequest=True )
    robot.wait(5.0)
    move( robot, 20, 10 )
    move( robot, 0, 10 )
    move( robot, -20, 5 )
    robot.wait(1.0)
Ejemplo n.º 3
0
def step2(robot):
    robot.update(cmd=jumpCmd(1), ackRequest=True)
    robot.wait(5.0)
    move(robot, 20, 20)
    move(robot, -20, 5)
    robot.update(cmd=addCapOffsetCmd(math.radians(10)))
Ejemplo n.º 4
0
def runSumo(robot):

    DEG_STEP = 30
    robot.setVideoCallback(keepLastImage)
    im = None
    global g_lastImage
    global lastkey
    global rcnn
    global stats
    global video
    global videorecording
    while True:
        lastkey = True
        dobreak = False
        move = False
        k = cv2.waitKey(30)
        if k == 27:
            if videorecording:
                video.release()
            dobreak = True
        elif k == ord(' '):
            robot.update(cmd=jumpCmd(1), ackRequest=True)
        elif k == ord('r'):
            rcnn = not rcnn
            if rcnn:
                print 'rcnn now on'
            else:
                print 'rcnn now off'
        elif k == ord('s'):
            stats = not stats
            if stats:
                print 'stats now on'
            else:
                print 'stats now off'
        elif k == ord('v'):
            videorecording = not videorecording
            if videorecording:
                fps = 5
                open_cv_image = cvImage(g_lastImage)
                height, width, layers = open_cv_image.shape
                today = datetime.datetime.now()
                filename = "img{:%Y-%m-%d-%H%M%S}".format(today)
                video = cv2.VideoWriter(
                    os.path.join('ardrone', 'video', filename + '.avi'), -1,
                    fps, (width, height))
                video.write(open_cv_image)
                print 'Video recording on'
            else:
                video.release()
                print 'Video recording stopped'
        elif k == ord('w'):
            open_cv_image = cvImage(g_lastImage)
            today = datetime.datetime.now()
            filename = "img{:%Y-%m-%d-%H%M%S}".format(today)
            cv2.imwrite(os.path.join('ardrone', 'images', filename + '.png'),
                        open_cv_image)
            print 'Screenshot saved to ' + os.path.join(
                'ardrone', 'images', filename + '.png')
        elif k == ord('j') or k == ord('i') or k == ord('k') or k == ord('l'):
            move = k
        if dobreak:
            break
        if move:
            MOVE_STEP = 0
            if move == ord('j'):
                DEG_STEP = -25
            elif move == ord('l'):
                DEG_STEP = 25
            elif move == ord('i'):
                DEG_STEP = 0
                MOVE_STEP = 25
            elif move == ord('k'):
                DEG_STEP = 0
                MOVE_STEP = -25

            if MOVE_STEP != 0:
                robot.update(cmd=moveCmd(MOVE_STEP, 0))
                #robot.update( cmd=moveCmd(0,0) )
            if DEG_STEP != 0:
                robot.update(cmd=addCapOffsetCmd(math.radians(DEG_STEP)))
            print "Battery:", robot.battery
            #robot.wait(0.1)
        else:
            robot.update(cmd=moveCmd(0, 0))
Ejemplo n.º 5
0
def step2( robot ):
    robot.update( cmd=jumpCmd(1), ackRequest=True )
    robot.wait(5.0)
    move( robot, 20, 20 )
    move( robot, -20, 5 )
    robot.update( cmd=addCapOffsetCmd(math.radians(10)) )