Beispiel #1
0
def process_command(_command, _time):
    data = _command
    if not data:
        print "received data:", data

    if len(data) != 1:
        print ("Invalid command")
        return "Invalid command"
    elif data == 'w':
        gopigo.fwd()
        # return "Moving forward"
    elif data == 'x':
        gopigo.stop()
        # return "Stopping"
    elif data == 's':
        gopigo.bwd()
        # return "Moving back"
    elif data == 'a':
        gopigo.left()
        # return "Turning left"
    elif data == 'd':
        gopigo.right()
        # return "Turning right"
    elif data == 't':
        gopigo.increase_speed()
        # return "Increase speed"
    elif data == 'g':
        gopigo.decrease_speed()
        # return "Decrease speed"
    elif data == 'v':
        # print gopigo.volt(), 'V'
        return str(gopigo.volt())
    elif data == 'l':
        gopigo.led_on(0)
        gopigo.led_on(1)
        time.sleep(1)
        gopigo.led_off(0)
        gopigo.led_off(1)
        return "Flash LED"
    else:
        print ("Invalid command")
        return "Invalid command"  # run as a app

    if _time:
        time.sleep(_time)
        gopigo.stop()
#!/usr/bin/env python 

import gopigo

gopigo.increase_speed()
Beispiel #3
0
        while True:
            current_time = time.time()
            program_duration = current_time - start_time
            if program_duration > WARMUP_SLEEP_SEC and not driving:
                driving = True
                motorController.drive()
            if program_duration > MAX_PROGRAM_DURATION_SEC:
                print "Shutting down.  Program duration {dur} (sec) exceeds max duration of {max_dur} (sec)".format(
                    dur=program_duration, max_dur=MAX_PROGRAM_DURATION_SEC)
                break

            if (current_time - last_speed_increase >
                    INCREASE_SPEED_INTERVAL_SEC) and (num_speed_increases <
                                                      MAX_SPEED_INCREASES):
                gopigo.increase_speed()
                num_speed_increases += 1
                last_speed_increase = current_time
                print '--- increasing speed ---'

            state_estimates = stateEstimator.getCurrentState()
            print "Acceleration: ({accel_x},{accel_y},{accel_z}) - Position: ({x},{y},{z}) - program time: {t} (sec)".format(
                accel_x=state_estimates['acceleration'][0],
                accel_y=state_estimates['acceleration'][1],
                accel_z=state_estimates['acceleration'][2],
                x=state_estimates['position'][0],
                y=state_estimates['position'][1],
                z=state_estimates['position'][2],
                t=state_estimates['t'] - start_time)

            dataRecorder.captureData({
Beispiel #4
0
def increase_speed(kargs):
    r = {'return_value': gopigo.increase_speed()}
    return r