⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mov_joystick.m

📁 是一个在matlab下的机器人运动仿真的软件
💻 M
字号:
function Mov_joystick(hObject, eventdata, handles)

%%%%%%Experimentar colocar y_joy_anterior e Z_jo.. com parametros da funcao
global flag_joy d2 d3 teta1 teta4 teta5 teta6 T06 y_joy_anteriord2 z_joy_anteriord3
global y_joy_anteriorteta1 y_joy_anteriorteta4 y_joy_anteriorteta5 y_joy_anteriorteta6

warning off;

%ai=analoginput('joy',1); % the number is an ID number of installed joystick (see Controller IDs in Control panel/Gaming options
% k=0.2:0.2:1;
% i=5;
%addchannel(ai,[1 2 3 4 5 6]);
%channels 
% 1 - X axis
% 2 - Y axis
% 3 - Z axis
% 4 - R axis
% 5 - buttons pressed (quasy binary data - see below)
% 6 - no of buttons pressed at the time
% Set up the display

% d2inicialstr=get(handles.textd2,'String');
% d2inicial=str2num(d2inicialstr);
% d3inicialstr=get(handles.textd3,'String');
% d3inicial=str2num(d3inicialstr);
%k=1; %absoluto

flag_joy=1;
while flag_joy==1         
    pause(0.05);
    samples = jst;
    samples(1) = -samples(1)*100;  %Y data
    samples(2) = samples(2)*100;   %X data
    samples(3) = -samples(3)*100;  %Z data
    % decoding the data from dll. You may play with the dll. Please see
    % JoyIn.cpp
    ButtonsPressed = samples(5);
    BP = ButtonsPressed;
     
    
    if BP==32         %BP==32 =>R1 com y_joy varia d2 altura e z_joy d3
        % pause(0.01);          
       y_joy=samples(1);   
       y_joy=y_joy+y_joy_anteriord2;
       y_joy_anteriord2=y_joy;      
       d2=((y_joy*180)/200)+90; %90 d2inicial
       if(y_joy>100)
          d2=180;     
       end
       if(y_joy<-100)
          d2=0;
       end     
         
       z_joy=-samples(3); %%- pq estava invertido
       z_joy=z_joy+z_joy_anteriord3;
       z_joy_anteriord3=z_joy;
       d3=((z_joy*250)/200)+125;  %d3 inicial
       if(z_joy>100)
          d3=250;     
       end
       if(z_joy<-100)
          d3=0;
       end     
        d2str=num2str(d2);
        d3str=num2str(d3);
        set(handles.textd2,'String',d2str);
        set(handles.textd3,'String',d3str);
                
        SimuladorCs('Desenha_robo',hObject, eventdata,handles); %tem q estar dentro senao o cpu est

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -