コード例 #1
0
ファイル: main.py プロジェクト: reecej/GroundControl
    def computeSettings(self, section, key, value):
        # Update Computed settings
        if key == 'kinematicsType':
            if value == 'Quadrilateral':
                self.config.set('Computed Settings', 'kinematicsTypeComputed',
                                "1")
            else:
                self.config.set('Computed Settings', 'kinematicsTypeComputed',
                                "2")

        elif (key == 'gearTeeth'
              or key == 'chainPitch') and self.config.has_option(
                  'Advanced Settings', 'gearTeeth') and self.config.has_option(
                      'Advanced Settings', 'chainPitch'):
            distPerRot = float(
                self.config.get('Advanced Settings', 'gearTeeth')) * float(
                    self.config.get('Advanced Settings', 'chainPitch'))
            self.config.set('Computed Settings', "distPerRot", str(distPerRot))

        elif key == 'enablePosPIDValues':
            for key in ('KpPos', 'KiPos', 'KdPos', 'propWeight'):
                if int(
                        self.config.get('Advanced Settings',
                                        'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue(
                        'Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)

        elif key == 'enableVPIDValues':
            for key in ('KpV', 'KiV', 'KdV'):
                if int(
                        self.config.get('Advanced Settings',
                                        'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue(
                        'Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)

        elif key == 'chainOverSprocket':
            if value == 'Top':
                self.config.set('Computed Settings',
                                'chainOverSprocketComputed', 1)
            else:
                self.config.set('Computed Settings',
                                'chainOverSprocketComputed', 2)

        elif key == 'fPWM':
            if value == '31,000Hz':
                self.config.set('Computed Settings', 'fPWMComputed', 1)
            elif value == '4,100Hz':
                self.config.set('Computed Settings', 'fPWMComputed', 2)
            else:
                self.config.set('Computed Settings', 'fPWMComputed', 3)
コード例 #2
0
    def computeSettings(self, section, key, value):
        # Update Computed settings
        if key == 'kinematicsType':
            if value == 'Quadrilateral':
                self.config.set('Computed Settings', 'kinematicsTypeComputed', "1")
            else:
                self.config.set('Computed Settings', 'kinematicsTypeComputed', "2")

        elif (key == 'gearTeeth' or key == 'chainPitch') and self.config.has_option('Advanced Settings', 'gearTeeth') and self.config.has_option('Advanced Settings', 'chainPitch'):
            distPerRot = float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch'))
            self.config.set('Computed Settings', "distPerRot", str(distPerRot))

            if self.config.has_option('Advanced Settings', 'leftChainTolerance'):
                distPerRotLeftChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'leftChainTolerance')) / 100)) * float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch'))
                self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str("{0:.5f}".format(distPerRotLeftChainTolerance)))
            if self.config.has_option('Advanced Settings', 'rightChainTolerance'):
                distPerRotRightChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'rightChainTolerance')) / 100)) * float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch'))
                self.config.set('Computed Settings', "distPerRotRightChainTolerance", str("{0:.5f}".format(distPerRotRightChainTolerance)))
        
        elif key == 'leftChainTolerance' and self.config.has_option('Advanced Settings', 'leftChainTolerance') and self.config.has_option('Computed Settings', 'distPerRot'):
            distPerRotLeftChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'leftChainTolerance')) / 100)) * float(self.config.get('Computed Settings', 'distPerRot'))
            self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str("{0:.5f}".format(distPerRotLeftChainTolerance)))
        
        elif key == 'rightChainTolerance' and self.config.has_option('Advanced Settings', 'rightChainTolerance') and self.config.has_option('Computed Settings', 'distPerRot'):
            distPerRotRightChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'rightChainTolerance')) / 100)) * float(self.config.get('Computed Settings', 'distPerRot'))
            self.config.set('Computed Settings', "distPerRotRightChainTolerance", str("{0:.5f}".format(distPerRotRightChainTolerance)))
        
        elif key == 'enablePosPIDValues':
            for key in ('KpPos', 'KiPos', 'KdPos', 'propWeight'):
                if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue('Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)

        elif key == 'enableVPIDValues':
            for key in ('KpV', 'KiV', 'KdV'):
                if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue('Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)
        
        elif key == 'chainOverSprocket':
            if value == 'Top':
                self.config.set('Computed Settings',  'chainOverSprocketComputed', 1)
            else:
                self.config.set('Computed Settings',  'chainOverSprocketComputed', 2)

        elif key == 'fPWM':
            if value == '31,000Hz':
                self.config.set('Computed Settings',  'fPWMComputed', 1)
            elif value == '4,100Hz':
                self.config.set('Computed Settings',  'fPWMComputed', 2)
            else: 
                self.config.set('Computed Settings',  'fPWMComputed', 3)