Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::VoltageEstimation Class Reference

Feedforward Controller. More...

#include <math.hpp>

Public Member Functions

 VoltageEstimation (kv_fn_t kV, double motorGearing=200)
 Creates a simple feedforward controller for a V5 motor. More...
 
double estimate (double rpm)
 Outputs an estimated voltage value for acheiving the desired RPM based on the kV function supplied in the constructor. More...
 
kv_fn_t getKv () const
 Gets the current kV function. More...
 
double getMotorGearing () const
 Gets the set motor gearing for the estimator. More...
 
void setkV (kv_fn_t value)
 Sets the kV function. More...
 
double getOutput () const
 Gets the current stored output value without adding any new input. More...
 

Detailed Description

Feedforward Controller.

Constructor & Destructor Documentation

◆ VoltageEstimation()

sylib::VoltageEstimation::VoltageEstimation ( kv_fn_t  kV,
double  motorGearing = 200 
)

Creates a simple feedforward controller for a V5 motor.

Parameters
kVA lambda function that takes double as an input for target RPM and returns a voltage constant to use for the estimation
motorGearingThe output speed of the motor, in RPM, if the motor internally is spinning at 3600 RPM. 200 is default for a green motor cartridge

Member Function Documentation

◆ estimate()

double sylib::VoltageEstimation::estimate ( double  rpm)

Outputs an estimated voltage value for acheiving the desired RPM based on the kV function supplied in the constructor.

Parameters
rpmThe target velocity of the motor, in RPM

◆ getKv()

kv_fn_t sylib::VoltageEstimation::getKv ( ) const

Gets the current kV function.

Returns
kV function

◆ getMotorGearing()

double sylib::VoltageEstimation::getMotorGearing ( ) const

Gets the set motor gearing for the estimator.

Returns
Output RPM of the motor at 100% velocity

◆ getOutput()

double sylib::VoltageEstimation::getOutput ( ) const

Gets the current stored output value without adding any new input.

Returns
Voltage estimate

◆ setkV()

void sylib::VoltageEstimation::setkV ( kv_fn_t  value)

Sets the kV function.

Parameters
valueA lambda function that takes double as an input for target RPM and returns a voltage constant to use for the estimation