ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
Loading...
Searching...
No Matches
BLUETOOTH Class Reference

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.

Detailed Description

Finite State Machine for Bluetooth-based control input.

Converts ASCII command characters received via UART into motor setpoints for directional movement.

Member Enumeration Documentation

◆ state

Enumerator
S0_INIT 

Initialization state.

S1_STOP 

Stop motors.

SF_FORWARD 

Move forward.

SB_BACKWARD 

Move backward.

SR_RIGHT 

Turn right.

SL_LEFT 

Turn left.

Constructor & Destructor Documentation

◆ BLUETOOTH()

BLUETOOTH::BLUETOOTH ( )

Constructor for the BLUETOOTH class.

Initializes the FSM to the S0_INIT state and motor setpoints to zero.

Member Function Documentation

◆ get_M1_set()

int16_t BLUETOOTH::get_M1_set ( void )

Retrieves the motor 1 setpoint based on last command.

Retrieves the setpoint for motor 1.

Returns
Signed 16-bit motor setpoint value for motor 1.
Motor 1 velocity setpoint.

◆ get_M2_set()

int16_t BLUETOOTH::get_M2_set ( void )

Retrieves the motor 2 setpoint based on last command.

Retrieves the setpoint for motor 2.

Returns
Signed 16-bit motor setpoint value for motor 2.
Motor 2 velocity setpoint.

◆ run()

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.

◆ set_command()

void BLUETOOTH::set_command ( char cmd)

Sets the most recent command character received over Bluetooth.

Sets the most recent command received via Bluetooth.

Parameters
cmdSingle character representing a motion command.
cmdSingle ASCII character representing the command: 'F' = forward, 'B' = backward, 'L' = left, 'R' = right, 'S' = stop.

The documentation for this class was generated from the following files: