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

#include <control_interface.h>

Inheritance diagram for Motor_Out:
Inheritance graph
[legend]
Collaboration diagram for Motor_Out:
Collaboration graph
[legend]

Public Member Functions

 Motor_Out (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 ()
 
- Public Member Functions inherited from IOInterface
bool isReady ()
 
void setReady (bool b)
 

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
 
- Protected Attributes inherited from IOInterface
bool ready =false
 

Detailed Description

Output from Configurator to Motors

Member Function Documentation

◆ adjust_gain()

void Motor_Out::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 Motor_Out::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 Motor_Out::PID ( float  e)

Implements a PID controller.

Parameters
e

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