def main():
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("outD")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")

    # change color sensor to color and define colors
    C4.mode = 'COL-COLOR'
    colors = ('', 'Black', 'Blue', 'Brown', 'Green', 'Yellow', 'Red', 'White')

    # turn on motors forever
    MB.run_forever(speed_sp=75)
    MC.run_forever(speed_sp=75)
    # while color sensor doesn't sense black. Wait until sensing black.
    while C4.value() != 1:
        print(colors[C4.value()])
        sleep(0.005)


# after loop ends, brake motor B and C
    MB.stop(stop_action="hold")
    MC.stop(stop_action="hold")
Exemple #2
0
def main():
    Sound.speak("").wait()
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")

    GY.mode = 'GYRO-ANG'
    GY.mode = 'GYRO-RATE'
    GY.mode = 'GYRO-ANG'
    tank_drive = MoveTank(OUTPUT_B, OUTPUT_C)
    loop_gyro = 0
    gyro_adjust = 1
    # change this to whatever speed what you want
    left_wheel_speed = -300
    right_wheel_speed = -300
    # change the loop_gyro verses the defined value argument to however far you want to go
    # if Gyro value is the same as the starting value, go straight, if more turn right, if less turn left
    # change the value to how far you want the robot to go
    while MB.position > -160:
        if GY.value() == 0:
            left_wheel_speed = -300
            right_wheel_speed = -300
            MB.run_forever(speed_sp=left_wheel_speed)
            MC.run_forever(speed_sp=right_wheel_speed)
            gyro_adjust = 12
        else:
            if GY.value() > 0:
                correct_rate = abs(
                    GY.value()
                )  # This captures the gyro value at the beginning of the statement
                left_wheel_speed = left_wheel_speed + gyro_adjust
                right_wheel_speed = right_wheel_speed - gyro_adjust
                MB.run_forever(speed_sp=left_wheel_speed)
                MC.run_forever(speed_sp=right_wheel_speed)
                left_wheel_speed = -300
                right_wheel_speed = -300
                if abs(
                        GY.value()
                ) > correct_rate:  # If gyro value has worsened despite the correction then change the adjust variable for next time
                    gyro_adjust = gyro_adjust + 1
            else:
                correct_rate = abs(
                    GY.value())  # Same idea as the other if statement
                right_wheel_speed = right_wheel_speed + gyro_adjust
                left_wheel_speed = left_wheel_speed - gyro_adjust
                MB.run_forever(speed_sp=left_wheel_speed)
                MC.run_forever(speed_sp=right_wheel_speed)
                left_wheel_speed = -300
                right_wheel_speed = -300
                if abs(GY.value()) > correct_rate:
                    gyro_adjust = gyro_adjust + 1


# stop all motors
    MB.stop(stop_action="hold")
    MC.stop(stop_action="hold")
Exemple #3
0
    def __init__(self, *args, **kwargs):
        self.exposed_candy_loader = MediumMotor(OUTPUT_A)
        self.exposed_candy_thrower = MediumMotor(OUTPUT_B)
        self.exposed_left_cs = ColorSensor(INPUT_1)
        self.exposed_right_cs = ColorSensor(INPUT_2)

        super().__init__(*args, **kwargs)
def main():

    # start sensor and motor definitions
    Sound.speak("").wait()
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")
    # end sensor and motor definitions

    # start calibration
    GY.mode = 'GYRO-ANG'
    GY.mode = 'GYRO-RATE'
    GY.mode = 'GYRO-ANG'
    # end calibration

    # The following line would be if we used tank_drive
    #    tank_drive = MoveTank(OUTPUT_B, OUTPUT_C)

    # start definition of driving parameters
    loop_gyro = 0
    starting_value = GY.value()
    # end definition of driving parameters

    # set initial speed parameters
    speed = 20
    adjust = 1

    # change 999999999999 to however you want to go
    while loop_gyro < 999999999999:

        # while Gyro value is the same as the starting value, then go straigt.
        while GY.value() == starting_value:
            left_wheel_speed = speed
            right_wheel_speed = speed
            MB.run_forever(speed_sp=left_wheel_speed)
            MC.run_forever(speed_sp=right_wheel_speed)
            return

# while greater than starting value, then go left.
        while GY.value() > starting_value:
            left_wheel_speed = speed - adjust
            right_wheel_speed = speed
            MB.run_forever(speed_sp=left_wheel_speed)
            MC.run_forever(speed_sp=right_wheel_speed)
            return

# while less than starting value, then go right.
        while GY.value() < starting_value:
            left_wheel_speed = speed + adjust
            right_wheel_speed = speed
            MB.run_forever(speed_sp=left_wheel_speed)
            MC.run_forever(speed_sp=right_wheel_speed)
            return
        return
def main():
    Sound.speak("").wait()
    MA = MediumMotor("outA")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("outD")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")
def main():
    program_running = 0
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("outD")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")

    MA.on_for_degrees(SpeedPercent(50), 9000)
Exemple #7
0
    def __init__(self):
        #Performs Alexa Gadget initialization routines and ev3dev resource allocation.
        super().__init__()

        self.leds = Leds()
        self.sound = Sound()

        #Connect the blue motor to Port A
        self.blueMotor = MediumMotor(OUTPUT_A)
        #Connect the red motor to Port B
        self.redMotor = MediumMotor(OUTPUT_B)
Exemple #8
0
def main():
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("outD")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")
    tank_drive = MoveTank(OUTPUT_B, OUTPUT_C)
    def Safety_factor():
        tank_drive.on_for_rotations(SpeedPercent(100), SpeedPercent(100), 1)
        tank_drive.on_for_rotations(SpeedPercent(-100), SpeedPercent(-100), 1)
def main():
    Sound.speak("").wait()
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")

    GY.mode = 'GYRO-ANG'
    GY.mode = 'GYRO-RATE'
    GY.mode = 'GYRO-ANG'
    tank_drive = MoveTank(OUTPUT_B, OUTPUT_C)
    loop_gyro = 0
    starting_value = GY.value()
    # change 20 to whatever speed what you want
    left_wheel_speed = 100
    right_wheel_speed = 100
    # change 999999999999 to however you want to go
    # if Gyro value is the same as the starting value, go straigt. if more turn right. if less turn left
    while loop_gyro < 999:
        if GY.value() == starting_value:
            left_wheel_speed = -300
            right_wheel_speed = -300
            MB.run_forever(speed_sp=left_wheel_speed)
            MC.run_forever(speed_sp=right_wheel_speed)
        else:
            if GY.value() > starting_value:
                left_wheel_speed = left_wheel_speed - GY.value() / 2
                right_wheel_speed = right_wheel_speed + GY.value() * -1 / 2
                MB.run_forever(speed_sp=left_wheel_speed)
                MC.run_forever(speed_sp=right_wheel_speed)
                left_wheel_speed = -300
                right_wheel_speed = -300
            else:
                right_wheel_speed = right_wheel_speed + GY.value() / 2
                left_wheel_speed = left_wheel_speed - GY.value() / 2
                MB.run_forever(speed_sp=left_wheel_speed)
                MC.run_forever(speed_sp=right_wheel_speed)
                left_wheel_speed = -300
                right_wheel_speed = -300
        loop_gyro + 1


# stop all motors
    MB.stop(stop_action="hold")
    MC.stop(stop_action="hold")
Exemple #10
0
    def __init__(self,
                 left_foot_motor_port: str = OUTPUT_B,
                 right_foot_motor_port: str = OUTPUT_C,
                 bazooka_blast_motor_port: str = OUTPUT_A,
                 touch_sensor_port: str = INPUT_1,
                 color_sensor_port: str = INPUT_3,
                 ir_sensor_port: str = INPUT_4,
                 ir_beacon_channel: int = 1):
        super().__init__(left_motor_port=left_foot_motor_port,
                         right_motor_port=right_foot_motor_port,
                         polarity=Motor.POLARITY_NORMAL,
                         speed=1000,
                         channel=ir_beacon_channel)

        self.tank_driver = MoveTank(left_motor_port=left_foot_motor_port,
                                    right_motor_port=right_foot_motor_port,
                                    motor_class=LargeMotor)

        self.bazooka_blast_motor = MediumMotor(
            address=bazooka_blast_motor_port)

        self.touch_sensor = TouchSensor(address=touch_sensor_port)
        self.color_sensor = ColorSensor(address=color_sensor_port)

        self.ir_sensor = InfraredSensor(address=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel

        self.leds = Leds()
        self.speaker = Sound()
Exemple #11
0
 def __init__(self, sensorList=[]):
     try:
         self.tank = MoveTank(OUTPUT_B, OUTPUT_C)
         self.outputList = [OUTPUT_B, OUTPUT_C]
     except:
         self.tank = None
     try:
         self.cs = ColorSensor()
     except:
         self.cs = None
     try:
         self.gyro = GyroSensor()
     except:
         self.gyro = None
     try:
         self.ultrasonicSensor = UltrasonicSensor()
     except:
         self.ultrasonicSensor = None
     try:
         self.large = LargeMotor(OUTPUT_D)
         self.outputList.append(OUTPUT_D)
     except:
         self.large = None
     try:
         self.medium = MediumMotor(OUTPUT_D)
         self.outputList.append(OUTPUT_D)
     except:
         self.medium = None
Exemple #12
0
    def __init__(self):
        """
        Performs Alexa Gadget initialization routines and ev3dev resource allocation.
        """
        super().__init__()

        # Gadget state
        self.in_progress = False

        # Ev3dev initialization
        self.leds = Leds()
        self.sound = Sound()
        self.drive = MoveTank(OUTPUT_B, OUTPUT_A)
        self.stick = MediumMotor(OUTPUT_C)
        self.cs = ColorSensor(INPUT_4)
        self.cs.mode = 'COL-REFLECT'
        self.floor_light = self.cs.value()
        print("floor light intensity = {}".format(self.floor_light))
        self.speed = 20
        self.kickAngle = 170
        paho.Client.connected_flag = False
        self.client = paho.Client()
        self.client.loop_start()
        self.client.on_connect = self.mqtt_connected
        self.client.connect('broker.hivemq.com', 1883)
        while not self.client.connected_flag:
            time.sleep(1)

        self.client.subscribe('/hockeybot/game/over')
        self.client.on_message = self.mqtt_on_message

        # Start threads
        threading.Thread(target=self.check_for_obstacles_thread,
                         daemon=True).start()
Exemple #13
0
 def __init__(self,
              medium_motor=OUTPUT_A,
              left_motor=OUTPUT_C,
              right_motor=OUTPUT_B):
     RemoteControlledTank.__init__(self, left_motor, right_motor)
     self.medium_motor = MediumMotor(medium_motor)
     self.medium_motor.reset()
Exemple #14
0
def main():

    threadPool = []
    actions = []
    stopProcessing = False

    largeMotor_Left = LargeMotor(OUTPUT_B)
    largeMotor_Right = LargeMotor(OUTPUT_C)
    mediumMotor = MediumMotor()
    ts = TouchSensor()

    action1 = createAction('onForSeconds', largeMotor_Left, 20, 4)
    action2 = createAction('onForSeconds', largeMotor_Right, 40, 3)
    action3 = createAction('delayForSeconds', None, None, 2)
    action4 = createAction('onForSeconds', mediumMotor, 10, 8)

    actionParallel = []
    actionParallel.append(action1)
    actionParallel.append(action2)

    actions.append(actionParallel)
    actions.append(action3)
    actions.append(action4)

    for action in actions:

        # are their multiple actions to execute in parallel?
        if isinstance(action, list):

            for subAction in action:
                thread = launchStep(subAction)
                threadPool.append(thread)

        # is there a single action to execute?
        else:

            thread = launchStep(action)
            threadPool.append(thread)

        while not stopProcessing:

            # remove any completed threads from the pool
            for thread in threadPool:
                if not thread.isAlive():
                    threadPool.remove(thread)

            # if there are no threads running, exist the 'while' loop
            # and start the next action from the list
            if not threadPool:
                break

            # if the touch sensor is pressed then complete everything
            if ts.is_pressed:
                stopProcessing = True

            sleep(0.25)

        # if the 'stopProcessing' flag has been set then break out of the program altogether
        if stopProcessing:
            break
def launchStep(stop, action):

    largeMotor_Left = LargeMotor(OUTPUT_B)
    largeMotor_Right = LargeMotor(OUTPUT_C)
    mediumMotor = MediumMotor()

    name = action.get('action')
    motor = action.get('motor')
    speed = float(action.get('speed'))
    seconds = float(action.get('seconds'))

    if name == 'onForSeconds':

        if (motor == "largeMotor_Left"):
            motorToUse = largeMotor_Left
        if (motor == "largeMotor_Right"):
            motorToUse = largeMotor_Right
        if (motor == "mediumMotor"):
            motorToUse = mediumMotor

        thread = threading.Thread(target=onForSeconds,
                                  args=(stop, motorToUse, speed, seconds))
        thread.start()
        return thread

    if name == 'delayForSeconds':
        thread = threading.Thread(target=delayForSeconds, args=(stop, seconds))
        thread.start()
        return thread
def main():

    largeMotor_Left = LargeMotor(OUTPUT_B)
    largeMotor_Right = LargeMotor(OUTPUT_C)
    mediumMotor = MediumMotor()

    # create a threadPool array to 'collect' the threads ..
    threadPool = []
    thread1 = threading.Thread(target=onForSeconds,
                               args=(largeMotor_Left, 30, 4))
    thread2 = threading.Thread(target=onForSeconds,
                               args=(largeMotor_Right, 40, 3))
    threadPool.append(thread1)
    threadPool.append(thread2)

    # start threads
    thread1.start()
    thread2.start()

    # are any threads still working?
    waitUntilAllThreadsComplete(threadPool)

    # All threads are complete, so we can run the next step ..
    threadPool = []
    thread3 = threading.Thread(target=onForSeconds, args=(mediumMotor, 10, 6))
    threadPool.append(thread3)

    # start the thread
    thread3.start()

    # are any threads still working?
    waitUntilAllThreadsComplete(threadPool)
Exemple #17
0
    def __init__(self,
                 drive_motor_port=OUTPUT_B,
                 strike_motor_port=OUTPUT_D,
                 steer_motor_port=OUTPUT_A,
                 drive_speed_pct=60):

        self.drive_motor = LargeMotor(drive_motor_port)
        self.strike_motor = LargeMotor(strike_motor_port)
        self.steer_motor = MediumMotor(steer_motor_port)
        self.speaker = Sound()
        STEER_SPEED_PCT = 30

        self.remote = InfraredSensor()
        self.remote.on_channel1_top_left = self.make_move(self.drive_motor, drive_speed_pct)
        self.remote.on_channel1_bottom_left = self.make_move(self.drive_motor, drive_speed_pct * -1)
        self.remote.on_channel1_top_right = self.make_move(self.steer_motor, STEER_SPEED_PCT)
        self.remote.on_channel1_bottom_right = self.make_move(self.steer_motor, STEER_SPEED_PCT * -1)

        self.shutdown_event = Event()
        self.mrc = MonitorRemoteControl(self)

        # Register our signal_term_handler() to be called if the user sends
        # a 'kill' to this process or does a Ctrl-C from the command line
        signal.signal(signal.SIGTERM, self.signal_term_handler)
        signal.signal(signal.SIGINT, self.signal_int_handler)
    def __init__(self):
        """
        Performs Alexa Gadget initialization routines and ev3dev resource allocation.
        """
        super().__init__()

        # Robot state
        self.patrol_mode = False
        self.enemy_not_detected = True
        print("+++++ self.patrol_mode = {} y self.enemy_not_detected = {}".
              format(self.patrol_mode, self.enemy_not_detected))
        self.positionX = 0
        self.positionY = 0
        self.direction = ['forward', 'right', 'backward', 'left']
        self.offset = [0, 1, 0, -1]
        self.index = 0
        self.pointing = self.direction[self.index]

        # Connect two large motors on output ports B and C
        self.drive = MoveTank(OUTPUT_B, OUTPUT_C)
        self.weapon = MediumMotor(OUTPUT_A)
        self.sound = Sound()
        self.leds = Leds()
        self.ir = InfraredSensor()

        # Start threads
        threading.Thread(target=self._patrol_thread, daemon=True).start()
        threading.Thread(target=self._proximity_thread, daemon=True).start()
    def __init__(self,
                 jaw_motor_port: str = OUTPUT_A,
                 left_motor_port: str = OUTPUT_B,
                 right_motor_port: str = OUTPUT_C,
                 touch_sensor_port: str = INPUT_1,
                 color_sensor_port: str = INPUT_3,
                 ir_sensor_port: str = INPUT_4,
                 ir_beacon_channel: int = 1):
        self.jaw_motor = MediumMotor(address=jaw_motor_port)

        self.left_motor = LargeMotor(address=left_motor_port)
        self.right_motor = LargeMotor(address=right_motor_port)
        self.tank_driver = MoveTank(left_motor_port=left_motor_port,
                                    right_motor_port=right_motor_port,
                                    motor_class=LargeMotor)
        self.steer_driver = MoveSteering(left_motor_port=left_motor_port,
                                         right_motor_port=right_motor_port,
                                         motor_class=LargeMotor)

        self.touch_sensor = TouchSensor(address=touch_sensor_port)
        self.color_sensor = ColorSensor(address=color_sensor_port)

        self.ir_sensor = InfraredSensor(address=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel

        self.speaker = Sound()

        self.roaring = False
        self.walk_speed = self.NORMAL_WALK_SPEED
Exemple #20
0
def main():
    Sound.speak("").wait()
    MA = MediumMotor("")
    MB = LargeMotor("outB")
    MC = LargeMotor("outC")
    MD = MediumMotor("")
    GY = GyroSensor("")
    C3 = ColorSensor("")
    C4 = ColorSensor("")

    tank_drive = MoveTank(OUTPUT_B, OUTPUT_C)
    # speaks "before" tacho count
    Sound.speak(MB.position).wait()
    tank_drive.on_for_rotations(SpeedPercent(50), SpeedPercent(0), 1)
    # speaks "after" tacho count
    Sound.speak(MB.position).wait()
Exemple #21
0
def follow_path(path):
    current_x = 0
    current_y = 0

    sensor_motor = MediumMotor(OUTPUT_D)
    tank = MoveTank(OUTPUT_B, OUTPUT_C)

    print("Length of path: " + str(len(path)))

    y_off = path[-1].y - path[0].y + 1
    tank.on_for_degrees(-10, -10, 38 * y_off)

    i = 0
    for p in path:
        print(str(i) + "'th: " + str(current_x), str(current_y))

        x_off = p.x - current_x
        y_off = p.y - current_y

        if x_off > 0:
            sensor_motor.on_for_degrees(20, 55)
        elif x_off < 0:
            sensor_motor.on_for_degrees(-20, 55)

        if y_off > 0:
            tank.on_for_degrees(10, 10, 38)
        elif y_off < 0:
            tank.on_for_degrees(-10, -10, 38)

        current_x = p.x
        current_y = p.y
        i += 1
Exemple #22
0
def main():
    '''The main function of our program'''

    # set the console just how we want it
    reset_console()
    set_cursor(OFF)
    set_font('Lat15-Terminus24x12')

    print('How are you?')
    print("")
    print("Hello Selina.")
    print("Hello Ethan.")
    STUD_MM = 8
    tank = MoveDifferential(OUTPUT_A, OUTPUT_B, EV3Tire, 16 * STUD_MM)
    motorLift = MediumMotor(OUTPUT_D)
    sound = Sound()

    # sound.speak('How are you master!')
   # sound.speak("I like my family")
   # sound.speak("I like my sister and i like my brother.")
    sound.beep()

    eye = InfraredSensor(INPUT_1)
    robot = Robot(tank, None, eye)
    botton = Button()
    while not botton.any():
        distance = eye.distance(channel=1)
        heading = eye.heading(channel=1)
        print('distance: {}, heading: {}'.format(distance, heading))

        motorLift.on_to_position(speed=40, position=-7200, block=True)  #20 Rounds

        if distance is None:
            sound.speak("I am lost, there is no beacon!")
        else:
            if (distance < 14):
                tank.off()
                sound.speak("I am very close to the beacon!")
                motorLift.on_to_position(speed=40, position=7200, block=True)
                sound.speak("I had to get some more rubbish.")
                sound.speak("Please wait while I lift up my fork.")
                tank.turn_right(speed=20, degrees=random.randint(290, 340))  # random.randint(150, 210)
                tank.on_for_seconds(left_speed=20, right_speed=20, seconds=20)
                tank.turn_right(speed=20, degrees=330)
                motorLift.on_to_position(speed=40, position=0, block=True)

            elif distance >= 100:
                sound.speak("I am too faraway from the beacon")
            elif (distance  < 99) and (-4 <= heading <= 4):  # in right heading
                sound.speak("Moving farward")
                tank.on(left_speed=20, right_speed=20)
            else:
                if heading > 0:
                    tank.turn_left(speed=20, degrees=20)
                else:
                    tank.turn_right(speed=20, degrees=20)
                sound.speak("I am finding the beacon.")


        time.sleep(0.1)
Exemple #23
0
 def __init__(self, baseSpeed=500, dt=50):
     self.leftMotor = LargeMotor(OUTPUT_C)
     self.rightMotor = LargeMotor(OUTPUT_A)
     self.steeringDrive = MoveSteering(OUTPUT_C, OUTPUT_A)
     self.craneMotor = MediumMotor(OUTPUT_B)
     self.baseSpeed = baseSpeed
     self.dt = dt
Exemple #24
0
    def __init__(self):
        self.shutdown = False
        self.flipper = LargeMotor(OUTPUT_A)
        self.turntable = LargeMotor(OUTPUT_B)
        self.colorarm = MediumMotor(OUTPUT_C)
        self.color_sensor = ColorSensor()
        self.color_sensor.mode = self.color_sensor.MODE_RGB_RAW
        self.infrared_sensor = InfraredSensor()
        self.init_motors()
        self.state = ['U', 'D', 'F', 'L', 'B', 'R']
        self.rgb_solver = None
        signal.signal(signal.SIGTERM, self.signal_term_handler)
        signal.signal(signal.SIGINT, self.signal_int_handler)

        filename_max_rgb = 'max_rgb.txt'

        if os.path.exists(filename_max_rgb):
            with open(filename_max_rgb, 'r') as fh:
                for line in fh:
                    (color, value) = line.strip().split()

                    if color == 'red':
                        self.color_sensor.red_max = int(value)
                        log.info("red max is %d" % self.color_sensor.red_max)
                    elif color == 'green':
                        self.color_sensor.green_max = int(value)
                        log.info("green max is %d" %
                                 self.color_sensor.green_max)
                    elif color == 'blue':
                        self.color_sensor.blue_max = int(value)
                        log.info("blue max is %d" % self.color_sensor.blue_max)
Exemple #25
0
 def __init__(self, motor_address=OUTPUT_D, us_sensor_address=INPUT_2, start_open=True):
     self.claw_motor = MediumMotor(motor_address)
     self.eyes = UltrasonicSensor(us_sensor_address)
     if start_open and not self.is_open():
         self.open()
     elif not start_open and self.is_open():
         self.close()
Exemple #26
0
 def __init__(self):
     
     super().__init__()
     self.leds = Leds()
     self.motorOne = LargeMotor(OUTPUT_C)
     self.motorTwo = LargeMotor(OUTPUT_B)
     self.motorThree = MediumMotor(OUTPUT_A)
 def __init__(self, left_motor_port, right_motor_port, infra_sensor_mode,
              color_sensor_mode):
     self.__movesteering = MoveSteering(left_motor_port, right_motor_port)
     self.__mediummotor = MediumMotor()
     self.__cs = ColorSensor()
     self.__cs.mode = color_sensor_mode
     self.__ir = InfraredSensor()
     self.__ir.mode = infra_sensor_mode
Exemple #28
0
 def __init__(self):
     self.angleToRunTo = 0
     self.motorArm = MediumMotor(OUTPUT_B)
     self.CurrentAngle = 0
     self.motorAngle = 0
     self.motorDestinationAngle = 0
     self.Hold = False
     self.gainAngle = 0
Exemple #29
0
    def __init__(self):
        """
        Performs Alexa Gadget initialization routines and ev3dev resource allocation.
        """
        super().__init__()

        # Ev3dev initialization
        self.leds = Leds()
        self.sound = Sound()
        self.left_motor = LargeMotor(OUTPUT_B)
        self.right_motor = LargeMotor(OUTPUT_C)
        self.hand_motor = MediumMotor(OUTPUT_A)
        # Gadget states
        self.bpm = 0
        self.trigger_bpm = "off"
        self.drive = MoveTank(OUTPUT_B, OUTPUT_C)
        self.weapon = MediumMotor(OUTPUT_A)
Exemple #30
0
    def __init__(self):

        self.leds = Leds()
        self.arm_position = ArmPosition.CONTRACT
        self.color_arm = MediumMotor(OUTPUT_A)
        self.color_sensor = ColorSensor()
        self.color_scaned = ColorScanOptions.NONE
        self.sound = Sound()