86 unsigned char OdomControl::run(
bool e_stop_on,
bool control_on,
double commanded_vel,
double measured_vel,
double dt)
148 double p_val =
P(error, dt);
149 double i_val =
I(error, dt);
150 double d_val =
D(error, dt);
151 double pid_val = p_val + i_val + d_val;
152 ROS_DEBUG(
"\nerror: %lf\n dt: %lf", error, dt);
153 ROS_DEBUG(
"\n kp: %lf \n ki: %lf \n kd: %lf \n", p_val, i_val, d_val);
165 return (
int)round(pid_val + 125.0);
184 double p_val = error *
K_P_;
190 double avg = (fabs(vel_history[0]) + fabs(vel_history[1]) + fabs(vel_history[2])) / 3.0;
202 if (motor_speed > max)
207 if (motor_speed < min)
221 return (motor_speed + deadband_offset);
225 return (motor_speed - deadband_offset);
231 static double time = 0;
232 float change_in_velocity = 0;
bool hasZeroHistory(const std::vector< double > &vel_history)
const double MIN_VELOCITY_
int deadbandOffset(int motor_speed, int deadband_offset)
double D(double error, double dt)
std::vector< double > velocity_history_
int PID(double error, double dt)
const double MAX_VELOCITY_
int boundMotorSpeed(int motor_speed, int max, int min)
double I(double error, double dt)
const int MOTOR_SPEED_MAX
double velocity_filtered_
void start(bool use_control, PidGains pid_gains, int max, int min)
double P(double error, double dt)
double filter(double left_motor_vel, double dt)
bool enable_file_logging_
unsigned char run(bool e_stop_on, bool control_on, double commanded_vel, double measured_vel, double dt)
const double MAX_ACCEL_CUTOFF_
const int MOTOR_SPEED_MIN
double velocity_commanded_
std::string log_filename_
const int MOTOR_DEADBAND_
double velocity_measured_