コード例 #1
0
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)

        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.MAX_SPEED = 900

        self.running = True

        self.color_sensor = ev3.ColorSensor()
        assert self.color_sensor

        self.ir_sensor = ev3.InfraredSensor()
        assert self.ir_sensor

        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        assert self.pixy
コード例 #2
0
    def __init__(self):
        self.mqtt_client = None
        self.running = True
        self.touch_sensor = ev3.TouchSensor()
        self.seeker = ev3.BeaconSeeker(channel=1)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)

        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        assert self.pixy
        assert self.color_sensor
        assert self.ir_sensor
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
コード例 #3
0
ファイル: library.py プロジェクト: myersjm/ev3dev-curriculum
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.beacon_seeker = ev3.BeaconSeeker(channel=1)
        #  self.keep_going = self.touch_sensor.is_pressed
        self.break_out = False

        assert self.pixy
        assert self.ir_sensor
        assert self.color_sensor
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor.connected
コード例 #4
0
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        assert self.color_sensor
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.ir_sensor.connected
        assert self.pixy

        self.led_colors = [ev3.Leds.BLACK, ev3.Leds.GREEN, ev3.Leds.RED]

        self.current_color_index = 0
コード例 #5
0
 def __init__(self):
     """Establishes a left, right, and arm motor. Establishes the sensors
     (touch, ir, and color) sensors. Establishes the pixy camera. Sets
     inches moved to zero. Sets the state of running to be true. This all
     only occurs when the sensors are connected."""
     self.inches_moved = 0
     self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
     self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
     self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
     self.touch_sensor = ev3.TouchSensor()
     self.running = True
     self.ir_sensor = ev3.InfraredSensor()
     self.color_sensor = ev3.ColorSensor()
     assert self.color_sensor
     assert self.ir_sensor
     assert self.touch_sensor
     self.arm_motor.position = 0
     self.pixy = ev3.Sensor(driver_name="pixy-lego")
     assert self.pixy
コード例 #6
0
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)

        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker(channel=1)
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        # Check that the motors and sensors are actually connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor.connected
        assert self.color_sensor.connected
        assert self.ir_sensor.connected
        assert self.pixy
コード例 #7
0
    def __init__(self):
        """Construct the left, right, and arm motors as well as the touch sensor, and sets the maximum speed"""
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.MAX_SPEED = 900

        # Check that the motors are actually connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor
        assert self.touch_sensor
        assert self.color_sensor
        assert self.ir_sensor
        assert self.pixy
コード例 #8
0
def main():
    print("--------------------------------------------")
    print(" Printing distances")
    print("--------------------------------------------")
    ev3.Sound.speak("Printing distance").wait()
    print(" Press the touch sensor to exit")

    touch_sensor = ev3.TouchSensor()
    ir_sensor = ev3.InfraredSensor()
    assert touch_sensor
    assert ir_sensor

    while not touch_sensor.is_pressed:
        current_proximity = ir_sensor.proximity
        print("IR Distance = {}".format(current_proximity))
        time.sleep(0.5)

    print("Goodbye!")
    ev3.Sound.speak("Goodbye").wait()
コード例 #9
0
    def __init__(self):
        """ construct and store a left motor and a right motor."""
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        assert self.arm_motor.connected
        assert self.touch_sensor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected

        self.color_sensor = ev3.ColorSensor()
        assert self.color_sensor
        self.ir_sensor = ev3.InfraredSensor()
        assert self.ir_sensor
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        assert self.pixy

        self.running = True
コード例 #10
0
 def __init__(self):
     self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
     self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
     self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
     self.touch_sensor = ev3.TouchSensor()
     self.MAX_SPEED = 900
     self.color_sensor = ev3.ColorSensor()
     assert self.color_sensor
     self.ir_sensor = ev3.InfraredSensor()
     assert self.ir_sensor
     self.beacon_seeker = ev3.BeaconSeeker(channel=1)
     assert self.beacon_seeker
     self.pixy = ev3.Sensor(driver_name="pixy-lego")
     assert self.pixy
     self.come_back = False
     self.spot1 = True
     self.spot2 = True
     self.spot3 = True
     self.spot4 = True
コード例 #11
0
    def __init__(self):
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.running = None
        assert self.arm_motor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.touch_sensor
        assert self.color_sensor
        assert self.ir_sensor
        assert self.pixy

        self.MAX_SPEED = 900
コード例 #12
0
 def __init__(self):
     """Creates and stores left and right motor"""
     self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
     self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
     self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
     self.touch_sensor = ev3.TouchSensor()
     self.color_sensor = ev3.ColorSensor()
     self.ir_sensor = ev3.InfraredSensor()
     self.MAX_SPEED = 900
     self.pixy = ev3.Sensor(driver_name="pixy-lego")
     self.mqtt_client = com.MqttClient()
     self.mqtt_client.connect_to_pc()
     self.run = True
     assert self.left_motor.connected
     assert self.right_motor.connected
     assert self.arm_motor.connected
     assert self.touch_sensor
     assert self.color_sensor
     assert self.ir_sensor
     assert self.pixy
コード例 #13
0
    def __init__(self):
        self.robot = robo.Snatch3r()
        self.mqtt_client = None
        self.running = True
        self.touch_sensor = ev3.TouchSensor()
        self.seeker = ev3.BeaconSeeker(channel=1)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)

        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()

        self.code=[]

        assert self.color_sensor
        assert self.ir_sensor
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
コード例 #14
0
ファイル: ev3server.py プロジェクト: cherezov/curiosity_ev3
    def __init__(self, port, quite):
        self.host = socket.gethostbyname(socket.getfqdn())
        self.port = port
        self.quite = quite
        self.__socket = None
        self.__started = False
        self.__peer_sock = None
        self.__peer_addr = None

        self.__leftMotor = ev3.LargeMotor('outD')
        self.__rightMotor = ev3.LargeMotor('outA')
        self.__smallMotor = ev3.MediumMotor('outC')
        self.__ir = ev3.InfraredSensor()
        self.__power = ev3.PowerSupply()

        self.__last_ping = 0
        self.__last_ir = 0
        self.__last_pwr = 0

        self.__gear = 1
コード例 #15
0
    def __init__(self):
        # Connect the required equipement
        self.lm = ev3.LargeMotor('outB')
        self.rm = ev3.LargeMotor('outC')
        self.mm = ev3.MediumMotor()

        self.ir = ev3.InfraredSensor()
        self.ts = ev3.TouchSensor()
        self.cs = ev3.ColorSensor()

        self.screen = ev3.Screen()

        # Reset the motors
        for m in (self.lm, self.rm, self.mm):
            m.reset()
            m.position = 0
            m.stop_action = 'brake'

        self.draw_face()

        quote('initiating')
コード例 #16
0
    def __init__(self):

        # The code below connects all of the robots sensors and motors to
        # specific variables
        self.mqtt_client = None
        self.running = True
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        # Then is assures that all sensors and motors are connected properly
        assert self.color_sensor
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.ir_sensor.connected
        assert self.pixy
コード例 #17
0
    def __init__(self):

        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.touch_sensor = ev3.TouchSensor()

        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker(channel=1)
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        assert self.ir_sensor
        assert self.arm_motor
        assert self.touch_sensor
        assert self.left_motor
        assert self.right_motor
        assert self.color_sensor
        assert self.beacon_seeker
        assert self.pixy
        self.pixy.mode = "SIG1"
コード例 #18
0
    def __init__(self):
        # Connect two large motors on output ports B and C
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.running = True
        self.ir_sensor = ev3.InfraredSensor()
        self.color_sensor = ev3.ColorSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.beacon_seeker = ev3.BeaconSeeker(channel=1)
        self.btn = ev3.Button()

        # Check that the motors are actually connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor
        assert self.ir_sensor
        assert self.color_sensor
        assert self.pixy
コード例 #19
0
 def __init__(self):
     self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
     assert self.arm_motor.connected
     self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
     assert self.left_motor.connected
     self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
     assert self.right_motor.connected
     self.touch_sensor = ev3.TouchSensor()
     assert self.touch_sensor
     self.MAX_SPEED = 900
     self.SLOW_SPEED = 100
     self.running = True
     self.color_sensor = ev3.ColorSensor()
     assert self.color_sensor
     self.ir_sensor = ev3.InfraredSensor()
     assert self.ir_sensor
     self.pixy = ev3.Sensor(driver_name="pixy-lego")
     assert self.pixy
     self.active = False
     self.sides = 0
     self.degrees_turned = 0
コード例 #20
0
    def __init__(self):


        # Connect two large motors on output ports B and C
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")

        assert self.pixy
        assert self.beacon_seeker
        assert self.ir_sensor
        assert self.color_sensor
        assert self.touch_sensor
        assert self.arm_motor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected
コード例 #21
0
    def __init__(self):
        """Constructs and connects two large motors on output ports B and C."""
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.color_key = None

        self.MAX_SPEED = 900
        self.running = True
        """Check that the motors are actually connected."""
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor
        assert self.color_sensor
        assert self.ir_sensor
        assert self.pixy
コード例 #22
0
    def __init__(self):
        self.running = True
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_D)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker(channel=4)
        self.color_sensor = ev3.ColorSensor()
        self.pixy = ev3.Sensor(driver_name='pixy-lego')
        self.mqtt_client = com.MqttClient(self)
        self.mqtt_client.connect_to_pc()

        assert self.ir_sensor.connected
        assert self.color_sensor.connected
        assert self.pixy.connected
        assert self.touch_sensor
        assert self.arm_motor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        self.MAX_SPEED = 900
コード例 #23
0
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)

        assert self.left_motor.connected
        assert self.right_motor.connected
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)

        assert self.arm_motor.connected

        self.touch_sensor = ev3.TouchSensor()
        assert self.touch_sensor.connected

        self.color_sensor = ev3.ColorSensor()
        assert self.color_sensor

        self.ir_sensor = ev3.InfraredSensor()
        assert self.ir_sensor

        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        assert self.pixy
コード例 #24
0
 def __init__(self):
     """
     Creates and stores the instance variables for the Snatch3r class.
     Asserts the motors and sensors, so that the program will crash if
     they are not connected.
     """
     self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
     self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
     self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
     self.touch_sensor = ev3.TouchSensor()
     self.color_sensor = ev3.ColorSensor()
     self.ir_sensor = ev3.InfraredSensor()
     self.MAX_SPEED = 900
     self.pixy = ev3.Sensor(driver_name="pixy-lego")
     assert self.left_motor.connected
     assert self.right_motor.connected
     assert self.arm_motor.connected
     assert self.touch_sensor
     assert self.color_sensor
     assert self.ir_sensor
     assert self.pixy
コード例 #25
0
    def __init__(self):
        """"The constructor function that stores the components of the robot as
        well as asserts them to make sure that they are connected"""
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.w = 1

        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor.connected
        assert self.color_sensor.connected
        assert self.ir_sensor.connected
        assert self.pixy.connected

        self.MAX_SPEED = 900
        self.running = True
コード例 #26
0
    def __init__(self):

        self.MAX_SPEED = 900
        self.running = True

        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.remote_contol = ev3.RemoteControl()
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.btn = ev3.Button()

        assert self.pixy.connected
        assert self.ir_sensor.connected
        assert self.color_sensor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.arm_motor.connected
        assert self.touch_sensor.connected
コード例 #27
0
    def __init__(self):
        """Default main constructor for the Ev3TrackedExplor3r class"""
        # Call parent constructor
        super(Ev3TrackedExplor3r, self).__init__()

        # Init robot sensors and actuators
        try:
            # Init robot actuators
            self.left_motor = ev3.LargeMotor(
                'outB')  # Address is important for motors
            self.right_motor = ev3.LargeMotor('outC')
            self.head_motor = ev3.MediumMotor('outA')
            self.head_motor.position_i = 1000

            # Init robot sensors
            # self.color_sensor = ev3.ColorSensor()       # Address is not really important for sensors
            # self.color_sensor.mode = 'COL-REFLECT'      # if there are not two instance of the same type
            self.ir_sensor = ev3.InfraredSensor()  # of sensor
            self.ir_sensor.mode = 'IR-PROX'
        except Exception as theException:
            # Most probably one of the sensors or one of the actuators is not connected
            ev3te.ev3te_logger.critical(
                "Ev3TrackedExplor3r: Exception in routine __init__() + " +
                str(theException))
        # Single Scan
        self.ir_reading_update_counter = 0
        self.ir_samples_to_skip = 5
        self.ir_last_reading = 0

        # Continuous scan
        self.ircs_activated = False
        self.ircs_leftmost = -150
        self.ircs_rightmost = 150
        self.ircs_step = 10
        self.ircs_number_of_scans = int(
            (self.ircs_rightmost - self.ircs_leftmost) / self.ircs_step)
        self.ircs_scan_counter = 0
        self.ircs_scan_list = [0] * self.ircs_number_of_scans
コード例 #28
0
    def __init__(self):
        # Motors
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        # Sensors
        self.touch_sensor = ev3.TouchSensor()
        self.beacon_seeker = ev3.BeaconSeeker(channel=4)
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        # Defined Constants
        self.MAX_SPEED = 900
        self.running = True

        assert self.pixy
        assert self.color_sensor
        assert self.ir_sensor
        assert self.touch_sensor

        assert self.left_motor
        assert self.right_motor
        assert self.arm_motor
コード例 #29
0
    def __init__(self):
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.touch_sensor = ev3.TouchSensor()
        self.MAX_SPEED = 900
        self.Leds = ev3.Leds
        self.Sounds = ev3.Sound
        self.left_speed = 600
        self.right_speed = 600
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.man_up_value = 0
        self.follower = 0
        self.color = 0
        self.calibrate = 0
        self.time_s = 0
        self.user = 1
        self.SIG = "SIG1"
        self.finder = 0

        assert self.pixy
コード例 #30
0
    def __init__(self):
        """
        Creates motors and sensors for the Snatcher and makes sure they
        are connected.
        """
        self.left_motor = ev3.LargeMotor(ev3.OUTPUT_B)
        self.right_motor = ev3.LargeMotor(ev3.OUTPUT_C)
        self.touch_sensor = ev3.TouchSensor()
        self.arm_motor = ev3.MediumMotor(ev3.OUTPUT_A)
        self.running = True
        self.color_sensor = ev3.ColorSensor()
        self.ir_sensor = ev3.InfraredSensor()
        self.beacon_seeker = ev3.BeaconSeeker(channel=1)
        self.pixy = ev3.Sensor(driver_name="pixy-lego")
        self.mqtt_client = None

        self.light_level = 90
        self.light_calibrated = False
        self.dark_calibrated = False
        self.dark_level = 10

        self.obstructed = False
        self.is_stopped = True

        self.origin_x = 240
        self.origin_y = 240
        self.current_x = 240
        self.current_y = 240
        self.last_x = 240
        self.last_y = 240

        assert self.arm_motor.connected
        assert self.left_motor.connected
        assert self.right_motor.connected
        assert self.touch_sensor.connected
        assert self.color_sensor.connected
        assert self.ir_sensor.connected