Skip to content

Analyzing Brake Bias

awadell1 edited this page Jan 30, 2017 · 6 revisions

Brake Bias is the distribution of pressure in the braking system between the front and rear break calipers. For our purposes we will define the brake bias as:

Definition of Brake Bias

Our goal is to create a script for assessing the brake bias of the car. While the given example will not look at any collection of datasources in particular, dm.getDatasource can be used to examine a more refined selection. Ideally, the brake bias bar settings would be recorded in the details, which would allow plots to be generated and compared for various settings.

Mapping Function

Our analysis will use ds.mapReduce to handle analyzing the datasource en mass. As such will will need to first create a mapFun and reduceFun.

Using dm.allLogged we found the following relevant channel names:

Channel Name Description
Brake_Pressure_Front Measured the pressure of the front brake caliper system
Brake_Pressure_Rear Measured the pressure of the rear brake caliper system
function [brakeBias, BiasVsFront, duration] = mapFun(ds)
    %Load the required channels and synchronize their sampling rates
    ds.loadChannel({'Brake_Pressure_Front', 'Brake_Pressure_Rear'});
    ds.Sync;
    
    %% Brake Bias
    % Get the Front and Rear brake Pressure in kPa
    frontPress = ds.getChannel('Brake_Pressure_Front', 'unit', 'kPa').Value;
    rearPress = ds.getChannel('Brake_Pressure_Rear', 'unit', 'kPa').Value;
    
    %Calculate the Brake Bias
    brakeBiasCalc = 100 * frontPress ./ (frontPress + rearPress);
    
    %Bin brakeBias
    brakeBias = histcounts(brakeBiasCalc, BiasEdges);
    
    % Brake Bias vs Front Brake Pressure
    BiasVsFront = histcounts2(frontPress, brakeBiasCalc, PressEdges, BiasEdges);
    
    %Record the total logged duration
    duration =  ds.getChannel('Brake_Pressure_Front').Time(end);
end

Note: BiasEdges and PressEdges are not defined within the mapping function but will be defined before the in-line functions.

Reducing Function

As end output of the mapReduce will be essentially the results of a custom Histogram and Histogram2, we can borrow their reducing function.

function [brakeBias, BiasVsFront, duration] = reduceFun(brakeBias, BiasVsFront, duration)
    %Reducing Brake Bias Histogram
    brakeBias = sum(cell2mat(brakeBias));
    
    % Reducing Brake Bias vs Front Brake Pressure
    BiasVsFront = sum(cat(3, BiasVsFront{:}),3);
    
    % Compute total logged duration
    duration = sum([duration{:}]);
end

Plotting

We can now create a histogram plot using histogram as shown:

%% Create Brake Bias Histogram Plot
figure;
histogram('BinEdges', BiasEdges, 'BinCounts', brakeBias,...
    'normalization', 'pdf');

%Label Histogram
title(sprintf('Based on %3.2f hrs of data',duration/3600));
xlabel('Brake Bias [%]')
ylabel('Probability Density');

Additioanlly the Brake Pressure Bias vs Front Brake Pressure Relationship can be visualized using countourf as shown:

%% Create Brake Bias vs Front Pressure Bivariate Plot
figure

%Compute the Center Point of each Bin
xBarPoints = (PressEdges(1:end-1) + PressEdges(2:end))/2;
yBarPoints = (BiasEdges(1:end-1) + BiasEdges(2:end))/2;

%Plot Bivariate Histogram using countourf
% Note: Transpose as countourf and histocounts define x differently
[~,h] = contourf(xBarPoints, yBarPoints, log10(BiasVsFront'));
h.LineStyle = 'none';   %Remove Contour Lines

%Label Histogram
title(sprintf('Based on %3.2f hrs of data',duration/3600));
xlabel('Front Brake Pressure [kPa]')
ylabel('Brake Bias [%]')

%Add and label the colorbar
cBar = colorbar; Datamaster.colormap('cool');
ylabel(cBar, 'log10(counts)', 'FontSize', 12);

Next Steps...

Now that you have a function for generating plots for analyzing the brake bias of a race car, check out Chapter 5: Braking of Analysis Techniques for Racecar Data Acquisition to learn more about how to interpret these plots.

Additionally, by recording brake system parameters in the Log File Details (ie: Brake Bias Bar setting, Tire chamber, etc.) this analysis can be expanded to understand how changing the brake system configuration effects it's response.

Complete Code

function BrakeBias
    %Connect to Datamaster
    dm = Datamaster;
    ds = dm.getDatasource('channel', {'Brake_Pressure_Front', 'Brake_Pressure_Rear'});
    
    %Set Histogram Bin Edges
    BiasEdges = linspace(0, 100, 200);
    PressEdges = linspace(0, 4e3, 200);
    
    %% Define the Map and Reduce Functions
    function [brakeBias, BiasVsFront, duration] = mapFun(ds)
        %Load the required channels and synchronize their sampling rates
        ds.loadChannel({'Brake_Pressure_Front', 'Brake_Pressure_Rear'});
        ds.Sync;
        
        %% Brake Bias
        % Get the Front and Rear brake Pressure in kPa
        frontPress = ds.getChannel('Brake_Pressure_Front', 'unit', 'kPa').Value;
        rearPress = ds.getChannel('Brake_Pressure_Rear', 'unit', 'kPa').Value;
        
        %Calculate the Brake Bias
        brakeBiasCalc = 100 * frontPress ./ (frontPress + rearPress);
        
        %Bin brakeBias
        brakeBias = histcounts(brakeBiasCalc, BiasEdges);
        
        % Brake Bias vs Front Brake Pressure
        BiasVsFront = histcounts2(frontPress, brakeBiasCalc, PressEdges, BiasEdges);
        
        %Record the total logged duration
        duration =  ds.getChannel('Brake_Pressure_Front').Time(end);
    end
    
    function [brakeBias, BiasVsFront, duration] = reduceFun(brakeBias, BiasVsFront, duration)
        %Reducing Brake Bias Histogram
        brakeBias = sum(cell2mat(brakeBias));
        
        % Reducing Brake Bias vs Front Brake Pressure
        BiasVsFront = sum(cat(3, BiasVsFront{:}),3);
        
        % Compute total logged duration
        duration = sum([duration{:}]);
    end
    
    %Call mapReduce
    [brakeBias, BiasVsFront, duration] = ds.mapReduce(@mapFun, @reduceFun);
    
    %% Create Brake Bias Histogram Plot
    figure;
    histogram('BinEdges', BiasEdges, 'BinCounts', brakeBias,...
        'normalization', 'pdf');
    
    %Label Histogram
    title(sprintf('Based on %3.2f hrs of data',duration/3600));
    xlabel('Brake Bias [%]')
    ylabel('Probability Density');
    
    %% Create Brake Bias vs Front Pressure Bivariate Plot
    figure
    
    %Compute the Center Point of each Bin
    xBarPoints = (PressEdges(1:end-1) + PressEdges(2:end))/2;
    yBarPoints = (BiasEdges(1:end-1) + BiasEdges(2:end))/2;
    
    %Plot Bivariate Histogram using countourf
    % Note: Transpose as countourf and histocounts define x differently
    [~,h] = contourf(xBarPoints, yBarPoints, log10(BiasVsFront'));
    h.LineStyle = 'none';   %Remove Contour Lines
    
    %Label Histogram
    title(sprintf('Based on %3.2f hrs of data',duration/3600));
    xlabel('Front Brake Pressure [kPa]')
    ylabel('Brake Bias [%]')
    
    %Add and label the colorbar
    cBar = colorbar; Datamaster.colormap('cool');
    ylabel(cBar, 'log10(counts)', 'FontSize', 12);
end

Clone this wiki locally