Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::SpeedControllerInfo Struct Reference

Custom Velocity Controller. More...

#include <math.hpp>

Public Member Functions

 SpeedControllerInfo (kv_fn_t kV=[](double rpm) { return 0;}, double kP=0, double kI=0, double kD=0, double kH=0, bool antiWindupEnabled=false, double antiWindupRange=0, bool pRangeEnabled=false, double pRange=0, double kP2=0, double maxVoltageRange=0, bool coastDownEnabled=false, double coastDownRange=0, double coastDownModifier=1)
 

Public Attributes

kv_fn_t kV = [](double rpm) { return 0; }
 Lambda function to use for feedforward kV calculation. More...
 
double kP = 0
 P controller gain. More...
 
double kI = 0
 I controller gain. More...
 
double kD = 0
 D controller gain. More...
 
double kH = 0
 TBH controller gain. More...
 
bool antiWindupEnabled = false
 Whether or not to enable anti-windup on the I controller. More...
 
double antiWindupRange = 0
 Range to use for the anti-windup on the I controller, if enabled. More...
 
bool pRangeEnabled = false
 Whether or not to change the P controller gain within a certain target range. More...
 
double pRange = 0
 Range to use for changing P controller gain, if enabled. More...
 
double kP2 = 0
 Secondary kP value that the P controller uses when inside the target range, if enabled. More...
 
double maxVoltageRange = 0
 Positive range from target above which the motor applies max voltage outside of. More...
 
bool coastDownEnabled = false
 Whether or not to enable coast-down to more quickly move to a lower velocity. More...
 
double coastDownRange = 0
 Negative range from target below which the applied voltage is multiplied by the coast-down modifier. More...
 
double coastDownModifier = 1
 Constant to multiple the applied voltage by if error is below the coast-down range. More...
 

Detailed Description

Custom Velocity Controller.

To disable a particular controller, set its gain to 0.

Constructor & Destructor Documentation

◆ SpeedControllerInfo()

sylib::SpeedControllerInfo::SpeedControllerInfo ( kv_fn_t  kV = [](double rpm) { return 0; },
double  kP = 0,
double  kI = 0,
double  kD = 0,
double  kH = 0,
bool  antiWindupEnabled = false,
double  antiWindupRange = 0,
bool  pRangeEnabled = false,
double  pRange = 0,
double  kP2 = 0,
double  maxVoltageRange = 0,
bool  coastDownEnabled = false,
double  coastDownRange = 0,
double  coastDownModifier = 1 
)
inline

Member Data Documentation

◆ antiWindupEnabled

bool sylib::SpeedControllerInfo::antiWindupEnabled = false

Whether or not to enable anti-windup on the I controller.

◆ antiWindupRange

double sylib::SpeedControllerInfo::antiWindupRange = 0

Range to use for the anti-windup on the I controller, if enabled.

◆ coastDownEnabled

bool sylib::SpeedControllerInfo::coastDownEnabled = false

Whether or not to enable coast-down to more quickly move to a lower velocity.

◆ coastDownModifier

double sylib::SpeedControllerInfo::coastDownModifier = 1

Constant to multiple the applied voltage by if error is below the coast-down range.

◆ coastDownRange

double sylib::SpeedControllerInfo::coastDownRange = 0

Negative range from target below which the applied voltage is multiplied by the coast-down modifier.

◆ kD

double sylib::SpeedControllerInfo::kD = 0

D controller gain.

◆ kH

double sylib::SpeedControllerInfo::kH = 0

TBH controller gain.

◆ kI

double sylib::SpeedControllerInfo::kI = 0

I controller gain.

◆ kP

double sylib::SpeedControllerInfo::kP = 0

P controller gain.

◆ kP2

double sylib::SpeedControllerInfo::kP2 = 0

Secondary kP value that the P controller uses when inside the target range, if enabled.

◆ kV

kv_fn_t sylib::SpeedControllerInfo::kV = [](double rpm) { return 0; }

Lambda function to use for feedforward kV calculation.

◆ maxVoltageRange

double sylib::SpeedControllerInfo::maxVoltageRange = 0

Positive range from target above which the motor applies max voltage outside of.

◆ pRange

double sylib::SpeedControllerInfo::pRange = 0

Range to use for changing P controller gain, if enabled.

◆ pRangeEnabled

bool sylib::SpeedControllerInfo::pRangeEnabled = false

Whether or not to change the P controller gain within a certain target range.