ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
|
Finite State Machine for Bluetooth-based control input. More...
#include <bluetooth.h>
Public Types | |
enum | state { S0_INIT , S1_STOP , SF_FORWARD , SB_BACKWARD , SR_RIGHT , SL_LEFT } |
typedef enum BLUETOOTH::state | state_t |
Public Member Functions | |
BLUETOOTH () | |
Constructor for the BLUETOOTH class. | |
void | run (void) |
Executes one iteration of the Bluetooth FSM. | |
void | set_command (char cmd) |
Sets the most recent command character received over Bluetooth. | |
int16_t | get_M1_set (void) |
Retrieves the motor 1 setpoint based on last command. | |
int16_t | get_M2_set (void) |
Retrieves the motor 2 setpoint based on last command. |
Finite State Machine for Bluetooth-based control input.
Converts ASCII command characters received via UART into motor setpoints for directional movement.
enum BLUETOOTH::state |
BLUETOOTH::BLUETOOTH | ( | ) |
Constructor for the BLUETOOTH class.
Initializes the FSM to the S0_INIT state and motor setpoints to zero.
int16_t BLUETOOTH::get_M1_set | ( | void | ) |
Retrieves the motor 1 setpoint based on last command.
Retrieves the setpoint for motor 1.
int16_t BLUETOOTH::get_M2_set | ( | void | ) |
Retrieves the motor 2 setpoint based on last command.
Retrieves the setpoint for motor 2.
void BLUETOOTH::run | ( | void | ) |
Executes one iteration of the Bluetooth FSM.
Updates motor setpoints based on current state and command.
Translates command characters into motor setpoints by updating internal FSM state.
void BLUETOOTH::set_command | ( | char | cmd | ) |
Sets the most recent command character received over Bluetooth.
Sets the most recent command received via Bluetooth.
cmd | Single character representing a motion command. |
cmd | Single ASCII character representing the command: 'F' = forward, 'B' = backward, 'L' = left, 'R' = right, 'S' = stop. |