RIT VEXU Core API
Loading...
Searching...
No Matches
Lift< T > Class Template Reference

#include <lift.h>

Classes

struct  lift_cfg_t
 

Public Member Functions

 Lift (motor_group &lift_motors, lift_cfg_t &lift_cfg, map< T, double > &setpoint_map, limit *homing_switch=NULL)
 
void control_continuous (bool up_ctrl, bool down_ctrl)
 
void control_manual (bool up_btn, bool down_btn, int volt_up, int volt_down)
 
void control_setpoints (bool up_step, bool down_step, vector< T > pos_list)
 
bool set_position (T pos)
 
bool set_setpoint (double val)
 
double get_setpoint ()
 
void hold ()
 
void home ()
 
bool get_async ()
 
void set_async (bool val)
 
void set_sensor_function (double(*fn_ptr)(void))
 
void set_sensor_reset (void(*fn_ptr)(void))
 

Detailed Description

template<typename T>
class Lift< T >

LIFT A general class for lifts (e.g. 4bar, dr4bar, linear, etc) Uses a PID to hold the lift at a certain height under load, and to move the lift to different heights

Author
Ryan McGee

Constructor & Destructor Documentation

◆ Lift()

template<typename T >
Lift< T >::Lift ( motor_group & lift_motors,
lift_cfg_t & lift_cfg,
map< T, double > & setpoint_map,
limit * homing_switch = NULL )
inline

Construct the Lift object and begin the background task that controls the lift.

Usage example: /code{.cpp} enum Positions {UP, MID, DOWN}; map<Positions, double> setpt_map { {DOWN, 0.0}, {MID, 0.5}, {UP, 1.0} }; Lift<Positions> my_lift(motors, lift_cfg, setpt_map); /endcode

Parameters
lift_motorsA set of motors, all set that positive rotation correlates with the lift going up
lift_cfgLift characterization information; PID tunings and movement speeds
setpoint_mapA map of enum type T, in which each enum entry corresponds to a different lift height

Member Function Documentation

◆ control_continuous()

template<typename T >
void Lift< T >::control_continuous ( bool up_ctrl,
bool down_ctrl )
inline

Control the lift with an "up" button and a "down" button. Use PID to hold the lift when letting go.

Parameters
up_ctrlButton controlling the "UP" motion
down_ctrlButton controlling the "DOWN" motion

◆ control_manual()

template<typename T >
void Lift< T >::control_manual ( bool up_btn,
bool down_btn,
int volt_up,
int volt_down )
inline

Control the lift with manual controls (no holding voltage)

Parameters
up_btnRaise the lift when true
down_btnLower the lift when true
volt_upMotor voltage when raising the lift
volt_downMotor voltage when lowering the lift

◆ control_setpoints()

template<typename T >
void Lift< T >::control_setpoints ( bool up_step,
bool down_step,
vector< T > pos_list )
inline

Control the lift in "steps". When the "up" button is pressed, the lift will go to the next position as defined by pos_list. Order matters!

Parameters
up_stepA button that increments the position of the lift.
down_stepA button that decrements the position of the lift.
pos_listA list of positions for the lift to go through. The higher the index, the higher the lift should be (generally).

◆ get_async()

template<typename T >
bool Lift< T >::get_async ( )
inline
Returns
whether or not the background thread is running the lift

◆ get_setpoint()

template<typename T >
double Lift< T >::get_setpoint ( )
inline
Returns
The current setpoint for the lift

◆ hold()

template<typename T >
void Lift< T >::hold ( )
inline

Target the class's setpoint. Calculate the PID output and set the lift motors accordingly.

◆ home()

template<typename T >
void Lift< T >::home ( )
inline

A blocking function that automatically homes the lift based on a sensor or hard stop, and sets the position to 0. A watchdog times out after 3 seconds, to avoid damage.

◆ set_async()

template<typename T >
void Lift< T >::set_async ( bool val)
inline

Enables or disables the background task. Note that running the control functions, or set_position functions will immediately re-enable the task for autonomous use.

Parameters
valWhether or not the background thread should run the lift

◆ set_position()

template<typename T >
bool Lift< T >::set_position ( T pos)
inline

Enable the background task, and send the lift to a position, specified by the setpoint map from the constructor.

Parameters
posA lift position enum type
Returns
True if the pid has reached the setpoint

◆ set_sensor_function()

template<typename T >
void Lift< T >::set_sensor_function ( double(*)(void) fn_ptr)
inline

Creates a custom hook for any other type of sensor to be used on the lift. Example: /code{.cpp} my_lift.set_sensor_function( [](){return my_sensor.position();} ); /endcode

Parameters
fn_ptrPointer to custom sensor function

◆ set_sensor_reset()

template<typename T >
void Lift< T >::set_sensor_reset ( void(*)(void) fn_ptr)
inline

Creates a custom hook to reset the sensor used in set_sensor_function(). Example: /code{.cpp} my_lift.set_sensor_reset( my_sensor.resetPosition ); /endcode

◆ set_setpoint()

template<typename T >
bool Lift< T >::set_setpoint ( double val)
inline

Manually set a setpoint value for the lift PID to go to.

Parameters
valLift setpoint, in motor revolutions or sensor units defined by get_sensor. Cannot be outside the softstops.
Returns
True if the pid has reached the setpoint

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