LRT14
1.0
|
Asynchronous implementation of a CAN driver for the Jaguar. More...
#include <AsyncCANJaguar.h>
Public Member Functions | |
AsyncCANJaguar (UINT8 channel, std::string name) | |
Constructs a new Jaguar on the CAN network. | |
~AsyncCANJaguar () | |
Destroys the AsyncCANJaguar object. | |
void | Update () |
Sends the saved values to the speed controllers. | |
void | SetDutyCycle (float duty_cycle) |
Set the duty cycle of the Jaguar. | |
void | SetPosition (float position) |
Set the output position of the Jaguar. | |
void | SetVelocity (float velocity) |
Set the output velocity of the Jaguar. | |
void | SetPID (double p, double i, double d) |
Set the PID parameters. | |
void | ConfigNeutralMode (LRTSpeedController::NeutralMode mode) |
Set the new neutral mode. | |
void | SetSpeedReference (SpeedReference reference) |
Set the new speed reference. | |
void | ChangeControlMode (CANJaguar::ControlMode mode) |
Set the new control mode. | |
void | EnableControl (double encoderInitialPosition=0.0) |
Enables control. | |
void | SetVoltageRampRate (double rampRate) |
Set ramp rate of voltage output. | |
void | ConfigEncoderCodesPerRev (UINT16 codesPerRev) |
Set number of encoder codes per revolution. | |
void | ConfigPotentiometerTurns (UINT16 turns) |
Set number of potentiometer turns. | |
void | ConfigSoftPositionLimits (double forwardLimitPosition, double reverseLimitPosition) |
Sets soft position limits. | |
void | DisableSoftPositionLimits () |
Disables soft position limits. | |
void | DisableControl () |
Disables control. | |
void | ConfigMaxOutputVoltage (double voltage) |
Sets maximum output voltage. | |
void | ConfigFaultTime (float faultTime) |
Configure Fault time. | |
void | SetExpiration (float timeout) |
Configure Expiration time. | |
void | SetPositionReference (CANJaguar::PositionReference reference) |
Set the new position reference. | |
void | AddCollectionFlags (uint32_t flags=0xffffffff) |
Sets (does not clear) new collection flags. | |
void | RemoveCollectionFlags (uint32_t flags=0xffffffff) |
Clears (does not set) existing collection flags. | |
void | SetCollectionFlags (uint32_t flags) |
Sets collection flags to input (will clear old flags) | |
float | GetDutyCycle () |
Get the duty cycle of the Jaguar that is pending to be sent. | |
float | GetHardwareValue () |
Get the duty cycle of the Jaguar that was last received. | |
LRTSpeedController::NeutralMode | GetNeutralMode () |
Gets the neutral mode (brake or coast). | |
double | GetP () |
Gets the P gain. | |
double | GetI () |
Gets the I gain. | |
double | GetD () |
Gets the D gain. | |
SpeedReference | GetSpeedReference () |
Gets the current speed reference. | |
PositionReference | GetPositionReference () |
Gets the current position reference. | |
ControlMode | GetControlMode () |
Gets the control mode. | |
float | GetBusVoltage () |
Gets the bus voltage. | |
float | GetOutputVoltage () |
Gets the output voltage. | |
double | GetOutputCurrent () |
Gets the output current. | |
float | GetTemperature () |
Gets the temperature. | |
float | GetPosition () |
Gets the position. | |
double | GetSpeed () |
Gets the speed. | |
bool | GetForwardLimitOK () |
Get forward limit m_status. | |
bool | GetReverseLimitOK () |
Get reverse limit m_status. | |
bool | GetPowerCycled () |
Get power cycle m_status. | |
float | GetExpiration () |
Get expiration time. | |
bool | StatusOK () |
Simple wrapper for GetFaults() == 0. | |
void | ResetCache () |
Clear the cache. | |
![]() | |
void | RunOneCycle () |
Gives a semaphore which allows Tick() to be called. | |
virtual void | preTick () |
Takes a semaphore which blocks Tick() until RunOneCycle() is called. | |
![]() | |
void | Output () |
Checks safety and sends the saved values to the speed controllers. | |
void | RegisterSafety (CounterBase *encoder, double timeoutSeconds, float threshold=0.01) |
Registers an encoder with this speed controller for stall safety. | |
virtual void | SafetyCallback () |
Called when safety fails on this speed controller. | |
virtual void | Log () |
Logs data to the Logger. | |
virtual void | Send () |
Sends data to the LiveNetworkSender. | |
Static Public Attributes | |
static std::vector < AsyncCANJaguar * > | jaguar_vector |
Linked list of all of the constructed AsyncCANJaguars. | |
Protected Member Functions | |
void | Tick () |
Does the actual communication, not including timing. | |
Additional Inherited Members | |
![]() | |
static float | CurrentLimit (float dutyCycle, float speed, float forwardLimit, float reverseLimit) |
Calculates a duty cycle with current limiting applied. | |
Asynchronous implementation of a CAN driver for the Jaguar.
Reimplements the large majority of useful operations on the Jaguar in a threaded fashion.
AsyncCANJaguar::AsyncCANJaguar | ( | UINT8 | channel, |
std::string | name | ||
) |
Constructs a new Jaguar on the CAN network.
channel | Channel that the Jaguar is assigned to |
name | The name of the Jaguar |
void AsyncCANJaguar::AddCollectionFlags | ( | uint32_t | flags = 0xffffffff | ) |
Sets (does not clear) new collection flags.
flags | The flags to be set, defaults to all |
void AsyncCANJaguar::ChangeControlMode | ( | CANJaguar::ControlMode | mode | ) |
Set the new control mode.
mode | the new mode |
void AsyncCANJaguar::ConfigEncoderCodesPerRev | ( | UINT16 | codesPerRev | ) |
Set number of encoder codes per revolution.
codesPerRev | codes per revolution |
void AsyncCANJaguar::ConfigFaultTime | ( | float | faultTime | ) |
Configure Fault time.
faultTime | Fault time |
void AsyncCANJaguar::ConfigMaxOutputVoltage | ( | double | voltage | ) |
Sets maximum output voltage.
voltage | The voltage |
|
virtual |
Set the new neutral mode.
mode | the new mode |
Implements LRTSpeedController.
void AsyncCANJaguar::ConfigPotentiometerTurns | ( | UINT16 | turns | ) |
Set number of potentiometer turns.
turns | number of potentiometer turns |
void AsyncCANJaguar::ConfigSoftPositionLimits | ( | double | forwardLimitPosition, |
double | reverseLimitPosition | ||
) |
Sets soft position limits.
forwardLimitPosition | forward soft position limit |
reverseLimitPosition | reverse soft position limit |
void AsyncCANJaguar::EnableControl | ( | double | encoderInitialPosition = 0.0 | ) |
Enables control.
encoderInitialPosition | the initial position of the encoder |
float AsyncCANJaguar::GetBusVoltage | ( | ) |
Gets the bus voltage.
CANJaguar::ControlMode AsyncCANJaguar::GetControlMode | ( | ) |
Gets the control mode.
double AsyncCANJaguar::GetD | ( | ) |
Gets the D gain.
|
virtual |
Get the duty cycle of the Jaguar that is pending to be sent.
Implements LRTSpeedController.
float AsyncCANJaguar::GetExpiration | ( | ) |
Get expiration time.
bool AsyncCANJaguar::GetForwardLimitOK | ( | ) |
Get forward limit m_status.
|
virtual |
Get the duty cycle of the Jaguar that was last received.
Implements LRTSpeedController.
double AsyncCANJaguar::GetI | ( | ) |
Gets the I gain.
|
virtual |
Gets the neutral mode (brake or coast).
Implements LRTSpeedController.
double AsyncCANJaguar::GetOutputCurrent | ( | ) |
Gets the output current.
float AsyncCANJaguar::GetOutputVoltage | ( | ) |
Gets the output voltage.
double AsyncCANJaguar::GetP | ( | ) |
Gets the P gain.
float AsyncCANJaguar::GetPosition | ( | ) |
Gets the position.
CANJaguar::PositionReference AsyncCANJaguar::GetPositionReference | ( | ) |
Gets the current position reference.
bool AsyncCANJaguar::GetPowerCycled | ( | ) |
Get power cycle m_status.
bool AsyncCANJaguar::GetReverseLimitOK | ( | ) |
Get reverse limit m_status.
double AsyncCANJaguar::GetSpeed | ( | ) |
Gets the speed.
CANJaguar::SpeedReference AsyncCANJaguar::GetSpeedReference | ( | ) |
Gets the current speed reference.
float AsyncCANJaguar::GetTemperature | ( | ) |
Gets the temperature.
void AsyncCANJaguar::RemoveCollectionFlags | ( | uint32_t | flags = 0xffffffff | ) |
Clears (does not set) existing collection flags.
flags | The flags to be cleared, defaults to all |
void AsyncCANJaguar::SetCollectionFlags | ( | uint32_t | flags | ) |
Sets collection flags to input (will clear old flags)
flags | Flag register |
|
virtual |
Set the duty cycle of the Jaguar.
duty_cycle |
Implements LRTSpeedController.
void AsyncCANJaguar::SetExpiration | ( | float | timeout | ) |
Configure Expiration time.
timeout | Expiration timeout |
void AsyncCANJaguar::SetPID | ( | double | p, |
double | i, | ||
double | d | ||
) |
Set the PID parameters.
p | proportional gain |
i | integral gain |
d | derivative gain |
void AsyncCANJaguar::SetPosition | ( | float | position | ) |
Set the output position of the Jaguar.
position |
void AsyncCANJaguar::SetPositionReference | ( | CANJaguar::PositionReference | reference | ) |
Set the new position reference.
reference | The new reference |
void AsyncCANJaguar::SetSpeedReference | ( | SpeedReference | reference | ) |
Set the new speed reference.
reference | the new reference |
void AsyncCANJaguar::SetVelocity | ( | float | velocity | ) |
Set the output velocity of the Jaguar.
velocity |
void AsyncCANJaguar::SetVoltageRampRate | ( | double | rampRate | ) |
Set ramp rate of voltage output.
rampRate | ramp rate |
bool AsyncCANJaguar::StatusOK | ( | ) |
Simple wrapper for GetFaults() == 0.