예제 #1
0
  /**
   * Set the output set-point value.
   *
   * <p>The scale and the units depend on the mode the Jaguar is in. In PercentVbus Mode, the
   * outputValue is from -1.0 to 1.0 (same as PWM Jaguar). In Voltage Mode, the outputValue is in
   * Volts. In Current Mode, the outputValue is in Amps. In Speed Mode, the outputValue is in
   * Rotations/Minute. In Position Mode, the outputValue is in Rotations.
   *
   * @param outputValue The set-point to sent to the motor controller.
   * @param syncGroup The update group to add this set() to, pending updateSyncGroup(). If 0, update
   *     immediately.
   */
  public void setX(double outputValue, byte syncGroup) throws CANTimeoutException {
    int messageID = 0;
    byte[] dataBuffer = new byte[8];
    byte dataSize = 0;

    if (!m_safetyHelper.isAlive()) {
      enableControl();
    }

    switch (m_controlMode.value) {
      case ControlMode.kPercentVbus_val:
        messageID = JaguarCANProtocol.LM_API_VOLT_T_SET;
        if (outputValue > 1.0) outputValue = 1.0;
        if (outputValue < -1.0) outputValue = -1.0;
        packPercentage(dataBuffer, outputValue);
        dataSize = 2;
        break;
      case ControlMode.kSpeed_val:
        {
          messageID = JaguarCANProtocol.LM_API_SPD_T_SET;
          dataSize = packFXP16_16(dataBuffer, outputValue);
        }
        break;
      case ControlMode.kPosition_val:
        {
          messageID = JaguarCANProtocol.LM_API_POS_T_SET;
          dataSize = packFXP16_16(dataBuffer, outputValue);
        }
        break;
      case ControlMode.kCurrent_val:
        {
          messageID = JaguarCANProtocol.LM_API_ICTRL_T_SET;
          dataSize = packFXP8_8(dataBuffer, outputValue);
        }
        break;
      case ControlMode.kVoltage_val:
        {
          messageID = JaguarCANProtocol.LM_API_VCOMP_T_SET;
          dataSize = packFXP8_8(dataBuffer, outputValue);
        }
        break;
      default:
        return;
    }
    if (syncGroup != 0) {
      dataBuffer[dataSize] = syncGroup;
      dataSize++;
    }
    setTransaction(messageID, dataBuffer, dataSize);
    m_safetyHelper.feed();
  }
예제 #2
0
 public boolean isAlive() {
   return m_safetyHelper.isAlive();
 }