This commit is contained in:
hg 2015-02-11 18:09:08 +01:00
parent 9672fab717
commit db20ef7c88
3 changed files with 54 additions and 19 deletions

View File

@ -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
View 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
View 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_ */