% Chapter 7 Section 1 Demos
Link([0, .1, .2, pi/2, 0])  % Arguments: theta, d, a, alpha, sigma
methods(Link)
help Link
%
% There are a lot of methods, but many are not defined.
%
% Methods for class Link:
% A            copy         findobj      islimit      lt           
% Link         delete       findprop     isprismatic  ne           
% RP           display      friction     isrevolute   nofriction   
% addlistener  dyn          ge           isvalid      notify       
% char         eq           gt           le
%
Link([0, .1, .2, pi/2, 1])
L = Link([0, .1, .2, pi/2, 1.1])  % Code breaks - theta=q, but j type is P
L = Link([0, .1, .2, pi/2, 0])  % Set joint to revolute

% Methods
L.A(0) % Check A tform when joint variable value is given
L.A(1.23)  
% A(L,1.23)  % Same a previous statement
L.RP;
fprintf('L.RP = %s\n\n', L.RP)
friction(L, 1.5)  % Friction force in joint.  Not sure why "[]" is returned.
L.nofriction
L.dyn   % Information needed for dynamic simulation
isrevolute(L)
isprismatic(L)
L.display
L.char    % Seems to be identical to the previous statement

% Read/Write Properties
L.theta = 2.3  % L.A still demands a joint displacement
L.d = 2.3
L.a = 2.3
L.alpha = 2.3
L.sigma = 2.3  % sigma = 0 ==> revolute.  Other values ==> prismatic
L.RP
L.mdh
L.mdh = 1
L.mdh = 0
L.offset

L.qlim       % joint limits are empty
L.qlim = [-0.9  1.2]  % Set joint limits
L.qlim       % Joint limits are set
islimit(L,-2)   % returns -1 ==> below lower limit
islimit(L,-.2)  % returns  0 ==> within valid range
islimit(L,1.4)  % returns  1 ==> above upper limit
L.m = 1.0  % Set the mass
L.r = [1 2 3];  % Position of c.o.m. with respect to Link frame
A = rand(3,3);
M = A * A'
L.I = M    % Moment of inertia matrix  What Frame??????
L.B = 1.2  % Motor viscous damping (morot referred)
L.Tc    % Coulomb friction limitss
L.G = 48   % set gear ratio
L.Jm   % Motor inertia (motor referred)
L.dyn   % Now more quantities relating to the dynamics are set