diff --git a/app.mlapp b/app.mlapp index 2a272a9..00be9e9 100644 Binary files a/app.mlapp and b/app.mlapp differ diff --git a/assets/sortdata.m b/assets/sortdata.m index 9832753..dedf2af 100644 --- a/assets/sortdata.m +++ b/assets/sortdata.m @@ -5,6 +5,7 @@ function [pltData] = sortdata(data,start,stop) time_s = time_s - time_s(1); % set beginning of session to 0 % x-Axis: + pltData.Time = data.Time(start:stop); pltData.time_s = time_s(start:stop)-time_s(start); pltData.time_hms = time_hms(start:stop); diff --git a/data/VL_2024_09_04_cleaned (1).mat b/data/VL_2024_09_04_cleaned (1).mat new file mode 100644 index 0000000..2704c5f Binary files /dev/null and b/data/VL_2024_09_04_cleaned (1).mat differ diff --git a/plot_settings/plot_accumulator.m b/plot_settings/plot_accumulator.m index e3a8d9a..3fc63e8 100644 --- a/plot_settings/plot_accumulator.m +++ b/plot_settings/plot_accumulator.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_accumulator(panel, selected_laps, pltData) +function [outputArg] = plot_accumulator(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,33 +7,27 @@ function [outputArg] = plot_accumulator(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) + % plot 2: power [kW] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Power [kW]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) - end + plot(ax2,pltData.xAxis(start:stop),pltData.ams_ptot(start:stop)) + % plot 3: Max Cell Temp [°C] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Max Cell Temp [°C]") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_tmax) - end + plot(ax3,pltData.xAxis(start:stop),pltData.ams_tmax(start:stop)) % plot 4: State of charge [%] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "SOC") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_soc) - end + plot(ax4,pltData.xAxis(start:stop),pltData.ams_soc(start:stop)) % link all x axes linkaxes([ax1, ax2, ax3, ax4],"x") diff --git a/plot_settings/plot_brakes.m b/plot_settings/plot_brakes.m index 7f6b922..a5f8587 100644 --- a/plot_settings/plot_brakes.m +++ b/plot_settings/plot_brakes.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_brakes(panel, selected_laps, pltData) +function [outputArg] = plot_brakes(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,47 +7,41 @@ function [outputArg] = plot_brakes(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) + % plot 2: brake pressure front/rear [bar] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Brake Pressure F/R [bar]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePRear_bar) - end + plot(ax2,pltData.xAxis(start:stop),pltData.brakePFront_bar(start:stop)) + plot(ax2,pltData.xAxis(start:stop),pltData.brakePRear_bar(start:stop)) legend(ax2, "Front", "Rear") + % plot 3: longitudinal acceleration [g] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Long Acc [g]") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) - end + plot(ax3,pltData.xAxis(start:stop),pltData.acc_long_g(start:stop)) + % plot 4: Brake Temp [°C] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Brake Temp [°C]") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontLeft_degC) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontRight_degC) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearLeft_degC) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearRight_degC) - end + plot(ax4,pltData.xAxis(start:stop),pltData.brakeTFrontLeft_degC(start:stop)) + plot(ax4,pltData.xAxis(start:stop),pltData.brakeTFrontRight_degC(start:stop)) + plot(ax4,pltData.xAxis(start:stop),pltData.brakeTRearLeft_degC(start:stop)) + plot(ax4,pltData.xAxis(start:stop),pltData.brakeTRearRight_degC(start:stop)) legend(ax4, "FL", "FR", "RL", "RR") + % plot 5: brake bias [%] ax5 = nexttile(tl); hold(ax5, "on") grid(ax5, "on") title(ax5, "Brake Bias [%]") - for i = 1:length(selected_laps) - plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeBias_perc) - end + plot(ax5,pltData.xAxis(start:stop),pltData.brakeBias_perc(start:stop)) % link all x axes linkaxes([ax1, ax2, ax3, ax4, ax5],"x") diff --git a/plot_settings/plot_custom.m b/plot_settings/plot_custom.m new file mode 100644 index 0000000..ee8707f --- /dev/null +++ b/plot_settings/plot_custom.m @@ -0,0 +1,44 @@ +function [outputArg] = plot_custom(panel, start, stop, pltData) + % create tiledlayout (R2023a and newer) + + tl = tiledlayout(panel,"flow"); + + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Title") + ylabel(ax1, "y-axis label") + xlabel(ax1, "x-axis label") + %"XXX = enter name of data you want to plot" + plot(ax1,pltData.xAxis(start:stop),pltData.XXX(start:stop)) + + % more plots for customizing + + % plot 2: + % ax2 = nexttile(tl); + % hold(ax2, "on") + % grid(ax2, "on") + % title(ax2, "Power [kW]") + % plot(ax2,pltData.xAxis(start:stop),pltData. XXXX (start:stop)) + + % plot 3: + % ax3 = nexttile(tl); + % hold(ax3, "on") + % grid(ax3, "on") + % title(ax3, "Max Cell Temp [°C]") + % plot(ax3,pltData.xAxis(start:stop),pltData. XXXX (start:stop)) + + % plot 4: + % ax4 = nexttile(tl); + % hold(ax4, "on") + % grid(ax4, "on") + % title(ax4, "SOC") + % plot(ax4,pltData.xAxis(start:stop),pltData. XXXX (start:stop)) + + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/plot_settings/plot_driver_braking.m b/plot_settings/plot_driver_braking.m index c5643d5..0648479 100644 --- a/plot_settings/plot_driver_braking.m +++ b/plot_settings/plot_driver_braking.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_driver_braking(panel, selected_laps, pltData) +function [outputArg] = plot_driver_braking(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,33 +7,25 @@ function [outputArg] = plot_driver_braking(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: accelerator pedal position [%] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "APP [%]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) - end + plot(ax2,pltData.xAxis(start:stop),pltData.app_percent(start:stop)) % plot 3: brake pressure front [bar] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Brake Pressure Front [bar]") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) - end + plot(ax3,pltData.xAxis(start:stop),pltData.brakePFront_bar(start:stop)) % plot 4: longitudinal acceleration [g] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Long Acc [g]") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) - end + plot(ax4,pltData.xAxis(start:stop),pltData.acc_long_g(start:stop)) % link all x axes linkaxes([ax1, ax2, ax3, ax4],"x") diff --git a/plot_settings/plot_driver_general.m b/plot_settings/plot_driver_general.m index fbe881a..e33b68c 100644 --- a/plot_settings/plot_driver_general.m +++ b/plot_settings/plot_driver_general.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_driver_general(panel, selected_laps, pltData) +function [outputArg] = plot_driver_general(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,33 +7,25 @@ function [outputArg] = plot_driver_general(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: accelerator pedal position [%] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "APP [%]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) - end + plot(ax2,pltData.xAxis(start:stop),pltData.app_percent(start:stop)) % plot 3: brake pressure front [bar] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Brake Pressure Front [bar]") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) - end + plot(ax3,pltData.xAxis(start:stop),pltData.brakePFront_bar(start:stop)) % plot 4: steering angle [°] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Steering Angle [°]") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) - end + plot(ax4,pltData.xAxis(start:stop),pltData.steering_deg(start:stop)) % link all x axes linkaxes([ax1, ax2, ax3, ax4],"x") diff --git a/plot_settings/plot_driver_statistics.m b/plot_settings/plot_driver_statistics.m index 04cf635..a72408e 100644 --- a/plot_settings/plot_driver_statistics.m +++ b/plot_settings/plot_driver_statistics.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) +function [outputArg] = plot_driver_statistics(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,17 +7,13 @@ function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: accelerator pedal position [%] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "APP [%]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).app_percent) - end + plot(ax2,pltData.xAxis(start:stop),pltData.app_percent(start:stop)) linkaxes([ax1, ax2],"x") % plot 3: accelerator pedal position histogram ax3 = nexttile(tl); @@ -26,9 +22,7 @@ function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) title(ax3, "APP distribution") ylabel(ax3, "\sigma [%]") xlabel(ax3, "APP [%]") - for i = 1:length(selected_laps) - histogram(ax3,pltData(selected_laps(i)).app_percent,"Normalization","percentage") - end + histogram(ax3,pltData.app_percent(start:stop),"Normalization","percentage") % plot 4: brake pressure histogram ax4 = nexttile(tl); hold(ax4, "on") @@ -36,9 +30,7 @@ function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) title(ax4, "BrakeP distribution") ylabel(ax4, "\sigma [%]") xlabel(ax4, "Brake Pressure Front [bar]") - for i = 1:length(selected_laps) - histogram(ax4,pltData(selected_laps(i)).brakePFront_bar,"Normalization","percentage") - end + histogram(ax4,pltData.brakePFront_bar(start:stop),"Normalization","percentage") % return null (not relevant for plots!) outputArg = []; diff --git a/plot_settings/plot_driver_steering.m b/plot_settings/plot_driver_steering.m index d8066ea..dc1eb6f 100644 --- a/plot_settings/plot_driver_steering.m +++ b/plot_settings/plot_driver_steering.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) +function [outputArg] = plot_driver_steering(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,17 +7,13 @@ function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: steering angle [°] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Steering Angle [°]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) - end + plot(ax2,pltData.xAxis(start:stop),pltData.steering_deg(start:stop)) % plot 3: oversteer ax3 = nexttile(tl); hold(ax3, "on") @@ -30,9 +26,7 @@ function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) hold(ax4, "on") grid(ax4, "on") title(ax4, "Lateral Acc [g]") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_lat_g) - end + plot(ax4,pltData.xAxis(start:stop),pltData.acc_lat_g)(start:stop) % link all x axes linkaxes([ax1, ax2, ax3, ax4],"x") diff --git a/plot_settings/plot_inverter.m b/plot_settings/plot_inverter.m index 878f72f..6d57e10 100644 --- a/plot_settings/plot_inverter.m +++ b/plot_settings/plot_inverter.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_inverter(panel, selected_laps, pltData) +function [outputArg] = plot_inverter(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,48 +7,38 @@ function [outputArg] = plot_inverter(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: Inverter Temps [°C] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Inverter Temp [°C]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) - end + plot(ax2,pltData.xAxis(start:stop),pltData.invL_temp(start:stop)) + plot(ax2,pltData.xAxis(start:stop),pltData.invR_temp(start:stop)) legend(ax2, "Left", "Right") % plot 3: Torque request / actual inverter left ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Left Torque") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueDemand) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueActual) - end + plot(ax3,pltData.xAxis(start:stop),pltData.invL_torqueDemand(start:stop)) + plot(ax3,pltData.xAxis(start:stop),pltData.invL_torqueActual(start:stop)) legend(ax3, "Demand", "Actual") % plot 4: Torque request / actual inverter right ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Right Torque") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueDemand) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueActual) - end + plot(ax4,pltData.xAxis(start:stop),pltData.invR_torqueDemand(start:stop)) + plot(ax4,pltData.xAxis(start:stop),pltData.invR_torqueActual(start:stop)) legend(ax4, "Demand", "Actual") % plot 5: Motor velocities ax5 = nexttile(tl); hold(ax5, "on") grid(ax5, "on") title(ax5, "Motor Velocities [1/min]") - for i = 1:length(selected_laps) - plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) - plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) - end + plot(ax5,pltData.xAxis(start:stop),pltData.motL_vel_rpm(start:stop)) + plot(ax5,pltData.xAxis(start:stop),pltData.motR_vel_rpm(start:stop)) legend(ax5, "Left", "Right") % link all x axes diff --git a/plot_settings/plot_powertrain.m b/plot_settings/plot_powertrain.m index dfb51d8..d5199f6 100644 --- a/plot_settings/plot_powertrain.m +++ b/plot_settings/plot_powertrain.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_powertrain(panel, selected_laps, pltData) +function [outputArg] = plot_powertrain(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); @@ -7,46 +7,36 @@ function [outputArg] = plot_powertrain(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Speed [km/h]") - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) - end + plot(ax1,pltData.xAxis(start:stop),pltData.speed_kph(start:stop)) % plot 2: power [kW] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Power [kW]") - for i = 1:length(selected_laps) - plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) - end + plot(ax2,pltData.xAxis(start:stop),pltData.ams_ptot(start:stop)) % plot 3: Inverter Temps [°C] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Inverter Temp [°C]") - for i = 1:length(selected_laps) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) - plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) - end + plot(ax3,pltData.xAxis(start:stop),pltData.invL_temp(start:stop)) + plot(ax3,pltData.xAxis(start:stop),pltData.invR_temp(start:stop)) legend(ax3, "Left", "Right") % plot 4: Motor Temps ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Motor Temp [°C]") - for i = 1:length(selected_laps) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_temp) - plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_temp) - end + plot(ax4,pltData.xAxis(start:stop),pltData.motL_temp(start:stop)) + plot(ax4,pltData.xAxis(start:stop),pltData.motR_temp(start:stop)) legend(ax4, "Left", "Right") % plot 5: Motor velocities ax5 = nexttile(tl); hold(ax5, "on") grid(ax5, "on") title(ax5, "Motor Velocities [1/min]") - for i = 1:length(selected_laps) - plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) - plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) - end + plot(ax5,pltData.xAxis(start:stop),pltData.motL_vel_rpm(start:stop)) + plot(ax5,pltData.xAxis(start:stop),pltData.motR_vel_rpm(start:stop)) legend(ax5, "Left", "Right") % link all x axes diff --git a/plot_settings/plot_suspension_histogram.m b/plot_settings/plot_suspension_histogram.m index fa1e6b4..ed6363f 100644 --- a/plot_settings/plot_suspension_histogram.m +++ b/plot_settings/plot_suspension_histogram.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_suspension_histogram(panel, selected_laps, pltData) +function [outputArg] = plot_suspension_histogram(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); % plot 1: position heave front [mm/s] @@ -6,33 +6,25 @@ function [outputArg] = plot_suspension_histogram(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Heave Front [mm/s]") - for i = 1:length(selected_laps) - histogram(ax1, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") - end + histogram(ax1, pltData.velocityHeaveFront_mmps(start:stop),"Normalization","percentage") % plot 2: position roll front [mm/s] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Roll Front [mm/s]") - for i = 1:length(selected_laps) - histogram(ax2, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") - end + histogram(ax2, pltData.velocityHeaveFront_mmps(start:stop),"Normalization","percentage") % plot 3: position heave front [mm/s] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Heave Rear [mm/s]") - for i = 1:length(selected_laps) - histogram(ax3, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") - end + histogram(ax3, pltData.velocityHeaveFront_mmps(start:stop),"Normalization","percentage") % plot 4: position roll front [mm/s] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Roll Rear [mm/s]") - for i = 1:length(selected_laps) - histogram(ax4, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") - end + histogram(ax4, pltData.velocityHeaveFront_mmps(start:stop),"Normalization","percentage") linkaxes([ax1, ax2, ax3, ax4],"x") % return null (not relevant for plots!) diff --git a/plot_settings/plot_suspension_positions.m b/plot_settings/plot_suspension_positions.m index 844242f..49c1ea6 100644 --- a/plot_settings/plot_suspension_positions.m +++ b/plot_settings/plot_suspension_positions.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_suspension_positions(panel, selected_laps, pltData) +function [outputArg] = plot_suspension_positions(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); % plot 1: position heave front [mm] @@ -6,33 +6,25 @@ function [outputArg] = plot_suspension_positions(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Heave Front [mm]") - for i = 1:length(selected_laps) - plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveFront_mm) - end + plot(ax1, pltData.xAxis(start:stop),pltData.damperHeaveFront_mm(start:stop)) % plot 2: position roll front [mm] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Roll Front [mm]") - for i = 1:length(selected_laps) - plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollFront_mm) - end + plot(ax2, pltData.xAxis(start:stop),pltData.damperRollFront_mm(start:stop)) % plot 3: position heave front [mm] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Heave Rear [mm]") - for i = 1:length(selected_laps) - plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveRear_mm) - end + plot(ax3, pltData.xAxis(start:stop),pltData.damperHeaveRear_mm(start:stop)) % plot 4: position roll front [mm] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Roll Rear [mm]") - for i = 1:length(selected_laps) - plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollRear_mm) - end + plot(ax4, pltData.xAxis(start:stop),pltData.damperRollRear_mm(start:stop)) linkaxes([ax1, ax2, ax3, ax4],"x") % return null (not relevant for plots!) diff --git a/plot_settings/plot_suspension_velocities.m b/plot_settings/plot_suspension_velocities.m index aed80e5..a64a10e 100644 --- a/plot_settings/plot_suspension_velocities.m +++ b/plot_settings/plot_suspension_velocities.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_suspension_velocities(panel, selected_laps, pltData) +function [outputArg] = plot_suspension_velocities(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"vertical"); % plot 1: velocity heave front [mm/s] @@ -6,33 +6,25 @@ function [outputArg] = plot_suspension_velocities(panel, selected_laps, pltData) hold(ax1, "on") grid(ax1, "on") title(ax1, "Heave Front [mm/s]") - for i = 1:length(selected_laps) - plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveFront_mmps) - end + plot(ax1, pltData.xAxis(start:stop), pltData.velocityHeaveFront_mmps(start:stop)) % plot 2: velocity roll front [mm/s] ax2 = nexttile(tl); hold(ax2, "on") grid(ax2, "on") title(ax2, "Roll Front [mm/s]") - for i = 1:length(selected_laps) - plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollFront_mmps) - end + plot(ax2, pltData.xAxis(start:stop), pltData.velocityRollFront_mmps(start:stop)) % plot 3: velocity heave front [mm/s] ax3 = nexttile(tl); hold(ax3, "on") grid(ax3, "on") title(ax3, "Heave Rear [mm/s]") - for i = 1:length(selected_laps) - plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveRear_mmps) - end + plot(ax3, pltData.xAxis(start:stop), pltData.velocityHeaveRear_mmps(start:stop)) % plot 4: velocity roll front [mm/s] ax4 = nexttile(tl); hold(ax4, "on") grid(ax4, "on") title(ax4, "Roll Rear [mm/s]") - for i = 1:length(selected_laps) - plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollRear_mmps) - end + plot(ax4, pltData.xAxis(start:stop), pltData.velocityRollRear_mmps(start:stop)) linkaxes([ax1, ax2, ax3, ax4],"x") % return null (not relevant for plots!) diff --git a/plot_settings/plot_tires_firctionCircle.m b/plot_settings/plot_tires_firctionCircle.m index baa117e..ef2830c 100644 --- a/plot_settings/plot_tires_firctionCircle.m +++ b/plot_settings/plot_tires_firctionCircle.m @@ -1,4 +1,4 @@ -function [outputArg] = plot_tires_firctionCircle(panel, selected_laps, pltData) +function [outputArg] = plot_tires_firctionCircle(panel, start, stop, pltData) % create tiledlayout (R2023a and newer) tl = tiledlayout(panel,"flow"); @@ -10,13 +10,9 @@ function [outputArg] = plot_tires_firctionCircle(panel, selected_laps, pltData) ylabel(ax1, "Longitudinal Acc [g]") xlabel(ax1, "Lateral Acc [g]") colors = colororder(ax1); - for i = 1:length(selected_laps) - plot(ax1,pltData(selected_laps(i)).acc_lat_g, ... - pltData(selected_laps(i)).acc_long_g,"Color",colors(i,:)) - K = convhull(pltData(selected_laps(i)).acc_lat_g, pltData(selected_laps(i)).acc_long_g); - plot(ax1,pltData(selected_laps(i)).acc_lat_g(K), ... - pltData(selected_laps(i)).acc_long_g(K),"Color",colors(i,:),"LineStyle","--","LineWidth",2) - end + plot(ax1,pltData.acc_lat_g(start:stop), pltData.acc_long_g(start:stop),"Color",colors(i,:)) + K = convhull(pltData.acc_lat_g(start:stop), pltData.acc_long_g(start:stop)); + plot(ax1,pltData.acc_lat_g(K), pltData.acc_long_g(K),"Color",colors(i,:),"LineStyle","--","LineWidth",2) % return null (not relevant for plots!) outputArg = []; diff --git a/season/FT23/plot_settings/plot_accumulator.m b/season/FT23/plot_settings/plot_accumulator.m new file mode 100644 index 0000000..e3a8d9a --- /dev/null +++ b/season/FT23/plot_settings/plot_accumulator.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_accumulator(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Max Cell Temp [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Max Cell Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_tmax) + end + % plot 4: State of charge [%] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "SOC") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_soc) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_brakes.m b/season/FT23/plot_settings/plot_brakes.m new file mode 100644 index 0000000..7f6b922 --- /dev/null +++ b/season/FT23/plot_settings/plot_brakes.m @@ -0,0 +1,59 @@ +function [outputArg] = plot_brakes(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: brake pressure front/rear [bar] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Brake Pressure F/R [bar]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePRear_bar) + end + legend(ax2, "Front", "Rear") + % plot 3: longitudinal acceleration [g] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % plot 4: Brake Temp [°C] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Brake Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontRight_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearRight_degC) + end + legend(ax4, "FL", "FR", "RL", "RR") + % plot 5: brake bias [%] + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Brake Bias [%]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeBias_perc) + end + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_driver_braking.m b/season/FT23/plot_settings/plot_driver_braking.m new file mode 100644 index 0000000..c5643d5 --- /dev/null +++ b/season/FT23/plot_settings/plot_driver_braking.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_braking(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: longitudinal acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_driver_general.m b/season/FT23/plot_settings/plot_driver_general.m new file mode 100644 index 0000000..fbe881a --- /dev/null +++ b/season/FT23/plot_settings/plot_driver_general.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_general(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: steering angle [°] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_driver_statistics.m b/season/FT23/plot_settings/plot_driver_statistics.m new file mode 100644 index 0000000..04cf635 --- /dev/null +++ b/season/FT23/plot_settings/plot_driver_statistics.m @@ -0,0 +1,46 @@ +function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).app_percent) + end + linkaxes([ax1, ax2],"x") + % plot 3: accelerator pedal position histogram + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "APP distribution") + ylabel(ax3, "\sigma [%]") + xlabel(ax3, "APP [%]") + for i = 1:length(selected_laps) + histogram(ax3,pltData(selected_laps(i)).app_percent,"Normalization","percentage") + end + % plot 4: brake pressure histogram + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "BrakeP distribution") + ylabel(ax4, "\sigma [%]") + xlabel(ax4, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + histogram(ax4,pltData(selected_laps(i)).brakePFront_bar,"Normalization","percentage") + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_driver_steering.m b/season/FT23/plot_settings/plot_driver_steering.m new file mode 100644 index 0000000..d8066ea --- /dev/null +++ b/season/FT23/plot_settings/plot_driver_steering.m @@ -0,0 +1,42 @@ +function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: steering angle [°] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % plot 3: oversteer + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Oversteer") + % TODO!! + + % plot 4: lateral acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Lateral Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_lat_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_inverter.m b/season/FT23/plot_settings/plot_inverter.m new file mode 100644 index 0000000..878f72f --- /dev/null +++ b/season/FT23/plot_settings/plot_inverter.m @@ -0,0 +1,60 @@ +function [outputArg] = plot_inverter(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: Inverter Temps [°C] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax2, "Left", "Right") + % plot 3: Torque request / actual inverter left + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Left Torque") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueDemand) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueActual) + end + legend(ax3, "Demand", "Actual") + % plot 4: Torque request / actual inverter right + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Right Torque") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueDemand) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueActual) + end + legend(ax4, "Demand", "Actual") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_powertrain.m b/season/FT23/plot_settings/plot_powertrain.m new file mode 100644 index 0000000..dfb51d8 --- /dev/null +++ b/season/FT23/plot_settings/plot_powertrain.m @@ -0,0 +1,58 @@ +function [outputArg] = plot_powertrain(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Inverter Temps [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax3, "Left", "Right") + % plot 4: Motor Temps + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Motor Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_temp) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_temp) + end + legend(ax4, "Left", "Right") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_suspension_histogram.m b/season/FT23/plot_settings/plot_suspension_histogram.m new file mode 100644 index 0000000..fa1e6b4 --- /dev/null +++ b/season/FT23/plot_settings/plot_suspension_histogram.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_histogram(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax1, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 2: position roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax2, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 3: position heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax3, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 4: position roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax4, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_suspension_positions.m b/season/FT23/plot_settings/plot_suspension_positions.m new file mode 100644 index 0000000..844242f --- /dev/null +++ b/season/FT23/plot_settings/plot_suspension_positions.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_positions(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveFront_mm) + end + % plot 2: position roll front [mm] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollFront_mm) + end + % plot 3: position heave front [mm] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveRear_mm) + end + % plot 4: position roll front [mm] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollRear_mm) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_suspension_velocities.m b/season/FT23/plot_settings/plot_suspension_velocities.m new file mode 100644 index 0000000..aed80e5 --- /dev/null +++ b/season/FT23/plot_settings/plot_suspension_velocities.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_velocities(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: velocity heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveFront_mmps) + end + % plot 2: velocity roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollFront_mmps) + end + % plot 3: velocity heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveRear_mmps) + end + % plot 4: velocity roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollRear_mmps) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/plot_tires_firctionCircle.m b/season/FT23/plot_settings/plot_tires_firctionCircle.m new file mode 100644 index 0000000..baa117e --- /dev/null +++ b/season/FT23/plot_settings/plot_tires_firctionCircle.m @@ -0,0 +1,24 @@ +function [outputArg] = plot_tires_firctionCircle(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + + tl = tiledlayout(panel,"flow"); + + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Friction Circle") + ylabel(ax1, "Longitudinal Acc [g]") + xlabel(ax1, "Lateral Acc [g]") + colors = colororder(ax1); + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).acc_lat_g, ... + pltData(selected_laps(i)).acc_long_g,"Color",colors(i,:)) + K = convhull(pltData(selected_laps(i)).acc_lat_g, pltData(selected_laps(i)).acc_long_g); + plot(ax1,pltData(selected_laps(i)).acc_lat_g(K), ... + pltData(selected_laps(i)).acc_long_g(K),"Color",colors(i,:),"LineStyle","--","LineWidth",2) + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT23/plot_settings/sidebar_stats.m b/season/FT23/plot_settings/sidebar_stats.m new file mode 100644 index 0000000..018b9b8 --- /dev/null +++ b/season/FT23/plot_settings/sidebar_stats.m @@ -0,0 +1,21 @@ +function [sidebarLabel] = sidebar_stats(pltData) +%SIDEBAR_STATS Summary of this function goes here +% Detailed explanation goes here + sidebarLabel = sprintf(... + "Statistics:\nEnergy\n Used: %.2f kWh\n" + ... + " Regen: %.2f kWh\n" + ... + " Total: %.2f kWh\n" + ... + "\nPower\n Peak: %.1f kW\n" + ... + " Peak (mean): %1.f kW\n" + ... + "\nDistance: %.2f km\n" + ... + "\nTopspeed: %.1f km/h\n", ... + pltData.energy_used_kwh, ... + pltData.energy_regen_kwh, ... + pltData.energy_kwh, ... + pltData.peakPower_kw, ... + pltData.peakPowerMean_kw, ... + pltData.distanceTotal_km, ... + pltData.maxSpeed_kph ... + ); +end + diff --git a/season/FT23/sortdata.m b/season/FT23/sortdata.m new file mode 100644 index 0000000..9832753 --- /dev/null +++ b/season/FT23/sortdata.m @@ -0,0 +1,122 @@ +function [pltData] = sortdata(data,start,stop) + date = dateshift(data.Time(1),'start','day'); + time_hms = data.Time-date; + time_s = seconds(time_hms); + time_s = time_s - time_s(1); % set beginning of session to 0 + + % x-Axis: + pltData.time_s = time_s(start:stop)-time_s(start); + pltData.time_hms = time_hms(start:stop); + + % distance calculation + speed_mps = movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % TODO: test different speed filters for distance calculation + pltData.distance(1) = 0; + for i = 2:length(speed_mps) + pltData.distance(i) = speed_mps(i)*(pltData.time_s(i)-pltData.time_s(i-1)) + pltData.distance(i-1); + end + pltData.xAxis = pltData.time_s; % set time as default x-Axis for plotting + + %% Misc + pltData.app_percent = data.ABX_Driver_ABX_APPS_percent(start:stop); + pltData.speed_kph = 3.6*movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % same filter as for distance calculation ??? + pltData.steering_deg = data.ABX_Driver_ABX_Steering_Angle(start:stop); + + %% AMS: + pltData.ams_soc = data.AMS_Status_SOC(start:stop); + pltData.ams_tmax = data.AMS_Status_Max_cell_temp(start:stop); + pltData.ams_utot = data.Shunt_Voltage1_Shunt_Voltage1(start:stop); + pltData.ams_itot = data.Shunt_Current_Shunt_Current(start:stop); + % calculations: + pltData.ams_ptot = pltData.ams_utot.*pltData.ams_itot/1000; + + %% Brakes + % brake pressure + pltData.brakePFront_bar = data.ABX_Driver_ABX_BrakeP_F(start:stop); + pltData.brakePRear_bar = data.ABX_Driver_ABX_BrakeP_R(start:stop); + % brake disc temperatures + pltData.brakeTFrontLeft_degC = data.ABX_BrakeT_ABX_BrakeT_FL(start:stop); + pltData.brakeTFrontRight_degC = data.ABX_BrakeT_ABX_BrakeT_FR(start:stop); + pltData.brakeTRearLeft_degC = data.ABX_BrakeT_ABX_BrakeT_RL(start:stop); + pltData.brakeTRearRight_degC = data.ABX_BrakeT_ABX_BrakeT_RR(start:stop); + % calculate brake bias [%] + minBrakeP = 5; % minimum brake pressure to avoid artifacts due to sensor noise near 0 bar + brakePFront = pltData.brakePFront_bar; + brakePFront(brakePFront < minBrakeP) = minBrakeP; + brakePRear = pltData.brakePRear_bar; + brakePRear(brakePRear < minBrakeP) = minBrakeP; + pltData.brakeBias_perc = 100*brakePFront./brakePRear; % check calculation! + + %% Cooling system + + %% Dampers + % damper positions + pltData.damper_FL_mm = data.ABX_Dampers_ABX_Damper_FL(start:stop); %Heave_F + pltData.damper_FR_mm = data.ABX_Dampers_ABX_Damper_FR(start:stop); %Roll_F + pltData.damper_RL_mm = data.ABX_Dampers_ABX_Damper_RL(start:stop); %Heave_R + pltData.damper_RR_mm = data.ABX_Dampers_ABX_Damper_RR(start:stop); %Roll_R + % calculate damper velocities + pltData.velocity_FL_mmps(1) = 0; + pltData.velocity_FR_mmps(1) = 0; + pltData.velocity_RL_mmps(1) = 0; + pltData.velocity_RR_mmps(1) = 0; + for i = 2:length(pltData.time_s) + timestep = pltData.time_s(i)-pltData.time_s(i-1); + pltData.velocity_FL_mmps(i) = pltData.damper_FL_mm(i)-pltData.damper_FL_mm(i-1)/timestep; + pltData.velocity_FR_mmps(i) = pltData.damper_FR_mm(i)-pltData.damper_FR_mm(i-1)/timestep; + pltData.velocity_RL_mmps(i) = pltData.damper_RL_mm(i)-pltData.damper_RL_mm(i-1)/timestep; + pltData.velocity_RR_mmps(i) = pltData.damper_RR_mm(i)-pltData.damper_RR_mm(i-1)/timestep; + end + % filter damper velocities ??? bessere Berechnung über mittelwert aus mehreren werten? Vorfilterung? + pltData.velocity_FL_mmps = movmean(pltData.velocity_FL_mmps,100); + pltData.velocity_FR_mmps = movmean(pltData.velocity_FR_mmps,100); + pltData.velocity_RL_mmps = movmean(pltData.velocity_RL_mmps,100); + pltData.velocity_RR_mmps = movmean(pltData.velocity_RR_mmps,100); + + %% IMU + % Acceleration + % pltData.acc_long_g = movmean(data.XSens_Acceleration_XSens_accX(start:stop),100)/9.81; + % pltData.acc_lat_g = movmean(data.XSens_Acceleration_XSens_accY(start:stop),100)/9.81; + % Rate of turn + % pltData.rot_roll_degps = movmean(data.XSens_RateOfTurn_XSens_gyrX(start:stop),100); + % pltData.rot_pitch_degps = movmean(data.XSens_RateOfTurn_XSens_gyrY(start:stop),100); + % pltData.rot_yaw_degps = movmean(data.XSens_RateOfTurn_XSens_gyrZ(start:stop),100); + + %% Inverters + % inverter temperatures + pltData.invL_temp = data.INV_L_TxPDO_1_T_Inv_L(start:stop); + pltData.invR_temp = data.INV_R_TxPDO_1_T_Inv_R(start:stop); + % motor temperatures + pltData.motL_temp = data.INV_L_TxPDO_1_T_Mot_L(start:stop); + pltData.motR_temp = data.INV_R_TxPDO_1_T_Mot_R(start:stop); + % motor velocities + pltData.motL_vel_rpm = 60*data.INV_L_TxPDO_4_Velocity_L(start:stop); + pltData.motR_vel_rpm = 60*data.INV_R_TxPDO_4_Velocity_R(start:stop); + % inverter torque demand + pltData.invL_torqueDemand = data.INV_L_TxPDO_3_DemandedTorque_L(start:stop)/10; % /10 to match autobox torque + pltData.invR_torqueDemand = data.INV_R_TxPDO_3_DemandedTorque_R(start:stop)/10; + % inverter actual torque + pltData.invL_torqueActual = data.INV_L_TxPDO_3_ActualTorque_L(start:stop)/10; + pltData.invR_torqueActual = data.INV_R_TxPDO_3_ActualTorque_R(start:stop)/10; + + %% Wheelspeed + + + + + %% Statistics: + power_regen_kw = pltData.ams_ptot; + power_regen_kw(power_regen_kw > 0) = 0; + power_used_kw = pltData.ams_ptot; + power_used_kw(power_used_kw < 0) = 0; + pltData.energy_kwh = trapz(pltData.time_s, pltData.ams_ptot)/3600; + pltData.energy_regen_kwh = trapz(pltData.time_s, power_regen_kw)/3600; + pltData.energy_used_kwh = trapz(pltData.time_s, power_used_kw)/3600; + pltData.distanceTotal_km = trapz(pltData.time_s, pltData.speed_kph./3.6)/1000; % 1/3.6 for km/h to m/s and /1000 for km output + pltData.peakPower_kw = max(pltData.ams_ptot); + pltData.peakPowerMean_kw = max(movmean(pltData.ams_ptot,500)); + + pltData.maxSpeed_kph = max(pltData.speed_kph); + pltData.startTime = time_hms(start); + pltData.stopTime = time_hms(stop); +end + diff --git a/season/FT24/plot_settings/plot_accumulator.m b/season/FT24/plot_settings/plot_accumulator.m new file mode 100644 index 0000000..e3a8d9a --- /dev/null +++ b/season/FT24/plot_settings/plot_accumulator.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_accumulator(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Max Cell Temp [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Max Cell Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_tmax) + end + % plot 4: State of charge [%] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "SOC") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_soc) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_brakes.m b/season/FT24/plot_settings/plot_brakes.m new file mode 100644 index 0000000..7f6b922 --- /dev/null +++ b/season/FT24/plot_settings/plot_brakes.m @@ -0,0 +1,59 @@ +function [outputArg] = plot_brakes(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: brake pressure front/rear [bar] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Brake Pressure F/R [bar]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePRear_bar) + end + legend(ax2, "Front", "Rear") + % plot 3: longitudinal acceleration [g] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % plot 4: Brake Temp [°C] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Brake Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontRight_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearRight_degC) + end + legend(ax4, "FL", "FR", "RL", "RR") + % plot 5: brake bias [%] + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Brake Bias [%]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeBias_perc) + end + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_driver_braking.m b/season/FT24/plot_settings/plot_driver_braking.m new file mode 100644 index 0000000..c5643d5 --- /dev/null +++ b/season/FT24/plot_settings/plot_driver_braking.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_braking(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: longitudinal acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_driver_general.m b/season/FT24/plot_settings/plot_driver_general.m new file mode 100644 index 0000000..fbe881a --- /dev/null +++ b/season/FT24/plot_settings/plot_driver_general.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_general(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: steering angle [°] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_driver_statistics.m b/season/FT24/plot_settings/plot_driver_statistics.m new file mode 100644 index 0000000..04cf635 --- /dev/null +++ b/season/FT24/plot_settings/plot_driver_statistics.m @@ -0,0 +1,46 @@ +function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).app_percent) + end + linkaxes([ax1, ax2],"x") + % plot 3: accelerator pedal position histogram + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "APP distribution") + ylabel(ax3, "\sigma [%]") + xlabel(ax3, "APP [%]") + for i = 1:length(selected_laps) + histogram(ax3,pltData(selected_laps(i)).app_percent,"Normalization","percentage") + end + % plot 4: brake pressure histogram + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "BrakeP distribution") + ylabel(ax4, "\sigma [%]") + xlabel(ax4, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + histogram(ax4,pltData(selected_laps(i)).brakePFront_bar,"Normalization","percentage") + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_driver_steering.m b/season/FT24/plot_settings/plot_driver_steering.m new file mode 100644 index 0000000..d8066ea --- /dev/null +++ b/season/FT24/plot_settings/plot_driver_steering.m @@ -0,0 +1,42 @@ +function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: steering angle [°] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % plot 3: oversteer + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Oversteer") + % TODO!! + + % plot 4: lateral acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Lateral Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_lat_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_inverter.m b/season/FT24/plot_settings/plot_inverter.m new file mode 100644 index 0000000..878f72f --- /dev/null +++ b/season/FT24/plot_settings/plot_inverter.m @@ -0,0 +1,60 @@ +function [outputArg] = plot_inverter(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: Inverter Temps [°C] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax2, "Left", "Right") + % plot 3: Torque request / actual inverter left + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Left Torque") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueDemand) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueActual) + end + legend(ax3, "Demand", "Actual") + % plot 4: Torque request / actual inverter right + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Right Torque") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueDemand) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueActual) + end + legend(ax4, "Demand", "Actual") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_powertrain.m b/season/FT24/plot_settings/plot_powertrain.m new file mode 100644 index 0000000..dfb51d8 --- /dev/null +++ b/season/FT24/plot_settings/plot_powertrain.m @@ -0,0 +1,58 @@ +function [outputArg] = plot_powertrain(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Inverter Temps [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax3, "Left", "Right") + % plot 4: Motor Temps + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Motor Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_temp) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_temp) + end + legend(ax4, "Left", "Right") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_suspension_histogram.m b/season/FT24/plot_settings/plot_suspension_histogram.m new file mode 100644 index 0000000..fa1e6b4 --- /dev/null +++ b/season/FT24/plot_settings/plot_suspension_histogram.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_histogram(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax1, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 2: position roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax2, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 3: position heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax3, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 4: position roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax4, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_suspension_positions.m b/season/FT24/plot_settings/plot_suspension_positions.m new file mode 100644 index 0000000..844242f --- /dev/null +++ b/season/FT24/plot_settings/plot_suspension_positions.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_positions(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveFront_mm) + end + % plot 2: position roll front [mm] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollFront_mm) + end + % plot 3: position heave front [mm] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveRear_mm) + end + % plot 4: position roll front [mm] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollRear_mm) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_suspension_velocities.m b/season/FT24/plot_settings/plot_suspension_velocities.m new file mode 100644 index 0000000..aed80e5 --- /dev/null +++ b/season/FT24/plot_settings/plot_suspension_velocities.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_velocities(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: velocity heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveFront_mmps) + end + % plot 2: velocity roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollFront_mmps) + end + % plot 3: velocity heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveRear_mmps) + end + % plot 4: velocity roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollRear_mmps) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/plot_tires_firctionCircle.m b/season/FT24/plot_settings/plot_tires_firctionCircle.m new file mode 100644 index 0000000..baa117e --- /dev/null +++ b/season/FT24/plot_settings/plot_tires_firctionCircle.m @@ -0,0 +1,24 @@ +function [outputArg] = plot_tires_firctionCircle(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + + tl = tiledlayout(panel,"flow"); + + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Friction Circle") + ylabel(ax1, "Longitudinal Acc [g]") + xlabel(ax1, "Lateral Acc [g]") + colors = colororder(ax1); + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).acc_lat_g, ... + pltData(selected_laps(i)).acc_long_g,"Color",colors(i,:)) + K = convhull(pltData(selected_laps(i)).acc_lat_g, pltData(selected_laps(i)).acc_long_g); + plot(ax1,pltData(selected_laps(i)).acc_lat_g(K), ... + pltData(selected_laps(i)).acc_long_g(K),"Color",colors(i,:),"LineStyle","--","LineWidth",2) + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT24/plot_settings/sidebar_stats.m b/season/FT24/plot_settings/sidebar_stats.m new file mode 100644 index 0000000..018b9b8 --- /dev/null +++ b/season/FT24/plot_settings/sidebar_stats.m @@ -0,0 +1,21 @@ +function [sidebarLabel] = sidebar_stats(pltData) +%SIDEBAR_STATS Summary of this function goes here +% Detailed explanation goes here + sidebarLabel = sprintf(... + "Statistics:\nEnergy\n Used: %.2f kWh\n" + ... + " Regen: %.2f kWh\n" + ... + " Total: %.2f kWh\n" + ... + "\nPower\n Peak: %.1f kW\n" + ... + " Peak (mean): %1.f kW\n" + ... + "\nDistance: %.2f km\n" + ... + "\nTopspeed: %.1f km/h\n", ... + pltData.energy_used_kwh, ... + pltData.energy_regen_kwh, ... + pltData.energy_kwh, ... + pltData.peakPower_kw, ... + pltData.peakPowerMean_kw, ... + pltData.distanceTotal_km, ... + pltData.maxSpeed_kph ... + ); +end + diff --git a/season/FT24/sortdata.m b/season/FT24/sortdata.m new file mode 100644 index 0000000..9832753 --- /dev/null +++ b/season/FT24/sortdata.m @@ -0,0 +1,122 @@ +function [pltData] = sortdata(data,start,stop) + date = dateshift(data.Time(1),'start','day'); + time_hms = data.Time-date; + time_s = seconds(time_hms); + time_s = time_s - time_s(1); % set beginning of session to 0 + + % x-Axis: + pltData.time_s = time_s(start:stop)-time_s(start); + pltData.time_hms = time_hms(start:stop); + + % distance calculation + speed_mps = movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % TODO: test different speed filters for distance calculation + pltData.distance(1) = 0; + for i = 2:length(speed_mps) + pltData.distance(i) = speed_mps(i)*(pltData.time_s(i)-pltData.time_s(i-1)) + pltData.distance(i-1); + end + pltData.xAxis = pltData.time_s; % set time as default x-Axis for plotting + + %% Misc + pltData.app_percent = data.ABX_Driver_ABX_APPS_percent(start:stop); + pltData.speed_kph = 3.6*movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % same filter as for distance calculation ??? + pltData.steering_deg = data.ABX_Driver_ABX_Steering_Angle(start:stop); + + %% AMS: + pltData.ams_soc = data.AMS_Status_SOC(start:stop); + pltData.ams_tmax = data.AMS_Status_Max_cell_temp(start:stop); + pltData.ams_utot = data.Shunt_Voltage1_Shunt_Voltage1(start:stop); + pltData.ams_itot = data.Shunt_Current_Shunt_Current(start:stop); + % calculations: + pltData.ams_ptot = pltData.ams_utot.*pltData.ams_itot/1000; + + %% Brakes + % brake pressure + pltData.brakePFront_bar = data.ABX_Driver_ABX_BrakeP_F(start:stop); + pltData.brakePRear_bar = data.ABX_Driver_ABX_BrakeP_R(start:stop); + % brake disc temperatures + pltData.brakeTFrontLeft_degC = data.ABX_BrakeT_ABX_BrakeT_FL(start:stop); + pltData.brakeTFrontRight_degC = data.ABX_BrakeT_ABX_BrakeT_FR(start:stop); + pltData.brakeTRearLeft_degC = data.ABX_BrakeT_ABX_BrakeT_RL(start:stop); + pltData.brakeTRearRight_degC = data.ABX_BrakeT_ABX_BrakeT_RR(start:stop); + % calculate brake bias [%] + minBrakeP = 5; % minimum brake pressure to avoid artifacts due to sensor noise near 0 bar + brakePFront = pltData.brakePFront_bar; + brakePFront(brakePFront < minBrakeP) = minBrakeP; + brakePRear = pltData.brakePRear_bar; + brakePRear(brakePRear < minBrakeP) = minBrakeP; + pltData.brakeBias_perc = 100*brakePFront./brakePRear; % check calculation! + + %% Cooling system + + %% Dampers + % damper positions + pltData.damper_FL_mm = data.ABX_Dampers_ABX_Damper_FL(start:stop); %Heave_F + pltData.damper_FR_mm = data.ABX_Dampers_ABX_Damper_FR(start:stop); %Roll_F + pltData.damper_RL_mm = data.ABX_Dampers_ABX_Damper_RL(start:stop); %Heave_R + pltData.damper_RR_mm = data.ABX_Dampers_ABX_Damper_RR(start:stop); %Roll_R + % calculate damper velocities + pltData.velocity_FL_mmps(1) = 0; + pltData.velocity_FR_mmps(1) = 0; + pltData.velocity_RL_mmps(1) = 0; + pltData.velocity_RR_mmps(1) = 0; + for i = 2:length(pltData.time_s) + timestep = pltData.time_s(i)-pltData.time_s(i-1); + pltData.velocity_FL_mmps(i) = pltData.damper_FL_mm(i)-pltData.damper_FL_mm(i-1)/timestep; + pltData.velocity_FR_mmps(i) = pltData.damper_FR_mm(i)-pltData.damper_FR_mm(i-1)/timestep; + pltData.velocity_RL_mmps(i) = pltData.damper_RL_mm(i)-pltData.damper_RL_mm(i-1)/timestep; + pltData.velocity_RR_mmps(i) = pltData.damper_RR_mm(i)-pltData.damper_RR_mm(i-1)/timestep; + end + % filter damper velocities ??? bessere Berechnung über mittelwert aus mehreren werten? Vorfilterung? + pltData.velocity_FL_mmps = movmean(pltData.velocity_FL_mmps,100); + pltData.velocity_FR_mmps = movmean(pltData.velocity_FR_mmps,100); + pltData.velocity_RL_mmps = movmean(pltData.velocity_RL_mmps,100); + pltData.velocity_RR_mmps = movmean(pltData.velocity_RR_mmps,100); + + %% IMU + % Acceleration + % pltData.acc_long_g = movmean(data.XSens_Acceleration_XSens_accX(start:stop),100)/9.81; + % pltData.acc_lat_g = movmean(data.XSens_Acceleration_XSens_accY(start:stop),100)/9.81; + % Rate of turn + % pltData.rot_roll_degps = movmean(data.XSens_RateOfTurn_XSens_gyrX(start:stop),100); + % pltData.rot_pitch_degps = movmean(data.XSens_RateOfTurn_XSens_gyrY(start:stop),100); + % pltData.rot_yaw_degps = movmean(data.XSens_RateOfTurn_XSens_gyrZ(start:stop),100); + + %% Inverters + % inverter temperatures + pltData.invL_temp = data.INV_L_TxPDO_1_T_Inv_L(start:stop); + pltData.invR_temp = data.INV_R_TxPDO_1_T_Inv_R(start:stop); + % motor temperatures + pltData.motL_temp = data.INV_L_TxPDO_1_T_Mot_L(start:stop); + pltData.motR_temp = data.INV_R_TxPDO_1_T_Mot_R(start:stop); + % motor velocities + pltData.motL_vel_rpm = 60*data.INV_L_TxPDO_4_Velocity_L(start:stop); + pltData.motR_vel_rpm = 60*data.INV_R_TxPDO_4_Velocity_R(start:stop); + % inverter torque demand + pltData.invL_torqueDemand = data.INV_L_TxPDO_3_DemandedTorque_L(start:stop)/10; % /10 to match autobox torque + pltData.invR_torqueDemand = data.INV_R_TxPDO_3_DemandedTorque_R(start:stop)/10; + % inverter actual torque + pltData.invL_torqueActual = data.INV_L_TxPDO_3_ActualTorque_L(start:stop)/10; + pltData.invR_torqueActual = data.INV_R_TxPDO_3_ActualTorque_R(start:stop)/10; + + %% Wheelspeed + + + + + %% Statistics: + power_regen_kw = pltData.ams_ptot; + power_regen_kw(power_regen_kw > 0) = 0; + power_used_kw = pltData.ams_ptot; + power_used_kw(power_used_kw < 0) = 0; + pltData.energy_kwh = trapz(pltData.time_s, pltData.ams_ptot)/3600; + pltData.energy_regen_kwh = trapz(pltData.time_s, power_regen_kw)/3600; + pltData.energy_used_kwh = trapz(pltData.time_s, power_used_kw)/3600; + pltData.distanceTotal_km = trapz(pltData.time_s, pltData.speed_kph./3.6)/1000; % 1/3.6 for km/h to m/s and /1000 for km output + pltData.peakPower_kw = max(pltData.ams_ptot); + pltData.peakPowerMean_kw = max(movmean(pltData.ams_ptot,500)); + + pltData.maxSpeed_kph = max(pltData.speed_kph); + pltData.startTime = time_hms(start); + pltData.stopTime = time_hms(stop); +end + diff --git a/season/FT25/plot_settings/plot_accumulator.m b/season/FT25/plot_settings/plot_accumulator.m new file mode 100644 index 0000000..e3a8d9a --- /dev/null +++ b/season/FT25/plot_settings/plot_accumulator.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_accumulator(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Max Cell Temp [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Max Cell Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_tmax) + end + % plot 4: State of charge [%] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "SOC") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_soc) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_brakes.m b/season/FT25/plot_settings/plot_brakes.m new file mode 100644 index 0000000..7f6b922 --- /dev/null +++ b/season/FT25/plot_settings/plot_brakes.m @@ -0,0 +1,59 @@ +function [outputArg] = plot_brakes(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: brake pressure front/rear [bar] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Brake Pressure F/R [bar]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePRear_bar) + end + legend(ax2, "Front", "Rear") + % plot 3: longitudinal acceleration [g] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % plot 4: Brake Temp [°C] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Brake Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTFrontRight_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearLeft_degC) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeTRearRight_degC) + end + legend(ax4, "FL", "FR", "RL", "RR") + % plot 5: brake bias [%] + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Brake Bias [%]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakeBias_perc) + end + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_driver_braking.m b/season/FT25/plot_settings/plot_driver_braking.m new file mode 100644 index 0000000..c5643d5 --- /dev/null +++ b/season/FT25/plot_settings/plot_driver_braking.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_braking(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: longitudinal acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Long Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_long_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_driver_general.m b/season/FT25/plot_settings/plot_driver_general.m new file mode 100644 index 0000000..fbe881a --- /dev/null +++ b/season/FT25/plot_settings/plot_driver_general.m @@ -0,0 +1,43 @@ +function [outputArg] = plot_driver_general(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).app_percent) + end + % plot 3: brake pressure front [bar] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).brakePFront_bar) + end + % plot 4: steering angle [°] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_driver_statistics.m b/season/FT25/plot_settings/plot_driver_statistics.m new file mode 100644 index 0000000..04cf635 --- /dev/null +++ b/season/FT25/plot_settings/plot_driver_statistics.m @@ -0,0 +1,46 @@ +function [outputArg] = plot_driver_statistics(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).speed_kph) + end + % plot 2: accelerator pedal position [%] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "APP [%]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis,pltData(selected_laps(i)).app_percent) + end + linkaxes([ax1, ax2],"x") + % plot 3: accelerator pedal position histogram + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "APP distribution") + ylabel(ax3, "\sigma [%]") + xlabel(ax3, "APP [%]") + for i = 1:length(selected_laps) + histogram(ax3,pltData(selected_laps(i)).app_percent,"Normalization","percentage") + end + % plot 4: brake pressure histogram + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "BrakeP distribution") + ylabel(ax4, "\sigma [%]") + xlabel(ax4, "Brake Pressure Front [bar]") + for i = 1:length(selected_laps) + histogram(ax4,pltData(selected_laps(i)).brakePFront_bar,"Normalization","percentage") + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_driver_steering.m b/season/FT25/plot_settings/plot_driver_steering.m new file mode 100644 index 0000000..d8066ea --- /dev/null +++ b/season/FT25/plot_settings/plot_driver_steering.m @@ -0,0 +1,42 @@ +function [outputArg] = plot_driver_steering(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: steering angle [°] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Steering Angle [°]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).steering_deg) + end + % plot 3: oversteer + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Oversteer") + % TODO!! + + % plot 4: lateral acceleration [g] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Lateral Acc [g]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).acc_lat_g) + end + % link all x axes + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_inverter.m b/season/FT25/plot_settings/plot_inverter.m new file mode 100644 index 0000000..878f72f --- /dev/null +++ b/season/FT25/plot_settings/plot_inverter.m @@ -0,0 +1,60 @@ +function [outputArg] = plot_inverter(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: Inverter Temps [°C] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax2, "Left", "Right") + % plot 3: Torque request / actual inverter left + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Left Torque") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueDemand) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_torqueActual) + end + legend(ax3, "Demand", "Actual") + % plot 4: Torque request / actual inverter right + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Right Torque") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueDemand) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_torqueActual) + end + legend(ax4, "Demand", "Actual") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_powertrain.m b/season/FT25/plot_settings/plot_powertrain.m new file mode 100644 index 0000000..dfb51d8 --- /dev/null +++ b/season/FT25/plot_settings/plot_powertrain.m @@ -0,0 +1,58 @@ +function [outputArg] = plot_powertrain(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + + % plot 1: speed [km/h] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Speed [km/h]") + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).speed_kph) + end + % plot 2: power [kW] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Power [kW]") + for i = 1:length(selected_laps) + plot(ax2,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).ams_ptot) + end + % plot 3: Inverter Temps [°C] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Inverter Temp [°C]") + for i = 1:length(selected_laps) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invL_temp) + plot(ax3,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).invR_temp) + end + legend(ax3, "Left", "Right") + % plot 4: Motor Temps + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Motor Temp [°C]") + for i = 1:length(selected_laps) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_temp) + plot(ax4,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_temp) + end + legend(ax4, "Left", "Right") + % plot 5: Motor velocities + ax5 = nexttile(tl); + hold(ax5, "on") + grid(ax5, "on") + title(ax5, "Motor Velocities [1/min]") + for i = 1:length(selected_laps) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motL_vel_rpm) + plot(ax5,pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).motR_vel_rpm) + end + legend(ax5, "Left", "Right") + + % link all x axes + linkaxes([ax1, ax2, ax3, ax4, ax5],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_suspension_histogram.m b/season/FT25/plot_settings/plot_suspension_histogram.m new file mode 100644 index 0000000..fa1e6b4 --- /dev/null +++ b/season/FT25/plot_settings/plot_suspension_histogram.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_histogram(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax1, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 2: position roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + histogram(ax2, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 3: position heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax3, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + % plot 4: position roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + histogram(ax4, pltData(selected_laps(i)).velocityHeaveFront_mmps,"Normalization","percentage") + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_suspension_positions.m b/season/FT25/plot_settings/plot_suspension_positions.m new file mode 100644 index 0000000..844242f --- /dev/null +++ b/season/FT25/plot_settings/plot_suspension_positions.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_positions(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: position heave front [mm] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveFront_mm) + end + % plot 2: position roll front [mm] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollFront_mm) + end + % plot 3: position heave front [mm] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperHeaveRear_mm) + end + % plot 4: position roll front [mm] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).damperRollRear_mm) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_suspension_velocities.m b/season/FT25/plot_settings/plot_suspension_velocities.m new file mode 100644 index 0000000..aed80e5 --- /dev/null +++ b/season/FT25/plot_settings/plot_suspension_velocities.m @@ -0,0 +1,41 @@ +function [outputArg] = plot_suspension_velocities(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + tl = tiledlayout(panel,"vertical"); + % plot 1: velocity heave front [mm/s] + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Heave Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax1, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveFront_mmps) + end + % plot 2: velocity roll front [mm/s] + ax2 = nexttile(tl); + hold(ax2, "on") + grid(ax2, "on") + title(ax2, "Roll Front [mm/s]") + for i = 1:length(selected_laps) + plot(ax2, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollFront_mmps) + end + % plot 3: velocity heave front [mm/s] + ax3 = nexttile(tl); + hold(ax3, "on") + grid(ax3, "on") + title(ax3, "Heave Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax3, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityHeaveRear_mmps) + end + % plot 4: velocity roll front [mm/s] + ax4 = nexttile(tl); + hold(ax4, "on") + grid(ax4, "on") + title(ax4, "Roll Rear [mm/s]") + for i = 1:length(selected_laps) + plot(ax4, pltData(selected_laps(i)).xAxis, pltData(selected_laps(i)).velocityRollRear_mmps) + end + linkaxes([ax1, ax2, ax3, ax4],"x") + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/plot_tires_firctionCircle.m b/season/FT25/plot_settings/plot_tires_firctionCircle.m new file mode 100644 index 0000000..baa117e --- /dev/null +++ b/season/FT25/plot_settings/plot_tires_firctionCircle.m @@ -0,0 +1,24 @@ +function [outputArg] = plot_tires_firctionCircle(panel, selected_laps, pltData) + % create tiledlayout (R2023a and newer) + + tl = tiledlayout(panel,"flow"); + + ax1 = nexttile(tl); + hold(ax1, "on") + grid(ax1, "on") + title(ax1, "Friction Circle") + ylabel(ax1, "Longitudinal Acc [g]") + xlabel(ax1, "Lateral Acc [g]") + colors = colororder(ax1); + for i = 1:length(selected_laps) + plot(ax1,pltData(selected_laps(i)).acc_lat_g, ... + pltData(selected_laps(i)).acc_long_g,"Color",colors(i,:)) + K = convhull(pltData(selected_laps(i)).acc_lat_g, pltData(selected_laps(i)).acc_long_g); + plot(ax1,pltData(selected_laps(i)).acc_lat_g(K), ... + pltData(selected_laps(i)).acc_long_g(K),"Color",colors(i,:),"LineStyle","--","LineWidth",2) + end + + % return null (not relevant for plots!) + outputArg = []; +end + diff --git a/season/FT25/plot_settings/sidebar_stats.m b/season/FT25/plot_settings/sidebar_stats.m new file mode 100644 index 0000000..018b9b8 --- /dev/null +++ b/season/FT25/plot_settings/sidebar_stats.m @@ -0,0 +1,21 @@ +function [sidebarLabel] = sidebar_stats(pltData) +%SIDEBAR_STATS Summary of this function goes here +% Detailed explanation goes here + sidebarLabel = sprintf(... + "Statistics:\nEnergy\n Used: %.2f kWh\n" + ... + " Regen: %.2f kWh\n" + ... + " Total: %.2f kWh\n" + ... + "\nPower\n Peak: %.1f kW\n" + ... + " Peak (mean): %1.f kW\n" + ... + "\nDistance: %.2f km\n" + ... + "\nTopspeed: %.1f km/h\n", ... + pltData.energy_used_kwh, ... + pltData.energy_regen_kwh, ... + pltData.energy_kwh, ... + pltData.peakPower_kw, ... + pltData.peakPowerMean_kw, ... + pltData.distanceTotal_km, ... + pltData.maxSpeed_kph ... + ); +end + diff --git a/season/FT25/sortdata.m b/season/FT25/sortdata.m new file mode 100644 index 0000000..9832753 --- /dev/null +++ b/season/FT25/sortdata.m @@ -0,0 +1,122 @@ +function [pltData] = sortdata(data,start,stop) + date = dateshift(data.Time(1),'start','day'); + time_hms = data.Time-date; + time_s = seconds(time_hms); + time_s = time_s - time_s(1); % set beginning of session to 0 + + % x-Axis: + pltData.time_s = time_s(start:stop)-time_s(start); + pltData.time_hms = time_hms(start:stop); + + % distance calculation + speed_mps = movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % TODO: test different speed filters for distance calculation + pltData.distance(1) = 0; + for i = 2:length(speed_mps) + pltData.distance(i) = speed_mps(i)*(pltData.time_s(i)-pltData.time_s(i-1)) + pltData.distance(i-1); + end + pltData.xAxis = pltData.time_s; % set time as default x-Axis for plotting + + %% Misc + pltData.app_percent = data.ABX_Driver_ABX_APPS_percent(start:stop); + pltData.speed_kph = 3.6*movmean(data.ABX_Driver_ABX_Speed(start:stop),50); % same filter as for distance calculation ??? + pltData.steering_deg = data.ABX_Driver_ABX_Steering_Angle(start:stop); + + %% AMS: + pltData.ams_soc = data.AMS_Status_SOC(start:stop); + pltData.ams_tmax = data.AMS_Status_Max_cell_temp(start:stop); + pltData.ams_utot = data.Shunt_Voltage1_Shunt_Voltage1(start:stop); + pltData.ams_itot = data.Shunt_Current_Shunt_Current(start:stop); + % calculations: + pltData.ams_ptot = pltData.ams_utot.*pltData.ams_itot/1000; + + %% Brakes + % brake pressure + pltData.brakePFront_bar = data.ABX_Driver_ABX_BrakeP_F(start:stop); + pltData.brakePRear_bar = data.ABX_Driver_ABX_BrakeP_R(start:stop); + % brake disc temperatures + pltData.brakeTFrontLeft_degC = data.ABX_BrakeT_ABX_BrakeT_FL(start:stop); + pltData.brakeTFrontRight_degC = data.ABX_BrakeT_ABX_BrakeT_FR(start:stop); + pltData.brakeTRearLeft_degC = data.ABX_BrakeT_ABX_BrakeT_RL(start:stop); + pltData.brakeTRearRight_degC = data.ABX_BrakeT_ABX_BrakeT_RR(start:stop); + % calculate brake bias [%] + minBrakeP = 5; % minimum brake pressure to avoid artifacts due to sensor noise near 0 bar + brakePFront = pltData.brakePFront_bar; + brakePFront(brakePFront < minBrakeP) = minBrakeP; + brakePRear = pltData.brakePRear_bar; + brakePRear(brakePRear < minBrakeP) = minBrakeP; + pltData.brakeBias_perc = 100*brakePFront./brakePRear; % check calculation! + + %% Cooling system + + %% Dampers + % damper positions + pltData.damper_FL_mm = data.ABX_Dampers_ABX_Damper_FL(start:stop); %Heave_F + pltData.damper_FR_mm = data.ABX_Dampers_ABX_Damper_FR(start:stop); %Roll_F + pltData.damper_RL_mm = data.ABX_Dampers_ABX_Damper_RL(start:stop); %Heave_R + pltData.damper_RR_mm = data.ABX_Dampers_ABX_Damper_RR(start:stop); %Roll_R + % calculate damper velocities + pltData.velocity_FL_mmps(1) = 0; + pltData.velocity_FR_mmps(1) = 0; + pltData.velocity_RL_mmps(1) = 0; + pltData.velocity_RR_mmps(1) = 0; + for i = 2:length(pltData.time_s) + timestep = pltData.time_s(i)-pltData.time_s(i-1); + pltData.velocity_FL_mmps(i) = pltData.damper_FL_mm(i)-pltData.damper_FL_mm(i-1)/timestep; + pltData.velocity_FR_mmps(i) = pltData.damper_FR_mm(i)-pltData.damper_FR_mm(i-1)/timestep; + pltData.velocity_RL_mmps(i) = pltData.damper_RL_mm(i)-pltData.damper_RL_mm(i-1)/timestep; + pltData.velocity_RR_mmps(i) = pltData.damper_RR_mm(i)-pltData.damper_RR_mm(i-1)/timestep; + end + % filter damper velocities ??? bessere Berechnung über mittelwert aus mehreren werten? Vorfilterung? + pltData.velocity_FL_mmps = movmean(pltData.velocity_FL_mmps,100); + pltData.velocity_FR_mmps = movmean(pltData.velocity_FR_mmps,100); + pltData.velocity_RL_mmps = movmean(pltData.velocity_RL_mmps,100); + pltData.velocity_RR_mmps = movmean(pltData.velocity_RR_mmps,100); + + %% IMU + % Acceleration + % pltData.acc_long_g = movmean(data.XSens_Acceleration_XSens_accX(start:stop),100)/9.81; + % pltData.acc_lat_g = movmean(data.XSens_Acceleration_XSens_accY(start:stop),100)/9.81; + % Rate of turn + % pltData.rot_roll_degps = movmean(data.XSens_RateOfTurn_XSens_gyrX(start:stop),100); + % pltData.rot_pitch_degps = movmean(data.XSens_RateOfTurn_XSens_gyrY(start:stop),100); + % pltData.rot_yaw_degps = movmean(data.XSens_RateOfTurn_XSens_gyrZ(start:stop),100); + + %% Inverters + % inverter temperatures + pltData.invL_temp = data.INV_L_TxPDO_1_T_Inv_L(start:stop); + pltData.invR_temp = data.INV_R_TxPDO_1_T_Inv_R(start:stop); + % motor temperatures + pltData.motL_temp = data.INV_L_TxPDO_1_T_Mot_L(start:stop); + pltData.motR_temp = data.INV_R_TxPDO_1_T_Mot_R(start:stop); + % motor velocities + pltData.motL_vel_rpm = 60*data.INV_L_TxPDO_4_Velocity_L(start:stop); + pltData.motR_vel_rpm = 60*data.INV_R_TxPDO_4_Velocity_R(start:stop); + % inverter torque demand + pltData.invL_torqueDemand = data.INV_L_TxPDO_3_DemandedTorque_L(start:stop)/10; % /10 to match autobox torque + pltData.invR_torqueDemand = data.INV_R_TxPDO_3_DemandedTorque_R(start:stop)/10; + % inverter actual torque + pltData.invL_torqueActual = data.INV_L_TxPDO_3_ActualTorque_L(start:stop)/10; + pltData.invR_torqueActual = data.INV_R_TxPDO_3_ActualTorque_R(start:stop)/10; + + %% Wheelspeed + + + + + %% Statistics: + power_regen_kw = pltData.ams_ptot; + power_regen_kw(power_regen_kw > 0) = 0; + power_used_kw = pltData.ams_ptot; + power_used_kw(power_used_kw < 0) = 0; + pltData.energy_kwh = trapz(pltData.time_s, pltData.ams_ptot)/3600; + pltData.energy_regen_kwh = trapz(pltData.time_s, power_regen_kw)/3600; + pltData.energy_used_kwh = trapz(pltData.time_s, power_used_kw)/3600; + pltData.distanceTotal_km = trapz(pltData.time_s, pltData.speed_kph./3.6)/1000; % 1/3.6 for km/h to m/s and /1000 for km output + pltData.peakPower_kw = max(pltData.ams_ptot); + pltData.peakPowerMean_kw = max(movmean(pltData.ams_ptot,500)); + + pltData.maxSpeed_kph = max(pltData.speed_kph); + pltData.startTime = time_hms(start); + pltData.stopTime = time_hms(stop); +end +