Matthew's Portfolio
ctrlTask.ctrlTask Class Reference

Controller for the system. More...

Public Member Functions

def __init__ (self, kMatrixX, kMatrixY, debugFlag=True)
 Create a controller task. More...
 
def ctrlTaskFcn (self)
 State machine for running the controller. More...
 
def transitionTo (self, state, newState)
 Method for transitioning states. More...
 

Public Attributes

 debugFlag
 Debugging flag for detailed analysis while running.
 
 kPrimeFactor
 Conversion factor for going from torque to duty cycle.
 
 kMatrixX
 K matrix for motor X as derived analytically and tuned.
 
 kMatrixY
 K matrix for motor X as derived analytically and tuned.
 
 xThresh
 Threshold to determine if the ball is balanced in the center (mm)
 
 yThresh
 Threshold to determine if the ball is balanced in the center (mm)
 
 dataToSave
 A flag to determine if we're saving x or y data. More...
 

Static Public Attributes

 S0_INIT = const(0)
 The initial state to set up the task.
 
 S1_BALANCE_PLATFORM = const(1)
 State to allow the platform to initially be balanced.
 
 S2_BALANCE_BALL = const(2)
 Main state to run the controller and balance the ball.
 
 S3_STOP_MOTORS = const(3)
 State to turn off motors (as specified or if balanced).
 

Detailed Description

Controller for the system.

This class implements the full-state feedback control algorithm to balance the platform with the ball in the center.

Constructor & Destructor Documentation

◆ __init__()

def ctrlTask.ctrlTask.__init__ (   self,
  kMatrixX,
  kMatrixY,
  debugFlag = True 
)

Create a controller task.

This task will be called from the priority scheduler to read from shares.py in order to get the ball's newest position and velocity as well as the platform's angle and angular velocity.

Parameters
kMatrixXK matrix for the x motor for the full-state feedback controller.
kMatrixYK matrix for the y motor for the full-state feedback controller.
debugFlagEnables or prevents certain print statements from appearing.

Member Function Documentation

◆ ctrlTaskFcn()

def ctrlTask.ctrlTask.ctrlTaskFcn (   self)

State machine for running the controller.

This generator is used to run the controller. It will read commands from the uiTask as well as send new duty cycles to the motors.

◆ transitionTo()

def ctrlTask.ctrlTask.transitionTo (   self,
  state,
  newState 
)

Method for transitioning states.

The method will reassign the state variable when directed to transition.

Parameters
stateThe current state of the system.
newStateThe new desired state for the system.
Returns
The new state of the finite state machine.

Member Data Documentation

◆ dataToSave

ctrlTask.ctrlTask.dataToSave

A flag to determine if we're saving x or y data.

The corrected K value for multiplying against the x position.

The corrected K value for multiplying against the y theta.

The corrected K value for multiplying against the x velocity.

The corrected K value for multiplying against the y angular velocity.

The corrected K value for multiplying against the y position.

The corrected K value for multiplying against the x theta.

The corrected K value for multiplying against the y velocity.

The corrected K value for multiplying against the x angular velocity.

Contains the information for which state its in.

Flag to determine if x or y data will be stored

The current command as sent from the uiTask

The current x position of the ball

The current y theta of the platform (as read by encoders)

The current x velocity of the ball

The current y angular velocity of the platform (as read by encoders)

The current y position of the ball

The current x theta of the platform (as read by encoders)

The current y velocity of the ball

The current x angular velocity of the platform (as read by encoders)


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