close all;
clear all;
clc;

%% Problem specifications

% Weight of the vehicle [Kg]
m=8;
% Wheel diameter [m]
D=0.060;
% Maximum velocity [m/s]
v=3;
% Maximum acceleration [m/s/s]
a=2;
% Gear ratio between the motor and the wheel [-]
R=3.71;
% Efficiency of the gear box [-]
Eta=0.9;
% Angle of maximum slope [rad]
Alpha=pi/9; %=20°


% Display title
disp ('____________________________');
disp ('::: Problem specications :::');
disp (' ');

% Display specification
disp (sprintf('Vehicle weight : \t\t\t%2.4f rpm',m));
disp (sprintf('Wheels diameter: \t\t\t%2.4f m',D));
disp (sprintf('Maximum velocity: \t\t\t%2.4f m/s',v));
disp (sprintf('Maximum acceleration: \t\t\t%2.4f m/s/s',a));
disp (sprintf('Gear box ratio: \t\t\t%2.4f m/s/s',R));
disp (sprintf('Gear box efficiency: \t\t\t%2.2f %%',Eta*100));
disp (sprintf('Maximum slope angle: \t\t\t%2.4f rad = %2.2f°',Alpha,Alpha*180/pi));


% Display title
disp (' ');
disp ('__________________________');
disp ('::: Motor specications :::');
disp (' ');


%% Compute angular velocities

% Wheel angular velocity
Omega_Wheel=(60*v)/(D*pi);
% Motor angular velocity
Omega_Motor=R*(60*v)/(D*pi);

% Display angular velocities
disp (sprintf('Angular velocity of wheel shaft: \t%2.4f rpm',Omega_Wheel));
disp (sprintf('Angular velocity of motor shaft: \t%2.4f rpm',Omega_Motor));



%% Compute torques

% Torque on wheels
Tau_Wheel=m*D*(a+9.81*sin(Alpha))/2;
% Torque on motor
Tau_Motor=Tau_Wheel/(R*Eta);


% Display torque
disp (sprintf('Torque on wheel shaft: \t\t\t%2.4f N.m',Tau_Wheel));
disp (sprintf('Torque on motor shaft: \t\t\t%2.4f N.m',Tau_Motor));


%% Compute power

% Power on motor's shaft
P=m*v*(a+9.81*sin(Alpha))/Eta;

disp (sprintf('Power motor shaft: \t\t\t%2.4f W',P));

