139Serial
pc(USBTX, USBRX, 115200);
150Motor motor_left (
MOTORL_PWM_PIN,
MOTORL_DIRECTION_PIN,
MOTORL_BIPOLAR_PIN,
MOTORL_CHA_PIN,
MOTORL_CHB_PIN, PULSE_PER_REV, MOTOR_PWM_FREQ,
CONTROL_UPDATE_RATE, LP_SPEED_A0, LP_SPEED_B0, LP_SPEED_B1, WHEEL_RADIUS);
151Motor motor_right(
MOTORR_PWM_PIN,
MOTORR_DIRECTION_PIN,
MOTORR_BIPOLAR_PIN,
MOTORR_CHA_PIN,
MOTORR_CHB_PIN, PULSE_PER_REV, MOTOR_PWM_FREQ,
CONTROL_UPDATE_RATE, LP_SPEED_A0, LP_SPEED_B0, LP_SPEED_B1, WHEEL_RADIUS);
218 pc.printf(
"%.5f,%.3f,%.3f,%.3f,%.3f,%.3f\n",
316 for (
int i = 0; i < 6; i++)
583 if (speed_offset > 0)
711 char cmd_type = rx_buffer[0];
712 char exec_type = rx_buffer[1];
713 char data_type = rx_buffer[1];
714 char obj_type = rx_buffer[2];
BLE HM-10 Interface Class.
bool data_recieved_complete(void)
Returns true if incoming data is fully recieved.
void set_send_once(bool status)
Set the send once property to the bool value passed.
char * get_rx_buffer(void)
returns the raw data recieved as a character array
void reset_rx_buffer(void)
Resets the recieved data buffer for new incoming data.
bool is_send_once(void)
returns true if send once is enabled
void send_fstring(const char *format,...)
Sends formatted string to the bluetooth.
void set_continous(bool status)
Set the continous property to the bool value passed.
bool is_continous(void)
returns true if continous update is enabled
bool is_ready(void)
returns true if bluetooth module is ready
Contains all the functionality of the ESP motor driver board.
float get_voltage(void)
returns the actual voltage value
void update_measurements(void)
updates the measurements of voltage and current values
void disable(void)
causes the enable pin to be set to LOW
void set_enable(bool expression)
enable pin will be set to the boolean value in the paremeter
float get_current(void)
returns the actual curent value
Represents a motor with integrated quadrature encoder for the buggy.
float get_speed(void)
Get the tangential speed of the wheel.
float get_filtered_speed(void)
Get the low-pass filtered speed of the wheel.
void set_duty_cycle(float DutyCycle)
Set the duty cycle of the motor.
void update(void)
Calculate and update all the speed variables.
float get_duty_cycle()
Get the duty cycle of the motor.
void reset(void)
Reset the encoder tick count.
int get_tick_count(void)
Get the cumulative tick count.
float ** get_terms(void)
Get the PID terms.
float get_output(void)
Get the output of the PID controller.
float * get_constants(void)
void set_constants(float kp_, float ki_, float kd_)
Takes in the 3 parameters to set the PID coefficients values.
void update(float set_point, float measurement)
Updates the output of PID controller based on the real time measurement.
void reset()
Reset the PID controller.
Represents an array of sensors with corresponding LEDs for detection.
void calibrate_sensors(void)
float get_filtered_output(void)
void update(void)
Updates the sensor array.
float * get_calibration_constants(void)
bool is_line_detected(void)
Checks if a line is detected (in the last update).
void set_all_led_on(bool status)
Sets the status of all LEDs.
contains all the constant variables for easy access from one file
#define CONTROL_UPDATE_PERIOD
#define LINE_FOLLOW_STOP_DISTANCE
#define SQUARE_VELOCITY_SET
#define LINE_FOLLOW_VELOCITY_UTURN
#define SLOW_ACCEL_DIVIDER
#define SQUARE_TURNING_LEFT_ANGLE
#define SQUARE_TURNING_RIGHT_ANGLE
#define CONTROL_UPDATE_RATE
#define SENSOR_UPDATE_PERIOD
#define SERIAL_UPDATE_PERIOD
#define LINE_FOLLOW_VELOCITY
#define SENS_DETECT_RANGE
#define CONTROL_UPDATE_PERIOD_US
#define SENSOR_UPDATE_PERIOD_US
#define SENS_SAMPLE_COUNT
short int data_log[LOG_SIZE][5]
Buggy_status buggy_status
void bt_send_data(void)
Send data to the bt module.
PID PID_angle(PID_A_KP, PID_A_KI, PID_A_KD, PID_A_TAU, PID_A_MIN_OUT, PID_A_MAX_OUT, PID_A_MIN_INT, PID_A_MAX_INT, CONTROL_UPDATE_PERIOD)
void reset_everything(void)
Reset all buggy values and all objects variables.
PID PID_sensor(PID_S_KP, PID_S_KI, PID_S_KD, PID_S_TAU, PID_S_MIN_OUT, PID_S_MAX_OUT, PID_S_MIN_INT, PID_S_MAX_INT, SENSOR_UPDATE_PERIOD)
volatile bool pc_serial_update
void pc_send_data(void)
Send data to the pc.
Bluetooth bt(BT_TX_PIN, BT_RX_PIN, BT_BAUD_RATE)
void stop_motors(void)
Set pwm dc to 0 for both motors.
void serial_update_ISR(void)
ISR to update flag to send data to pc/bt in main()
void update_buggy_status(int tick_count_left, int tick_count_right)
Update buggy status variables.
Serial pc(USBTX, USBRX, 115200)
Buggy_modes prev_buggy_mode
Motor motor_right(MOTORR_PWM_PIN, MOTORR_DIRECTION_PIN, MOTORR_BIPOLAR_PIN, MOTORR_CHA_PIN, MOTORR_CHB_PIN, PULSE_PER_REV, MOTOR_PWM_FREQ, CONTROL_UPDATE_RATE, LP_SPEED_A0, LP_SPEED_B0, LP_SPEED_B1, WHEEL_RADIUS)
PID PID_motor_right(PID_M_R_KP, PID_M_R_KI, PID_M_R_KD, PID_M_TAU, PID_M_MIN_OUT, PID_M_MAX_OUT, PID_M_MIN_INT, PID_M_MAX_INT, CONTROL_UPDATE_PERIOD)
volatile float lf_velocity
void slow_accel_ISR(void)
void control_update_ISR(void)
ISR updating the control algorithm.
MotorDriverBoard driver_board(DRIVER_ENABLE_PIN, DRIVER_MONITOR_PIN)
Motor motor_left(MOTORL_PWM_PIN, MOTORL_DIRECTION_PIN, MOTORL_BIPOLAR_PIN, MOTORL_CHA_PIN, MOTORL_CHB_PIN, PULSE_PER_REV, MOTOR_PWM_FREQ, CONTROL_UPDATE_RATE, LP_SPEED_A0, LP_SPEED_B0, LP_SPEED_B1, WHEEL_RADIUS)
void stop_detect_ISR(void)
volatile bool bt_serial_update
bool bt_parse_rx(char *rx_buffer)
Parse recieved bluetooth data.
SensorArray sensor_array(SENSOR0_IN_PIN, SENSOR1_IN_PIN, SENSOR2_IN_PIN, SENSOR3_IN_PIN, SENSOR4_IN_PIN, SENSOR5_IN_PIN, SENSOR0_OUT_PIN, SENSOR1_OUT_PIN, SENSOR2_OUT_PIN, SENSOR3_OUT_PIN, SENSOR4_OUT_PIN, SENSOR5_OUT_PIN, SENS_SAMPLE_COUNT, SENS_DETECT_RANGE, SENS_ANGLE_COEFF)
PID PID_motor_left(PID_M_L_KP, PID_M_L_KI, PID_M_L_KD, PID_M_TAU, PID_M_MIN_OUT, PID_M_MAX_OUT, PID_M_MIN_INT, PID_M_MAX_INT, CONTROL_UPDATE_PERIOD)
Motor and Encoder class library.
ESP Motor Driver Board Interface library
MCU pin assigments in one file for easy modification.
#define MOTORR_DIRECTION_PIN
#define MOTORR_BIPOLAR_PIN
#define MOTORL_DIRECTION_PIN
#define MOTORL_BIPOLAR_PIN
#define DRIVER_ENABLE_PIN
#define DRIVER_MONITOR_PIN
Sensor Array PCB interface class library
Represents the status of a buggy.
float left_set_speed
The set speed of the left wheel.
float set_velocity
The set velocity for the buggy.
float right_set_speed
The set speed of the right wheel.
float sq_set_distance
The set distance for the square task.
float lf_line_last_seen
The position of the last seen line by the left front sensor.
float sq_set_angle
The set angle for the square task.
float set_angle
The set angle for the buggy.
float distance_travelled
The distance travelled by the buggy.
float cumulative_angle_deg
The cumulative angle (in degrees) traveled by the buggy.
int sq_stage
The current stage of the square task.
float accel_start_distance