RIT VEXU Core API
Loading...
Searching...
No Matches
Flywheel Class Reference

#include <flywheel.h>

Public Member Functions

 Flywheel (vex::motor_group &motors, Feedback &feedback, FeedForward &helper, const double ratio, Filter &filt)
 
double get_target () const
 
double getRPM () const
 
vex::motor_group & get_motors () const
 
void spin_manual (double speed, directionType dir=fwd)
 
void spin_rpm (double rpm)
 
void stop ()
 
bool is_on_target ()
 check if the feedback controller thinks the flywheel is on target
 
screen::PagePage () const
 Creates a page displaying info about the flywheel.
 
AutoCommand * SpinRpmCmd (int rpm)
 Creates a new auto command to spin the flywheel at the desired velocity.
 
AutoCommand * WaitUntilUpToSpeedCmd ()
 Creates a new auto command that will hold until the flywheel has its target as defined by its feedback controller.
 

Friends

int spinRPMTask (void *wheelPointer)
 

Detailed Description

a Flywheel class that handles all control of a high inertia spinning disk It gives multiple options for what control system to use in order to control wheel velocity and functions alerting the user when the flywheel is up to speed. Flywheel is a set and forget class. Once you create it you can call spin_rpm or stop on it at any time and it will take all necessary steps to accomplish this

Constructor & Destructor Documentation

◆ Flywheel()

Flywheel::Flywheel ( vex::motor_group & motors,
Feedback & feedback,
FeedForward & helper,
const double ratio,
Filter & filt )

Create the Flywheel object using PID + feedforward for control.

Parameters
motorspointer to the motors on the fly wheel
feedbacka feedback controleller
helpera feedforward config (only kV is used) to help the feedback controller along
ratioratio of the gears from the motor to the flywheel just multiplies the velocity
filterthe filter to use to smooth noisy motor readings

Member Function Documentation

◆ get_motors()

motor_group & Flywheel::get_motors ( ) const

Returns the motors

Returns
the motors used to run the flywheel

◆ get_target()

double Flywheel::get_target ( ) const

Return the target_rpm that the flywheel is currently trying to achieve

Returns
target_rpm the target rpm

Return the current value that the target_rpm should be set to

◆ getRPM()

double Flywheel::getRPM ( ) const

return the velocity of the flywheel

◆ is_on_target()

bool Flywheel::is_on_target ( )
inline

check if the feedback controller thinks the flywheel is on target

Returns
true if on target

◆ Page()

screen::Page * Flywheel::Page ( ) const

Creates a page displaying info about the flywheel.

Returns
the page should be used for `screen::start_screen(screen, {fw.Page()});

◆ spin_manual()

void Flywheel::spin_manual ( double speed,
directionType dir = fwd )

Spin motors using voltage; defaults forward at 12 volts FOR USE BY OPCONTROL AND AUTONOMOUS - this only applies if the target_rpm thread is not running

Parameters
speed- speed (between -1 and 1) to set the motor
dir- direction that the motor moves in; defaults to forward

Spin motors using voltage; defaults forward at 12 volts FOR USE BY OPCONTROL AND AUTONOMOUS - this only applies if the RPM thread is not running

Parameters
speed- speed (between -1 and 1) to set the motor
dir- direction that the motor moves in; defaults to forward

◆ spin_rpm()

void Flywheel::spin_rpm ( double input_rpm)

starts or sets the target_rpm thread at new value what control scheme is dependent on control_style

Parameters
rpm- the target_rpm we want to spin at

starts or sets the RPM thread at new value what control scheme is dependent on control_style

Parameters
input_rpm- set the current RPM

◆ SpinRpmCmd()

AutoCommand * Flywheel::SpinRpmCmd ( int rpm)
inline

Creates a new auto command to spin the flywheel at the desired velocity.

Parameters
rpmthe rpm to spin at
Returns
an auto command to add to a command controller

◆ stop()

void Flywheel::stop ( )

Stops the motors. If manually spinning, this will do nothing just call spin_mainual(0.0) to send 0 volts

stop the RPM thread and the wheel

◆ WaitUntilUpToSpeedCmd()

AutoCommand * Flywheel::WaitUntilUpToSpeedCmd ( )
inline

Creates a new auto command that will hold until the flywheel has its target as defined by its feedback controller.

Returns
an auto command to add to a command controller

Friends And Related Symbol Documentation

◆ spinRPMTask

int spinRPMTask ( void * wheelPointer)
friend

Runs a thread that keeps track of updating flywheel RPM and controlling it accordingly


The documentation for this class was generated from the following files: