コード例 #1
0
ファイル: motors.py プロジェクト: ranul-pallemulle/Mars-Rover
    def __init__(self):
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("Wheels")
        left_pwm_pin = cfg.motor_config.get_pwm_pin("Wheels", "Left")
        left_digital_pin = cfg.motor_config.get_digital_pin("Wheels", "Left")

        right_pwm_pin = cfg.motor_config.get_pwm_pin("Wheels", "Right")
        right_digital_pin = cfg.motor_config.get_digital_pin("Wheels", "Right")

        self._ymax = 100
        self._xmax = 100

        self.leftmotor_in1_pin = left_digital_pin
        self.rightmotor_in1_pin = right_digital_pin
        self.PWM_left = left_pwm_pin
        self.PWM_right = right_pwm_pin

        io.setmode(io.BCM)

        io.setup(self.leftmotor_in1_pin, io.OUT)
        io.setup(self.rightmotor_in1_pin, io.OUT)
        io.output(self.leftmotor_in1_pin, False)
        io.output(self.rightmotor_in1_pin, False)

        io.setwarnings(False)

        self.duty_cycle = 4095
        self.PCA9685_pwm = PCA9685_motor.PCA9685()
        self.PCA9685_pwm.set_pwm_freq(60)
コード例 #2
0
    def __init__(self):
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("DeployableCamera")
        dg.print("Deployable camera motors settings:")

        servo1_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo1")
        self.servo1_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo1", "Upper")
        self.servo1_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo1", "Lower")
        servo2_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo2")
        self.servo2_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo2", "Upper")
        self.servo2_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo2", "Lower")
        servo3_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo3")
        self.servo3_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo3", "Upper")
        self.servo3_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo3", "Lower")

        dg.print("   Servo 1 pin: {}".format(servo1_pin))
        dg.print("   Servo 1 upper limit: {}".format(self.servo1_lim_upper))
        dg.print("   Servo 1 lower limit: {}".format(self.servo1_lim_lower))
        dg.print("   Servo 2 pin: {}".format(servo2_pin))
        dg.print("   Servo 2 upper limit: {}".format(self.servo2_lim_upper))
        dg.print("   Servo 2 lower limit: {}".format(self.servo2_lim_lower))
        dg.print("   Servo 3 pin: {}".format(servo3_pin))
        dg.print("   Servo 3 upper limit: {}".format(self.servo3_lim_upper))
        dg.print("   Servo 3 lower limit: {}".format(self.servo3_lim_lower))
コード例 #3
0
    def __init__(self):
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("DeployableCamera")
        self.i2c = busio.I2C(board.SCL, board.SDA)
        self.servo = adafruit_pca9685.PCA9685(self.i2c)
        self.kit = ServoKit(channels=16)
        servo1_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo1")
        self.servo1_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo1", "Upper")
        self.servo1_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo1", "Lower")
        servo2_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo2")
        self.servo2_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo2", "Upper")
        self.servo2_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo2", "Lower")
        servo3_pin = cfg.motor_config.get_pin("DeployableCamera", "Servo3")
        self.servo3_lim_upper = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo3", "Upper")
        self.servo3_lim_lower = cfg.motor_config.get_limit(
            "DeployableCamera", "Servo3", "Lower")

        self.servo_top = self.kit.servo[servo1_pin]
        self.servo_middle = self.kit.servo[servo2_pin]
        self.servo_bottom = self.kit.servo[servo3_pin]
        self.servo_top.actuation_range = 360
        self.servo_middle.actuation_range = 360
        self.servo_bottom.actuation_range = 360
        self.servo_top.set_pulse_width_range(500, 3250)
        self.servo_middle.set_pulse_width_range(500, 3250)
        self.servo_bottom.set_pulse_width_range(500, 3250)
コード例 #4
0
 def __init__(self):
     Resource.__init__(self)
     self.policy = Policy.SHARED
     self.register_name("Ultrasound")
     try:
         self.trigger_pin = cfg.auto_config.ultrasound_trigger_pin()
         self.echo_pin = cfg.auto_config.ultrasound_echo_pin()
     except cfg.ConfigurationError as e:
         raise ResourceRawError(str(e))
     self.active = False
     self.distance = -1
     self.lock = RWLock()
コード例 #5
0
    def __init__(self):
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("Arm")
        dg.print("Mock arm motors settings:")

        servo1_pin = cfg.motor_config.get_pin("Arm", "Servo1")
        servo2_pin = cfg.motor_config.get_pin("Arm", "Servo2")
        servo3_pin = cfg.motor_config.get_pin("Arm", "Servo3")
        gripper_pin = cfg.motor_config.get_pin("Arm", "Gripper")

        dg.print("    Servo 1 pin: {}".format(servo1_pin))
        dg.print("    Servo 2 pin: {}".format(servo2_pin))
        dg.print("    Servo 3 pin: {}".format(servo3_pin))
        dg.print("    Gripper pin: {}".format(gripper_pin))
コード例 #6
0
    def __init__(self):
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("Wheels")
        self._ymax = 100
        self._xmax = 100
        self.duty_cycle = 4095
        dg.print("Mock wheel motors settings:")

        left_pwm_pin = cfg.motor_config.get_pwm_pin("Wheels", "Left")
        left_digital_pin = cfg.motor_config.get_digital_pin("Wheels", "Left")
        right_pwm_pin = cfg.motor_config.get_pwm_pin("Wheels", "Right")
        right_digital_pin = cfg.motor_config.get_digital_pin("Wheels", "Right")

        dg.print("    Left PWM pin: {}".format(left_pwm_pin))
        dg.print("    Left digital pin: {}".format(left_digital_pin))
        dg.print("    Right PWM pin: {}".format(right_pwm_pin))
        dg.print("    Right digital pin: {}".format(right_digital_pin))
コード例 #7
0
 def __init__(self):
     '''Register name and access policy. Obtain settings from 
     CameraConfiguration. Initialise members.'''
     Resource.__init__(self)
     self.policy = Policy.SHARED
     self.register_name("Camera")
     try:
         self.source = cfg.cam_config.device()  # gstreamer device name
         self.framerate = cfg.cam_config.capture_framerate()
         self.frame_width = cfg.cam_config.capture_frame_width()
         self.frame_height = cfg.cam_config.capture_frame_height()
     except cfg.ConfigurationError as e:
         raise ResourceRawError(str(e))
     self.gst_comm = None  # string corresponding to gstreamer pipe
     self.cap = None  # opencv capture object
     self.active = False
     self.camlock = RWLock()  # allow multiple readers, single writer
     self.frame = np.zeros(3)  # current camera frame
コード例 #8
0
ファイル: motors.py プロジェクト: ranul-pallemulle/Mars-Rover
    def __init__(self):
        """
        Call set_values to set angles ofs servos.
        Will need to callibrate for limits
        """
        Resource.__init__(self)
        self.policy = Policy.UNIQUE
        self.register_name("Arm")

        self.i2c = busio.I2C(board.SCL, board.SDA)
        # self.servo = PCA9685_servo.PCA9685(self.i2c)
        self.servo = adafruit_pca9685.PCA9685(self.i2c)
        self.kit = ServoKit(channels=16)

        gripper_pin = cfg.motor_config.get_pin("Arm", "Gripper")
        servo1_pin = cfg.motor_config.get_pin("Arm", "Servo1")
        servo2_pin = cfg.motor_config.get_pin("Arm", "Servo2")
        servo3_pin = cfg.motor_config.get_pin("Arm", "Servo3")

        #servo1_pwm_pin = cfg.motor_config.get_pwm_pin("Arm", "Servo1")
        #servo1_digital_pin = cfg.motor_config.get_digital_pin("Arm", "Servo1")
        #servo2_pwm_pin = cfg.motor_config.get_pwm_pin("Arm", "Servo2")
        #servo2_digital_pin = cfg.motor_config.get_digital_pin("Arm", "Servo2")
        #servo3_pwm_pin = cfg.motor_config.get_pwm_pin("Arm", "Servo3")
        #servo3_digital_pin = cfg.motor_config.get_digital_pin("Arm", "Servo3")
        #gripper_pwm_pin = cfg.motor_config.get_pwm_pin("Arm", "Gripper")
        #gripper_digital_pin = cfg.motor_config.get_digital_pin("Arm", "Gripper")

        # 3 Servos, defines PIN numbers
        self.servo_grab = self.kit.servo[gripper_pin]
        self.servo_top = self.kit.servo[servo1_pin]
        self.servo_middle = self.kit.servo[servo2_pin]
        self.servo_bottom = self.kit.servo[servo3_pin]

        self.servo_grab.actuation_range = 360
        self.servo_top.actuation_range = 360
        self.servo_middle.actuation_range = 360
        self.servo_bottom.actuation_range = 360

        # Callibrated to Proper Servo values.
        self.servo_grab.set_pulse_width_range(500, 3250)
        self.servo_top.set_pulse_width_range(500, 3250)
        self.servo_middle.set_pulse_width_range(500, 3250)
        self.servo_bottom.set_pulse_width_range(500, 3250)
コード例 #9
0
 def __init__(self):
     Resource.__init__(self)
     self.policy = Policy.SHARED
     self.register_name("IPCamera")
     self.host = None
     self.port = 5520