Controller task class. More...
Public Member Functions | |
| def | __init__ (self, controllerPeriod, debugFlag=False) |
| Constructor for controller task. More... | |
| def | run (self) |
| Main run method for controller task. More... | |
| def | transitionTo (self, newState) |
| Method for transitioning states. More... | |
| def | loadData (self, refFileName) |
| Method for loaading resampled data into arrays. More... | |
| def | interpolate (self, t0, iStart) |
| Method for interpolating from reference data. More... | |
Public Attributes | |
| enc1 | |
| First encoder object. | |
| enc2 | |
| Second encoder object. | |
| mot1 | |
| First motor object. | |
| mot2 | |
| Second motor object. | |
| control | |
| Controller object. | |
| KpPrime | |
| Velocity feedback constant. | |
| KiPrime | |
| Position feedback constant. | |
| debugFlag | |
| Debugging flag for print statements in Putty. | |
| state | |
| Finite state machine needs a state variable to regularly update as state transitions occur. | |
| controllerPeriod | |
| Controller period. | |
| currentTime | |
| Current absolute time in microseconds. | |
| zeroTime | |
| Set refrence point for data collection (in microseconds) | |
| lastTime | |
| Previous time, used for period mechanism. | |
| nextTime | |
| Next time, used for period mechanism. | |
| lastIndex | |
| Index variable for interpolation. More... | |
| J1 | |
| J summation portion for encoder 1. More... | |
| J2 | |
| J summation portion for encoder 2. | |
| tRef | |
| Array for storing refrence data time values, holds type float. | |
| posRef | |
| Array for storing refrence data position values, holds type float. | |
| speedRef | |
| Array for storing refrence data speed values, holds type float. | |
| elapsedTime | |
| Time since data collection began. | |
| enc1Pos | |
| Current encoder 1 position. | |
| enc2Pos | |
| Current encoder 2 position. | |
| enc1Omega | |
| Current encoder 1 speed. | |
| enc2Omega | |
| Current encoder 2 speed. | |
| mot1DutyNew | |
| New motor 1 duty cycle, to be sent to motor object. | |
| mot2DutyNew | |
| New motor 2 duty cycle, to be sent to motor object. | |
Static Public Attributes | |
| int | S0_INIT = 0 |
| Initial state. | |
| int | S1_CONTROLLER_OFF = 1 |
| Controller off state. | |
| int | S2_CONTROLLER_ON = 2 |
| Controller operational state. | |
Controller task class.
This class uses instances of three different drivers for encoders, motors, and controllers. It is used in conjuction with a uiTask from the main file for this project
| def controllerTask.controllerTask.__init__ | ( | self, | |
| controllerPeriod, | |||
debugFlag = False |
|||
| ) |
Constructor for controller task.
| controllerPeriod | Controller period, must be slower than UI period |
| debugFlag | Debugging flag related to print statements in Putty |
| def controllerTask.controllerTask.interpolate | ( | self, | |
| t0, | |||
| iStart | |||
| ) |
Method for interpolating from reference data.
This method quickly interpolates using a short for loop (should only run through a few possibilites before reaching the correct value) from the reference data set.
| t0 | Time query point for interpolation |
| iStart | Last index value from interpolation, used as a starting point for next interpolation speed up code |
| def controllerTask.controllerTask.loadData | ( | self, | |
| refFileName | |||
| ) |
Method for loaading resampled data into arrays.
This method strips and splits the reference data from a csv file, and places time, position, and speed data into seperate arrays for use in interpolation
| refFileName | File name for CSV loaded onto Nucleo that contains reference data (resampled) |
| def controllerTask.controllerTask.run | ( | self | ) |
Main run method for controller task.
Called as fast as possible from a main file, and operates on period defined in constructor
| def controllerTask.controllerTask.transitionTo | ( | self, | |
| newState | |||
| ) |
Method for transitioning states.
The method will reassign the self.state variable when directed to transition.
| newState | is the state to transition to |
| controllerTask.controllerTask.J1 |
J summation portion for encoder 1.
This value is iterated upon each time the controller is updated
| controllerTask.controllerTask.lastIndex |
Index variable for interpolation.
Instead of searching through the entire reference data set, start at the last index value