fix wheel direction for rpm feedback functions
This commit is contained in:
parent
00b432942f
commit
8d180debf7
|
@ -35,16 +35,18 @@ bool ESCSerialComm::update(unsigned long loopmillis) //returns true if something
|
|||
}
|
||||
|
||||
#define TRIP_UPDATE_INTERVAL 100
|
||||
static unsigned long last_update_trip;
|
||||
if ( loopmillis > last_update_trip+TRIP_UPDATE_INTERVAL) {
|
||||
unsigned long trip_update_interval_real=loopmillis-last_update_trip;
|
||||
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;
|
||||
meanSpeedms=_meanRPM*wheelcircumference/60.0; // Units: 1/min * m / 60s
|
||||
trip+=abs(meanSpeedms)* ((TRIP_UPDATE_INTERVAL)/1000.0);
|
||||
trip+=abs(meanSpeedms)* ((trip_update_interval_real)/1000.0);
|
||||
|
||||
|
||||
//mah consumed
|
||||
currentConsumed += (Motorparams.filtered_curL+Motorparams.filtered_curR)* (TRIP_UPDATE_INTERVAL/1000.0)/3600.0; //amp hours
|
||||
currentConsumed += (Motorparams.filtered_curL+Motorparams.filtered_curR)* (trip_update_interval_real/1000.0)/3600.0; //amp hours
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,7 +231,7 @@ int16_t ESCSerialComm::getFeedback_speedL_meas() {
|
|||
return Feedback.speedL_meas;
|
||||
}
|
||||
int16_t ESCSerialComm::getFeedback_speedR_meas() {
|
||||
return Feedback.speedR_meas;
|
||||
return -Feedback.speedR_meas; //negate rpm, so that positive rpm means driving forward
|
||||
}
|
||||
float ESCSerialComm::getFeedback_batVoltage() {
|
||||
return Feedback.batVoltage/100.0;
|
||||
|
|
|
@ -142,6 +142,8 @@ class ESCSerialComm
|
|||
|
||||
unsigned long feedback_interval_timed;
|
||||
|
||||
unsigned long last_update_trip;
|
||||
|
||||
|
||||
SerialCommand Command;
|
||||
SerialRead SRead;
|
||||
|
|
Loading…
Reference in New Issue