ME 305 Group 6 Documentation
Functions | Variables
taskUser.py File Reference

Manages the states for the User Interface task. More...

Functions

def taskUser.printLegend (PrintQueue print_queue)
 Prints the available user key commands to the console. More...
 
def taskUser.printDevTools (PrintQueue print_queue)
 Prints the available dev tool key commands to the console. More...
 
def taskUser.taskUserFcn (str task_name, int period, shares.Share roll_target_duty, shares.Share pitch_target_duty, shares.Share gFlag, shares.Share sFlag, shares.Share prop_gain_roll, shares.Share deriv_gain_roll, shares.Share cont_enable, shares.Share euler_angles, shares.Share angular_velocities, shares.Share roll_target_pos, shares.Share pitch_target_pos, shares.Share x_target_position, shares.Share y_target_position, PrintQueue print_queue, shares.Share ball_detected, shares.Share x_position_signal, shares.Share y_position_signal, shares.Share imu_calib_status, shares.Share touch_calib_status, shares.Share positionx_prop_gain, shares.Share int_gain_roll, shares.Share positionx_deriv_gain, shares.Share positionx_int_gain, shares.Share positiony_prop_gain, shares.Share positiony_deriv_gain, shares.Share positiony_int_gain, shares.Share controller_signalsx, shares.Share controller_signalsy, shares.Share prop_gain_pitch, shares.Share deriv_gain_pitch, shares.Share int_gain_pitch, shares.Share data_collect_flag)
 Main task function to control UI states. More...
 

Variables

 taskUser.S0_INIT = micropython.const(0)
 State 0. More...
 
 taskUser.S1_CMD = micropython.const(1)
 State 1. More...
 
 taskUser.S2_IMUCAL = micropython.const(2)
 State 2. More...
 
 taskUser.S3_PRINT = micropython.const(3)
 State 3. More...
 
 taskUser.S4_INPUT = micropython.const(4)
 State 4. More...
 
 taskUser.S5_PANELCAL = micropython.const(5)
 State 5. More...
 
 taskUser.S6_SRESP = micropython.const(6)
 State 6. More...
 

Detailed Description

Manages the states for the User Interface task.

Manages the current state and executes state-related logic for all User Interface functionality. States available are:

  1. Initialization: Objects are instantiated and if sensors are not calibrated, triggers for the appropriate states are set.
  2. Command: User input is recieved and appropriate triggers actions are taken.
  3. IMU Calibration: The calibration method for the IMU is called.
  4. Print: Methods from the PrintQueue are called to print any outstanding jobs.
  5. Input: Multi-character input for things such as gain values are accepted in this state.
  6. Panel Calibration: The calibration method for the touch panel is called.
  7. Step Response: Perform a step response of the platform and log the results. These are later printed to the window.

A state diagram is shown below.

taskUser State Diagram

Author
Caleb Savard
Chris Linthacum
Date
March 18, 2022

Function Documentation

◆ printDevTools()

def taskUser.printDevTools ( PrintQueue  print_queue)

Prints the available dev tool key commands to the console.

Prints a table of available user input commands oriented towards dev tools to the console to preview the available user key commands.

Parameters
print_queueA print queue object to add the legend print statements to

◆ printLegend()

def taskUser.printLegend ( PrintQueue  print_queue)

Prints the available user key commands to the console.

Prints a table of available user input commands to the console to preview the available user key commands.

Parameters
print_queueA print queue object to add the legend print statements to

◆ taskUserFcn()

def taskUser.taskUserFcn ( str  task_name,
int  period,
shares.Share  roll_target_duty,
shares.Share  pitch_target_duty,
shares.Share  gFlag,
shares.Share  sFlag,
shares.Share  prop_gain_roll,
shares.Share  deriv_gain_roll,
shares.Share  cont_enable,
shares.Share  euler_angles,
shares.Share  angular_velocities,
shares.Share  roll_target_pos,
shares.Share  pitch_target_pos,
shares.Share  x_target_position,
shares.Share  y_target_position,
PrintQueue  print_queue,
shares.Share  ball_detected,
shares.Share  x_position_signal,
shares.Share  y_position_signal,
shares.Share  imu_calib_status,
shares.Share  touch_calib_status,
shares.Share  positionx_prop_gain,
shares.Share  int_gain_roll,
shares.Share  positionx_deriv_gain,
shares.Share  positionx_int_gain,
shares.Share  positiony_prop_gain,
shares.Share  positiony_deriv_gain,
shares.Share  positiony_int_gain,
shares.Share  controller_signalsx,
shares.Share  controller_signalsy,
shares.Share  prop_gain_pitch,
shares.Share  deriv_gain_pitch,
shares.Share  int_gain_pitch,
shares.Share  data_collect_flag 
)

Main task function to control UI states.

Manage different User Input states, including Init, Read_Cmd, Zero_Encoder, and Print_Data. On function run, executes the logic of the current state and if appropriate shifts state for next run of function.

Parameters
task_nameTask name for the function to help with debugging
periodPeriod to run execute function at. Period defines frequency that states are executed and refreshed.
roll_target_dutyShared data object to store the duty cycle for motor 1.
pitch_target_dutyShared data object to store the duty cycle for motor 2.
gFlagShared data object to encapsulate the g key being pressed. Signals to begin data collection.
sFlagShared data object to encapsulate the s key being pressed. Signals to end data collection prematurely.
prop_gain_rollShared data object for the roll controller proportional gain.
deriv_gain_rollShared data object for the roll controller derivative gain.
cont_enableShared data object to specificy whether closed-loop controller is enabled (True) or not
euler_anglesShared data object for the euler angles recorded by the IMU.
angular_velocitiesShared data object for the angular velocities being recorded by the IMU.
roll_target_posShared data object for the roll target position output from the angle controller.
pitch_target_posShared data object for the pitch target position being output from the angle controller.
x_target_positionShared data object for the target x position being fed to the angle controller.
y_target_positionShared data object for the target y position being fed to the angle controller.
print_queuePrint queue object for passing out print statements.
ball_detectedShared data object for if the ball is on the platform.
x_position_signalShared data object for the current X position of the ball.
y_position_signalShared data object for the current Y position of the ball.
imu_calib_statusShared data object for the IMU Calibration status.
touch_calib_statusShared data object for whether or not the touch panel is calibrated.
positionx_prop_gainShared data object for the x position controller proportional gain.
int_gain_rollShared data object for the roll angle controller integral gain.
positionx_deriv_gainShared data object for the x position controller derivative gain.
positionx_int_gainShared data object for the x position controller integral gain.
positiony_prop_gainShared data object for the y position controller proportional gain.
positiony_deriv_gainShared data object for the y position controller derivative gain.
positiony_int_gainShared data object for the y position controller integral gain.
controller_signalsxOutput signal from the x position controller.
controller_signalsyOutput signal from the y position controller.
prop_gain_pitchPitch angle controller proportional gain.
deriv_gain_pitchPitch angle controller derivative gain.
int_gain_pitchPitch angle controller integral gain.
data_collect_flagShared variable to hold the data collection flag

Variable Documentation

◆ S0_INIT

taskUser.S0_INIT = micropython.const(0)

State 0.

Maps state 0 to a more readable name

◆ S1_CMD

taskUser.S1_CMD = micropython.const(1)

State 1.

Maps state 1 to a more readable name

◆ S2_IMUCAL

taskUser.S2_IMUCAL = micropython.const(2)

State 2.

Maps state 2 to a more readable name

◆ S3_PRINT

taskUser.S3_PRINT = micropython.const(3)

State 3.

Maps state 3 to a more readable name

◆ S4_INPUT

taskUser.S4_INPUT = micropython.const(4)

State 4.

Maps state 4 to a more readable name

◆ S5_PANELCAL

taskUser.S5_PANELCAL = micropython.const(5)

State 5.

Maps state 5 to a more readable name

◆ S6_SRESP

taskUser.S6_SRESP = micropython.const(6)

State 6.

Maps state 6 to a more readable name