示例#1
0
    def __init__(self):
        """
        This constructor sets the variables to the following values:
        : CONST_GRIPPER_FULL_OPEN : Position of gripper servo when open
        : CONST_GRIPPER_FULL_CLOSE: Position of gripper servo when closed
        : CONST_GRIPPER_FULL_OPEN : Position of gripper servo to grab ball
        : easygopigo3.EasyGoPiGo3 Easy_GPG: Initialization of EasyGoPiGo3
        : easygopigo3 Easy_GPG: Initialization of EasyGoPiGo3
        : easygopigo3.Servo gpgGripper: Initialization of Gripper Servo on Servo Pin 1
        : init_distance_sensor my_distance_sensor: Initialization of Distance Sensor
        : IOError: When the GoPiGo3 is not detected. It also debugs a message in the terminal.
        : gopigo3.FirmwareVersionError: If the GoPiGo3 firmware needs to be updated. It also debugs a message in the terminal.
        : Exception: For any other kind of exceptions.
        """

        # Settings for cars in US Reston Office (these grippers were built differently)
        self.CONST_GRIPPER_FULL_OPEN = 90
        self.CONST_GRIPPER_FULL_CLOSE = 0
        self.CONST_GRIPPER_GRAB_POSITION = 40

        # Settings for cars in London Office (default method of assembly for grippers)
        #self.CONST_GRIPPER_FULL_OPEN = 180
        #self.CONST_GRIPPER_FULL_CLOSE = 20
        #self.CONST_GRIPPER_GRAB_POSITION = 120

        self.Easy_GPG = easygopigo3.EasyGoPiGo3(
        )  # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
        self.gpgGripper = easygopigo3.Servo("SERVO1", self.Easy_GPG)
        self.my_distance_sensor = self.Easy_GPG.init_distance_sensor()
        self.SetLEDsGreen()
示例#2
0
# (on GPG3 some sensors do not require mutex)
# Nicole Parrot
####################################################

import easygopigo3 as easy

g = easy.EasyGoPiGo3(use_mutex=True)

light_sensor = easy.LightSensor(gpg=g, use_mutex=True)
buzzer = easy.Buzzer(gpg=g, use_mutex=True)
led = easy.Led(gpg=g, use_mutex=True)
motion = easy.MotionSensor(gpg=g, use_mutex=True)
button = easy.ButtonSensor(gpg=g, use_mutex=True)
remote = easy.Remote(gpg=g, use_mutex=True)
line_follower = easy.LineFollower(gpg=g, use_mutex=True)
servo = easy.Servo(gpg=g, use_mutex=True)
distance_sensor = easy.DistanceSensor(gpg=g, use_mutex=True)
dht = easy.DHTSensor(gpg=g, use_mutex=True)
assert (g.use_mutex == True)
assert (light_sensor.use_mutex == True)
assert (buzzer.use_mutex == True)
assert (led.use_mutex == True)
assert (motion.use_mutex == True)
assert (button.use_mutex == True)
assert (remote.use_mutex == True)
assert (line_follower.use_mutex == True)
assert (servo.use_mutex == True)
assert (distance_sensor.use_mutex == True)
assert (dht.use_mutex == True)
print("Done")