Ejemplo n.º 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();
  }
Ejemplo n.º 2
0
  /**
   * Common relay initialization method. This code is common to all Relay constructors and
   * initializes the relay and reserves all resources that need to be locked. Initially the relay is
   * set to both lines at 0v.
   */
  private void initRelay() {
    SensorBase.checkRelayChannel(m_channel);
    impl = new SimSpeedController("simulator/relay/" + m_channel);

    m_safetyHelper = new MotorSafetyHelper(this);
    m_safetyHelper.setSafetyEnabled(false);

    LiveWindow.addActuator("Relay", m_channel, this);
  }
Ejemplo n.º 3
0
 /** Provides the service routine for the DS polling thread. */
 private void task() {
   int safetyCounter = 0;
   while (m_thread_keepalive) {
     try {
       m_packetDataAvailableSem.takeForever();
       synchronized (this) {
         getData();
         m_enhancedIO.updateData();
         setData();
       }
       synchronized (m_dataSem) {
         m_dataSem.notifyAll();
       }
       if (++safetyCounter >= 5) {
         //               System.out.println("Checking safety");
         MotorSafetyHelper.checkMotors();
         safetyCounter = 0;
       }
     } catch (SemaphoreException ex) {
       //
     }
   }
 }
Ejemplo n.º 4
0
 public void setSafetyEnabled(boolean enabled) {
   m_safetyHelper.setSafetyEnabled(enabled);
 }
Ejemplo n.º 5
0
 public boolean isSafetyEnabled() {
   return m_safetyHelper.isSafetyEnabled();
 }
Ejemplo n.º 6
0
 public boolean isAlive() {
   return m_safetyHelper.isAlive();
 }
Ejemplo n.º 7
0
 public double getExpiration() {
   return m_safetyHelper.getExpiration();
 }
Ejemplo n.º 8
0
 public void setExpiration(double timeout) {
   m_safetyHelper.setExpiration(timeout);
 }