Code covered by the BSD License  

Highlights from
Task Space control of RPRP manipulator

image thumbnail
from Task Space control of RPRP manipulator by Sumit Tripathi
Forward and inverse kinematics of RPRP manipulator with task space control to trace trajectories.

robotics_project(varargin)
% Sumit Tripathi
% MAE593(Math Methods in Robotics),University at Buffalo
%!!!IMPORTANT :: Any Time you see broken linkages, please press Forward Kin/Home Push button 
% Copy forward_kin.m, inverse_kin.m,My_fun.m,plot_RPRP.m, robotics_project.m,
% robotics_project.fig, RPRP_sgraph.m, rprp_trace.m, set_dimentions.m into same directory
% open robotics_project.fig using guide command and run it.
% Use different values of gains to compare effect of gain on trajectory
% tracing.
% 
function varargout = robotics_project(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @robotics_project_OpeningFcn, ...
                   'gui_OutputFcn',  @robotics_project_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before robotics_project is made visible.
function robotics_project_OpeningFcn(hObject, eventdata, handles, varargin)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g wd_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;

r_g=1.5;% Radius of robot arm base
len_g=3;
wd_g=2;
theta1_g=get(handles.Theta1_slider,'Value');% get values of sliders from GUI
theta2_g=get(handles.Theta2_slider,'Value');
d1_g=get(handles.D1_slider,'Value');
d2_g=get(handles.D2_slider,'Value');
x_ee_g=22;y_ee_g=0; % Default end effector position
y_max=40;y_min=-40;x_max=40;x_min=-40;
th_base=linspace(pi,0,25);
x_base=(r_g+.2)*cos(th_base);
y_base=(r_g+.2)*sin(th_base)-r_g-.5;
color=x_base;
axis([x_min x_max y_min y_max])	% axis limits
axis manual					% set axis to exact manual value
axis equal					% x-scale=y-scale
hold on						% does not erase previous graphs 
grid off						% turns on grid
% manual grid

% minor grid lines
for y=y_min:1:y_max
   plot([x_min+.1 x_max],[y y],'Color',[.8,.97,.97])
end  
for x=x_min+.1:1:x_max
   plot([x x],[y_min y_max],'Color',[.8,.97,.97])
end 
% major grid lines
for y=0:5:y_max
   plot([x_min+.1 x_max],[y y],'Color',[0.9 0.9 0.9])
end  
for x=x_min:5:x_max
   plot([x x],[y_min y_max],'Color',[.9,.9,.9])
end   

fill(x_base,y_base,color);

th_jr1=linspace(-pi,pi,50);
xjr1=r_g*cos(th_jr1);
ystart_jr1=0;
yjr1=ystart_jr1+r_g*sin(th_jr1);
jr1=[xjr1' yjr1' zeros(size(xjr1))' ones(size(xjr1))']';  % rotaion joint 1 matrix
pF_jr1=fill(xjr1,yjr1,'g', 'erasemode','xor');	% color fill rotation jont 1
set(pF_jr1,'FaceColor',[.2 .8 .6]);


ystart_pL1_prism=ystart_jr1;
yc=ystart_pL1_prism;
xstart_pL1_prism=r_g;
xc=xstart_pL1_prism;
wd=wd_g;
x1_g=xc;y1_g=yc;
xc=0;yc=0;
plunger1=d1_g-5;
xend_pL1_plunger=xc+ 5 +plunger1;
xep=xend_pL1_plunger;
wdc=wd_g/5;
ypL1_prism=[yc-.5 yc-.5  yc-wd  yc-wd  yc-wd+.5  yc-wd+.5  yc-wd   yc-wd yc-wdc yc-wdc yc+wdc yc+wdc  yc+wd  yc+wd   yc+wd-.5  yc+wd-.5  yc+wd  yc+wd  yc+.5  yc+.5];
xpL1_prism=[xc    xc+.5  xc+.5  xc+1   xc+1      xc+4.5    xc+4.5  xc+5  xc+5   xc+xep xc+xep xc+5    xc+5   xc+4.5  xc+4.5    xc+1      xc+1   xc+.5  xc+.5  xc];
pL1_prism_g=[xpL1_prism' ypL1_prism' zeros(size(xpL1_prism))' ones(size(xpL1_prism))']';
% The above matrices are used to transform the polygon, representing prismatic joint, from one
% frame to other.

th_jr2=linspace(-pi,pi,50);
xjr2=r_g*cos(th_jr2);
yjr2=r_g*sin(th_jr2);
jr2_g=[xjr2' yjr2' zeros(size(xjr2))' ones(size(xjr2))']';  % rotaion joint 2 matrix


yc=0;
xc=0;
plunger2=d2_g-5;
xend_pL2_plunger=xc + 5 +plunger2;
xep=xend_pL2_plunger;
wdc=wd_g/5;
ypL2_prism=[yc-.5 yc-.5  yc-wd  yc-wd  yc-wd+.5  yc-wd+.5  yc-wd   yc-wd yc-wdc yc-wdc yc+wdc yc+wdc  yc+wd  yc+wd   yc+wd-.5  yc+wd-.5  yc+wd  yc+wd  yc+.5  yc+.5];
xpL2_prism=[xc    xc+.5  xc+.5  xc+1   xc+1      xc+4.5    xc+4.5  xc+5  xc+5   xc+xep xc+xep xc+5    xc+5   xc+4.5  xc+4.5    xc+1      xc+1   xc+.5  xc+.5  xc];
pL2_prism_g=[xpL2_prism' ypL2_prism' zeros(size(xpL2_prism))' ones(size(xpL2_prism))']';  % "prismatic joint" # 2 matrix

%Calculations to draw end effector
wd=len_g/2;
yc=0;xc=0;
wdc=wd_g/2;
yEE_RPRP=[yc+wd  yc+wd-wdc yc+wd-wdc   yc-wd+wdc   yc-wd+wdc yc-wd];
xEE_RPRP=[xc     xc+len_g  xc+len_g/2  xc+len_g/2  xc+len_g    xc];
pEE_RPRP_g=[xEE_RPRP' yEE_RPRP' zeros(size(xEE_RPRP))' ones(size(xEE_RPRP))']';

%Calculate positions of different links and joints using Forward kinamatics
forward_kin();
pF_pL1_prism_g=fill(Link1_g(1,:),Link1_g(2,:),'y', 'erasemode','xor');	% color fill prismatic jont 1
set(pF_pL1_prism_g,'FaceColor',[.8 .9 .2]);


pF_jr2_g=fill(joint2_g(1,:),joint2_g(2,:),'g', 'erasemode','xor');	% color fill rotation jont 2
set(pF_jr2_g,'FaceColor',[.2 .8 .6]);

pF_pL2_prism_g=fill(Link2_g(1,:),Link2_g(2,:),'y', 'erasemode','xor');	% color fill prismatic jont 2
set(pF_pL2_prism_g,'FaceColor',[.8 .9 .2]);

pF_EE_RPRP_g=fill(EE_g(1,:),EE_g(2,:),'r', 'erasemode','xor');	% color fill end effector
set(pF_EE_RPRP_g,'FaceColor',[.8 .2 .2]);

handles.number_errors_Xee = 0;
handles.number_errors_Yee = 0;
handles.number_errors_Phi = 0;

handles.number_errors_D1 = 0;
handles.number_errors_D2 = 0;
handles.number_errors_Theta1 = 0;
handles.number_errors_Theta2 = 0;
handles.sgraph_flag=1;
handles.control_flag=0;
% Choose default command line output for robotics_project
handles.output = hObject;
handles.sgraph_case='Circle';
% Update handles structure
guidata(hObject, handles);


% --- Outputs from this function are returned to the command line.
function varargout = robotics_project_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;


% --- Executes on slider movement.
function Xee_slider_Callback(hObject, eventdata, handles)

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));
% --- Executes during object creation, after setting all properties.
function Xee_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function Yee_slider_Callback(hObject, eventdata, handles)
set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

% --- Executes during object creation, after setting all properties.
function Yee_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function Phi_slider_Callback(hObject, eventdata, handles)
set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

% --- Executes during object creation, after setting all properties.
function Phi_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Xee_edit_Callback(hObject, eventdata, handles)
val = str2double(get(handles.Xee_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.Xee_slider,'Min') & ...
    val <= get(handles.Xee_slider,'Max')
    set(handles.Xee_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_Xee = handles.number_errors_Xee+1;
    guidata(hObject,handles); % store the changes
    set(handles.Xee_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_Xee),' times.']);
end

function Xee_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Yee_edit_Callback(hObject, eventdata, handles)
val = str2double(get(handles.Yee_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.Yee_slider,'Min') & ...
    val <= get(handles.Yee_slider,'Max')
    set(handles.Yee_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_Yee = handles.number_errors_Yee+1;
    guidata(hObject,handles); % store the changes
    set(handles.Yee_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_Yee),' times.']);
end

% --- Executes during object creation, after setting all properties.
function Yee_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Phi_edit_Callback(hObject, eventdata, handles)
val = str2double(get(handles.Phi_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.Phi_slider,'Min') & ...
    val <= get(handles.Phi_slider,'Max')
    set(handles.Phi_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_Phi = handles.number_errors_Phi+1;
    guidata(hObject,handles); % store the changes
    set(handles.Phi_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_Phi),' times.']);
end


% --- Executes during object creation, after setting all properties.
function Phi_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in Analytical_pushbutton. 
% Analytical Push Button is reserved for future versions of this RPRP Manipulator GUI
function Analytical_pushbutton_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g; 
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;

% hObject    handle to Analytical_pushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in Numerical_pushbutton.
function Numerical_pushbutton_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g; 
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;


x_ee_g = str2double(get(handles.Xee_edit,'String'));
y_ee_g = str2double(get(handles.Yee_edit,'String'));

inverse_kin; % Calling inverse kinamatics function to set joint variables
forward_kin; % Forward Kinamatics takes the calculated joint variables from inverse_kin and set to output screen
set(handles.Theta1_slider,'Value',theta1_g);
set(handles.Theta2_slider,'Value',theta2_g);
set(handles.D1_slider,'Value',d1_g);
set(handles.D2_slider,'Value',d2_g);

set(handles.Theta1_edit,'String',...
    num2str(get(handles.Theta1_slider,'Value')));

set(handles.Theta2_edit,'String',...
    num2str(get(handles.Theta2_slider,'Value')));

set(handles.D1_edit,'String',...
    num2str(get(handles.D1_slider,'Value')));

set(handles.D2_edit,'String',...
    num2str(get(handles.D2_slider,'Value')));
[flag_set]=set_dimensions();% set_dimensions sets the value of position matrices of different joints
if(flag_set==1)
    plot_RPRP; %plot_RPRP gets the dimension, which are set by  set_dimensions and plots it to output screen
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function axes2_CreateFcn(hObject, eventdata, handles)
s1 = ['T1 = get(gco,''Value'');' ...		% defines T1 as slider value
      'forkin;' ...
   	'robotics_ball;'];
guidata(hObject, handles);



% --- Executes on slider movement.
function Theta2_slider_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g; 
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
set(handles.Theta2_edit,'String',...
    num2str(get(handles.Theta2_slider,'Value')));
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function Theta2_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Theta2_edit_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
val = str2double(get(handles.Theta2_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.Theta2_slider,'Min') & ...
    val <= get(handles.Theta2_slider,'Max')
    set(handles.Theta2_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_Theta2 = handles.number_errors_Theta2+1;
    guidata(hObject,handles); % store the changes
    set(handles.Theta2_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_Theta2),' times.']);
end
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function Theta2_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function D2_slider_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
set(handles.D2_edit,'String',...
    num2str(get(handles.D2_slider,'Value')));
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function D2_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function D2_edit_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
val = str2double(get(handles.D2_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.D2_slider,'Min') & ...
    val <= get(handles.D2_slider,'Max')
    set(handles.D2_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_D2 = handles.number_errors_D2+1;
    guidata(hObject,handles); % store the changes
    set(handles.D2_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_D2),' times.']);
end
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function D2_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function Theta1_slider_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
set(handles.Theta1_edit,'String',...
    num2str(get(handles.Theta1_slider,'Value')));

d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function Theta1_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Theta1_edit_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
val = str2double(get(handles.Theta1_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.Theta1_slider,'Min') & ...
    val <= get(handles.Theta1_slider,'Max')
    set(handles.Theta1_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_Theta1 = handles.number_errors_Theta1+1;
    guidata(hObject,handles); % store the changes
    set(handles.Theta1_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_Theta1),' times.']);
end
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end

% --- Executes during object creation, after setting all properties.
function Theta1_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function D1_slider_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
set(handles.D1_edit,'String',...
    num2str(get(handles.D1_slider,'Value')));
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function D1_slider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function D1_edit_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
val = str2double(get(handles.D1_edit,'String'));

% --- Executes during object creation, after setting all properties.

if isnumeric(val)& ...
    val >= get(handles.D1_slider,'Min') & ...
    val <= get(handles.D1_slider,'Max')
    set(handles.D1_slider,'Value',val);
else
    % Increment the error count, and display it
    handles.number_errors_D1 = handles.number_errors_D1+1;
    guidata(hObject,handles); % store the changes
    set(handles.D1_edit,'String',...
    ['invalid',...
num2str(handles.number_errors_D1),' times.']);
end
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function D1_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end




% --- Executes on button press in Forkin_pushbutton.
function Forkin_pushbutton_Callback(hObject, eventdata, handles)

global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
d1_g = str2double(get(handles.D1_edit,'String'));
d2_g = str2double(get(handles.D2_edit,'String'));
theta1_g = str2double(get(handles.Theta1_edit,'String'));
theta2_g = str2double(get(handles.Theta2_edit,'String'));

forward_kin;

set(handles.Xee_slider,'Value',x_ee_g);
set(handles.Yee_slider,'Value',y_ee_g);
set(handles.Phi_slider,'Value',phi_g);

set(handles.Xee_edit,'String',...
    num2str(get(handles.Xee_slider,'Value')));

set(handles.Yee_edit,'String',...
    num2str(get(handles.Yee_slider,'Value')));

set(handles.Phi_edit,'String',...
    num2str(get(handles.Phi_slider,'Value')));

[flag_set]=set_dimensions();
if(flag_set==1)
    plot_RPRP;
    set(handles.Warning_text,'visible','off');
elseif(flag_set==0)
    set(handles.Warning_text,'visible','on');
end

% --- Executes on button press in point1_pushbutton.



% --- Executes during object creation, after setting all properties.
function uipanel4_CreateFcn(hObject, eventdata, handles)


% --- Executes on button press in standard_graphs_checkbox.
function standard_graphs_checkbox_Callback(hObject, eventdata, handles)

if (get(handles.standard_graphs_checkbox,'Value') == get(handles.standard_graphs_checkbox,'Max'))
    handles.sgraph_flag=1;
else
    
    handles.sgraph_flag=0;
end
if ((isequal(handles.sgraph_flag,1))&(isequal(handles.sgraph_case,'Circle')))
    set(handles.Ellipse_min_axis_text,'visible','off');
    set(handles.Ellipse_min_axis_edit,'visible','off');
    set(handles.Ellipse_maj_axis_text,'visible','off');
    set(handles.Ellipse_maj_axis_edit,'visible','off');
    set(handles.Ellipse_Xc_text,'visible','off');
    set(handles.Ellipse_Xc_edit,'visible','off');
    set(handles.Ellipse_Yc_text,'visible','off');
    set(handles.Ellipse_Yc_edit,'visible','off');
    set(handles.Ellipse_ori_text,'visible','off');
    set(handles.Ellipse_ori_edit,'visible','off');
    
    
    set(handles.sgraph_circle_rad_text,'visible','on');
    set(handles.sgraph_circle_rad_edit,'visible','on');
    set(handles.sgraph_circle_Xc_text,'visible','on');
    set(handles.sgraph_circle_Xc_edit,'visible','on');
    set(handles.sgraph_circle_Yc_text,'visible','on');
    set(handles.sgraph_circle_Yc_edit,'visible','on');
    
    
elseif ((isequal(handles.sgraph_flag,1))&(isequal(handles.sgraph_case,'Ellipse')))
    set(handles.Ellipse_min_axis_text,'visible','on');
    set(handles.Ellipse_min_axis_edit,'visible','on');
    set(handles.Ellipse_maj_axis_text,'visible','on');
    set(handles.Ellipse_maj_axis_edit,'visible','on');
    set(handles.Ellipse_Xc_text,'visible','on');
    set(handles.Ellipse_Xc_edit,'visible','on');
    set(handles.Ellipse_Yc_text,'visible','on');
    set(handles.Ellipse_Yc_edit,'visible','on');
    set(handles.Ellipse_ori_text,'visible','on');
    set(handles.Ellipse_ori_edit,'visible','on');
    
     set(handles.sgraph_circle_rad_text,'visible','off');
    set(handles.sgraph_circle_rad_edit,'visible','off');
    set(handles.sgraph_circle_Xc_text,'visible','off');
    set(handles.sgraph_circle_Xc_edit,'visible','off');
    set(handles.sgraph_circle_Yc_text,'visible','off');
    set(handles.sgraph_circle_Yc_edit,'visible','off');
elseif (isequal(handles.sgraph_flag,0))
    set(handles.sgraph_circle_rad_text,'visible','off');
    set(handles.sgraph_circle_rad_edit,'visible','off');
    set(handles.sgraph_circle_Xc_text,'visible','off');
    set(handles.sgraph_circle_Xc_edit,'visible','off');
    set(handles.sgraph_circle_Yc_text,'visible','off');
    set(handles.sgraph_circle_Yc_edit,'visible','off');
    
    set(handles.Ellipse_min_axis_text,'visible','off');
    set(handles.Ellipse_min_axis_edit,'visible','off');
    set(handles.Ellipse_maj_axis_text,'visible','off');
    set(handles.Ellipse_maj_axis_edit,'visible','off');
    set(handles.Ellipse_Xc_text,'visible','off');
    set(handles.Ellipse_Xc_edit,'visible','off');
    set(handles.Ellipse_Yc_text,'visible','off');
    set(handles.Ellipse_Yc_edit,'visible','off');
    set(handles.Ellipse_ori_text,'visible','off');
    set(handles.Ellipse_ori_edit,'visible','off');
end
guidata(hObject,handles);
% --- Executes on selection change in standard_graphs_popupmenu.
function standard_graphs_popupmenu_Callback(hObject, eventdata, handles)
val=get(hObject,'Value');
str=get(hObject,'String');
switch str{val}
    case 'Circle'
        handles.sgraph_case='Circle';
    case 'Ellipse'
        handles.sgraph_case='Ellipse';;
end
if ((isequal(handles.sgraph_flag,1))&(isequal(handles.sgraph_case,'Circle')))
    set(handles.sgraph_circle_rad_text,'visible','on');
    set(handles.sgraph_circle_rad_edit,'visible','on');
    set(handles.sgraph_circle_Xc_text,'visible','on');
    set(handles.sgraph_circle_Xc_edit,'visible','on');
    set(handles.sgraph_circle_Yc_text,'visible','on');
    set(handles.sgraph_circle_Yc_edit,'visible','on');
    
    set(handles.Ellipse_min_axis_text,'visible','off');
    set(handles.Ellipse_min_axis_edit,'visible','off');
    set(handles.Ellipse_maj_axis_text,'visible','off');
    set(handles.Ellipse_maj_axis_edit,'visible','off');
    set(handles.Ellipse_Xc_text,'visible','off');
    set(handles.Ellipse_Xc_edit,'visible','off');
    set(handles.Ellipse_Yc_text,'visible','off');
    set(handles.Ellipse_Yc_edit,'visible','off');
    set(handles.Ellipse_ori_text,'visible','off');
    set(handles.Ellipse_ori_edit,'visible','off');
elseif ((isequal(handles.sgraph_flag,1))&(isequal(handles.sgraph_case,'Ellipse')))
    set(handles.Ellipse_min_axis_text,'visible','on');
    set(handles.Ellipse_min_axis_edit,'visible','on');
    set(handles.Ellipse_maj_axis_text,'visible','on');
    set(handles.Ellipse_maj_axis_edit,'visible','on');
    set(handles.Ellipse_Xc_text,'visible','on');
    set(handles.Ellipse_Xc_edit,'visible','on');
    set(handles.Ellipse_Yc_text,'visible','on');
    set(handles.Ellipse_Yc_edit,'visible','on');
    set(handles.Ellipse_ori_text,'visible','on');
    set(handles.Ellipse_ori_edit,'visible','on');
    
    set(handles.sgraph_circle_rad_text,'visible','off');
    set(handles.sgraph_circle_rad_edit,'visible','off');
    set(handles.sgraph_circle_Xc_text,'visible','off');
    set(handles.sgraph_circle_Xc_edit,'visible','off');
    set(handles.sgraph_circle_Yc_text,'visible','off');
    set(handles.sgraph_circle_Yc_edit,'visible','off');
elseif (isequal(handles.sgraph_flag,0))
    set(handles.sgraph_circle_rad_text,'visible','off');
    set(handles.sgraph_circle_rad_edit,'visible','off');
    set(handles.sgraph_circle_Xc_text,'visible','off');
    set(handles.sgraph_circle_Xc_edit,'visible','off');
    set(handles.sgraph_circle_Yc_text,'visible','off');
    set(handles.sgraph_circle_Yc_edit,'visible','off');
    
    set(handles.Ellipse_min_axis_text,'visible','off');
    set(handles.Ellipse_min_axis_edit,'visible','off');
    set(handles.Ellipse_maj_axis_text,'visible','off');
    set(handles.Ellipse_maj_axis_edit,'visible','off');
    set(handles.Ellipse_Xc_text,'visible','off');
    set(handles.Ellipse_Xc_edit,'visible','off');
    set(handles.Ellipse_Yc_text,'visible','off');
    set(handles.Ellipse_Yc_edit,'visible','off');
end

guidata(hObject,handles);
function standard_graphs_popupmenu_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function sgraph_circle_rad_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function sgraph_circle_rad_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function sgraph_circle_Xc_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function sgraph_circle_Xc_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function sgraph_circle_Yc_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function sgraph_circle_Yc_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end




% --- Executes on button press in Trace_pushbutton.
function Trace_pushbutton_Callback(hObject, eventdata, handles)
global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;
global g_case;
g_case=1;
c=get(handles.standard_graphs_checkbox,'Value');
tspan=linspace(0,3*pi,200);
options=odeset;
if (c==1)
    if(isequal(handles.sgraph_case,'Circle'))
        par(1) = str2double(get(handles.sgraph_circle_rad_edit,'String'));
        par(2) = str2double(get(handles.sgraph_circle_Xc_edit,'String'));
        par(3) = str2double(get(handles.sgraph_circle_Yc_edit,'String'));
        par(4) =get(handles.control_checkbox,'Value');
        par(5)=str2double(get(handles.Gain_edit,'String'));
        g_case=1;
        xc=par(2);
        yc=par(3);
    elseif(isequal(handles.sgraph_case,'Ellipse'))
        par(1) = str2double(get(handles.Ellipse_maj_axis_edit,'String'));
        par(2) = str2double(get(handles.Ellipse_min_axis_edit,'String'));
        par(3) = str2double(get(handles.Ellipse_Xc_edit,'String'));
        par(4) = str2double(get(handles.Ellipse_Yc_edit,'String'));
        par(5) = str2double(get(handles.Ellipse_ori_edit,'String'))
        par(6) =get(handles.control_checkbox,'Value');
        par(7)=str2double(get(handles.Gain_edit,'String'));
        g_case=2;
        xc=par(3);
        yc=par(4);
    end
        
    y0=[d1_g d2_g theta1_g*pi/180 theta2_g*pi/180]';
    %y0=[11 11 0 0]'
    [T,Y] = ode45(@RPRP_sgraph,tspan,y0,options,par);
    k=length(T);
    P=par(1);
    fig=gcf;
    for i=1:k
        d1_g=Y(i,1);
        d2_g=Y(i,2);
        theta1_g=Y(i,3)*180/pi;
        theta2_g=Y(i,4)*180/pi;
        while(theta1_g>360)
            theta1_g=theta1_g-360;
        end
        while(theta2_g>360)
            theta2_g= theta2_g-360;
        end
        while(theta1_g<(-360))
            theta1_g=theta1_g+360;
        end
        while(theta2_g<(-360))
            theta2_g= theta2_g+360;
        end

        [flag_set]=set_dimensions();
        forward_kin;
        if(flag_set==1)
            plot_RPRP;
            set(handles.Warning_text,'visible','off');
        elseif(flag_set==0)
            set(handles.Warning_text,'visible','on');
        end
        th1=Y(i,3);
        th2=Y(i,4);
        pause(.005);
        offset_x=x1_g*cos(th1)+ r_g*cos(th1)+r_g*cos(th1+th2);
        offset_y=y1_g+r_g*sin(th1)+ r_g*sin(th1)+r_g*sin(th1+th2);
        x=offset_x+d1_g*cos(th1) + d2_g*cos((th1+th2));
        y=offset_y+d1_g*sin(th1) + d2_g*sin((th1+th2));
        plot(x,y,'.','LineWidth',2);
        P=[P;sqrt((x_ee_g-xc)^2+(y_ee_g-yc)^2)];
        

    end
    P(1)=[];
    if(isequal(handles.sgraph_case,'Circle'))
        figure(2)
        plot(T,P);
        xlabel('Time');
        ylabel('Radius w.r.t. (X_c, Y_c)');
        Title('Plot of Radius with respect to center of the circle');
    else
        %%%%
    end
end



% --- Executes on button press in Erase_pushbutton.
function Erase_pushbutton_Callback(hObject, eventdata, handles)
axis normal;
hold off;
plot(0,0,'erasemode','xor');

global theta1_g d1_g theta2_g d2_g;
global x_ee_g y_ee_g phi_g;
global pF_jr2_g pF_pL1_prism_g pF_pL2_prism_g;
global jr2_g  pL1_prism_g  pL2_prism_g;
global x1_g y1_g r_g len_g wd_g;
global Link1_g Link2_g joint2_g;
global pF_EE_RPRP_g  pEE_RPRP_g EE_g;

r_g=1.5;
len_g=3;
wd_g=2;
y_max=40;y_min=-40;x_max=40;x_min=-40;
th_base=linspace(pi,0,25);
x_base=(r_g+.2)*cos(th_base);
y_base=(r_g+.2)*sin(th_base)-r_g-.5;
color=x_base;
axis([x_min x_max y_min y_max])	% axis limits
axis manual					% set axis to exact manual value
axis equal					% x-scale=y-scale
hold on						% does not erase previous graphs 
grid off						% turns on grid

% minor grid lines
for y=y_min:1:y_max
   plot([x_min+.1 x_max],[y y],'Color',[.8,.97,.97])
end  
for x=x_min+.1:1:x_max
   plot([x x],[y_min y_max],'Color',[.8,.97,.97])
end 
% major grid lines
for y=0:5:y_max
   plot([x_min+.1 x_max],[y y],'Color',[0.9 0.9 0.9])
end  
for x=x_min:5:x_max
   plot([x x],[y_min y_max],'Color',[.9,.9,.9])
end   

fill(x_base,y_base,color);

th_jr1=linspace(-pi,pi,50);
xjr1=r_g*cos(th_jr1);
ystart_jr1=0;
yjr1=ystart_jr1+r_g*sin(th_jr1);
jr1=[xjr1' yjr1' zeros(size(xjr1))' ones(size(xjr1))']';  % rotaion joint 1 matrix
pF_jr1=fill(xjr1,yjr1,'g', 'erasemode','xor');	% color fill rotation jont 1
set(pF_jr1,'FaceColor',[.2 .8 .6]);

[flag_set]=set_dimensions();
forward_kin;
pF_pL1_prism_g=fill(Link1_g(1,:),Link1_g(2,:),'y', 'erasemode','xor');	% color fill rotation jont 1
set(pF_pL1_prism_g,'FaceColor',[.8 .9 .2]);


pF_jr2_g=fill(joint2_g(1,:),joint2_g(2,:),'g', 'erasemode','xor');	% color fill rotation jont 2
set(pF_jr2_g,'FaceColor',[.2 .8 .6]);

pF_pL2_prism_g=fill(Link2_g(1,:),Link2_g(2,:),'y', 'erasemode','xor');	% color fill rotation jont 2
set(pF_pL2_prism_g,'FaceColor',[.8 .9 .2]);

pF_EE_RPRP_g=fill(EE_g(1,:),EE_g(2,:),'r', 'erasemode','xor');	% color fill rotation jont 2
set(pF_EE_RPRP_g,'FaceColor',[.8 .2 .2]);


% --- Executes during object creation, after setting all properties.
function Warning_text_CreateFcn(hObject, eventdata, handles)

% --- Executes on button press in control_checkbox.
function control_checkbox_Callback(hObject, eventdata, handles)
if (get(handles.control_checkbox,'Value') == get(handles.control_checkbox,'Max'))
    handles.control_flag=1;
    disp('clicked')
    c=get(handles.control_checkbox,'Value')
else
    handles.control_flag=0;
    disp('unclicked')
    c=get(handles.control_checkbox,'Value')
end

guidata(hObject,handles);

function Gain_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Gain_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function Ellipse_maj_axis_edit_Callback(hObject, eventdata, handles)

% --- Executes during object creation, after setting all properties.
function Ellipse_maj_axis_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Ellipse_min_axis_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Ellipse_min_axis_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Ellipse_Xc_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Ellipse_Xc_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit44_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function edit44_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Ellipse_ori_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Ellipse_ori_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function Ellipse_Yc_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Ellipse_Yc_edit_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


Contact us at files@mathworks.com