Exemplo n.º 1
0
def right(duration=1.0, verbose=True):
    """
    Drive the car forward and right for `duration` seconds.
    """
    from car import motors
    if duration > 5.0:
        print(
            "Error: The duration exceeds 5 seconds; will reset to 5 seconds.")
        duration = 5.0
    if verbose:
        print("Driving right for {} seconds.".format(duration))
    if duration <= 0.0:
        return
    motors.drive(-45.0, motors.CAR_THROTTLE_FORWARD_SAFE_SPEED, duration)
Exemplo n.º 2
0
def right(sec=None, deg=None, verbose=True):
    """
    Drive the car forwad and right for `sec` seconds or `deg` degrees (passing in both
    will raise an error). If neither is passed in, the car will drive for 1 second.
    """
    from car import motors

    if sec is not None and deg is not None:
        _ctx_print_all(
            "Error: Please specify duration (sec) OR degrees (deg) - not both."
        )
        return

    if sec is None and deg is None:
        sec = 1.0

    if sec is not None:
        if sec > 5.0:
            _ctx_print_all(
                "Error: The duration (sec) exceeds 5 seconds; will reset to 5 seconds."
            )
            sec = 5.0
        if sec <= 0.0:
            return
        if verbose:
            _ctx_print_all("Driving right for {} seconds.".format(sec))

    if deg is not None:
        if deg > 360.0:
            _ctx_print_all(
                "Error: The degrees (deg) exceeds 360; will reset to 360.")
            deg = 360.0
        if deg <= 0.0:
            return
        if verbose:
            _ctx_print_all("Driving right for {} degrees.".format(deg))

    motors.drive(-45.0, motors.safe_forward_throttle(), sec, deg)
Exemplo n.º 3
0
def _demo_forward_reverse_no_pid(duration=1.0):
    m.drive(0.0, m.CAR_THROTTLE_FORWARD_SAFE_SPEED, duration)
    m.drive(0.0, m.CAR_THROTTLE_REVERSE_SAFE_SPEED, duration)