Call slider values from within another function
Show older comments
I've got the following code setting up a timer object that should take a demical value from a slider (named AlphaSider) convert that into radians and pass that into another angle variable. The idea is that this is done for 4 slider variables and these angles are used to construct a serial link plot with the robotics toolbox. All relevant code (I hope) is below:
L(1)=Link ( [ 0 0 1 0 0] ) ;
L(2)=Link ( [ 0 0 1 0 0] ) ;
L(3)=Link ( [ 0 0 0.1 pi/2 0] ) ;
L(4)=Link ( [ 0 0 1 0 0] ) ;
fourlink = serialLink(L,'name', 'four link');
%declare decimal angle variables
global o
global a
global b
global g
%set initial values
o=0;
a=0;
b=0;
g=0;
function runbtn_Callback(hObject, eventdata, handles)
global t
t = timer('TimerFcn', ReadVals, 'ExecutionMode', 'FixedRate', 'BusyMode', 'Queue', 'Period', 0.5);
set(handles.statusdisp,'String', 'Running');
start(t)
function [rado,rada,radb,radg]=ReadVals(o,a,b,g, hObject, eventdata, handles)
global fourlink
o=get(handles.OmegaSlider,'Value');
set(handles.OmegaVal,'Value', o);
rado=(o*pi)/180;
a=get(handles.AlphaSlider,'Value');
set(handles.AlphaVal,'Value', o);
rada=(a*pi)/180;
% etc... for the other two then :
L(1)=Link ( [ 0 0 1 0 0] ) ;
L(2)=Link ( [ 0 0 1 0 0] ) ;
L(3)=Link ( [ 0 0 0.1 pi/2 0] ) ;
L(4)=Link ( [ 0 0 1 0 0] ) ;
fourlink = serialLink(L,'name', 'four link');
fourlink.plot([rado rada radb radd]);
function stopbtn-Callback(hObject, eventdata, handles)
global t
stop(t)
set(handles statusdisp,'String', 'Stopped');
Unfortunately when I run this it throws back "Not enough input arguements" Concerning the lines such as "o = get (handles.OmegaSlider,'Value'
When I remove these and just set o = to any number, say 90, and do so with the other 3 angles, the code runs fine and plots the serial plot with all joints at 90 degrees to each other so i know that that aspect of the code should be ok and its just obtaining the values in the first place from the slider. HELP PLEASE?
Thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Noncentral t Distribution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!