示例#1
0
    def setF(self, f):
        """
        Set the feedforward value of the currently selected profile.

        :param f: Feedforward constant for the currently selected PID profile.
        :see: #setProfile For selecting a certain profile.
        """
        if self.profile == 0:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot0_F, f)
        else:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot1_F, f)
示例#2
0
    def setD(self, d):
        """
        Set the derivative constant of the currently selected profile.

        :param d: Derivative constant for the currently selected PID profile.
        :see: #setProfile For selecting a certain profile.
        """
        if self.profile == 0:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot0_D, d)
        else:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot1_D, d)
示例#3
0
    def setI(self, i):
        """
        Set the integration constant of the currently selected profile.

        :param i: Integration constant for the currently selected PID profile.
        :see: #setProfile For selecting a certain profile.
        """
        if self.profile == 0:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot0_I, i)
        else:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot1_I, i)
示例#4
0
    def setP(self, p):
        """
        Set the proportional value of the currently selected profile.

        :param p: Proportional constant for the currently selected PID profile.
        :see: #setProfile For selecting a certain profile.
        """
        if self.profile == 0:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot0_P, p)
        else:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot1_P, p)
示例#5
0
    def setCloseLoopRampRate(self, rampRate):
        """
        Set the closed loop ramp rate for the current profile.

        Limits the rate at which the throttle will change.
        Only affects position and speed closed loop modes.

        :param rampRate: Maximum change in voltage, in volts / sec.
        :see: #setProfile For selecting a certain profile.
        """
        # CanTalonSRX takes units of Throttle (0 - 1023) / 1ms.
        rate = int(rampRate * 1023.0 / 12.0 / 1000.0)
        if self.profile == 0:
            hal.TalonSRX_SetParam(
                self.handle,
                hal.TalonSRXParam.eProfileParamSlot0_CloseLoopRampRate, rate)
        else:
            hal.TalonSRX_SetParam(
                self.handle,
                hal.TalonSRXParam.eProfileParamSlot1_CloseLoopRampRate, rate)
示例#6
0
    def setIZone(self, izone):
        """
        Set the integration zone of the current Closed Loop profile.

        Whenever the error is larger than the izone value, the accumulated
        integration error is cleared so that high errors aren't racked up when
        at high errors.

        An izone value of 0 means no difference from a standard PIDF loop.

        :param izone: Width of the integration zone.
        :see: #setProfile For selecting a certain profile.
        """
        if self.profile == 0:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot0_IZone,
                                  izone)
        else:
            hal.TalonSRX_SetParam(self.handle,
                                  hal.TalonSRXParam.eProfileParamSlot1_IZone,
                                  izone)
示例#7
0
 def configRevLimitSwitchNormallyOpen(self, normallyOpen):
     """
     * Configure the rev limit switch to be normally open or normally closed.
     * Talon will disable momentarilly if the Talon's current setting
     * is dissimilar to the caller's requested setting.
     *
     * Since Talon saves setting to flash this should only affect
     * a given Talon initially during robot install.
     *
     * @param normallyOpen true for normally open.  false for normally closed.
     """
     hal.TalonSRX_SetParam(
         self.handle,
         hal.TalonSRXParam.eOnBoot_LimitSwitch_Reverse_NormallyClosed,
         0 if normallyOpen else 1)
示例#8
0
    def configFwdLimitSwitchNormallyOpen(self, normallyOpen):
        """
        Configure the fwd limit switch to be normally open or normally closed.
        Talon will disable momentarilly if the Talon's current setting
        is dissimilar to the caller's requested setting.

        Since Talon saves setting to flash this should only affect
        a given Talon initially during robot install.

        :param normallyOpen: True for normally open. False for normally closed.
        """
        hal.TalonSRX_SetParam(
            self.handle,
            hal.TalonSRXParam.eOnBoot_LimitSwitch_Forward_NormallyClosed,
            0 if normallyOpen else 1)
示例#9
0
 def enableReverseSoftLimit(self, enable):
     hal.TalonSRX_SetParam(
         self.handle, hal.TalonSRXParam.eProfileParamSoftLimitRevEnable,
         1 if enable else 0)
示例#10
0
 def setReverseSoftLimit(self, reverseLimit):
     hal.TalonSRX_SetParam(
         self.handle, hal.TalonSRXParam.eProfileParamSoftLimitRevThreshold,
         reverseLimit)
示例#11
0
 def enableForwardSoftLimit(self, enable):
     hal.TalonSRX_SetParam(
         self.handle, hal.TalonSRXParam.eProfileParamSoftLimitForEnable,
         1 if enable else 0)
示例#12
0
 def setForwardSoftLimit(self, forwardLimit):
     hal.TalonSRX_SetParam(
         self.handle, hal.TalonSRXParam.eProfileParamSoftLimitForThreshold,
         forwardLimit)
示例#13
0
 def setSensorPosition(self, pos):
     hal.TalonSRX_SetParam(self.handle, hal.TalonSRXParam.eSensorPosition,
                           pos)
示例#14
0
 def clearIaccum(self):
     """
     Clear the accumulator for I gain.
     """
     hal.TalonSRX_SetParam(self.handle, hal.TalonSRXParam.ePidIaccum, 0)