Ejemplo n.º 1
0
/**
 * Get the recently set outputValue setpoint.
 *
 * 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.
 *
 * @return The most recently set outputValue setpoint.
 */
float CANJaguar::Get()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    switch(m_controlMode)
    {
    case kPercentVbus:
	getTransaction(LM_API_VOLT_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackPercentage(dataBuffer);
	}
	break;
    case kSpeed:
	getTransaction(LM_API_SPD_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int32_t))
	{
	    return unpackFXP16_16(dataBuffer);
	}
	break;
    case kPosition:
	getTransaction(LM_API_POS_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int32_t))
	{
	    return unpackFXP16_16(dataBuffer);
	}
	break;
    case kCurrent:
	getTransaction(LM_API_ICTRL_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackFXP8_8(dataBuffer);
	}
	break;
    case kVoltage:
	getTransaction(LM_API_VCOMP_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackFXP8_8(dataBuffer);
	}
	break;
    }
    return 0.0;
}
Ejemplo n.º 2
0
/**
 * Get the internal temperature of the Jaguar.
 *
 * @return The temperature of the Jaguar in degrees Celsius.
 */
float CANJaguar::GetTemperature()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    getTransaction(LM_API_STATUS_TEMP, dataBuffer, &dataSize);
    if (dataSize == sizeof(int16_t))
    {
	return unpackFXP8_8(dataBuffer);
    }
    return 0.0;
}
Ejemplo n.º 3
0
/**
 * Get the current through the motor terminals of the Jaguar.
 *
 * @return The output current in Amps.
 */
float CANJaguar::GetOutputCurrent()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    getTransaction(LM_API_STATUS_CURRENT, dataBuffer, &dataSize);
    if (dataSize == sizeof(int16_t))
    {
	return unpackFXP8_8(dataBuffer);
    }
    return 0.0;
}
Ejemplo n.º 4
0
/**
 * Get the voltage at the battery input terminals of the Jaguar.
 *
 * @return The bus voltage in Volts.
 */
float CANJaguar::GetBusVoltage()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    getTransaction(LM_API_STATUS_VOLTBUS, dataBuffer, &dataSize);
    if (dataSize == sizeof(int16_t))
    {
	return unpackFXP8_8(dataBuffer);
    }
    return 0.0;
}
Ejemplo n.º 5
0
/**
 * Get the internal temperature of the Jaguar.
 * 
 * @return The temperature of the Jaguar in degrees Celsius.
 */
float CANJaguar::GetTemperature()
{
	UINT8 dataBuffer[8];
	UINT8 dataSize;

	getTransaction(LM_API_STATUS_TEMP, dataBuffer, &dataSize);
	if (dataSize == sizeof(INT16))
	{
		return unpackFXP8_8(dataBuffer);
	}
	return 0.0;
}
Ejemplo n.º 6
0
/**
 * Get the voltage being output from the motor terminals of the Jaguar.
 *
 * @return The output voltage in Volts.
 */
float CANJaguar::GetOutputVoltage()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    // Read the volt out which is in Volts units.
    getTransaction(LM_API_STATUS_VOUT, dataBuffer, &dataSize);
    if (dataSize == sizeof(int16_t))
    {
	return unpackFXP8_8(dataBuffer);
    }
    return 0.0;
}