コード例 #1
0
    def __init__(
            self,
            left_track_motor_port: Port = Port.B,
            right_track_motor_port: Port = Port.C,
            gripping_motor_port: Port = Port.A,
            touch_sensor_port: Port = Port.S1,
            ir_sensor_port: Port = Port.S4,
            ir_beacon_channel: int = 1):
        super().__init__(
            wheel_diameter=self.WHEEL_DIAMETER,
            axle_track=self.AXLE_TRACK,
            left_motor_port=left_track_motor_port,
            right_motor_port=right_track_motor_port,
            ir_sensor_port=ir_sensor_port,
            ir_beacon_channel=ir_beacon_channel)

        self.ev3_brick = EV3Brick()

        self.gripping_motor = Motor(port=gripping_motor_port,
                                    positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #2
0
    def __init__(
            self,
            crushing_claw_motor_port: Port = Port.A,
            moving_motor_port: Port = Port.B,
            lightning_tail_motor_port: Port = Port.D,
            touch_sensor_port: Port = Port.S1,
            color_sensor_port: Port = Port.S3,
            ir_sensor_port: Port = Port.S4,
            ir_beacon_channel: int = 1):
        self.ev3_brick = EV3Brick()

        self.crushing_claw_motor = \
            Motor(port=crushing_claw_motor_port,
                  positive_direction=Direction.CLOCKWISE)
        self.moving_motor = \
            Motor(port=moving_motor_port,
                  positive_direction=Direction.CLOCKWISE)
        self.lightning_tail_motor = \
            Motor(port=lightning_tail_motor_port,
                  positive_direction=Direction.CLOCKWISE)

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

        self.touch_sensor = TouchSensor(port=touch_sensor_port)
        self.color_sensor = ColorSensor(port=color_sensor_port)
コード例 #3
0
    def __init__(self,
                 left_foot_motor_port: Port = Port.B,
                 right_foot_motor_port: Port = Port.C,
                 bazooka_blast_motor_port: Port = Port.A,
                 touch_sensor_port: Port = Port.S1,
                 color_sensor_port: Port = Port.S3,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        self.drive_base = DriveBase(
            left_motor=Motor(port=left_foot_motor_port,
                             positive_direction=Direction.CLOCKWISE),
            right_motor=Motor(port=right_foot_motor_port,
                              positive_direction=Direction.CLOCKWISE),
            wheel_diameter=self.WHEEL_DIAMETER,
            axle_track=self.AXLE_TRACK)

        self.bazooka_blast_motor = Motor(
            port=bazooka_blast_motor_port,
            positive_direction=Direction.CLOCKWISE)

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

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #4
0
    def __init__(
            self,
            wheel_diameter: float,
            axle_track: float,  # both in milimeters
            left_motor_port: Port = Port.B,
            right_motor_port: Port = Port.C,
            polarity: str = 'normal',
            ir_sensor_port: Port = Port.S4,
            ir_beacon_channel: int = 1):
        self.left_motor = Motor(
            port=left_motor_port,
            positive_direction=Direction.CLOCKWISE
            if polarity == 'normal' else Direction.COUNTERCLOCKWISE)

        self.right_motor = Motor(
            port=left_motor_port,
            positive_direction=Direction.CLOCKWISE
            if polarity == 'normal' else Direction.COUNTERCLOCKWISE)

        self.drive_base = DriveBase(left_motor=self.left_motor,
                                    right_motor=self.right_motor,
                                    wheel_diameter=wheel_diameter,
                                    axle_track=axle_track)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.tank_drive_ir_beacon_channel = ir_beacon_channel
コード例 #5
0
    def __init__(
            self,
            left_motor_port: str = Port.B, right_motor_port: str = Port.C,
            polarity: str = 'inversed',
            steer_motor_port: str = Port.A,
            ir_sensor_port: str = Port.S4, ir_beacon_channel: int = 1):
        if polarity == 'normal':
            self.left_motor = Motor(port=left_motor_port,
                                    positive_direction=Direction.CLOCKWISE)
            self.right_motor = Motor(port=right_motor_port,
                                     positive_direction=Direction.CLOCKWISE)
        else:
            self.left_motor = \
                Motor(port=left_motor_port,
                      positive_direction=Direction.COUNTERCLOCKWISE)
            self.right_motor = \
                Motor(port=right_motor_port,
                      positive_direction=Direction.COUNTERCLOCKWISE)
        self.driver = DriveBase(left_motor=self.left_motor,
                                right_motor=self.right_motor,
                                wheel_diameter=self.WHEEL_DIAMETER,
                                axle_track=self.AXLE_TRACK)

        self.steer_motor = Motor(port=steer_motor_port,
                                 positive_direction=Direction.CLOCKWISE)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #6
0
ファイル: bobb3e.py プロジェクト: israelptr/pybricks-projects
    def __init__(self,
                 left_motor_port: str = Port.B,
                 right_motor_port: str = Port.C,
                 lift_motor_port: str = Port.A,
                 ir_sensor_port: str = Port.S4,
                 ir_beacon_channel: int = 1):
        self.ev3_brick = EV3Brick()

        self.drive_base = \
            DriveBase(
                left_motor=
                    Motor(port=left_motor_port,
                          positive_direction=Direction.COUNTERCLOCKWISE),
                right_motor=
                    Motor(port=right_motor_port,
                          positive_direction=Direction.COUNTERCLOCKWISE),
                wheel_diameter=self.WHEEL_DIAMETER,
                axle_track=self.AXLE_TRACK)

        self.lift_motor = Motor(port=lift_motor_port,
                                positive_direction=Direction.CLOCKWISE)

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

        self.reversing = False
コード例 #7
0
    def __init__(self,
                 left_motor_port: Port = Port.B,
                 right_motor_port: Port = Port.C,
                 grip_motor_port: Port = Port.A,
                 touch_sensor_port: Port = Port.S1,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        self.drive_base = DriveBase(
            left_motor=Motor(port=left_motor_port,
                             positive_direction=Direction.CLOCKWISE),
            right_motor=Motor(port=right_motor_port,
                              positive_direction=Direction.CLOCKWISE),
            wheel_diameter=self.WHEEL_DIAMETER,
            axle_track=self.AXLE_TRACK)

        self.drive_base.settings(
            straight_speed=750,  # milimeters per second
            straight_acceleration=750,
            turn_rate=90,  # degrees per second
            turn_acceleration=90)

        self.grip_motor = Motor(port=grip_motor_port,
                                positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #8
0
    def __init__(self,
                 lever_motor_port: Port = Port.D,
                 touch_sensor_port: Port = Port.S1,
                 ir_sensor_port: Port = Port.S4):
        self.ev3_brick = EV3Brick()

        self.lever_motor = Motor(port=lever_motor_port,
                                 positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
コード例 #9
0
    def __init__(self):
        """The type of sensor is determined during the initialization."""

        self.type = "none"
        try:
            self.sensor = InfraredSensor(Port.S2)
            self.type = "infra"
        except:
            try:
                self.sensor = UltrasonicSensor(Port.S2)
                self.type = "ultra"
            except:
                print("No distance sensor")
コード例 #10
0
def fahre_bis_ir():
    """
    drive until ir distance drops below 50%
    """
    ev3.screen.load_image(ImageFile.PINCHED_LEFT)

    infrarot = InfraredSensor(Port.S4)
    db.drive(speed=20, turn_rate=0)
    while (infrarot.distance() > 50):
        time.sleep(0.1)
    db.stop()
    db.turn(180)
    db.straight(150)
コード例 #11
0
    def __init__(
            self,
            wheel_diameter: float, axle_track: float,   # both in milimeters
            left_motor_port: Port = Port.B, right_motor_port: Port = Port.C,
            ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):
        self.driver = \
            DriveBase(
                left_motor=Motor(port=left_motor_port,
                                 positive_direction=Direction.CLOCKWISE),
                right_motor=Motor(port=right_motor_port,
                                  positive_direction=Direction.CLOCKWISE),
                wheel_diameter=wheel_diameter,
                axle_track=axle_track)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #12
0
ファイル: wack3m.py プロジェクト: israelptr/pybricks-projects
    def __init__(
            self,
            left_motor_port: str = Port.B, right_motor_port: str = Port.C,
            middle_motor_port: str = Port.A,
            touch_sensor_port: str = Port.S1, ir_sensor_port: str = Port.S4):
        self.ev3_brick = EV3Brick()
        
        self.left_motor = Motor(port=left_motor_port,
                                positive_direction=Direction.CLOCKWISE)
        self.right_motor = Motor(port=right_motor_port,
                                 positive_direction=Direction.CLOCKWISE)
        self.middle_motor = Motor(port=middle_motor_port,
                                  positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
コード例 #13
0
    def __init__(
            self,
            left_foot_motor_port: Port = Port.B, right_foot_motor_port: Port = Port.C,
            medium_motor_port: Port = Port.A,
            touch_sensor_port: Port = Port.S1, color_sensor_port: Port = Port.S3,
            ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):            
        super().__init__(
            wheel_diameter=self.WHEEL_DIAMETER, axle_track=self.AXLE_TRACK,
            left_motor_port=left_foot_motor_port, right_motor_port=right_foot_motor_port,
            ir_sensor_port=ir_sensor_port, ir_beacon_channel=ir_beacon_channel)

        self.medium_motor = Motor(port=medium_motor_port)

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

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #14
0
    def __init__(
            self,
            sting_motor_port: Port = Port.D, go_motor_port: Port = Port.B,
            claw_motor_port: Port = Port.A,
            touch_sensor_port: Port = Port.S1, color_sensor_port: Port = Port.S3,
            ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):
        self.sting_motor = Motor(port=sting_motor_port,
                                 positive_direction=Direction.CLOCKWISE)
        self.go_motor = Motor(port=go_motor_port,
                              positive_direction=Direction.CLOCKWISE)
        self.claw_motor = Motor(port=claw_motor_port,
                                positive_direction=Direction.CLOCKWISE)

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

        self.touch_sensor = TouchSensor(port=touch_sensor_port)
        self.color_sensor = ColorSensor(port=color_sensor_port)
コード例 #15
0
    def __init__(
            self,
            left_motor_port: Port = Port.B, right_motor_port: Port = Port.C,
            jaw_motor_port: Port = Port.A,
            touch_sensor_port: Port = Port.S1,
            ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):
        self.left_motor = Motor(port=left_motor_port,
                                positive_direction=Direction.CLOCKWISE)
        self.right_motor = Motor(port=right_motor_port,
                                 positive_direction=Direction.CLOCKWISE)

        self.jaw_motor = Motor(port=jaw_motor_port,
                               positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #16
0
    def __init__(
            self,
            turn_motor_port: Port = Port.A,
            move_motor_port: Port = Port.B,
            scare_motor_port: Port = Port.D,
            touch_sensor_port: Port = Port.S1, color_sensor_port: Port = Port.S3,
            ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):
        self.turn_motor = Motor(port=turn_motor_port,
                                positive_direction=Direction.CLOCKWISE)
        self.move_motor = Motor(port=move_motor_port,
                                positive_direction=Direction.CLOCKWISE)
        self.scare_motor = Motor(port=scare_motor_port,
                                 positive_direction=Direction.CLOCKWISE)

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

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #17
0
    def __init__(self,
                 steering_motor_port: Port = Port.A,
                 driving_motor_port: Port = Port.B,
                 striking_motor_port: Port = Port.D,
                 touch_sensor_port: Port = Port.S1,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        self.ev3_brick = EV3Brick()

        self.steering_motor = Motor(port=steering_motor_port,
                                    positive_direction=Direction.CLOCKWISE)
        self.driving_motor = Motor(port=driving_motor_port,
                                   positive_direction=Direction.CLOCKWISE)
        self.striking_motor = Motor(port=striking_motor_port,
                                    positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #18
0
    def __init__(self,
                 back_foot_motor_port: Port = Port.C,
                 front_foot_motor_port: Port = Port.B,
                 gear_motor_port: Port = Port.A,
                 touch_sensor_port: Port = Port.S1,
                 color_sensor_port: Port = Port.S3,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        self.front_foot_motor = Motor(port=front_foot_motor_port,
                                      positive_direction=Direction.CLOCKWISE)
        self.back_foot_motor = Motor(
            port=back_foot_motor_port,
            positive_direction=Direction.COUNTERCLOCKWISE)

        self.gear_motor = Motor(port=gear_motor_port)

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

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #19
0
ファイル: ev3_game.py プロジェクト: wsy2220/pybricks-projects
    def __init__(self,
                 b_motor_port: Port = Port.B,
                 c_motor_port: Port = Port.C,
                 grip_motor_port: Port = Port.A,
                 touch_sensor_port: Port = Port.S1,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        self.ev3_brick = EV3Brick()

        self.b_motor = Motor(port=b_motor_port,
                             positive_direction=Direction.CLOCKWISE)
        self.c_motor = Motor(port=c_motor_port,
                             positive_direction=Direction.CLOCKWISE)

        self.grip_motor = Motor(port=grip_motor_port,
                                positive_direction=Direction.CLOCKWISE)

        self.touch_sensor = TouchSensor(port=touch_sensor_port)

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #20
0
    def __init__(self,
                 left_motor_port: Port = Port.B,
                 right_motor_port: Port = Port.C,
                 catapult_motor_port: Port = Port.A,
                 touch_sensor_port: Port = Port.S1,
                 color_sensor_port: Port = Port.S3,
                 ir_sensor_port: Port = Port.S4,
                 ir_beacon_channel: int = 1):
        super().__init__(wheel_diameter=self.WHEEL_DIAMETER,
                         axle_track=self.AXLE_TRACK,
                         left_motor_port=left_motor_port,
                         right_motor_port=right_motor_port,
                         ir_sensor_port=ir_sensor_port,
                         ir_beacon_channel=ir_beacon_channel)

        self.catapult_motor = Motor(port=catapult_motor_port,
                                    positive_direction=Direction.CLOCKWISE)

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

        self.ir_sensor = InfraredSensor(port=ir_sensor_port)
        self.ir_beacon_channel = ir_beacon_channel
コード例 #21
0
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile
from time import sleep
# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.
# Create your objects here.
ev3 = EV3Brick()
# Write your program here.
ev3.speaker.beep()
# Initialize the motors.
left_motor = Motor(Port.A)
right_motor = Motor(Port.B)
# Initialize the drive base.
robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=104)
ir_sensor = InfraredSensor(Port.S4)
ir_sensor.beacon(1)
while True:
    buttons = ir_sensor.keypad()
    if len(buttons) == 1:
        print(buttons[0])
        if (buttons[0] == Button.LEFT_UP):
            print("###")
            robot.straight(-30)
        elif (buttons[0] == Button.RIGHT_UP):
            pass
        elif (buttons[0] == Button.LEFT_DOWN):
            pass
        elif (buttons[0] == Button.RIGHT_DOWN):
            pass
    elif len(buttons) == 2:
コード例 #22
0
ファイル: main.py プロジェクト: Widizzi/EV3-Roomcontrol
Room Control handles the light and the sound in your room with a lego
EV3 Robot. It uses the light switch and pressed it with a motor. So it's
the perfect idea if there isn't already a inbuild smart-home system.

Idea and Code comes from Widizzi

Version-1.0.0

'''

ev3 = EV3Brick()
watch = StopWatch()

motor = Motor(Port.A)
soundMotor = Motor(Port.B)
sensor = InfraredSensor(Port.S1)
colorSensor = ColorSensor(Port.S2)
infraredSensor = InfraredSensor(Port.S3)
touchSensor = TouchSensor(Port.S4)

# true when ev3 is forced to shutdown
shutdown = False
# room state
active = False
# light state
light = False
# sound state
sound = False
# true if manual mode is active
manualLight = False
manualSound = False
コード例 #23
0
ファイル: main.py プロジェクト: Xaplomian/MaizeRoboCupSBHS
                                 SoundFile, ImageFile, Align)
from pybricks.tools import print as pt
from pybricks.tools import wait, StopWatch
from pybricks.robotics import DriveBase
import MotorActions as MA
import Calibaration as Cal
import lightsensor

# Write your program here
brick.sound.beep()
left = Motor(Port.B)
right = Motor(Port.C)
robot = DriveBase(left, right, 50, 100)
ForwardSensor = UltrasonicSensor(Port.S1)
cSensor = ColorSensor(Port.S2)
LeftSensor = InfraredSensor(Port.S3)
lightSensor = lightsensor.CustomLight(Port.S4)
time = 0


def foundvictim():
    notes = [(523, 1000), (494, 1000), (440, 500), (330, 500),
             ("repeat", 5, 330), ("repeat", 3, 440), (440, 500), (392, 250),
             (440, 500), (349, 500)]
    #  brick.sound.beep(frequency=500, duration=100, volume=30)
    for note in notes:
        if note[0] == "repeat":
            for i in range(note[1]):
                brick.sound.beep(note[2], 125, 10)
                wait(125)
        else:
コード例 #24
0
 def __init__(self, sensor_input):
     """
     Initializes the ultrasonic sensor component.
     :param sensor_input: the input pin of the sensor
     """
     self._sensor = InfraredSensor(sensor_input)
コード例 #25
0
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, InfraredSensor)
from pybricks.parameters import Port, Button
from pybricks.tools import wait

# Initialize the EV3 Brick
ev3 = EV3Brick()

# Set volume to 100% and make a beep to signify program has started
ev3.speaker.set_volume(100)
ev3.speaker.beep()

# Initialize EV3 touch sensor and motors
motorLeft = Motor(Port.A)
motorRight = Motor(Port.B)
infrared = InfraredSensor(Port.S1)

# Create a loop to react to buttons
while True:

    # Check for center button events
    if Button.CENTER in ev3.buttons.pressed():
        motorLeft.stop()
        motorRight.stop()
        break

    # React to the left up and down buttons
    if Button.LEFT_DOWN in infrared.keypad():
        motorLeft.dc(-50)
    elif Button.LEFT_UP in infrared.keypad():
        motorLeft.dc(50)
コード例 #26
0
                   positive_direction=Direction.CLOCKWISE)
RIGHT_MOTOR = Motor(port=Port.C,
                    positive_direction=Direction.CLOCKWISE)
WHEEL_DIAMETER = 26
AXLE_TRACK = 140
DRIVE_BASE = DriveBase(left_motor=LEFT_MOTOR,
                       right_motor=RIGHT_MOTOR,
                       wheel_diameter=WHEEL_DIAMETER,
                       axle_track=AXLE_TRACK)
DRIVE_BASE.settings(
    straight_speed=750,   # milimeters per second
    straight_acceleration=750,
    turn_rate=90,   # degrees per second
    turn_acceleration=90)

IR_SENSOR = InfraredSensor(port=Port.S4)


MEDIUM_MOTOR.run_time(
    speed=-200,   # deg/s
    time=1000,   # ms
    then=Stop.HOLD,
    wait=True)

while True:
    if IR_SENSOR.distance() < 25:
        BRICK.screen.load_image(ImageFile.PINCHED_RIGHT)

        DRIVE_BASE.turn(angle=-180)

        BRICK.screen.load_image(ImageFile.ANGRY)
コード例 #27
0
 def iniciaSensorInfra(self, portaSensor): # Para o sensor infravermelho
     self.sensor = InfraredSensor(portaSensor)
     self.tipoSensor = "infra"
コード例 #28
0
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile
import random

# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.

# Create your objects here.
ev3 = EV3Brick()
irSensor = InfraredSensor(Port.S2)
motor = Motor
touchsensor = TouchSensor(Port.S3)

# Write your program here.

# Initialize two motors with default settings on Port B and Port C.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)
# The wheel diameter of the Robot Educator is 56 millimeters. # The distance between wheels (axle_track) is 114 millimeters.
wheel_diameter = 43.2
axle_track = 145
# Create a DriveBase object. The wheel_diameter and axle_track values are needed to move robot correct speed/distance when you give drive commands.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# This drives at 100 mm/sec straight
コード例 #29
0
ファイル: main.py プロジェクト: JesperLarsson/RobotTest
enableBeaconMoves = False
enableSensorAutoMove = False
posDeadZone = 40  # Upwards sensor deadzone, will not move when within this
negDeadZone = 40  # Downwards sensor deadzone, will not move when within this
infraredChannel = 1

# Touch sensors
enableTouchSensors = False

# Sensor auto movement
sensorAutoDeadzone = 3

# Init
print("Initializing...")
ev3 = EV3Brick()
ir = InfraredSensor(Port.S4)

moveMotorLeft = Motor(Port.D)
moveMotorRight = Motor(Port.A)

sensorMotorLeft = Motor(Port.C)
sensorMotorRight = Motor(Port.B)

if enableTouchSensors:
    touchSensorRight = TouchSensor(Port.S1)
    touchSensorLeft = TouchSensor(Port.S2)
print("Init OK")


# Draws text on the given row on robot LCD screen
def DrawText(textString, targetRow):
コード例 #30
0
 def __init__(self):
     self.infraredSensor = InfraredSensor(Port.S2)