refactor
This commit is contained in:
parent
9672fab717
commit
db20ef7c88
20
control.cpp
20
control.cpp
@ -7,28 +7,10 @@
|
||||
|
||||
|
||||
#include "control.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
|
||||
int32_t max(int32_t a, int32_t b){
|
||||
return (a >= b) ? a : b;
|
||||
}
|
||||
|
||||
|
||||
int32_t min(int32_t a, int32_t b) {
|
||||
return (a <= b) ? a : b;
|
||||
}
|
||||
|
||||
int32_t minmax(int32_t lowerBound, int32_t value, int32_t upperBound){
|
||||
int32_t res = value;
|
||||
if (value <= lowerBound) {
|
||||
res = lowerBound;
|
||||
} else if (value >= upperBound) {
|
||||
res = upperBound;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Control::Control(float p_rMin, float p_rMax, float p_kP, float p_kI, float p_kD) :
|
||||
m_rOld(0), m_eOld(0), m_eOld2(0),
|
||||
|
33
utils.cpp
Normal file
33
utils.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* utils.cpp
|
||||
*
|
||||
* Created on: Feb 11, 2015
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
int32_t max(int32_t a, int32_t b){
|
||||
return (a >= b) ? a : b;
|
||||
}
|
||||
|
||||
|
||||
int32_t min(int32_t a, int32_t b) {
|
||||
return (a <= b) ? a : b;
|
||||
}
|
||||
|
||||
int32_t minmax(int32_t lowerBound, int32_t value, int32_t upperBound){
|
||||
int32_t res = value;
|
||||
if (value <= lowerBound) {
|
||||
res = lowerBound;
|
||||
} else if (value >= upperBound) {
|
||||
res = upperBound;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
20
utils.h
Normal file
20
utils.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* utils.h
|
||||
*
|
||||
* Created on: Feb 11, 2015
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef UTILS_H_
|
||||
#define UTILS_H_
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t max(int32_t a, int32_t b);
|
||||
int32_t min(int32_t a, int32_t b);
|
||||
int32_t minmax(int32_t lowerBound, int32_t value, int32_t upperBound);
|
||||
|
||||
|
||||
|
||||
#endif /* UTILS_H_ */
|
Loading…
x
Reference in New Issue
Block a user