modify trip measurement
This commit is contained in:
parent
8d180debf7
commit
150ce61f9f
|
@ -37,14 +37,13 @@ bool ESCSerialComm::update(unsigned long loopmillis) //returns true if something
|
||||||
#define TRIP_UPDATE_INTERVAL 100
|
#define TRIP_UPDATE_INTERVAL 100
|
||||||
if ( loopmillis > last_update_trip+TRIP_UPDATE_INTERVAL) {
|
if ( loopmillis > last_update_trip+TRIP_UPDATE_INTERVAL) {
|
||||||
unsigned long trip_update_interval_real=loopmillis-last_update_trip;
|
unsigned long trip_update_interval_real=loopmillis-last_update_trip;
|
||||||
last_update_trip=loopmillis;
|
last_update_trip=loopmillis;
|
||||||
|
|
||||||
//double _meanRPM=(-Feedback.speedL_meas+Feedback.speedR_meas)/2.0;
|
//double _meanRPM=(-Feedback.speedL_meas+Feedback.speedR_meas)/2.0;
|
||||||
double _meanRPM=(getFeedback_speedL_meas()+getFeedback_speedR_meas())/2.0;
|
double _meanRPM=(getFeedback_speedL_meas()+getFeedback_speedR_meas())/2.0;
|
||||||
meanSpeedms=_meanRPM*wheelcircumference/60.0; // Units: 1/min * m / 60s
|
meanSpeedms=_meanRPM*wheelcircumference/60.0; // Units: 1/min * m / 60s
|
||||||
trip+=abs(meanSpeedms)* ((trip_update_interval_real)/1000.0);
|
trip+=abs(meanSpeedms)* ((trip_update_interval_real)/1000.0);
|
||||||
|
|
||||||
|
|
||||||
//mah consumed
|
//mah consumed
|
||||||
currentConsumed += (Motorparams.filtered_curL+Motorparams.filtered_curR)* (trip_update_interval_real/1000.0)/3600.0; //amp hours
|
currentConsumed += (Motorparams.filtered_curL+Motorparams.filtered_curR)* (trip_update_interval_real/1000.0)/3600.0; //amp hours
|
||||||
}
|
}
|
||||||
|
@ -309,4 +308,11 @@ unsigned long ESCSerialComm::getFeedbackInterval() {
|
||||||
|
|
||||||
bool ESCSerialComm::getControllerConnected() {
|
bool ESCSerialComm::getControllerConnected() {
|
||||||
return controller_connected;
|
return controller_connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ESCSerialComm::getWheelspeed_L() {
|
||||||
|
return getFeedback_speedL_meas()*wheelcircumference/60.0; // Units: 1/min * m / 60s
|
||||||
|
}
|
||||||
|
float ESCSerialComm::getWheelspeed_R() {
|
||||||
|
return getFeedback_speedR_meas()*wheelcircumference/60.0; // Units: 1/min * m / 60s
|
||||||
}
|
}
|
|
@ -109,6 +109,11 @@ class ESCSerialComm
|
||||||
|
|
||||||
void resetStatistics();
|
void resetStatistics();
|
||||||
|
|
||||||
|
float getWheelspeed_L();
|
||||||
|
float getWheelspeed_R();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long _millis_lastinput; //declare private variable
|
long _millis_lastinput; //declare private variable
|
||||||
|
|
||||||
|
@ -161,6 +166,8 @@ class ESCSerialComm
|
||||||
|
|
||||||
|
|
||||||
float filterMedian(int16_t* values);
|
float filterMedian(int16_t* values);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue