fix logging
This commit is contained in:
parent
27e7863d5e
commit
4d191648be
|
@ -83,8 +83,8 @@ typedef struct{
|
|||
uint16_t start;
|
||||
int16_t cmd1;
|
||||
int16_t cmd2;
|
||||
int16_t speedL_meas;
|
||||
int16_t speedR_meas;
|
||||
int16_t speedL_meas; //left speed is negative when driving forward
|
||||
int16_t speedR_meas; //right speed is positive when driving forward
|
||||
int16_t batVoltage;
|
||||
int16_t boardTemp;
|
||||
int16_t curL_DC; //negative values are current drawn. positive values mean generated current
|
||||
|
@ -244,9 +244,9 @@ void loop() {
|
|||
uint16_t brake_raw = analogRead(PIN_BRAKE);
|
||||
brake_pos=max(0,min(1000,map(brake_raw,calib_brake_min,calib_brake_max,0,1000))); //map and constrain
|
||||
|
||||
if (brake_pos>0) { //pressed brake disables throttle
|
||||
throttle_pos=0;
|
||||
}
|
||||
int16_t throttlebreak_pos = throttle_pos-brake_pos*2;
|
||||
throttle_pos=constrain(throttlebreak_pos,0,1000); //reduce throttle_when applying brake
|
||||
brake_pos=constrain(-throttlebreak_pos/2,0,1000);
|
||||
|
||||
//Serial.print(throttle_raw); Serial.print(", "); Serial.print(brake_raw); Serial.print(", ");
|
||||
//Serial.print(throttle_pos); Serial.print(", "); Serial.print(brake_pos); Serial.println();
|
||||
|
@ -371,37 +371,37 @@ float filterMedian(int16_t* values) {
|
|||
|
||||
|
||||
void writeLogHeader(HardwareSerial &SerialRef) {
|
||||
SerialRef.print("time, cmd_FrontL, cmd_FrontR, cmd_RearL, cmd_RearR, ");
|
||||
SerialRef.print("current_FrontL, current_FrontR, current_RearL, current_RearR, ");
|
||||
SerialRef.print("temp_Front, temp_Rear, vbat_Front, vbat_Rear, ");
|
||||
SerialRef.print("speed_FrontL, speed_FrontR, speed_RearL, speed_RearR, ");
|
||||
SerialRef.print("currentAll, throttle, brake"); Serial.println();
|
||||
SerialRef.print("time,cmd_FrontL,cmd_FrontR,cmd_RearL,cmd_RearR,");
|
||||
SerialRef.print("current_FrontL,current_FrontR,current_RearL,current_RearR,");
|
||||
SerialRef.print("speed_FrontL,speed_FrontR,speed_RearL,speed_RearR,");
|
||||
SerialRef.print("temp_Front,temp_Rear,vbat_Front,vbat_Rear,");
|
||||
SerialRef.println("currentAll,throttle,brake");
|
||||
}
|
||||
|
||||
void writeLog(HardwareSerial &SerialRef, unsigned long time, MotorParameter &mpfront, MotorParameter &mprear, SerialFeedback &fbfront, SerialFeedback &fbrear, float currentAll, int16_t throttle, int16_t brake)
|
||||
{
|
||||
SerialRef.print(time/1000.0); SerialRef.print(", "); //time in seconds
|
||||
SerialRef.print(mpfront.cmdL); SerialRef.print(", ");
|
||||
SerialRef.print(mpfront.cmdR); SerialRef.print(", ");
|
||||
SerialRef.print(mprear.cmdL); SerialRef.print(", ");
|
||||
SerialRef.print(mprear.cmdR); SerialRef.print(", ");
|
||||
SerialRef.print(time/1000.0); SerialRef.print(","); //time in seconds
|
||||
SerialRef.print(mpfront.cmdL); SerialRef.print(",");
|
||||
SerialRef.print(mpfront.cmdR); SerialRef.print(",");
|
||||
SerialRef.print(mprear.cmdL); SerialRef.print(",");
|
||||
SerialRef.print(mprear.cmdR); SerialRef.print(",");
|
||||
|
||||
SerialRef.print(mpfront.filtered_curL,3); SerialRef.print(", ");
|
||||
SerialRef.print(mpfront.filtered_curR,3); SerialRef.print(", ");
|
||||
SerialRef.print(mprear.filtered_curL,3); SerialRef.print(", ");
|
||||
SerialRef.print(mprear.filtered_curR,3); SerialRef.print(", ");
|
||||
SerialRef.print(mpfront.filtered_curL,3); SerialRef.print(",");
|
||||
SerialRef.print(mpfront.filtered_curR,3); SerialRef.print(",");
|
||||
SerialRef.print(mprear.filtered_curL,3); SerialRef.print(",");
|
||||
SerialRef.print(mprear.filtered_curR,3); SerialRef.print(",");
|
||||
|
||||
SerialRef.print(fbfront.speedL_meas); SerialRef.print(", ");
|
||||
SerialRef.print(fbfront.speedR_meas); SerialRef.print(", ");
|
||||
SerialRef.print(fbrear.speedL_meas); SerialRef.print(", ");
|
||||
SerialRef.print(fbrear.speedR_meas); SerialRef.print(", ");
|
||||
SerialRef.print(-fbfront.speedL_meas); SerialRef.print(","); //invert speed, because left wheels are negated
|
||||
SerialRef.print(fbfront.speedR_meas); SerialRef.print(",");
|
||||
SerialRef.print(-fbrear.speedL_meas); SerialRef.print(","); //invert speed, because left wheels are negated
|
||||
SerialRef.print(fbrear.speedR_meas); SerialRef.print(",");
|
||||
|
||||
SerialRef.print(fbfront.boardTemp); SerialRef.print(", ");
|
||||
SerialRef.print(fbrear.boardTemp); SerialRef.print(", ");
|
||||
SerialRef.print(fbfront.batVoltage); SerialRef.print(", ");
|
||||
SerialRef.print(fbrear.batVoltage); SerialRef.print(", ");
|
||||
SerialRef.print(fbfront.boardTemp/10.0); SerialRef.print(","); //in degC
|
||||
SerialRef.print(fbrear.boardTemp/10.0); SerialRef.print(","); //in degC
|
||||
SerialRef.print(fbfront.batVoltage); SerialRef.print(",");
|
||||
SerialRef.print(fbrear.batVoltage); SerialRef.print(",");
|
||||
|
||||
SerialRef.print(currentAll,3); SerialRef.print(", ");
|
||||
SerialRef.print(throttle); SerialRef.print(", ");
|
||||
SerialRef.print(currentAll,3); SerialRef.print(",");
|
||||
SerialRef.print(throttle); SerialRef.print(",");
|
||||
SerialRef.print(brake); SerialRef.println();
|
||||
}
|
Loading…
Reference in New Issue