예제 #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)