SAE WS_2324
Loading...
Searching...
No Matches
main.py File Reference

WS23-24 Semi Autonomous Program. More...

Classes

class  main.man_point
 This is a manuevre segment array base class. More...
 

Namespaces

namespace  main
 WS23-24 Semi Autonomous Program.
 

Variables

int main.max_steer = 600;
 Creating an array of Point objects.
 
bool main.two_motors = True;
 Flag used during debugging.
 
 main.motor_drive = Motor(Port.A);
 Initialize the drive motor.
 
 main.sen_us = UltrasonicSensor(Port.S1);
 init Ultrasonic sensor.
 
 main.sen_gyro = GyroSensor(Port.S2,Direction.CLOCKWISE);
 Init Gyro sensor.
 
 main.emergency_button = TouchSensor(Port.S4);
 touchsensor is also the ESTOP button
 
int main.start_distance = 0;
 Variable used to store the start distance during object detection.
 
int main.end_distance = 0;
 Variable used to store the start distance during object detection.
 
bool main.run_flag = False;
 Flag used to see if the drive motor needs to be active.
 
int main.button_press_ctr = 0;
 ESTOP Button Press samples counter.
 
int main.center_button_ctr = 0;
 Center Button pressed samples counter.
 
int main.left_button_ctr = 0;
 Left button pressed samples counter.
 
int main.man = 0;
 Index for segments in path planning.
 
int main.detect_flag = 0;
 Flag used to detect the start first object.
 
int main.parking_spot_detected = 0;
 Flag to detect if the parking spot is successfully detected.
 
int main.detect_obj1_flag = 0;
 Flag to detect if first object was successfully detected.
 
int main.obj1_valid = 0;
 Flag to denote if first object is valid.
 
int main.obj1_last_distance = 0;
 Variable to store the last detected Ultrasonic Sensor Distance.
 
int main.start_distance_obj1 = 0;
 Start Distance variale to store the distance value when object 1 was detected which helps us to calculate the length of the object.
 
int main.obj1_distance = 0;
 Length of the object 1.
 
int main.parking_length_detected = 0;
 Flag to denote if a valid parking length for parallel parking manuevre was detected.
 
int main.park_distance = 0;
 Variable to store the current parking spot length to check if it valid.
 
int main.detect_obj2_flag = 0;
 Flag to detect if second object was successfully detected.
 
int main.obj2_valid = 0;
 Flag to denote if second object is valid.
 
int main.start_distance_obj2 = 0;
 Start Distance variale to store the distance value when object 2 was detected which helps us to calculate the length of the object.
 
int main.obj2_distance = 0;
 Length of the object 2.
 
int main.park_flag = 0;
 Flag used to wait for park confirmation.
 
str main.previous_state = 'init_0';
 Variable to store previous state.
 

Detailed Description

WS23-24 Semi Autonomous Program.

Description

This is main file of the application, where the main thread runs. The main thread runs in the an infinite while loop and it has the following structure:

  • Peripheral and Data Initialization
  • Main thread
    • Acquisation of User Inputs
    • Run the Drive Module functions
    • Acquisation of the Statemachine Events
    • Run the StateMachine
    • Run StateMachine Callbacks

Libraries/Modules

  • Pybricks (https://pybricks.com/)
    • Access to EV3 HUB for Sound and Display Access
    • Access to Output Devices like Motor
    • Access to Sensors: Ultrasonic, Touch, Color and Gyro
    • Access to Parameters such as, Directio, Port, Color etc.
  • Math
  • PID Controller
  • State Machine
  • Drive Module