FeedForward
Constructors
FeedForward()
Create a FeedForward
object for the fiven constants.
- Prototype
- Example
FeedForward(const double _kv, const double _ks, const double _ka);
lightning::FeedForward speed_controller (5,1000,350);
Parameters | |
---|---|
_kv | The velocity constant. |
_ks | The Friction constant. |
_ka | Acceleration control. |
FeedForward() copy
Copy constructor.
- Prototype
- Example
FeedForward(const FeedForward &other);
lightning::FeedForward speed_controller (5,1000,350);
lightning::FeedForward another_controller(speed_controller);
Parameters | |
---|---|
other | FeedForward object to copy. |
Functions
update()
Updates the controller.
info
You should put this function inside of while loop to update the input to the current reading.
- Prototype
- Example
void update(const double input);
//Controlling a Flywheel
void move_flywheel(lightning::FeedForward controller,const int target_rpm){
float velocity = get_flywheel_velocity();
while(1){
float velocity = get_flywheel_velocity();
controller.update(velocity);
flywheel.move_voltage(controller.get_output());
}
}
Parameters | |
---|---|
input | The actual input of the controller. "The current reading" |
Setters
set_kv()
Sets the kv constant.
- Prototype
- Example
void set_kv(const double kv);
void autonomous(){
velocity_control.set_kv(2.12);
}
Parameters | |
---|---|
kv | The kv constant. |
set_ks()
Sets the ks constant.
- Prototype
- Example
void set_ks(const double ks);
void autonomous(){
velocity_control.set_ks(1500);
}
Parameters | |
---|---|
ks | The friction constant. |
set_ka()
Sets the ka constant.
- Prototype
- Example
void set_ka(const double ka);
void autonomous(){
velocity_control.set_ka(2.25);
}
Parameters | |
---|---|
ka | The acceleration constant. |
Getters
get_kv()
Get the kv constant.
- Prototype
- Example
double get_kv(void) const;
null
Returns: The kv constant.
get_ks()
Get the friction constant
- Prototype
- Example
double get_ks(void) const;
double ks_constant = controller.get_ks();
Returns: The ks constant.
get_ka()
Gets the acceleration constant.
- Prototype
- Example
double get_ka(void) const;
double ka_constant = controller.get_ka();
Returns: The Ka constant.
get_output
Gets the current output of the controller.
note
You should put this output to your motors. Sending as voltage.
- Prototype
- Example
double get_output(void) const;
//Controlling a Flywheel
void move_flywheel(lightning::FeedForward controller,const int target_rpm){
float velocity = get_flywheel_velocity();
while(1){
float velocity = get_flywheel_velocity();
controller.update(velocity);
flywheel.move_voltage(controller.get_output());
}
}
Returns: The current output.