예제 #1
0
파일: elevons.py 프로젝트: jeryfast/piflyer
 def setPitchRollFromInput(self, pitch, roll):
     # both elevons have equal limits to pitch and roll input
     # pitch and roll input have seperate limits
     pitch = n.arduino_map(n.clamp(pitch, self.pitchDownLimit, self.pitchUpLimit), self.pitchDownLimit,
                           self.pitchUpLimit, -45, 45)
     roll = n.arduino_map(n.clamp(roll, self.rollDownLimit, self.rollUpLimit), self.rollDownLimit, self.rollUpLimit,
                          -45, 45)
     self.setPitchRoll(pitch, roll)
예제 #2
0
 def setPitchRollFromInput(self, pitch, roll):
     # both elevons have equal limits to pitch and roll input
     # pitch and roll input have seperate limits
     pitch = n.arduino_map(
         n.clamp(pitch, self.pitchDownLimit, self.pitchUpLimit),
         self.pitchDownLimit, self.pitchUpLimit, -45, 45)
     roll = n.arduino_map(
         n.clamp(roll, self.rollDownLimit, self.rollUpLimit),
         self.rollDownLimit, self.rollUpLimit, -45, 45)
     self.setPitchRoll(pitch, roll)
예제 #3
0
    def setUpDownLimit(self, up, down):

        # save history for live servo update - to know which value to update - top/left or bottom/right
        a, b = self.oldRange
        u, d = False, False
        if (up != a):
            u = True
            self.oldRange[0] = up
        if (down != b):
            d = True
            self.oldRange[1] = down

        """
        Sets up and down servo limitations in percentage values: range - 0 to 100,
        useful for flap of airbrake definition, control surface offsets for
        airplane neutral point correction
        Correct upDirection values must be set to work properly
        up=0, down=100 -> full range
        """
        if (self.upAdd == -1):
            self.up = n.arduino_map(up, 0, 100, MIN, MAX)
            self.down = n.arduino_map(down, 0, 100, MIN, MAX)
            if (u):
                self.setPosition(self.up)
                print("Servo position: %d" % (self.up))
                u = False
            elif (d):
                self.setPosition(self.down)
                print("Servo position: %d" % (self.down))
                d = False
        elif (self.upAdd == 1):
            self.up = n.arduino_map(up, 0, 100, MAX, MIN)
            self.down = n.arduino_map(down, 0, 100, MAX, MIN)
            if (u):
                self.setPosition(self.up)
                print("Servo position: %d" % (self.up))
                u = False
            elif (d):
                self.setPosition(self.down)
                print("Servo position: %d" % (self.down))
                d = False
예제 #4
0
    def setUpDownLimit(self, up, down):

        # save history for live servo update - to know which value to update - top/left or bottom/right
        a, b = self.oldRange
        u, d = False, False
        if (up != a):
            u = True
            self.oldRange[0] = up
        if (down != b):
            d = True
            self.oldRange[1] = down
        """
        Sets up and down servo limitations in percentage values: range - 0 to 100,
        useful for flap of airbrake definition, control surface offsets for
        airplane neutral point correction
        Correct upDirection values must be set to work properly
        up=0, down=100 -> full range
        """
        if (self.upAdd == -1):
            self.up = n.arduino_map(up, 0, 100, MIN, MAX)
            self.down = n.arduino_map(down, 0, 100, MIN, MAX)
            if (u):
                self.setPosition(self.up)
                print("Servo position: %d" % (self.up))
                u = False
            elif (d):
                self.setPosition(self.down)
                print("Servo position: %d" % (self.down))
                d = False
        elif (self.upAdd == 1):
            self.up = n.arduino_map(up, 0, 100, MAX, MIN)
            self.down = n.arduino_map(down, 0, 100, MAX, MIN)
            if (u):
                self.setPosition(self.up)
                print("Servo position: %d" % (self.up))
                u = False
            elif (d):
                self.setPosition(self.down)
                print("Servo position: %d" % (self.down))
                d = False
예제 #5
0
 def setPositionPercent(self, position):
     position = n.arduino_map(position, 0, 100, MIN, MAX)
     self.setPosition(position)
예제 #6
0
 def setThrottle(self, throttle):
     self.throttle = throttle
     self.setServoValue(
         self.channel, n.arduino_map(throttle, MIN, MAX, servoMin,
                                     servoMax))
예제 #7
0
 def setThrottleFromInput(self, throttle):
     throttle = n.arduino_map(n.clamp(throttle, MIN, MAX), MIN, MAX,
                              self.minThrottle, self.maxThrottle)
     self.setThrottle(throttle)
     print("throttle: %d" % (self.throttle))
예제 #8
0
 def setServoValue(self, channel, value):
     t = time.time()
     if (t - self.timer > delays.SERVO_COMMAND_REFRESH_DELAY):
         self.timer = t
         value = n.arduino_map(value, 0, 180, servoMin, servoMax)
         pwm.set_pwm(channel, on, int(value))
예제 #9
0
 def tiltToPositionWithLimits(self, tilt, upTilt, downTilt):
     return n.arduino_map(tilt, downTilt, upTilt, self.down, self.up)
예제 #10
0
 def setRollFromInput(self, roll):
     roll = n.arduino_map(
         n.clamp(roll, self.rollDownLimit, self.rollUpLimit),
         self.rollDownLimit, self.rollUpLimit, -45, 45)
     self.setRoll(roll)
예제 #11
0
 def setPitchFromInput(self, pitch):
     pitch = n.arduino_map(
         n.clamp(pitch, self.pitchDownLimit, self.pitchUpLimit),
         self.pitchDownLimit, self.pitchUpLimit, -45, 45)
     self.setPitch(pitch)
예제 #12
0
 def setPositionPercent(self, position):
     position = n.arduino_map(position, 0, 100, MIN, MAX)
     self.setPosition(position)
예제 #13
0
 def positionToTilt(self, position):
     return n.arduino_map(position, self.down, self.up, self.downTilt, self.upTilt)
예제 #14
0
 def tiltToPositionWithLimits(self, tilt, upTilt, downTilt):
     return n.arduino_map(tilt, downTilt, upTilt, self.down, self.up)
예제 #15
0
 def tiltToPosition(self, tilt):
     return n.arduino_map(tilt, self.downTilt, self.upTilt, self.down, self.up)
예제 #16
0
 def setServoValue(self, channel, value):
     t = time.time()
     if (t - self.timer > delays.SERVO_COMMAND_REFRESH_DELAY):
         self.timer = t
         value = n.arduino_map(value, 0, 180, servoMin, servoMax)
         pwm.set_pwm(channel, on, int(value))
예제 #17
0
 def tiltToPosition(self, tilt):
     return n.arduino_map(tilt, self.downTilt, self.upTilt, self.down,
                          self.up)
예제 #18
0
파일: elevons.py 프로젝트: jeryfast/piflyer
 def setPitchFromInput(self, pitch):
     pitch = n.arduino_map(n.clamp(pitch, self.pitchDownLimit, self.pitchUpLimit), self.pitchDownLimit,
                           self.pitchUpLimit, -45, 45)
     self.setPitch(pitch)
예제 #19
0
 def positionToTilt(self, position):
     return n.arduino_map(position, self.down, self.up, self.downTilt,
                          self.upTilt)
예제 #20
0
파일: elevons.py 프로젝트: jeryfast/piflyer
 def setRollFromInput(self, roll):
     roll = n.arduino_map(n.clamp(roll, self.rollDownLimit, self.rollUpLimit), self.rollDownLimit, self.rollUpLimit,
                          -45, 45)
     self.setRoll(roll)