ME 305 Group 6 Documentation
Functions
taskMotorController.py File Reference

Sets up and calls the closed loop controller class for the inner loop. More...

Functions

def taskMotorController.taskMotorControllerFcn (str taskName, int period, shares.Share euler_angles, shares.Share angular_velocities, shares.Share roll_target_pos, shares.Share roll_target_deriv, shares.Share pitch_target_pos, shares.Share pitch_target_deriv, shares.Share prop_gain_roll, shares.Share deriv_gain_roll, shares.Share int_gain_roll, shares.Share cont_enable, shares.Share roll_target_duty, shares.Share pitch_target_duty, shares.Share prop_gain_pitch, shares.Share deriv_gain_pitch, shares.Share int_gain_pitch)
 Sets up and calls the closed loop controller class. More...
 

Detailed Description

Sets up and calls the closed loop controller class for the inner loop.

Configures a PID controller object and continuously updates the controller output value and assigns to the proper motor duty cycle. In this case, the derivative of position for derivative control is drawn directly from the gyroscope data. This is more accurate than a numerical derivative.

Author
Caleb Savard
Chris Linthacum
Date
March 18, 2022

Function Documentation

◆ taskMotorControllerFcn()

def taskMotorController.taskMotorControllerFcn ( str  taskName,
int  period,
shares.Share  euler_angles,
shares.Share  angular_velocities,
shares.Share  roll_target_pos,
shares.Share  roll_target_deriv,
shares.Share  pitch_target_pos,
shares.Share  pitch_target_deriv,
shares.Share  prop_gain_roll,
shares.Share  deriv_gain_roll,
shares.Share  int_gain_roll,
shares.Share  cont_enable,
shares.Share  roll_target_duty,
shares.Share  pitch_target_duty,
shares.Share  prop_gain_pitch,
shares.Share  deriv_gain_pitch,
shares.Share  int_gain_pitch 
)

Sets up and calls the closed loop controller class.

Every period, this task resets the gains using set_Kx() and updates the controller. Saturation limits are set to 100 and -100.

Parameters
taskNameTask name label for debugging purposes.
periodPeriod to run taskControllerFcn
euler_anglesShared variable to store the euler angles being recorded by the IMU.
angular_velocitiesShared variable to store angular velocities being recorded by the IMU.
roll_target_posShared variable to store the roll target position output from the angle controller.
roll_target_derivShared variable to store the roll target velocity output from the angle controller (0).
pitch_target_posShared variable to store the pitch target position output from the angle controller.
pitch_target_derivShared variable to store the pitch target velocity output from the angle controller (0).
prop_gain_rollShared variable for the roll controller proportional gain
deriv_gain_rollShared variable for the roll controller derivative gain.
int_gain_rollShared variable for the roll controller integral gain.
cont_enableShared variable for whether or not the controller is enabled.
roll_target_dutyShared variable for the roll motor target duty cycle.
pitch_target_dutyShared variable for the pitch motor target duty cycle.
prop_gain_pitchShared variable for the pitch controller proportional gain.
deriv_gain_pitchShared variable for the pitch controller derivative gain.
int_gain_pitchShared variable for the pitch controller integral gain.