ME 405 Romi
Loading...
Searching...
No Matches
main.py File Reference

This file contains creates all shares, queues, hardware driver constants, controllers, and task objects for the ROMI program. More...

Go to the source code of this file.

Namespaces

namespace  main

Variables

float main.ERR_SAT_LEFT = 50.0
float main.EFF_SAT_LEFT = 85.0
float main.ERR_SAT_RIGHT = 50.0
float main.EFF_SAT_RIGHT = 85.0
int main.ERR_SAT_LINE = 1
int main.EFF_SAT_LINE = 40
int main.ERR_SAT_YAW = .8
int main.EFF_SAT_YAW = 100
 main.m_state_l = task_share.Share('b', thread_protect = False, name = "m_state_l")
 main.m_state_r = task_share.Share('b', thread_protect = False, name = "m_state_r")
 main.PWM_l = task_share.Share('f', thread_protect = False, name = "PWM_l")
 main.PWM_r = task_share.Share('f', thread_protect = False, name = "PWM_r")
 main.position_r = task_share.Share('f', thread_protect = False, name = "position_r")
 main.velocity_r = task_share.Share('f', thread_protect = False, name = "velocity_r")
 main.position_l = task_share.Share('f', thread_protect = False, name = "position_l")
 main.velocity_l = task_share.Share('f', thread_protect = False, name = "velocity_l")
 main.testing_flg = task_share.Share('b', thread_protect = False, name = "testing_flg")
 main.delay = task_share.Share('b', thread_protect = False, name = "delay")
 main.fwd_ref = task_share.Share('l', thread_protect = False, name = "fwd_ref")
 main.arc_ref = task_share.Share('l', thread_protect = False, name = "arc_ref")
 main.piv_ref = task_share.Share('f', thread_protect = False, name = "piv_ref")
 main.c_state = task_share.Share('b', thread_protect = False, name = "c_state")
 main.l_state = task_share.Share('b', thread_protect = False, name = "l_state")
 main.ready_Black = task_share.Share('b', thread_protect = False, name = "ready_Black")
 main.ready_White = task_share.Share('b', thread_protect = False, name = "ready_White")
 main.need_Calibrate = task_share.Share('b', thread_protect = False, name = "need calibrate")
 main.centroid = task_share.Share('f', thread_protect = False, name ="centroid")
 main.automatic_mode = task_share.Share('b', thread_protect = False, name = "automatic_mode" )
 main.imu_flg = task_share.Share('b', thread_protect= False, name = "imu_flg")
 main.yaw = task_share.Share('f', thread_protect = False, name = "yaw")
 main.yaw_velocity = task_share.Share('f', thread_protect = False, name = "yaw_velocity")
 main.total_dist = task_share.Share("f", thread_protect = False, name = "S")
 main.centroid_goal = task_share.Share("f", thread_protect = False, name = "Goal Centroid")
 main.yaw_goal = task_share.Share("f", thread_protect = False, name = "Yaw Goal")
 main.bump_on_off = task_share.Share("b", thread_protect = False, name = "Bump Flag")
 main.bump_flg = task_share.Share("b", thread_protect = False, name = "Bump Flag")
 main.velocity = task_share.Queue('f', 50, thread_protect = False, overwrite = False, name = "velocity")
 main.velocity2 = task_share.Queue('f', 50, thread_protect = False, overwrite = False, name = "velocity2")
 main.position = task_share.Queue('f', 50, thread_protect = False, overwrite = False, name = "position")
 main.times = task_share.Queue('l', 50, thread_protect = False, overwrite = False, name = "times")
 main.tim1 = Timer(1, prescaler=0, period=65535)
 main.tim3 = Timer(3, prescaler=0, period=65535)
 main.tim4 = Timer(4, freq=20000)
 main.my_motor_Left = Motor(Pin.cpu.B7, Pin.cpu.C13, Pin.cpu.C14, tim4, 1)
 main.encoder_Right = Encoder(tim3, Pin.cpu.C6, Pin.cpu.C7)
 main.my_motor_Right = Motor(Pin.cpu.B6, Pin.cpu.B10, Pin.cpu.A10, tim4, 2)
 main.encoder_Left = Encoder(tim1, Pin.cpu.A8, Pin.cpu.A9)
 main.bump_sensor_right = Bump_Sensor(Pin.cpu.B13, Pin.cpu.B3, Pin.cpu.B5)
 main.bump_sensor_left = Bump_Sensor(Pin.cpu.B11, Pin.cpu.B15, Pin.cpu.B14)
 main.ir1 = IR_Sensor(Pin.cpu.A6)
 main.ir2 = IR_Sensor(Pin.cpu.A7)
 main.ir3 = IR_Sensor(Pin.cpu.C4)
 main.ir4 = IR_Sensor(Pin.cpu.A0)
 main.ir5 = IR_Sensor(Pin.cpu.A1)
 main.ir6 = IR_Sensor(Pin.cpu.C4)
 main.ir7 = IR_Sensor(Pin.cpu.B0)
 main.ir8 = IR_Sensor(Pin.cpu.C0)
 main.ir9 = IR_Sensor(Pin.cpu.C1)
 main.ir10 = IR_Sensor(Pin.cpu.C2)
 main.ir11 = IR_Sensor(Pin.cpu.C3)
 main.ir12 = IR_Sensor(Pin.cpu.C5)
 main.ir13 = IR_Sensor(Pin.cpu.B1)
 main.line_sensor_obj = Line_Sensor(ir1, ir2, ir3, ir4, ir5, ir6, ir7, ir8, ir9, ir10, ir11, ir12, ir13)
 main.uart_obj = UART(5, 115200)
 main.bits
 main.parity
 main.None
 main.stop
 main.timeout
 main.i2c_obj = I2C(1,I2C.CONTROLLER,baudrate = 400000)
 main.imu_obj = IMU(i2c_obj)
 main.controller_obj_left = Controller(.2,1.95,1, ERR_SAT_LEFT, EFF_SAT_LEFT)
 main.controller_obj_right = Controller(.2,1.95,1, ERR_SAT_RIGHT, EFF_SAT_RIGHT)
 main.controller_obj_line = Controller(150, 10, 1, ERR_SAT_LINE, EFF_SAT_LINE)
 main.controller_obj_yaw = Controller(.8,.3,1, ERR_SAT_YAW, EFF_SAT_YAW)
 main.motor_Left_class = motor_encoder_left_class(my_motor_Left, encoder_Left, m_state_l, position_l, velocity_l, times, PWM_l, delay)
 main.motor_Right_class = motor_encoder_right_class(my_motor_Right, encoder_Right, m_state_r, position_r, velocity_r, times, PWM_r, delay)
 main.ui_obj = ui(testing_flg, m_state_l, m_state_r, position, velocity, times, PWM_l, PWM_r, delay, uart_obj, fwd_ref, arc_ref, piv_ref, c_state, velocity2, need_Calibrate, ready_Black, ready_White, automatic_mode, imu_flg)
 main.data_collector_obj = data_collector(testing_flg, position, velocity, times, position_l, velocity_l, position_r, velocity_r, velocity2)
 main.control_task_obj = control_task(fwd_ref, arc_ref, piv_ref, c_state, controller_obj_left, controller_obj_right, position_l, velocity_l, position_r, velocity_r, PWM_l, PWM_r, encoder_Right, encoder_Left, m_state_l, m_state_r, centroid, controller_obj_line, automatic_mode, line_sensor_obj, need_Calibrate, yaw, centroid_goal, yaw_goal, controller_obj_yaw)
 main.line_task_obj = line_task(line_sensor_obj, l_state, need_Calibrate, ready_Black, ready_White,centroid)
 main.imu_task_obj = imu_task(imu_obj, imu_flg, yaw, yaw_velocity)
 main.observer_obj = observer(position_l, position_r, yaw, yaw_velocity, PWM_l, PWM_r, velocity_l, velocity_r, total_dist)
 main.pathing_obj = pathing_plan(total_dist, automatic_mode, c_state, fwd_ref, piv_ref, yaw, centroid_goal, yaw_goal, bump_on_off, bump_flg)
 main.bump_obj = Bump_Task(c_state, bump_sensor_right, bump_sensor_left, bump_on_off, bump_flg)
 main.task1 = cotask.Task(data_collector_obj.run, name="data_collector", priority=2, period=18, profile=True, trace=False, shares=())
 main.task2 = cotask.Task(motor_Left_class.run, name="motor_encoder_left", priority=7, period=13, profile=True, trace=False, shares=())
 main.task3 = cotask.Task(motor_Right_class.run, name="motor_encoder_right", priority=7, period=13, profile=True, trace=False, shares=())
 main.task4 = cotask.Task(ui_obj.run, name="ui", priority=1, period=1, profile=True, trace=False, shares=())
 main.task5 = cotask.Task(control_task_obj.run, name="control_task", priority=6, period=15, profile = True, trace=False, shares=())
 main.task6 = cotask.Task(line_task_obj.run, name="line_task", priority = 5, period = 22, profile = True, trace = False, shares=())
 main.task7 = cotask.Task(imu_task_obj.run, name = "imu_task", priority = 6, period = 20, profile= True, trace= False, shares = ())
 main.task8 = cotask.Task(observer_obj.run, name = "observer", priority = 4, period = 20, profile = True, trace = False, shares = ())
 main.task9 = cotask.Task(pathing_obj.run, name= "pathing", priority = 3, period = 30, profile = True, trace = False, shares = ())
 main.task10 = cotask.Task(bump_obj.run, name = "bump task", priority = 2, period = 50, profile = True, trace = False, shares=())

Detailed Description

This file contains creates all shares, queues, hardware driver constants, controllers, and task objects for the ROMI program.

It also starts the scheduler from cotask.

In order main imports all files, sets defines, creates all shares, creates all queues, creates all hardware driver objects, creates all task class objects, creates all tasks, adds all tasks to the scheduler, and runs the scheduler.

Author
Alex Power, Lucas Heuchert, Erik Heuchert
Date
2025-Nov-10 Approximate date of creation of file
2025-Dec-12 Final alterations made

Definition in file main.py.