error while using inverse kinematics for 5 dof robotic arm

1 view (last 30 days)
I got an error when coding to find the angle theta of the joint
if true
Undefined function or variable 'c3'.
Error in guisine1>inversekinematic_Callback (line 656)
single(solve((sqrt(px^2+py^2)-h2-(a4+a5)*(-2*sqrt(1-c3^2)*c3))^2+((a4+a5)*(2*c3^2-1)+pz-h1)^2 == a2^2+a3^2-2*a2*a3*c3, c3));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in guisine1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)guisine1('inversekinematic_Callback',hObject,eventdata,guidata(hObject))
Error using PM_VIS.FigVis/draw
Error while evaluating UIControl Callback.
end
This is my code:
if true
function inversekinematic_Callback(hObject, eventdata, handles)
ModelName = 'robotsine';
global var;
px=get(handles.px,'value');
set(handles.edit9,'string',num2str(px));
py=get(handles.py,'value');
set(handles.edit10,'string',num2str(py));
pz=get(handles.pz,'value');
set(handles.edit11,'string',num2str(pz));
a2=320;
a3=245;
a4=67.7;
a5=57;
h1=322;
h2=72.95;
solve((sqrt(px^2+py^2)-h2-(a4+a5)*(-2*sqrt(1-c3^2)*c3))^2+((a4+a5)*(2*c3^2-1)+pz-h1)^2 == a2^2+a3^2-2*a2*a3*c3, c3);
s3 = single(sqrt(1-c3^2));
t1 = atan2(py, px);
t3 = atan2(s3, c3);
al = atan2((a3*s3), (a2+a3*c3));
be = atan2(((a4+a5)*(2*c3^2-1)+pz-h1), (sqrt(px^2+py^2)-h2-(a4+a5)*(-2*sqrt(1-c3^2)*c3)));
t2 = al+be;
t4 = -t2-t3;
t5=0;
guidata(hObject,handles);
set(handles.edit1,'string',num2str(t1));
set_param([ModelName '/Slider Gain'],'Gain',num2str(t1))
set(handles.edit2,'string',num2str(t2));
set_param([ModelName '/Slider Gain1'],'Gain',num2str(t2))
set(handles.edit3,'string',num2str(t3));
set_param([ModelName '/Slider Gain2'],'Gain',num2str(t3))
set(handles.edit4,'string',num2str(t4));
set_param([ModelName '/Slider Gain3'],'Gain',num2str(t4))
set(handles.edit5,'string',num2str(t5));
set_param([ModelName '/Slider Gain4'],'Gain',num2str(t5))
set(handles.edit6,'string',num2str(px));
set(handles.edit7,'string',num2str(py));
set(handles.edit8,'string',num2str(pz));
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!