Home > compassGaitSimulator > generateTerrain.m

generateTerrain

PURPOSE ^

GENERATETERRAIN M-file for generateTerrain.fig

SYNOPSIS ^

function varargout = generateTerrain(varargin)

DESCRIPTION ^

 GENERATETERRAIN M-file for generateTerrain.fig
      GENERATETERRAIN, by itself, creates a new GENERATETERRAIN or raises the existing
      singleton*.

      H = GENERATETERRAIN returns the handle to a new GENERATETERRAIN or the handle to
      the existing singleton*.

      GENERATETERRAIN('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in GENERATETERRAIN.M with the given input arguments.

      GENERATETERRAIN('Property','Value',...) creates a new GENERATETERRAIN or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before generateTerrain_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to generateTerrain_OpeningFcn via varargin.

      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
      instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = generateTerrain(varargin)
0002 % GENERATETERRAIN M-file for generateTerrain.fig
0003 %      GENERATETERRAIN, by itself, creates a new GENERATETERRAIN or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = GENERATETERRAIN returns the handle to a new GENERATETERRAIN or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      GENERATETERRAIN('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in GENERATETERRAIN.M with the given input arguments.
0011 %
0012 %      GENERATETERRAIN('Property','Value',...) creates a new GENERATETERRAIN or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before generateTerrain_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to generateTerrain_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help generateTerrain
0024 
0025 % Last Modified by GUIDE v2.5 17-May-2009 00:00:11
0026 
0027 % Begin initialization code - DO NOT EDIT
0028 gui_Singleton = 1;
0029 gui_State = struct('gui_Name',       mfilename, ...
0030                    'gui_Singleton',  gui_Singleton, ...
0031                    'gui_OpeningFcn', @generateTerrain_OpeningFcn, ...
0032                    'gui_OutputFcn',  @generateTerrain_OutputFcn, ...
0033                    'gui_LayoutFcn',  [] , ...
0034                    'gui_Callback',   []);
0035 if nargin && ischar(varargin{1})
0036     gui_State.gui_Callback = str2func(varargin{1});
0037 end
0038 
0039 if nargout
0040     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0041 else
0042     gui_mainfcn(gui_State, varargin{:});
0043 end
0044 % End initialization code - DO NOT EDIT
0045 
0046 % --- Executes just before generateTerrain is made visible.
0047 function generateTerrain_OpeningFcn(hObject, eventdata, handles, varargin)
0048 % This function has no output args, see OutputFcn.
0049 % hObject    handle to figure
0050 % eventdata  reserved - to be defined in a future version of MATLAB
0051 % handles    structure with handles and user data (see GUIDATA)
0052 % varargin   command line arguments to generateTerrain (see VARARGIN)
0053 
0054 % Choose default command line output for generateTerrain
0055 handles.output = hObject;
0056 
0057 % Update handles structure
0058 guidata(hObject, handles);
0059 
0060 % UIWAIT makes generateTerrain wait for user response (see UIRESUME)
0061 % uiwait(handles.figGenerateTerrain);
0062 
0063 
0064 % --- Outputs from this function are returned to the command line.
0065 function varargout = generateTerrain_OutputFcn(hObject, eventdata, handles) 
0066 % varargout  cell array for returning output args (see VARARGOUT);
0067 % hObject    handle to figure
0068 % eventdata  reserved - to be defined in a future version of MATLAB
0069 % handles    structure with handles and user data (see GUIDATA)
0070 
0071 % Get default command line output from handles structure
0072 varargout{1} = handles.output;
0073 
0074 
0075 % --- Executes on button press in pushbutton1.
0076 function pushbutton1_Callback(hObject, eventdata, handles)
0077 % hObject    handle to pushbutton1 (see GCBO)
0078 % eventdata  reserved - to be defined in a future version of MATLAB
0079 % handles    structure with handles and user data (see GUIDATA)
0080 
0081 stepno=1000;
0082 
0083 flatTerrain = get(handles.chbFlat,'Value');
0084 uphillTerrain = get(handles.chbUphill,'Value');
0085 downhillTerrain = get(handles.chbDownhill,'Value');
0086 stepTerrain = get(handles.chbStep,'Value');
0087 roughTerrain = get(handles.chbRough,'Value');
0088 
0089 % % Flat Terrain
0090 if flatTerrain ~= 0;
0091     env_prof(1:2)=0.0;
0092     for i=1:stepno
0093         env_prof(i*2+1)=i*0.01;
0094         env_prof(i*2+2)=0.0;
0095     end
0096     env=[stepno, env_prof];
0097     envFileName = ['env' filesep 'env00']; % env\env00.mat in Windows, env/env00.mat in Linux
0098     save (envFileName, 'env');
0099 end
0100 
0101 % % Uphill Terrain
0102 if uphillTerrain ~= 0;
0103     gamma=3.0*pi/180;
0104     env_prof(1:2)=0.0;
0105     for i=1:stepno
0106         env_prof(i*2+1)=i*0.01;
0107         env_prof(i*2+2)=gamma*(i*0.01+1)+ gamma;
0108     end
0109     env=[stepno, env_prof];
0110     envFileName = ['env' filesep 'env01']; % env\env01.mat in Windows, env/env01.mat in Linux
0111     save (envFileName, 'env');
0112 end
0113 
0114 % % Downhill Terrain
0115 if downhillTerrain ~= 0;
0116     gamma=-3.0*pi/180;
0117     env_prof(1:2)=0.0;
0118     for i=1:stepno
0119         env_prof(i*2+1)=i*0.01;
0120         env_prof(i*2+2)=gamma*(i*0.01+1)+ gamma;
0121     end
0122     env=[stepno, env_prof];
0123     envFileName = ['env' filesep 'env02']; % env\env02.mat in Windows, env/env02.mat in Linux
0124     save (envFileName, 'env');
0125 end
0126 
0127 % % One Step Terrain
0128 if stepTerrain ~= 0;
0129     env_prof(1:2)=0.0;
0130     for i=1:stepno
0131         env_prof(i*2+1)=i*0.01;
0132         env_prof(i*2+2)=0.0;
0133     end
0134     for i=101:110
0135         env_prof(i*2+1)=i*0.01;
0136         env_prof(i*2+2)=0.001;
0137     end
0138     env=[stepno, env_prof];
0139     envFileName = ['env' filesep 'env11']; % env\env11.mat in Windows, env/env11.mat in Linux
0140     save (envFileName, 'env');
0141 end
0142 
0143 % % Complex Terrain
0144 if roughTerrain ~= 0;
0145     env_prof(1:2)=0.0;
0146     for i=1:100
0147         env_prof(i*2+1)=i*0.01;
0148         env_prof(i*2+2)=0.0;
0149     end
0150 
0151     for i=101:120
0152         env_prof(i*2+1)=i*0.01;
0153         env_prof(i*2+2)=0.001;
0154     end
0155 
0156     for i=121:150
0157         env_prof(i*2+1)=i*0.01;
0158         env_prof(i*2+2)=0.0;
0159     end
0160 
0161     for i=151:2:200
0162         env_prof((i:i+2)*2+1)=(i:i+2)*0.01;
0163         env_prof((i:i+2)*2+2)=rand()*0.02-0.01;
0164     end
0165 
0166     for i=201:250
0167         env_prof(i*2+1)=i*0.01;
0168         env_prof(i*2+2)=0.01;
0169     end
0170 
0171     for i=250:stepno
0172         env_prof(i*2+1)=i*0.01;
0173         env_prof(i*2+2)=0.0;
0174     end
0175     
0176     env=[stepno, env_prof];
0177     envFileName = ['env' filesep 'env12']; % env\env12.mat in Windows, env/env12.mat in Linux
0178     save (envFileName, 'env');
0179 end
0180 delete(handles.figGenerateTerrain)
0181 return
0182 
0183 % --- Executes on button press in chbFlat.
0184 function chbFlat_Callback(hObject, eventdata, handles)
0185 % hObject    handle to chbFlat (see GCBO)
0186 % eventdata  reserved - to be defined in a future version of MATLAB
0187 % handles    structure with handles and user data (see GUIDATA)
0188 
0189 % Hint: get(hObject,'Value') returns toggle state of chbFlat
0190 
0191 
0192 % --- Executes on button press in chbStep.
0193 function chbStep_Callback(hObject, eventdata, handles)
0194 % hObject    handle to chbStep (see GCBO)
0195 % eventdata  reserved - to be defined in a future version of MATLAB
0196 % handles    structure with handles and user data (see GUIDATA)
0197 
0198 % Hint: get(hObject,'Value') returns toggle state of chbStep
0199 
0200 
0201 % --- Executes on button press in chbRough.
0202 function chbRough_Callback(hObject, eventdata, handles)
0203 % hObject    handle to chbRough (see GCBO)
0204 % eventdata  reserved - to be defined in a future version of MATLAB
0205 % handles    structure with handles and user data (see GUIDATA)
0206 
0207 % Hint: get(hObject,'Value') returns toggle state of chbRough
0208 
0209 % --- Executes on button press in chbdownhill.
0210 function chbUphill_Callback(hObject, eventdata, handles)
0211 % hObject    handle to chbRough (see GCBO)
0212 % eventdata  reserved - to be defined in a future version of MATLAB
0213 % handles    structure with handles and user data (see GUIDATA)
0214 
0215 % Hint: get(hObject,'Value') returns toggle state of chbUphill
0216 
0217 % --- Executes on button press in chbdownhill.
0218 function chbDownhill_Callback(hObject, eventdata, handles)
0219 % hObject    handle to chbRough (see GCBO)
0220 % eventdata  reserved - to be defined in a future version of MATLAB
0221 % handles    structure with handles and user data (see GUIDATA)
0222 
0223 % Hint: get(hObject,'Value') returns toggle state of chbDownhill
0224

Generated on Tue 09-Jun-2009 23:31:31 by m2html © 2003