%=========================================================================
% file: plotforces.m
% : plot forceplate data
%=========================================================================
close all
clear
clc
% read in mot file

fname = 'quickhop 6_grf_rot';
force = read_motionFile([fname,'.mot']);


flabels = force.labels;
fdata = force.data;
nr = force.nr;
nc = force.nc;

%plot data

set(0, 'Units', 'pixels');
scnsize = get(0, 'ScreenSize');
scnwidth = scnsize(3);
scnheight = scnsize(4);
figpos_whole = [0.1*scnwidth, 0.1*scnheight, 0.8*scnwidth, 0.5*scnheight];

figure(1) 
    clf
    set(gcf, 'Position', figpos_whole, 'Color', 'w');
    set(gcf, 'PaperOrientation', 'landscape');
    set(gcf, 'PaperPosition', [1 1 9 6.5]);
    
    subplot(3,1,1)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_vx = find(strcmpi(force.labels, 'ground_force_vx'));
    p = plot(force.data(:, cid_time), force.data(:, cid_vx(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force vx'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,2)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_vy = find(strcmpi(force.labels, 'ground_force_vy'));
    p = plot(force.data(:, cid_time), force.data(:, cid_vy(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force vy'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,3)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_vz = find(strcmpi(force.labels, 'ground_force_vz'));
    p = plot(force.data(:, cid_time), force.data(:, cid_vz(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force vz'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    
figure(2)
    clf
    set(gcf, 'Position', figpos_whole, 'Color', 'w');
    set(gcf, 'PaperOrientation', 'landscape');
    set(gcf, 'PaperPosition', [1 1 9 6.5]);
    subplot(3,1,1)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_px = find(strcmpi(force.labels, 'ground_force_px'));
    p = plot(force.data(:, cid_time), force.data(:, cid_px(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force px'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,2)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_py = find(strcmpi(force.labels, 'ground_force_py'));
    p = plot(force.data(:, cid_time), force.data(:, cid_py(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force vy'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,3)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_pz = find(strcmpi(force.labels, 'ground_force_pz'));
    p = plot(force.data(:, cid_time), force.data(:, cid_pz(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground force vz'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
figure(3)
    clf
    set(gcf, 'Position', figpos_whole, 'Color', 'w');
    set(gcf, 'PaperOrientation', 'landscape');
    set(gcf, 'PaperPosition', [1 1 9 6.5]);
    subplot(3,1,1)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_tx = find(strcmpi(force.labels, 'ground_torque_x'));
    p = plot(force.data(:, cid_time), force.data(:, cid_tx(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground torque x'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,2)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_ty = find(strcmpi(force.labels, 'ground_torque_y'));
    p = plot(force.data(:, cid_time), force.data(:, cid_ty(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground torque y'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);
    
    subplot(3,1,3)
    cid_time = find(strcmpi(force.labels, 'time'));
    cid_tz = find(strcmpi(force.labels, 'ground_torque_z'));
    p = plot(force.data(:, cid_time), force.data(:, cid_tz(1)));
    set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]);
    title_string = ['ground torque z'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
    ylabel('Force N', 'FontSize', 9, 'VerticalAlignment', 'bottom');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Box', 'off', 'FontSize', 8);