Bratmobile
Public Member Functions | Protected Attributes | List of all members
MotorInterface Class Reference

#include <control_interface.h>

Public Member Functions

 MotorInterface (float kp, float ki, float kd)
 
void getData (const Task::Action &a)
 
float get_L ()
 
float get_R ()
 
void adjust_gain (float angle_D, b2Transform observed, float *y_D=NULL)
 Adjusts L/R wheel gain, implements a PID controller with option to turn it into cascaded controller. More...
 
void PID (float e)
 Implements a PID controller. More...
 
float outer_loop (float e)
 Implements a P controller in the outer loop of the cascade controller. More...
 
void reset ()
 
void reset_error ()
 

Protected Attributes

float L =0
 
float R =0
 
float L_gain =1.0f
 
float R_gain =1.0f
 
float Kp =0.45
 
float Ki =0.25
 
float Kd =0.2
 
float prev_error =0
 
float integral =0
 

Detailed Description

Input/Output interface for Configurator Receives LIDAR data Output from Configurator to Motors

Member Function Documentation

◆ adjust_gain()

void MotorInterface::adjust_gain ( float  angle_D,
b2Transform  observed,
float *  y_D = NULL 
)

Adjusts L/R wheel gain, implements a PID controller with option to turn it into cascaded controller.

Parameters
angle_Ddesired angle from disturbance
observedobserved transform
y_Ddesired distance from disturbance on the y axis (pointer so optional)

◆ outer_loop()

float MotorInterface::outer_loop ( float  e)

Implements a P controller in the outer loop of the cascade controller.

max dl/dt and dr/dt = 2.0 (going from -1->1 and viceversa) max_corrective angle= ((max_dl-max_dr)/speed)*LIDAR_SAMPLING_RATE=(((-2-2)/0.2)*.15)*0.2= fabs(0.6)rad=34deg but this is not a typical case scenario. Usually the error is around 0.01-0.05rad for going straight. Since the angle is small, we want to keep Kp_outer around a plausible angle value. Distances will usually be +- 0.1m so the angle change will be in the range of 0.025-0.001 rad/s

Parameters
edistance error
Returns
desired angle

◆ PID()

void MotorInterface::PID ( float  e)

Implements a PID controller.

Parameters
e

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