ME 405 Romi
Loading...
Searching...
No Matches
control_task Namespace Reference

Classes

class  control_task
 This file contains a class to create a control_task object which is compatible with the cotask scheduler to run as a cooperative task. More...

Functions

 run (self)
 run is the generator that the cotask scheduler will run since our tasks are objects.

Variables

int state = 0:
int startup = 0:
 yaw_rate = self.line_controller.pi_Control(self.centroid.get(), 15)

Function Documentation

◆ run()

control_task.run ( self)

run is the generator that the cotask scheduler will run since our tasks are objects.

All shares it needs are already given to the task object on initialization. The generator will only run one state at a time on each run of the task, but it will always update the PWM of the motors to their expected set point on every loop. @detail The finite state machine for control_task has 8 states. State 0: Hub State. This state waits for either automatic_mode to be set or c_state to be set for a state change to active controls. State 1: Forward State. If c_state == 1, control task will use the fwd_ref to drive the wheels forward at that speed in mm/s State 2: Turn State. If c_state == 2, control task will use the arc_ref to drive the wheels to that turn radius in mm State 3: Pivot State. If c_state == 3, control task will use the piv_ref to drive the wheels to pivot in place at that angular speed in rad/s State 4: Disable State. If c_state ==4, control task will turn both motors off and clear all references then return to hub State 5: Automatic Control State. If automatic_mode == 1 and the line sensor is calibrated, control task will drive forward at a set 100 mm/s and made small adjustments to each wheel to place the centroid at centroid_goal based off of the centroid controllers values. State 6: Calibrate Check State. If automatic_mode == 1, control task will check the line sensor is calibrated before following the line. State 7: Heading Control State. If c_state == 7, control task will use the yaw controller to get a reference pivoting speed to move the motors unitl the yaw matches close to yaw_goal. Always : Every loop runs the control loops on the motors to keep them up to date on their reference speeds.

Note : Many of the comments at the bottom of the file are to comment out print statements for debugging purposes

IMPORTANT PWM Logic Filtering: Unknown why to the authors but testing found that giving both wheels the same sign on PWM will have expected behavior. If either PWM is 0 or the PWM values have different signs the motors will spin in the opposite direction of the sign of the PWM. The if logic at the bottom of the generator handles this but it is unknown if this is required if a different piece of ROMI hardware was used or if this is a software issue. If wheels immediately saturate on turning it is likely this issue does not exist for users hardware.

Definition at line 121 of file control_task.py.

Variable Documentation

◆ startup

Definition at line 131 of file control_task.py.

◆ state

Definition at line 125 of file control_task.py.

◆ yaw_rate

control_task.yaw_rate = self.line_controller.pi_Control(self.centroid.get(), 15)

Definition at line 203 of file control_task.py.