Пример #1
0
    def __init__(self, motorhat_addr=0x6f, drive_enabled=True):
        # Setup the motorhat with the passed in address
        self._mh = Raspi_MotorHAT(addr=motorhat_addr)

        # get local variable for each motor
        self.left_motor = self._mh.getMotor(1)
        self.right_motor = self._mh.getMotor(2)
        self.drive_enabled = drive_enabled

        # ensure the motors get stopped when the code exits
        atexit.register(self.stop_all)

        # Setup the line sensors
        self.left_line_sensor = LineSensor(23, queue_len=3, pull_up=True)
        self.right_line_sensor = LineSensor(16, queue_len=3, pull_up=True)

        # Setup The Distance Sensors
        self.left_distance_sensor = DistanceSensor(17, 27)
        self.right_distance_sensor = DistanceSensor(5, 6)

        # Setup the Encoders
        EncoderCounter.set_constants(self.wheel_diameter_mm,
                                     self.ticks_per_revolution)
        self.left_encoder = EncoderCounter(4)
        self.right_encoder = EncoderCounter(26)

        # Setup the Leds
        self.leds = leds_8_apa102c.Leds()

        # Set up servo motors for pan and tilt.
        self.servos = Servos(addr=motorhat_addr)
Пример #2
0
    def __init__(self, motorhat_addr=0x6f):
        # Setup the motorhat with the passed in address
        self._mh = Raspi_MotorHAT(addr=motorhat_addr)

        # get local variable for each motor
        self.left_motor = self._mh.getMotor(1)
        self.right_motor = self._mh.getMotor(2)

        # ensure the motors get stopped when the code exits
        atexit.register(self.stop_all)

        # Setup the line sensors
        self.left_line_sensor = LineSensor(23, queue_len=3, pull_up=True)
        self.right_line_sensor = LineSensor(16, queue_len=3, pull_up=True)

        # Setup the Leds
        self.leds = leds_8_apa102c.Leds()