Beispiel #1
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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #5
0
 def setPositionPercent(self, position):
     position = n.arduino_map(position, 0, 100, MIN, MAX)
     self.setPosition(position)
Beispiel #6
0
 def setThrottle(self, throttle):
     self.throttle = throttle
     self.setServoValue(
         self.channel, n.arduino_map(throttle, MIN, MAX, servoMin,
                                     servoMax))
Beispiel #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))
Beispiel #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))
Beispiel #9
0
 def tiltToPositionWithLimits(self, tilt, upTilt, downTilt):
     return n.arduino_map(tilt, downTilt, upTilt, self.down, self.up)
Beispiel #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)
Beispiel #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)
Beispiel #12
0
 def setPositionPercent(self, position):
     position = n.arduino_map(position, 0, 100, MIN, MAX)
     self.setPosition(position)
Beispiel #13
0
 def positionToTilt(self, position):
     return n.arduino_map(position, self.down, self.up, self.downTilt, self.upTilt)
Beispiel #14
0
 def tiltToPositionWithLimits(self, tilt, upTilt, downTilt):
     return n.arduino_map(tilt, downTilt, upTilt, self.down, self.up)
Beispiel #15
0
 def tiltToPosition(self, tilt):
     return n.arduino_map(tilt, self.downTilt, self.upTilt, self.down, self.up)
Beispiel #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))
Beispiel #17
0
 def tiltToPosition(self, tilt):
     return n.arduino_map(tilt, self.downTilt, self.upTilt, self.down,
                          self.up)
Beispiel #18
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)
Beispiel #19
0
 def positionToTilt(self, position):
     return n.arduino_map(position, self.down, self.up, self.downTilt,
                          self.upTilt)
Beispiel #20
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)