Functions | Variables

sfdrawrobot.m File Reference

Functions

function sfdrawrobot (block)%MSFUNTMPL A template for an M-file S-function%The M-file S-function is written as a MATLAB function with the%same name as the S-function.Replace 'msfuntmpl'with the name%of your S-function.%%It should be noted that the M-file S-function is very similar%to Level-2 C-Mex S-functions.You should be able to get more%information for each of the block methods by referring to the%documentation for C-Mex S-functions.%%Copyright 2003-2006 The MathWorks
function Inc etc Do not add
any other calls to the main
body of the function 
setup (block)
block SetSimViewingDevice (1)
Override input port properties
block 
InputPort (1).DatatypeID=0 = 'Real'
Inhrited block InputPort (2).DatatypeID=0 = 'Real'
Inhrited Override output port
properties block 
OutputPort (1).DatatypeID=0 = 'Real'
block SetAccelRunOnTLC (false)
block RegBlockMethod ('PostPropagationSetup',@DoPostPropSetup)
block RegBlockMethod ('ProcessParameters',@ProcessPrms)
block RegBlockMethod ('SetInputPortSampleTime',@SetInputPortSampleTime)
block RegBlockMethod ('SetInputPortDimensions',@SetInpPortDims)
block RegBlockMethod ('Start',@Start)
block RegBlockMethod ('Update',@Update)
idx di ()
endfunction function CheckPrms (block)%a
if ~strcmp (class(a), 'double')%error('Invalid parameter')
end endfunction function DoPostPropSetup (block) block.NumDworks
block Dwork (1).Name
block Dwork (2).Name
block Dwork (3).Name = 1
block Dwork (4).Name = 5
block Dwork (5).Name = 1
endfunction function SetInputPortSampleTime (block, port, time) block.InputPort(port).SampleTime
endfunction function Start (block) area
 set (hFig, 'Name', 'Robot')
 set (hFig, 'DoubleBuffer', 'on', 'Tag', 'robotScreen')
 set (fig, 'Renderer', 'painters')
 set (fig, 'Color', 'black')
 hold ('on')
if axis ('equal')
 set (gca, 'XLim',[0, area.w])
 set (gca, 'YLim',[0, area.h])
 cla (fig_axes)
endfunction function Update (block) x
if length (y)
 mod (counter, 4)+1
if oldPlot (counter)
if delete (oldPlot(counter))
oldPlot(oldPlot~=0 delete ()
end if any (y~=0)
 oldPlot (counter+i-1)
 if (block.CurrentTime< last_draw+1/20)
 set (0,'CurrentFigure', 1) desc
if any (toDelete)
if delete (oldPlot(toDelete))
if oldPlot (1)
 oldPlot (2)

Variables

function Inc $Revision
function Inc parameters
endfunction Function
block NumOutputPorts = 0
Setup port properties to be
inherited or dynamic block 
SetPreCompInpPortInfoToDynamic
Register parameters block NumDialogPrms = 2
block DialogPrmsTunable = {'Tunable','Nontunable','SimOnlyTunable'}
 hFig = figure(1)
 fig_axes = get(hFig, 'CurrentAxes')
 drawStyle = block.DialogPrm(2).Data
hold on end endfunction function hc
 y = block.InputPort(2).Data
We need to detect changes in y
to properly find the time of a
new measurement 
last_y = block.Dwork(4).Data(1:length(y))
 robot = desc.robot
Transformations trans
 oldPlot = block.Dwork(2).Data
 counter = block.Dwork(3).Data
 end
end if for i = [1:length(y)]
end if for beam
 line = beam*trans
end Do not draw everything too
often 
last_draw = block.Dwork(5).Data
 return
 outline = homog(desc.shape.outline)
 arrow = homog(desc.shape.arrow)
Transformations mid
 toDelete = oldPlot ~= 0

Function Documentation

end if any ( y~  = 0  ) 
if any ( toDelete   ) 
if axis ( 'equal'   ) 
endfunction function CheckPrms ( block   ) 
cla ( fig_axes   ) 
if delete ( oldPlot(counter  ) 
oldPlot(oldPlot ~= 0 delete (  )  [virtual]
if delete ( oldPlot(toDelete  ) 
idx di (  )  [virtual]
end endfunction function DoPostPropSetup ( block   ) 
block Dwork (  ) 
block Dwork (  ) 
block Dwork (  )  = 1
Clear space for storing last input values block Dwork (  )  = 5
end block Dwork (  )  = 1
hold ( 'on  ) 
if (  ) 
block InputPort (  )  = 'Real' [pure virtual]
block InputPort (  )  = 'Real' [pure virtual]
if length (  ) 

Here is the caller graph for this function:

mod ( counter  ,
 
)
if oldPlot ( counter   ) 
oldPlot ( counter+i 1  ) 
oldPlot (  ) 
if oldPlot (  ) 
double block OutputPort (  )  = 'Real' [pure virtual]
block RegBlockMethod ( 'PostPropagationSetup'  ,
DoPostPropSetup 
)
block RegBlockMethod ( 'SetInputPortSampleTime'  ,
SetInputPortSampleTime 
)
block RegBlockMethod ( 'SetInputPortDimensions'  ,
SetInpPortDims 
)
block RegBlockMethod ( 'ProcessParameters'  ,
ProcessPrms 
)
block RegBlockMethod ( 'Start'  ,
Start 
)
block RegBlockMethod ( 'Update'  ,
Update 
)
set ( gca  ,
'XLim'   
)
set ( gca  ,
'YLim'   
)
set ( ,
'CurrentFigure'  ,
 
)
set ( hFig  ,
'DoubleBuffer'  ,
'on ,
'Tag'  ,
'robotScreen'   
)
set ( hFig  ,
'Name'  ,
'Robot  
)
set ( fig  ,
'Renderer'  ,
'painters'   
)
set ( fig  ,
'Color ,
'black'   
)
block SetAccelRunOnTLC ( false   ) 
endfunction function SetInputPortSampleTime ( block  ,
port  ,
time   
)
block SetSimViewingDevice (  ) 
function Inc etc Do not add any other calls to the main body of the function setup ( block   ) 
function sfdrawrobot ( block   ) 
endfunction function Start ( block   ) 
endfunction function Update ( block   ) 
if ~strcmp ( class(a ,
'double'   
)

Variable Documentation

function Inc $Revision
end if for beam
Initial value:
 homog([robot.laserx             robot.lasery; ...
                              robot.laserx+4*cos(y(i)) robot.lasery+4*sin(y(i))])
if Delete only the line which is going to be redrawn counter = block.Dwork(3).Data
block DialogPrmsTunable = {'Tunable','Nontunable','SimOnlyTunable'}
if drawStyle = block.DialogPrm(2).Data
end
fig_axes = get(hFig, 'CurrentAxes')
endfunction Function
hold on end endfunction function hc
Initial value:
 homog(coords)
    hc=[coords ones(size(coords, 1), 1)]
hFig = figure(1)
end if for i = [1:length(y)]
end Do not draw everything too often last_draw = block.Dwork(5).Data
We need to detect changes in y to properly find the time of a new measurement last_y = block.Dwork(4).Data(1:length(y))
Transformations mid
Initial value:
 [
        1 0 -robot.cx
        0 1 -robot.cy
        0 0 1]'
Register parameters block NumDialogPrms = 2
block NumOutputPorts = 0
oldPlot = block.Dwork(2).Data
function Inc parameters
Setup port properties to be inherited or dynamic block SetPreCompInpPortInfoToDynamic
toDelete = oldPlot ~= 0
Initial value:
 [
                cos(x(3)) -sin(x(3)) x(1)
                sin(x(3))  cos(x(3)) x(2)
                0 0 1]'
y = block.InputPort(2).Data